diff options
author | Liang Qi <liang.qi@qt.io> | 2018-05-03 14:26:01 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-05-03 14:50:22 +0200 |
commit | 60fefff22f7fa259a8bdb023d1ec9a57cfd34bfb (patch) | |
tree | ab33ab6eeb08f7a72e0196ee5025790aaa01b1dd /src/plugins | |
parent | b1e0a71997111fc296001bc94e0da8342cf0ac97 (diff) | |
parent | da32360ffc3c7b677355c37ae54c89637c18047f (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
examples/widgets/graphicsview/elasticnodes/graphwidget.cpp
examples/widgets/graphicsview/elasticnodes/node.cpp
examples/widgets/graphicsview/elasticnodes/node.h
src/plugins/platforms/cocoa/qnsview.mm
src/plugins/platforms/cocoa/qnsview_drawing.mm
src/widgets/kernel/qmacgesturerecognizer_p.h
Change-Id: I13cf06bac75d48d779d8ee7b5c91bfc976f2a32c
Diffstat (limited to 'src/plugins')
11 files changed, 85 insertions, 17 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index ee1b79b4cd..a1cf1bc632 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -261,6 +261,16 @@ QRectF qt_mac_flip(const QRectF &rect, const QRectF &reference) // ------------------------------------------------------------------------- +/*! + \fn Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum) + + Returns the Qt::Button that corresponds to an NSEvent.buttonNumber. + + \note AppKit will use buttonNumber 0 to indicate both "left button" + and "no button". Only NSEvents that describes mouse press/release + events (e.g NSEventTypeOtherMouseDown) will contain a valid + button number. +*/ Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum) { if (buttonNum >= 0 && buttonNum <= 31) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 20358e7269..7e7740527f 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -394,10 +394,10 @@ void QCocoaWindow::setVisible(bool visible) removeMonitor(); monitor = [NSEvent addGlobalMonitorForEventsMatchingMask:NSLeftMouseDownMask|NSRightMouseDownMask|NSOtherMouseDownMask|NSMouseMovedMask handler:^(NSEvent *e) { QPointF localPoint = QCocoaScreen::mapFromNative([NSEvent mouseLocation]); - const auto eventType = e.type == NSMouseMoved ? QEvent::MouseMove : QEvent::MouseButtonPress; + const auto button = e.type == NSEventTypeMouseMoved ? Qt::NoButton : cocoaButton2QtButton([e buttonNumber]); + const auto eventType = e.type == NSEventTypeMouseMoved ? QEvent::MouseMove : QEvent::MouseButtonPress; QWindowSystemInterface::handleMouseEvent(window(), window()->mapFromGlobal(localPoint.toPoint()), localPoint, - Qt::MouseButtons(uint(NSEvent.pressedMouseButtons & 0xFFFF)), - cocoaButton2QtButton(e.buttonNumber), eventType); + Qt::MouseButtons(uint(NSEvent.pressedMouseButtons & 0xFFFF)), button, eventType); }]; } } diff --git a/src/plugins/platforms/cocoa/qnsview_drawing.mm b/src/plugins/platforms/cocoa/qnsview_drawing.mm index fc5f806cb6..3bba68b0cf 100644 --- a/src/plugins/platforms/cocoa/qnsview_drawing.mm +++ b/src/plugins/platforms/cocoa/qnsview_drawing.mm @@ -123,7 +123,7 @@ m_platformWindow->handleExposeEvent(dirtyRegion); } - if (m_platformWindow->hasPendingUpdateRequest()) { + if (m_updateRequested && m_platformWindow->hasPendingUpdateRequest()) { // A call to QWindow::requestUpdate was issued during event delivery above, // but AppKit will reset the needsDisplay state of the view after completing // the current display cycle, so we need to defer the request to redisplay. diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm index d34d7ddb0d..f2f29b26ee 100644 --- a/src/plugins/platforms/cocoa/qprintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm @@ -574,6 +574,11 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va d->setPageSize(QPageSize(QPageSize::id(value.toInt()))); break; case PPK_PrinterName: { + QVariant pageSize = QVariant::fromValue(d->m_pageLayout.pageSize()); + const bool isFullPage = d->m_pageLayout.mode() == QPageLayout::FullPageMode; + QVariant orientation = QVariant::fromValue(d->m_pageLayout.orientation()); + QVariant margins = QVariant::fromValue(QPair<QMarginsF, QPageLayout::Unit>(d->m_pageLayout.margins(), + d->m_pageLayout.units())); QString id = value.toString(); if (id.isEmpty()) id = QCocoaPrinterSupport().defaultPrintDeviceId(); @@ -583,7 +588,14 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va PMPrinter printer = d->m_printDevice->macPrinter(); PMRetain(printer); PMSessionSetCurrentPMPrinter(d->session(), printer); - // TODO Do we need to check if the page size, etc, are valid on new printer? + // Ensure the settings are up to date and valid + if (d->m_printDevice->supportedPageSize(pageSize.value<QPageSize>()).isValid()) + setProperty(PPK_QPageSize, pageSize); + else + setProperty(PPK_CustomPaperSize, pageSize.value<QPageSize>().size(QPageSize::Point)); + setProperty(PPK_FullPage, QVariant(isFullPage)); + setProperty(PPK_Orientation, orientation); + setProperty(PPK_QPageMargins, margins); break; } case PPK_CustomPaperSize: diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.cpp index 98cf1d3bfb..212ebde05a 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_rcar/qeglfsrcarintegration.cpp @@ -52,12 +52,28 @@ QT_BEGIN_NAMESPACE void QEglFSRcarIntegration::platformInit() { + bool ok; + QEglFSDeviceIntegration::platformInit(); PVRGrfxServerInit(); mScreenSize = q_screenSizeFromFb(0); mNativeDisplay = (NativeDisplayType)EGL_DEFAULT_DISPLAY; + + mNativeDisplayID = qEnvironmentVariableIntValue("QT_QPA_WM_DISP_ID", &ok); + if (!ok) + mNativeDisplayID = RCAR_DEFAULT_DISPLAY; + + r_wm_Error_t wm_err = R_WM_DevInit(mNativeDisplayID); + if (wm_err != R_WM_ERR_OK) + qFatal("Failed to init WM Dev: %d, error: %d", mNativeDisplayID, wm_err); + wm_err = R_WM_ScreenBgColorSet(mNativeDisplayID, 0x20, 0x20, 0x20); // Grey + if (wm_err != R_WM_ERR_OK) + qFatal("Failed to set screen background: %d", wm_err); + wm_err = R_WM_ScreenEnable(mNativeDisplayID); + if (wm_err != R_WM_ERR_OK) + qFatal("Failed to enable screen: %d", wm_err); } QSize QEglFSRcarIntegration::screenSize() const @@ -104,14 +120,6 @@ EGLNativeWindowType QEglFSRcarIntegration::createNativeWindow(QPlatformWindow *w { bool ok; - mNativeDisplayID = qEnvironmentVariableIntValue("QT_QPA_WM_DISP_ID", &ok); - if (!ok) - mNativeDisplayID = RCAR_DEFAULT_DISPLAY; - - r_wm_Error_t wm_err = R_WM_DevInit(mNativeDisplayID); - if (wm_err != R_WM_ERR_OK) - qFatal("Failed to init WM Dev: %d, error: %d", mNativeDisplayID, wm_err); - mNativeWindow = (EGLNativeWindowTypeREL*)malloc(sizeof(EGLNativeWindowTypeREL)); memset(mNativeWindow, 0, sizeof(EGLNativeWindowTypeREL)); @@ -134,7 +142,7 @@ EGLNativeWindowType QEglFSRcarIntegration::createNativeWindow(QPlatformWindow *w mNativeWindow->Surface.Type = R_WM_SURFACE_FB; mNativeWindow->Surface.BufMode = R_WM_WINBUF_ALLOC_INTERNAL; - wm_err = R_WM_WindowCreate(mNativeDisplayID, mNativeWindow); + r_wm_Error_t wm_err = R_WM_WindowCreate(mNativeDisplayID, mNativeWindow); if (wm_err != R_WM_ERR_OK) qFatal("Failed to create window layer: %d", wm_err); wm_err = R_WM_DevEventRegister(mNativeDisplayID, R_WM_EVENT_VBLANK, 0); diff --git a/src/plugins/platforms/qnx/qqnxnativeinterface.cpp b/src/plugins/platforms/qnx/qqnxnativeinterface.cpp index 3eebb9c742..3bd6a86b59 100644 --- a/src/plugins/platforms/qnx/qqnxnativeinterface.cpp +++ b/src/plugins/platforms/qnx/qqnxnativeinterface.cpp @@ -91,6 +91,9 @@ void *QQnxNativeInterface::nativeResourceForScreen(const QByteArray &resource, Q void *QQnxNativeInterface::nativeResourceForIntegration(const QByteArray &resource) { + if (resource == "screenContext") + return m_integration->screenContext(); + return 0; } diff --git a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp index dc844189d1..0014ef8c6e 100644 --- a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp @@ -158,7 +158,7 @@ QQnxBuffer &QQnxRasterWindow::renderBuffer() "Failed to clear window buffer"); } - Q_SCREEN_CHECKERROR(screen_flush_blits(platformScreen->nativeContext(), 0), + Q_SCREEN_CHECKERROR(screen_flush_blits(platformScreen->nativeContext(), SCREEN_WAIT_IDLE), "Failed to flush blits"); // Use the first available render buffer diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp index 5d230e2145..f211883e4f 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp @@ -591,6 +591,10 @@ void QQnxScreenEventHandler::handlePropertyEvent(screen_event_t event) case SCREEN_PROPERTY_FOCUS: handleKeyboardFocusPropertyEvent(window); break; + case SCREEN_PROPERTY_SIZE: + case SCREEN_PROPERTY_POSITION: + handleGeometryPropertyEvent(window); + break; default: // event ignored qScreenEventDebug() << "Ignore property event for property: " << property; @@ -617,6 +621,28 @@ void QQnxScreenEventHandler::handleKeyboardFocusPropertyEvent(screen_window_t wi m_focusLostTimer = startTimer(50); } +void QQnxScreenEventHandler::handleGeometryPropertyEvent(screen_window_t window) +{ + int pos[2]; + if (screen_get_window_property_iv(window, SCREEN_PROPERTY_POSITION, pos) != 0) { + qFatal("QQnx: failed to query window property, errno=%d", errno); + } + + int size[2]; + if (screen_get_window_property_iv(window, SCREEN_PROPERTY_SIZE, size) != 0) { + qFatal("QQnx: failed to query window property, errno=%d", errno); + } + + QRect rect(pos[0], pos[1], size[0], size[1]); + QWindow *qtWindow = QQnxIntegration::window(window); + if (qtWindow) { + qtWindow->setGeometry(rect); + QWindowSystemInterface::handleGeometryChange(qtWindow, rect); + } + + qScreenEventDebug() << qtWindow << "moved to" << rect; +} + void QQnxScreenEventHandler::timerEvent(QTimerEvent *event) { if (event->timerId() == m_focusLostTimer) { diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.h b/src/plugins/platforms/qnx/qqnxscreeneventhandler.h index d872f9b9aa..40697b7a09 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.h +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.h @@ -85,6 +85,7 @@ private: void handleDisplayEvent(screen_event_t event); void handlePropertyEvent(screen_event_t event); void handleKeyboardFocusPropertyEvent(screen_window_t window); + void handleGeometryPropertyEvent(screen_window_t window); private: enum { diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index df458e85d7..e1bd8eb752 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -750,7 +750,12 @@ void QXcbScreen::updateGeometry(const QRect &geometry, uint8_t rotation) m_sizeMillimeters = sizeInMillimeters(geometry.size(), virtualDpi()); qreal dpi = geometry.width() / physicalSize().width() * qreal(25.4); - m_pixelDensity = qMax(1, qRound(dpi/96)); + qreal rawFactor = dpi/96; + int roundedFactor = qFloor(rawFactor); + // Round up for .8 and higher. This favors "small UI" over "large UI". + if (rawFactor - roundedFactor >= 0.8) + roundedFactor = qCeil(rawFactor); + m_pixelDensity = qMax(1, roundedFactor); m_geometry = geometry; m_availableGeometry = geometry & m_virtualDesktop->workArea(); QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry); diff --git a/src/plugins/printsupport/cups/qcupsprintengine.cpp b/src/plugins/printsupport/cups/qcupsprintengine.cpp index f204e3b0da..c9683eb99d 100644 --- a/src/plugins/printsupport/cups/qcupsprintengine.cpp +++ b/src/plugins/printsupport/cups/qcupsprintengine.cpp @@ -285,7 +285,10 @@ void QCupsPrintEnginePrivate::changePrinter(const QString &newPrinter) grayscale = m_printDevice.defaultColorMode() == QPrint::GrayScale; // Get the equivalent page size for this printer as supported names may be different - setPageSize(m_pageLayout.pageSize()); + if (m_printDevice.supportedPageSize(m_pageLayout.pageSize()).isValid()) + setPageSize(m_pageLayout.pageSize()); + else + setPageSize(QPageSize(m_pageLayout.pageSize().size(QPageSize::Point), QPageSize::Point)); } void QCupsPrintEnginePrivate::setPageSize(const QPageSize &pageSize) |