From 2ec93e29f75e0cb37650255d478b8e3a9da4dc25 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 9 Oct 2019 15:48:03 +0200 Subject: Cocoa: Update the PPK_PrinterName property if one is explicitly set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a QPrinterInfo is passed in to the QPrinter then it needs to ensure that the underlying session is set up to use the specified printer, otherwise it uses the default one as it has not been changed. Change-Id: I90012223e9831303d02fd3ffc68223dc492ece0c Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qprintengine_mac.mm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm index 58ad53a6e1..dcb9a85a3c 100644 --- a/src/plugins/platforms/cocoa/qprintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm @@ -59,6 +59,8 @@ QMacPrintEngine::QMacPrintEngine(QPrinter::PrinterMode mode, const QString &devi QString id = deviceId; if (id.isEmpty()) id = QCocoaPrinterSupport().defaultPrintDeviceId(); + else + setProperty(QPrintEngine::PPK_PrinterName, deviceId); d->m_printDevice.reset(new QCocoaPrintDevice(id)); d->m_pageLayout.setPageSize(d->m_printDevice->defaultPageSize()); d->initialize(); -- cgit v1.2.3 From ed7dd9a6edd7afd8798751c8b1d3ee7802ae253f Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 6 Oct 2019 12:56:34 +0200 Subject: QODBC: Fix crash when a prepared statement is deleted after the db was removed When a prepared statement is still alive after the database was removed with QSqlDatabase::removeDatabase(), the cleanup routine is trying to access the driver which is no longer alive which results in a crash. Fixes: QTBUG-79019 Change-Id: I4630e3b947a12b23ed062f015abc373fc0e246c1 Reviewed-by: Andy Shaw --- src/plugins/sqldrivers/odbc/qsql_odbc.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp index 7f98efccba..7709b13cd1 100644 --- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp +++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp @@ -221,18 +221,18 @@ public: int disconnectCount; bool hasSQLFetchScroll; - bool isStmtHandleValid(); + bool isStmtHandleValid() const; void updateStmtHandleState(); }; -bool QODBCResultPrivate::isStmtHandleValid() +bool QODBCResultPrivate::isStmtHandleValid() const { - return disconnectCount == drv_d_func()->disconnectCount; + return drv_d_func() && disconnectCount == drv_d_func()->disconnectCount; } void QODBCResultPrivate::updateStmtHandleState() { - disconnectCount = drv_d_func()->disconnectCount; + disconnectCount = drv_d_func() ? drv_d_func()->disconnectCount : 0; } static QString qWarnODBCHandle(int handleType, SQLHANDLE handle, int *nativeCode = 0) @@ -975,7 +975,7 @@ QODBCResult::QODBCResult(const QODBCDriver *db) QODBCResult::~QODBCResult() { Q_D(QODBCResult); - if (d->hStmt && d->isStmtHandleValid() && driver()->isOpen()) { + if (d->hStmt && d->isStmtHandleValid() && driver() && driver()->isOpen()) { SQLRETURN r = SQLFreeHandle(SQL_HANDLE_STMT, d->hStmt); if (r != SQL_SUCCESS) qSqlWarning(QLatin1String("QODBCDriver: Unable to free statement handle ") -- cgit v1.2.3 From 5c37258b06107d247f254fc7e3e852d2838e0a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 8 Oct 2019 18:31:33 +0200 Subject: macOS: Don't dismiss menu during applicationShouldTerminate The logic was a leftover from the Carbon days and is no longer needed. Change-Id: I557b669eadea902fa439c43162218c5864077df9 Reviewed-by: Volker Hilsheimer --- src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 00f5a1bf09..9daf65abcf 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -142,8 +142,6 @@ QT_USE_NAMESPACE - (BOOL)canQuit { - [[NSApp mainMenu] cancelTracking]; - bool handle_quit = true; NSMenuItem *quitMenuItem = [[QCocoaMenuLoader sharedMenuLoader] quitMenuItem]; if (!QGuiApplicationPrivate::instance()->modalWindowList.isEmpty() -- cgit v1.2.3 From 14b61d48e8bad6223a08843cf363ef48f09c479b Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 11 Oct 2019 20:53:49 +0200 Subject: QPSQL: Add support for PostgreSQL 12 Add proper version check and replace long deprecated and now removed access to pg_attrdef.adsrc. [ChangeLog][QtSql][QPSQL] added support for PostgreSQL 12 Fixes: QTBUG-79033 Fixes: QTBUG-79064 Change-Id: Iec1b13945c34ea017139ad1c5539ab5b7f1e03aa Reviewed-by: Edward Welbourne --- src/plugins/sqldrivers/psql/qsql_psql.cpp | 43 +++++++++++++++++-------------- src/plugins/sqldrivers/psql/qsql_psql_p.h | 1 + 2 files changed, 25 insertions(+), 19 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index 3803f05b9f..760685f64b 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -1078,8 +1078,10 @@ static QPSQLDriver::Protocol qMakePSQLVersion(int vMaj, int vMin) return QPSQLDriver::Version10; case 11: return QPSQLDriver::Version11; + case 12: + return QPSQLDriver::Version12; default: - if (vMaj > 11) + if (vMaj > 12) return QPSQLDriver::UnknownLaterVersion; break; } @@ -1439,26 +1441,29 @@ QSqlRecord QPSQLDriver::record(const QString &tablename) const schema = stripDelimiters(schema, QSqlDriver::TableName); tbl = stripDelimiters(tbl, QSqlDriver::TableName); - QString stmt = QStringLiteral("SELECT pg_attribute.attname, pg_attribute.atttypid::int, " - "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, " - "pg_attrdef.adsrc " - "FROM pg_class, pg_attribute " - "LEFT JOIN pg_attrdef ON (pg_attrdef.adrelid = " - "pg_attribute.attrelid AND pg_attrdef.adnum = pg_attribute.attnum) " - "WHERE %1 " - "AND pg_class.relname = '%2' " - "AND pg_attribute.attnum > 0 " - "AND pg_attribute.attrelid = pg_class.oid " - "AND pg_attribute.attisdropped = false " - "ORDER BY pg_attribute.attnum"); - if (schema.isEmpty()) - stmt = stmt.arg(QStringLiteral("pg_table_is_visible(pg_class.oid)")); - else - stmt = stmt.arg(QStringLiteral("pg_class.relnamespace = (SELECT oid FROM " - "pg_namespace WHERE pg_namespace.nspname = '%1')").arg(schema)); + const QString adsrc = protocol() < Version8 + ? QStringLiteral("pg_attrdef.adsrc") + : QStringLiteral("pg_get_expr(pg_attrdef.adbin, pg_attrdef.adrelid)"); + const QString nspname = schema.isEmpty() + ? QStringLiteral("pg_table_is_visible(pg_class.oid)") + : QStringLiteral("pg_class.relnamespace = (SELECT oid FROM " + "pg_namespace WHERE pg_namespace.nspname = '%1')").arg(schema); + const QString stmt = + QStringLiteral("SELECT pg_attribute.attname, pg_attribute.atttypid::int, " + "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, " + "%1 " + "FROM pg_class, pg_attribute " + "LEFT JOIN pg_attrdef ON (pg_attrdef.adrelid = " + "pg_attribute.attrelid AND pg_attrdef.adnum = pg_attribute.attnum) " + "WHERE %2 " + "AND pg_class.relname = '%3' " + "AND pg_attribute.attnum > 0 " + "AND pg_attribute.attrelid = pg_class.oid " + "AND pg_attribute.attisdropped = false " + "ORDER BY pg_attribute.attnum").arg(adsrc, nspname, tbl); QSqlQuery query(createResult()); - query.exec(stmt.arg(tbl)); + query.exec(stmt); while (query.next()) { int len = query.value(3).toInt(); int precision = query.value(4).toInt(); diff --git a/src/plugins/sqldrivers/psql/qsql_psql_p.h b/src/plugins/sqldrivers/psql/qsql_psql_p.h index 99e0b5f60f..9ac1fb50d7 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql_p.h +++ b/src/plugins/sqldrivers/psql/qsql_psql_p.h @@ -93,6 +93,7 @@ public: Version9_6 = 22, Version10 = 23, Version11 = 24, + Version12 = 25, UnknownLaterVersion = 100000 }; -- cgit v1.2.3 From ff2ba8b9d2798c4b7a77734df723d6312b983f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 14 Oct 2019 14:07:20 +0200 Subject: macOS: Let system decide whether modal window should prevent app termination The logic for preventing application termination when there are modal windows active was a leftover from the Carbon to Cocoa port, and is no longer needed. AppKit will deal with this on its own, by checking the preventsApplicationTerminationWhenModal property of each NSWindow. In some cases AppKit will also ignore this property, such as when quitting the application from the menu entry, which means we now get the default system behavior for this use-case. Change-Id: Iac5d8d8e17eb0974448f7ee6f39c9b7761bf4d90 Reviewed-by: Shawn Rutledge Reviewed-by: Volker Hilsheimer --- .../platforms/cocoa/qcocoaapplicationdelegate.mm | 25 +++------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 9daf65abcf..33a45985a8 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -142,28 +142,9 @@ QT_USE_NAMESPACE - (BOOL)canQuit { - bool handle_quit = true; - NSMenuItem *quitMenuItem = [[QCocoaMenuLoader sharedMenuLoader] quitMenuItem]; - if (!QGuiApplicationPrivate::instance()->modalWindowList.isEmpty() - && [quitMenuItem isEnabled]) { - int visible = 0; - const QWindowList tlws = QGuiApplication::topLevelWindows(); - for (int i = 0; i < tlws.size(); ++i) { - if (tlws.at(i)->isVisible()) - ++visible; - } - handle_quit = (visible <= 1); - } - - if (handle_quit) { - QCloseEvent ev; - QGuiApplication::sendEvent(qGuiApp, &ev); - if (ev.isAccepted()) { - return YES; - } - } - - return NO; + QCloseEvent ev; + QGuiApplication::sendEvent(qGuiApp, &ev); + return ev.isAccepted(); } // This function will only be called when NSApp is actually running. -- cgit v1.2.3 From 2967510213373fa92db94385e3904196637e8df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 14 Oct 2019 14:14:01 +0200 Subject: macOS: Merge [QCocoaApplicationDelegate canQuit] into callsite The logic for handling termination without any event loops has been moved up as an early exit, and the code has been modernized. Change-Id: I202720b9923e35732cffea656e1ce108ef11953d Reviewed-by: Paul Olav Tvete --- .../platforms/cocoa/qcocoaapplicationdelegate.mm | 54 ++++++++++------------ 1 file changed, 24 insertions(+), 30 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 33a45985a8..01abeb1a0e 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -140,46 +140,40 @@ QT_USE_NAMESPACE return [[self.dockMenu retain] autorelease]; } -- (BOOL)canQuit -{ - QCloseEvent ev; - QGuiApplication::sendEvent(qGuiApp, &ev); - return ev.isAccepted(); -} - // This function will only be called when NSApp is actually running. - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { if ([reflectionDelegate respondsToSelector:_cmd]) return [reflectionDelegate applicationShouldTerminate:sender]; - if ([self canQuit]) { - if (!startedQuit) { - startedQuit = true; - // Close open windows. This is done in order to deliver de-expose - // events while the event loop is still running. - const QWindowList topLevels = QGuiApplication::topLevelWindows(); - for (int i = 0; i < topLevels.size(); ++i) { - QWindow *topLevelWindow = topLevels.at(i); - // Already closed windows will not have a platform window, skip those - if (topLevelWindow->handle()) - QWindowSystemInterface::handleCloseEvent(topLevelWindow); - } - QWindowSystemInterface::flushWindowSystemEvents(); - - QGuiApplication::exit(0); - startedQuit = false; - } - } - if (QGuiApplicationPrivate::instance()->threadData->eventLoops.isEmpty()) { - // INVARIANT: No event loop is executing. This probably - // means that Qt is used as a plugin, or as a part of a native - // Cocoa application. In any case it should be fine to - // terminate now: + // No event loop is executing. This probably means that Qt is used as a plugin, + // or as a part of a native Cocoa application. In any case it should be fine to + // terminate now. return NSTerminateNow; } + QCloseEvent ev; + QGuiApplication::sendEvent(qGuiApp, &ev); + if (!ev.isAccepted()) + return NSTerminateCancel; + + if (!startedQuit) { + startedQuit = true; + // Close open windows. This is done in order to deliver de-expose + // events while the event loop is still running. + for (QWindow *topLevelWindow : QGuiApplication::topLevelWindows()) { + // Already closed windows will not have a platform window, skip those + if (!topLevelWindow->handle()) + continue; + + QWindowSystemInterface::handleCloseEvent(topLevelWindow); + } + + QGuiApplication::exit(0); + startedQuit = false; + } + return NSTerminateCancel; } -- cgit v1.2.3 From 1b6db1849477be30ef0ca52c288d358b911ea1e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 14 Oct 2019 15:58:50 +0200 Subject: Propagate application termination requests through QPA Instead of having each platform plugin deal with application termination in their own weird ways, we now have a QPA API to signal that the system requested the application to terminate. On the QGuiApplication side this results in a Quit event being sent to the application, which triggers the default behavior of closing all app windows, and then finally calling QCoreApplication::quit(). The quit event replaces the misuse of a close event being sent to the application. Close events are documented as being sent to windows. The close events that are sent to individual windows as part of the quit process can be ignored. This will skip the final quit() of the application, and also inform the platform that the quit was not accepted, in case that should be propagated further. In the future the logic for closing windows should be unified between the various approaches in closeAllWindows, shouldQuit, and friends. Change-Id: I0ed7f1c0d3f0bf1a755e1dd4066e1575fc3a28e1 Reviewed-by: Paul Olav Tvete --- .../platforms/cocoa/qcocoaapplicationdelegate.mm | 31 +++++++++------------- src/plugins/platforms/haiku/qhaikuapplication.cpp | 5 ++-- src/plugins/platforms/xcb/qxcbsessionmanager.cpp | 5 ++-- 3 files changed, 18 insertions(+), 23 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 01abeb1a0e..9b0a6b1b86 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -88,10 +88,13 @@ #include #include +QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcQpaApplication, "qt.qpa.application"); +QT_END_NAMESPACE + QT_USE_NAMESPACE @implementation QCocoaApplicationDelegate { - bool startedQuit; NSObject *reflectionDelegate; bool inLaunch; } @@ -150,30 +153,20 @@ QT_USE_NAMESPACE // No event loop is executing. This probably means that Qt is used as a plugin, // or as a part of a native Cocoa application. In any case it should be fine to // terminate now. + qCDebug(lcQpaApplication) << "No running event loops, terminating now"; return NSTerminateNow; } - QCloseEvent ev; - QGuiApplication::sendEvent(qGuiApp, &ev); - if (!ev.isAccepted()) + if (!QWindowSystemInterface::handleApplicationTermination()) { + qCDebug(lcQpaApplication) << "Application termination canceled"; return NSTerminateCancel; - - if (!startedQuit) { - startedQuit = true; - // Close open windows. This is done in order to deliver de-expose - // events while the event loop is still running. - for (QWindow *topLevelWindow : QGuiApplication::topLevelWindows()) { - // Already closed windows will not have a platform window, skip those - if (!topLevelWindow->handle()) - continue; - - QWindowSystemInterface::handleCloseEvent(topLevelWindow); - } - - QGuiApplication::exit(0); - startedQuit = false; } + // Even if the application termination was accepted by the application we can't + // return NSTerminateNow, as that would trigger AppKit to ultimately call exit(). + // We need to ensure that the runloop continues spinning so that we can return + // from our own event loop back to main(), and exit from there. + qCDebug(lcQpaApplication) << "Termination accepted, but returning to runloop for exit through main()"; return NSTerminateCancel; } diff --git a/src/plugins/platforms/haiku/qhaikuapplication.cpp b/src/plugins/platforms/haiku/qhaikuapplication.cpp index b75810c453..de4acdfd4a 100644 --- a/src/plugins/platforms/haiku/qhaikuapplication.cpp +++ b/src/plugins/platforms/haiku/qhaikuapplication.cpp @@ -42,6 +42,8 @@ #include #include +#include + #include #include @@ -52,8 +54,7 @@ QHaikuApplication::QHaikuApplication(const char *signature) bool QHaikuApplication::QuitRequested() { - QEvent quitEvent(QEvent::Quit); - QCoreApplication::sendEvent(QCoreApplication::instance(), &quitEvent); + QWindowSystemInterface::handleApplicationTermination(); return true; } diff --git a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp index 2303ccf806..f880d4d722 100644 --- a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp +++ b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp @@ -42,6 +42,8 @@ #ifndef QT_NO_SESSIONMANAGER +#include + #include #include #include @@ -289,8 +291,7 @@ static void sm_dieCallback(SmcConn smcConn, SmPointer /* clientData */) if (smcConn != smcConnection) return; resetSmState(); - QEvent quitEvent(QEvent::Quit); - QGuiApplication::sendEvent(qApp, &quitEvent); + QWindowSystemInterface::handleApplicationTermination(); } static void sm_shutdownCancelledCallback(SmcConn smcConn, SmPointer clientData) -- cgit v1.2.3 From d3398207d0384e786f466662fa40c6fb86844fb6 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 16 Oct 2019 11:34:29 +0200 Subject: Revert "Release left button before showing the popup context menu" This partially reverts commit 5e8b16f0e4247cc978b08480450526cfa3b25029. Releasing the mouse button synthetically made it impossible to use tap and hold gestures. When investigating, it seems that other changes have fixed the original issue that 5e8b16f0e4247cc978b08480450526cfa3b25029 was meant to address, so this is no longer needed. [ChangeLog][Android] Fixed regression that made it impossible for an application to use the tap-and-hold gesture. Fixes: QTBUG-72408 Change-Id: I53f687d047a4ad0fdf3c8c96a00ed1b11d09f047 Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/androidjniinput.cpp | 14 -------------- src/plugins/platforms/android/androidjniinput.h | 2 -- src/plugins/platforms/android/qandroidinputcontext.cpp | 3 --- 3 files changed, 19 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index 9cdc5de0e1..56885f2e23 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -195,20 +195,6 @@ namespace QtAndroidInput angleDelta); } - void releaseMouse(int x, int y) - { - m_ignoreMouseEvents = true; - QPoint globalPos(x,y); - QWindow *tlw = topLevelWindowAt(globalPos); - QPoint localPos = tlw ? (globalPos-tlw->position()) : globalPos; - - // Release left button - QWindowSystemInterface::handleMouseEvent(tlw, - localPos, - globalPos, - Qt::MouseButtons(Qt::NoButton)); - } - static void longPress(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint x, jint y) { QAndroidInputContext *inputContext = QAndroidInputContext::androidInputContext(); diff --git a/src/plugins/platforms/android/androidjniinput.h b/src/plugins/platforms/android/androidjniinput.h index 2e2470ae8f..cc3070c4aa 100644 --- a/src/plugins/platforms/android/androidjniinput.h +++ b/src/plugins/platforms/android/androidjniinput.h @@ -61,8 +61,6 @@ namespace QtAndroidInput void updateHandles(int handleCount, QPoint editMenuPos = QPoint(), uint32_t editButtons = 0, QPoint cursor = QPoint(), QPoint anchor = QPoint(), bool rtl = false); bool registerNatives(JNIEnv *env); - - void releaseMouse(int x, int y); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 5614d3b04f..e78c317863 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -827,9 +827,6 @@ void QAndroidInputContext::longPress(int x, int y) focusObjectStopComposing(); - // Release left button, otherwise the following events will cancel the menu popup - QtAndroidInput::releaseMouse(x, y); - const double pixelDensity = QGuiApplication::focusWindow() ? QHighDpiScaling::factor(QGuiApplication::focusWindow()) -- cgit v1.2.3 From 444e947aadc82e2aeb72fa5b3e6a352ff02441f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 23 Oct 2019 15:33:46 +0200 Subject: macOS: Improve handling of wantsBestResolutionOpenGLSurface We were disabling wantsBestResolutionOpenGLSurface whenever we detected the Apple software renderer, but this isn't needed when layer-backed, and did in fact result in the exact same visual result as the bug the code was working around -- only rendering to a quarter of the viewport. We now apply the workaround only when software rendering is combined with surface-backed views. The logic has also been improved to not rely on string comparison to look for the software renderer, but instead uses the renderer ID that the context provides. Since tweaking the wantsBestResolutionOpenGLSurface is only relevant when using a window for GL rendering the logic has been moved into QCocoaGLContext. Change-Id: I021aaefbb7a9782bc8ee3c9703da246510326d50 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoaglcontext.h | 4 ++- src/plugins/platforms/cocoa/qcocoaglcontext.mm | 46 ++++++++++++++++---------- src/plugins/platforms/cocoa/qnsview_drawing.mm | 11 ------ 3 files changed, 31 insertions(+), 30 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h index bb309c0713..4210a4ed3f 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.h +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE +class QCocoaWindow; + class QCocoaGLContext : public QPlatformOpenGLContext { public: @@ -76,12 +78,12 @@ private: static NSOpenGLPixelFormat *pixelFormatForSurfaceFormat(const QSurfaceFormat &format); bool setDrawable(QPlatformSurface *surface); + void prepareDrawable(QCocoaWindow *platformWindow); void updateSurfaceFormat(); NSOpenGLContext *m_context = nil; NSOpenGLContext *m_shareContext = nil; QSurfaceFormat m_format; - bool m_didCheckForSoftwareContext = false; QVarLengthArray m_updateObservers; QAtomicInt m_needsUpdate = false; }; diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index ba7d12ce30..76a210d0b6 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -368,23 +368,6 @@ bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface) [m_context makeCurrentContext]; if (surface->surface()->surfaceClass() == QSurface::Window) { - // Disable high-resolution surfaces when using the software renderer, which has the - // problem that the system silently falls back to a to using a low-resolution buffer - // when a high-resolution buffer is requested. This is not detectable using the NSWindow - // convertSizeToBacking and backingScaleFactor APIs. A typical result of this is that Qt - // will display a quarter of the window content when running in a virtual machine. - if (!m_didCheckForSoftwareContext) { - // FIXME: This ensures we check only once per context, - // but the context may be used for multiple surfaces. - m_didCheckForSoftwareContext = true; - - const GLubyte* renderer = glGetString(GL_RENDERER); - if (qstrcmp((const char *)renderer, "Apple Software Renderer") == 0) { - NSView *view = static_cast(surface)->m_view; - [view setWantsBestResolutionOpenGLSurface:NO]; - } - } - if (m_needsUpdate.fetchAndStoreRelaxed(false)) update(); } @@ -413,11 +396,14 @@ bool QCocoaGLContext::setDrawable(QPlatformSurface *surface) } Q_ASSERT(surface->surface()->surfaceClass() == QSurface::Window); - QNSView *view = qnsview_cast(static_cast(surface)->view()); + auto *cocoaWindow = static_cast(surface); + QNSView *view = qnsview_cast(cocoaWindow->view()); if (view == m_context.view) return true; + prepareDrawable(cocoaWindow); + // Setting the drawable may happen on a separate thread as a result of // a call to makeCurrent, so we need to set up the observers before we // associate the view with the context. That way we will guarantee that @@ -460,6 +446,30 @@ bool QCocoaGLContext::setDrawable(QPlatformSurface *surface) return true; } +void QCocoaGLContext::prepareDrawable(QCocoaWindow *platformWindow) +{ + // We generally want high-DPI GL surfaces, unless the user has explicitly disabled them + bool prefersBestResolutionOpenGLSurface = qt_mac_resolveOption(YES, + platformWindow->window(), "_q_mac_wantsBestResolutionOpenGLSurface", + "QT_MAC_WANTS_BEST_RESOLUTION_OPENGL_SURFACE"); + + auto *view = platformWindow->view(); + + // The only case we have to opt out ourselves is when using the Apple software renderer + // in combination with surface-backed views, as these together do not support high-DPI. + if (prefersBestResolutionOpenGLSurface) { + int rendererID = 0; + [m_context getValues:&rendererID forParameter:NSOpenGLContextParameterCurrentRendererID]; + bool isSoftwareRenderer = (rendererID & kCGLRendererIDMatchingMask) == kCGLRendererGenericFloatID; + if (isSoftwareRenderer && !view.layer) { + qCInfo(lcQpaOpenGLContext) << "Disabling high resolution GL surface due to software renderer"; + prefersBestResolutionOpenGLSurface = false; + } + } + + view.wantsBestResolutionOpenGLSurface = prefersBestResolutionOpenGLSurface; +} + // NSOpenGLContext is not re-entrant. Even when using separate contexts per thread, // view, and window, calls into the API will still deadlock. For more information // see https://openradar.appspot.com/37064579 diff --git a/src/plugins/platforms/cocoa/qnsview_drawing.mm b/src/plugins/platforms/cocoa/qnsview_drawing.mm index eb9286519d..2fd63fad67 100644 --- a/src/plugins/platforms/cocoa/qnsview_drawing.mm +++ b/src/plugins/platforms/cocoa/qnsview_drawing.mm @@ -44,17 +44,6 @@ - (void)initDrawing { [self updateLayerBacking]; - - // Enable high-DPI OpenGL for retina displays. Enabling has the side - // effect that Cocoa will start calling glViewport(0, 0, width, height), - // overriding any glViewport calls in application code. This is usually not a - // problem, except if the application wants to have a "custom" viewport. - // (like the hellogl example) - if (m_platformWindow->window()->supportsOpenGL()) { - self.wantsBestResolutionOpenGLSurface = qt_mac_resolveOption(YES, m_platformWindow->window(), - "_q_mac_wantsBestResolutionOpenGLSurface", "QT_MAC_WANTS_BEST_RESOLUTION_OPENGL_SURFACE"); - // See also QCocoaGLContext::makeCurrent for software renderer workarounds. - } } - (BOOL)isOpaque -- cgit v1.2.3 From f39230fcac4de01f26945bde16c3a10c5ac74afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 18 Oct 2019 16:23:48 +0200 Subject: macOS: Skip NSOpenGLContext flush if window exposed size is out of sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some clients such as QOpenGLWidget will end up drawing and flushing during the resize event, which for GL will result in an immediate update on the screen. The problem is that the underlying Core Animation layer, and the window's frame, has not been visually updated yet to the new size, so we end up drawing "ahead" of what the window server is showing the user. Ideally we'd be able to present the GL drawing in a transaction, in sync with the drawing of the window frame, but this API is only available for CAMetalLayer and CAEAGLLayer. As a workaround we detect when the exposed size is out of sync with the window geometry, and skip the flush until the exposed size has caught up. We know this will happen eventually as AppKit will always ask us to display after a resize. Change-Id: I1739ac8878b3fc6820a55dd017ddd170fd5f55d6 Fixes: QTBUG-79139 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaglcontext.mm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index 76a210d0b6..7452d53579 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -501,6 +501,21 @@ void QCocoaGLContext::swapBuffers(QPlatformSurface *surface) return; } + if (m_context.view.layer) { + // Flushing an NSOpenGLContext will hit the screen immediately, ignoring + // any Core Animation transactions in place. This may result in major + // visual artifacts if the flush happens out of sync with the size + // of the layer, view, and window reflected by other parts of the UI, + // e.g. if the application flushes in the resize event or a timer during + // window resizing, instead of in the expose event. + auto *cocoaWindow = static_cast(surface); + if (cocoaWindow->geometry().size() != cocoaWindow->m_exposedRect.size()) { + qCInfo(lcQpaOpenGLContext) << "Window exposed size does not match geometry (yet)." + << "Skipping flush to avoid visual artifacts."; + return; + } + } + QMutexLocker locker(&s_reentrancyMutex); [m_context flushBuffer]; } -- cgit v1.2.3 From 312793f28eaa1eddd8ffd15f42f51c31ecd1c4ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 23 Oct 2019 13:15:07 +0200 Subject: macOS: Respect Qt::AA_UseSoftwareOpenGL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia83e8e9e571e4f46d2a8d810c376015552755457 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaglcontext.mm | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index 7452d53579..900f0608c8 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -223,6 +223,12 @@ NSOpenGLPixelFormat *QCocoaGLContext::pixelFormatForSurfaceFormat(const QSurface attrs << NSOpenGLPFAAllowOfflineRenderers; } + if (qGuiApp->testAttribute(Qt::AA_UseSoftwareOpenGL)) { + // kCGLRendererGenericFloatID is the modern software renderer on macOS, + // as opposed to kCGLRendererGenericID, which is deprecated. + attrs << NSOpenGLPFARendererID << kCGLRendererGenericFloatID; + } + // FIXME: Pull this information out of the NSView QByteArray useLayer = qgetenv("QT_MAC_WANTS_LAYER"); if (!useLayer.isEmpty() && useLayer.toInt() > 0) { -- cgit v1.2.3 From f2edc6cb3a12063005c77aae7946f4a07d3bd30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 23 Oct 2019 13:21:32 +0200 Subject: macOS: Don't set NSOpenGLPFANoRecovery for layer-backed views MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Apple software renderer is perfectly capable of being used when compositing CA layers. Change-Id: I3b78ff61a79869ecdb7bd431388041f2c124472e Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaglcontext.mm | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index 900f0608c8..b312e033cd 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -229,14 +229,6 @@ NSOpenGLPixelFormat *QCocoaGLContext::pixelFormatForSurfaceFormat(const QSurface attrs << NSOpenGLPFARendererID << kCGLRendererGenericFloatID; } - // FIXME: Pull this information out of the NSView - QByteArray useLayer = qgetenv("QT_MAC_WANTS_LAYER"); - if (!useLayer.isEmpty() && useLayer.toInt() > 0) { - // Disable the software rendering fallback. This makes compositing - // OpenGL and raster NSViews using Core Animation layers possible. - attrs << NSOpenGLPFANoRecovery; - } - attrs << 0; // 0-terminate array return [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs.constData()]; } -- cgit v1.2.3 From 7a605edc226d4051602e157fe575f17dfaac0964 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 21 Oct 2019 10:09:03 +0200 Subject: Fix static linking when bearer management plugins are built, part 2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After commit 5f160a3699d80d1736f691ad9ef774eb6aa28079 moved the code that's shared across all bearer management plugins into QtNetwork, there is one piece of code remaining that's shared across the connman and the networkmanager bearer plugin: The dbus ofono interface code. To avoid linking that twice (and causing duplicate symbol errors), this patch moves it into a static platform support library. This way for shared builds the code is included twice, but for static builds only once. Change-Id: Idf5414bc22fea45f11c600f28eaea91bb4dc6308 Reviewed-by: Mårten Nordheim --- src/plugins/bearer/connman/connman.pro | 4 +- src/plugins/bearer/connman/qconnmanengine.h | 2 +- .../bearer/linux_common/qofonoservice_linux.cpp | 384 --------------------- .../bearer/linux_common/qofonoservice_linux_p.h | 207 ----------- .../bearer/networkmanager/networkmanager.pro | 8 +- .../networkmanager/qnetworkmanagerengine.cpp | 1 - .../bearer/networkmanager/qnetworkmanagerengine.h | 2 +- 7 files changed, 6 insertions(+), 602 deletions(-) delete mode 100644 src/plugins/bearer/linux_common/qofonoservice_linux.cpp delete mode 100644 src/plugins/bearer/linux_common/qofonoservice_linux_p.h (limited to 'src/plugins') diff --git a/src/plugins/bearer/connman/connman.pro b/src/plugins/bearer/connman/connman.pro index d6577e9d7f..03e94cfe6a 100644 --- a/src/plugins/bearer/connman/connman.pro +++ b/src/plugins/bearer/connman/connman.pro @@ -1,14 +1,12 @@ TARGET = qconnmanbearer -QT = core network-private dbus +QT = core network-private dbus linuxofono_support_private HEADERS += qconnmanservice_linux_p.h \ - ../linux_common/qofonoservice_linux_p.h \ qconnmanengine.h SOURCES += main.cpp \ qconnmanservice_linux.cpp \ - ../linux_common/qofonoservice_linux.cpp \ qconnmanengine.cpp OTHER_FILES += connman.json diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h index eb79dbec1b..969eed45b1 100644 --- a/src/plugins/bearer/connman/qconnmanengine.h +++ b/src/plugins/bearer/connman/qconnmanengine.h @@ -54,7 +54,7 @@ #include #include "qconnmanservice_linux_p.h" -#include "../linux_common/qofonoservice_linux_p.h" +#include #include #include diff --git a/src/plugins/bearer/linux_common/qofonoservice_linux.cpp b/src/plugins/bearer/linux_common/qofonoservice_linux.cpp deleted file mode 100644 index 05f9b3ca17..0000000000 --- a/src/plugins/bearer/linux_common/qofonoservice_linux.cpp +++ /dev/null @@ -1,384 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "qofonoservice_linux_p.h" - -#ifndef QT_NO_DBUS - -QDBusArgument &operator<<(QDBusArgument &argument, const ObjectPathProperties &item) -{ - argument.beginStructure(); - argument << item.path << item.properties; - argument.endStructure(); - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, ObjectPathProperties &item) -{ - argument.beginStructure(); - argument >> item.path >> item.properties; - argument.endStructure(); - return argument; -} - -QT_BEGIN_NAMESPACE - -QOfonoManagerInterface::QOfonoManagerInterface( QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), - QLatin1String(OFONO_MANAGER_PATH), - OFONO_MANAGER_INTERFACE, - QDBusConnection::systemBus(), parent) -{ - qDBusRegisterMetaType(); - qDBusRegisterMetaType(); - - QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), - QLatin1String(OFONO_MANAGER_PATH), - QLatin1String(OFONO_MANAGER_INTERFACE), - QLatin1String("ModemAdded"), - this,SLOT(modemAdded(QDBusObjectPath,QVariantMap))); - QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), - QLatin1String(OFONO_MANAGER_PATH), - QLatin1String(OFONO_MANAGER_INTERFACE), - QLatin1String("ModemRemoved"), - this,SLOT(modemRemoved(QDBusObjectPath))); -} - -QOfonoManagerInterface::~QOfonoManagerInterface() -{ -} - -QStringList QOfonoManagerInterface::getModems() -{ - if (modemList.isEmpty()) { - QDBusPendingReply reply = call(QDBus::Block, QLatin1String("GetModems")); - reply.waitForFinished(); - if (!reply.isError()) { - const auto modems = reply.value(); - for (const ObjectPathProperties &modem : modems) - modemList << modem.path.path(); - } - } - - return modemList; -} - -QString QOfonoManagerInterface::currentModem() -{ - const QStringList modems = getModems(); - for (const QString &modem : modems) { - QOfonoModemInterface device(modem); - if (device.isPowered() && device.isOnline() - && device.interfaces().contains(QLatin1String("org.ofono.NetworkRegistration"))) - return modem; - } - return QString(); -} - -void QOfonoManagerInterface::modemAdded(const QDBusObjectPath &path, const QVariantMap &/*var*/) -{ - if (!modemList.contains(path.path())) { - modemList << path.path(); - Q_EMIT modemChanged(); - } -} - -void QOfonoManagerInterface::modemRemoved(const QDBusObjectPath &path) -{ - if (modemList.contains(path.path())) { - modemList.removeOne(path.path()); - Q_EMIT modemChanged(); - } -} - - -QOfonoModemInterface::QOfonoModemInterface(const QString &dbusPathName, QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), - dbusPathName, - OFONO_MODEM_INTERFACE, - QDBusConnection::systemBus(), parent) -{ - QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), - path(), - OFONO_MODEM_INTERFACE, - QLatin1String("PropertyChanged"), - this,SLOT(propertyChanged(QString,QDBusVariant))); -} - -QOfonoModemInterface::~QOfonoModemInterface() -{ -} - -void QOfonoModemInterface::propertyChanged(const QString &name,const QDBusVariant &value) -{ - propertiesMap[name] = value.variant(); -} - -bool QOfonoModemInterface::isPowered() -{ - QVariant var = getProperty(QStringLiteral("Powered")); - return qdbus_cast(var); -} - -bool QOfonoModemInterface::isOnline() -{ - QVariant var = getProperty(QStringLiteral("Online")); - return qdbus_cast(var); -} - -QStringList QOfonoModemInterface::interfaces() -{ - const QVariant var = getProperty(QStringLiteral("Interfaces")); - return var.toStringList(); -} - -QVariantMap QOfonoModemInterface::getProperties() -{ - if (propertiesMap.isEmpty()) { - QDBusPendingReply reply = call(QDBus::Block, QLatin1String("GetProperties")); - if (!reply.isError()) { - propertiesMap = reply.value(); - } - } - return propertiesMap; -} - -QVariant QOfonoModemInterface::getProperty(const QString &property) -{ - QVariant var; - QVariantMap map = getProperties(); - if (map.contains(property)) - var = map.value(property); - return var; -} - - -QOfonoNetworkRegistrationInterface::QOfonoNetworkRegistrationInterface(const QString &dbusPathName, QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), - dbusPathName, - OFONO_NETWORK_REGISTRATION_INTERFACE, - QDBusConnection::systemBus(), parent) -{ -} - -QOfonoNetworkRegistrationInterface::~QOfonoNetworkRegistrationInterface() -{ -} - -QString QOfonoNetworkRegistrationInterface::getTechnology() -{ - QVariant var = getProperty(QStringLiteral("Technology")); - return qdbus_cast(var); -} - -QVariant QOfonoNetworkRegistrationInterface::getProperty(const QString &property) -{ - QVariant var; - QVariantMap map = getProperties(); - if (map.contains(property)) - var = map.value(property); - return var; -} - -QVariantMap QOfonoNetworkRegistrationInterface::getProperties() -{ - if (propertiesMap.isEmpty()) { - QDBusPendingReply reply = call(QDBus::Block, QLatin1String("GetProperties")); - reply.waitForFinished(); - if (!reply.isError()) { - propertiesMap = reply.value(); - } - } - return propertiesMap; -} - -QOfonoDataConnectionManagerInterface::QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), - dbusPathName, - OFONO_DATA_CONNECTION_MANAGER_INTERFACE, - QDBusConnection::systemBus(), parent) -{ - QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), - path(), - QLatin1String(OFONO_MODEM_INTERFACE), - QLatin1String("PropertyChanged"), - this,SLOT(propertyChanged(QString,QDBusVariant))); -} - -QOfonoDataConnectionManagerInterface::~QOfonoDataConnectionManagerInterface() -{ -} - -QStringList QOfonoDataConnectionManagerInterface::contexts() -{ - if (contextList.isEmpty()) { - QDBusPendingReply reply = call(QLatin1String("GetContexts")); - reply.waitForFinished(); - if (!reply.isError()) { - const auto contexts = reply.value(); - for (const ObjectPathProperties &context : contexts) - contextList << context.path.path(); - } - } - return contextList; -} - -PathPropertiesList QOfonoDataConnectionManagerInterface::contextsWithProperties() -{ - if (contextListProperties.isEmpty()) { - QDBusPendingReply reply = call(QLatin1String("GetContexts")); - reply.waitForFinished(); - if (!reply.isError()) { - contextListProperties = reply.value(); - } - } - return contextListProperties; -} - -bool QOfonoDataConnectionManagerInterface::roamingAllowed() -{ - QVariant var = getProperty(QStringLiteral("RoamingAllowed")); - return qdbus_cast(var); -} - -QString QOfonoDataConnectionManagerInterface::bearer() -{ - QVariant var = getProperty(QStringLiteral("Bearer")); - return qdbus_cast(var); -} - -QVariant QOfonoDataConnectionManagerInterface::getProperty(const QString &property) -{ - return getProperties().value(property); -} - -QVariantMap &QOfonoDataConnectionManagerInterface::getProperties() -{ - if (propertiesMap.isEmpty()) { - QDBusPendingReply reply = call(QDBus::Block, QLatin1String("GetProperties")); - if (!reply.isError()) { - propertiesMap = reply.value(); - } - } - return propertiesMap; -} - -void QOfonoDataConnectionManagerInterface::propertyChanged(const QString &name, const QDBusVariant &value) -{ - propertiesMap[name] = value.variant(); - if (name == QLatin1String("RoamingAllowed")) - Q_EMIT roamingAllowedChanged(value.variant().toBool()); -} - - -QOfonoConnectionContextInterface::QOfonoConnectionContextInterface(const QString &dbusPathName, QObject *parent) - : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), - dbusPathName, - OFONO_CONNECTION_CONTEXT_INTERFACE, - QDBusConnection::systemBus(), parent) -{ - QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), - path(), - QLatin1String(OFONO_MODEM_INTERFACE), - QLatin1String("PropertyChanged"), - this,SLOT(propertyChanged(QString,QDBusVariant))); -} - -QOfonoConnectionContextInterface::~QOfonoConnectionContextInterface() -{ -} - -QVariantMap QOfonoConnectionContextInterface::getProperties() -{ - if (propertiesMap.isEmpty()) { - QDBusPendingReply reply = call(QDBus::Block, QLatin1String("GetProperties")); - if (!reply.isError()) { - propertiesMap = reply.value(); - } - } - return propertiesMap; -} - -void QOfonoConnectionContextInterface::propertyChanged(const QString &name, const QDBusVariant &value) -{ - propertiesMap[name] = value.variant(); -} - -QVariant QOfonoConnectionContextInterface::getProperty(const QString &property) -{ - QVariant var; - QVariantMap map = getProperties(); - if (map.contains(property)) - var = map.value(property); - return var; -} - -bool QOfonoConnectionContextInterface::active() -{ - QVariant var = getProperty(QStringLiteral("Active")); - return qdbus_cast(var); -} - -QString QOfonoConnectionContextInterface::accessPointName() -{ - QVariant var = getProperty(QStringLiteral("AccessPointName")); - return qdbus_cast(var); -} - -QString QOfonoConnectionContextInterface::name() -{ - QVariant var = getProperty(QStringLiteral("Name")); - return qdbus_cast(var); -} - -QT_END_NAMESPACE - -#endif // QT_NO_DBUS diff --git a/src/plugins/bearer/linux_common/qofonoservice_linux_p.h b/src/plugins/bearer/linux_common/qofonoservice_linux_p.h deleted file mode 100644 index 62df5d4fa7..0000000000 --- a/src/plugins/bearer/linux_common/qofonoservice_linux_p.h +++ /dev/null @@ -1,207 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QOFONOSERVICE_H -#define QOFONOSERVICE_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#ifndef QT_NO_DBUS - -#define OFONO_SERVICE "org.ofono" -#define OFONO_MANAGER_INTERFACE "org.ofono.Manager" -#define OFONO_MANAGER_PATH "/" - -#define OFONO_MODEM_INTERFACE "org.ofono.Modem" -#define OFONO_NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration" -#define OFONO_DATA_CONNECTION_MANAGER_INTERFACE "org.ofono.ConnectionManager" -#define OFONO_CONNECTION_CONTEXT_INTERFACE "org.ofono.ConnectionContext" - -QT_BEGIN_NAMESPACE - -QT_END_NAMESPACE - -struct ObjectPathProperties -{ - QDBusObjectPath path; - QVariantMap properties; -}; -QT_BEGIN_NAMESPACE -Q_DECLARE_TYPEINFO(ObjectPathProperties, Q_MOVABLE_TYPE); // QDBusObjectPath is movable, but cannot be - // marked as such until Qt 6 -QT_END_NAMESPACE - -typedef QVector PathPropertiesList; -Q_DECLARE_METATYPE(ObjectPathProperties) -Q_DECLARE_METATYPE (PathPropertiesList) - -QT_BEGIN_NAMESPACE - -class QOfonoManagerInterface : public QDBusAbstractInterface -{ - Q_OBJECT - -public: - - QOfonoManagerInterface( QObject *parent = nullptr); - ~QOfonoManagerInterface(); - - QStringList getModems(); - QString currentModem(); -signals: - void modemChanged(); -private: - QStringList modemList; -private slots: - void modemAdded(const QDBusObjectPath &path, const QVariantMap &var); - void modemRemoved(const QDBusObjectPath &path); -}; - -class QOfonoModemInterface : public QDBusAbstractInterface -{ - Q_OBJECT - -public: - - explicit QOfonoModemInterface(const QString &dbusModemPathName, QObject *parent = nullptr); - ~QOfonoModemInterface(); - - bool isPowered(); - bool isOnline(); - QStringList interfaces(); -private: - QVariantMap getProperties(); - QVariantMap propertiesMap; - QVariant getProperty(const QString &); - void propertyChanged(const QString &, const QDBusVariant &value); -}; - - -class QOfonoNetworkRegistrationInterface : public QDBusAbstractInterface -{ - Q_OBJECT - -public: - - explicit QOfonoNetworkRegistrationInterface(const QString &dbusModemPathName, QObject *parent = nullptr); - ~QOfonoNetworkRegistrationInterface(); - - QString getTechnology(); - -private: - QVariantMap getProperties(); - QVariant getProperty(const QString &); - QVariantMap propertiesMap; -Q_SIGNALS: - void propertyChanged(const QString &, const QDBusVariant &value); -}; - -class QOfonoDataConnectionManagerInterface : public QDBusAbstractInterface -{ - Q_OBJECT - -public: - - explicit QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent = nullptr); - ~QOfonoDataConnectionManagerInterface(); - - QStringList contexts(); - PathPropertiesList contextsWithProperties(); - bool roamingAllowed(); - QVariant getProperty(const QString &); - QString bearer(); -Q_SIGNALS: - void roamingAllowedChanged(bool); -private: - QVariantMap &getProperties(); - QVariantMap propertiesMap; - QStringList contextList; - PathPropertiesList contextListProperties; -private Q_SLOTS: - void propertyChanged(const QString &, const QDBusVariant &value); -}; - -class QOfonoConnectionContextInterface : public QDBusAbstractInterface -{ - Q_OBJECT - -public: - - explicit QOfonoConnectionContextInterface(const QString &dbusPathName, QObject *parent = nullptr); - ~QOfonoConnectionContextInterface(); - - QVariant getProperty(const QString &); - bool active(); - QString accessPointName(); - QString name(); - -Q_SIGNALS: -private: - QVariantMap getProperties(); - QVariantMap propertiesMap; -private slots: - void propertyChanged(const QString &, const QDBusVariant &value); -}; - -QT_END_NAMESPACE - -#endif // QT_NO_DBUS - -#endif //QOFONOSERVICE_H diff --git a/src/plugins/bearer/networkmanager/networkmanager.pro b/src/plugins/bearer/networkmanager/networkmanager.pro index 3fbad07ef5..3ca217f974 100644 --- a/src/plugins/bearer/networkmanager/networkmanager.pro +++ b/src/plugins/bearer/networkmanager/networkmanager.pro @@ -1,15 +1,13 @@ TARGET = qnmbearer -QT = core network-private dbus +QT = core network-private dbus linuxofono_support_private HEADERS += qnetworkmanagerservice.h \ - qnetworkmanagerengine.h \ - ../linux_common/qofonoservice_linux_p.h + qnetworkmanagerengine.h SOURCES += main.cpp \ qnetworkmanagerservice.cpp \ - qnetworkmanagerengine.cpp \ - ../linux_common/qofonoservice_linux.cpp + qnetworkmanagerengine.cpp OTHER_FILES += networkmanager.json diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index d686bc4e51..2fb5b2efbc 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -53,7 +53,6 @@ #include #include #include -#include "../linux_common/qofonoservice_linux_p.h" #ifndef QT_NO_DBUS diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h index c6c5280eca..c624d6087d 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h @@ -55,7 +55,7 @@ #include "qnetworkmanagerservice.h" -#include "../linux_common/qofonoservice_linux_p.h" +#include #include #include -- cgit v1.2.3 From 2fac76e719fcc3889441af08e71c2decb106676a Mon Sep 17 00:00:00 2001 From: Filippo Cucchetto Date: Fri, 25 Oct 2019 09:12:55 +0200 Subject: Windows QPA: add support for MouseDoubleClickDistance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Query the double click distance using the windows GetSystemMetric. See https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemmetrics Change-Id: I6198a38ab1a6216286897f8bdb305f334b7b148e Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/windows/qwindowstheme.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 437c9562ab..40f9652cbd 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -466,6 +466,8 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const result = int(scrollLines); return QVariant(result); } + case MouseDoubleClickDistance: + return GetSystemMetrics(SM_CXDOUBLECLK); default: break; } -- cgit v1.2.3 From a21d4395f4f9afea52b6c2da359ce6ad21ebc763 Mon Sep 17 00:00:00 2001 From: Yulong Bai Date: Thu, 10 Oct 2019 23:05:16 +0200 Subject: Drag'n'Drop: fix attached Drag object deleted when DnD is progressing The attached Drag object's owner, i.e. its parent, is also the dragged item. So the attached Drag object will also be destroyed as the dragged item is deleted. Fixes: QTBUG-65701 Change-Id: I39b0a3180f205c427deed5c70cd1912524f9324e Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbdrag.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 1ce947165d..3d525598ca 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -354,6 +354,11 @@ bool QXcbDrag::findXdndAwareTarget(const QPoint &globalPos, xcb_window_t *target void QXcbDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) { + // currentDrag() might be deleted while 'drag' is progressing + if (!currentDrag()) { + cancel(); + return; + } // The source sends XdndEnter and XdndPosition to the target. if (source_sameanswer.contains(globalPos) && source_sameanswer.isValid()) return; @@ -1076,7 +1081,8 @@ void QXcbDrag::cancel() send_leave(); // remove canceled object - currentDrag()->deleteLater(); + if (currentDrag()) + currentDrag()->deleteLater(); canceled = true; } -- cgit v1.2.3 From 22c3fd050843d2a56fb927492501c3798d253257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 25 Oct 2019 19:20:06 +0200 Subject: macOS: Remove assert that primary display always matches CGMainDisplayID Fixes: QTBUG-78707 Change-Id: Ia517f543728c76dcf19558e9e68ed97db7cfaaa4 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoascreen.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index 392099d083..0e55838e05 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -552,10 +552,10 @@ QPixmap QCocoaScreen::grabWindow(WId view, int x, int y, int width, int height) */ QCocoaScreen *QCocoaScreen::primaryScreen() { - auto screen = static_cast(QGuiApplication::primaryScreen()->handle()); - Q_ASSERT_X(screen == get(CGMainDisplayID()), "QCocoaScreen", - "The application's primary screen should always be in sync with the main display"); - return screen; + // Note: The primary screen that Qt knows about may not match the current CGMainDisplayID() + // if macOS has not yet been able to inform us that the main display has changed, but we + // will update the primary screen accordingly once the reconfiguration callback comes in. + return static_cast(QGuiApplication::primaryScreen()->handle()); } QList QCocoaScreen::virtualSiblings() const -- cgit v1.2.3 From 360a2e79c8abd90fb274b6dcbede222e1e5e37db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sun, 27 Oct 2019 18:23:10 +0100 Subject: macOS: Don't leak CFUUIDRefs when resolving NSScreen for platform screen Change-Id: I5609071346ef44dc9f16359db451ea9b29dd2b0d Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoascreen.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index 0e55838e05..886198d9d5 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -597,7 +597,7 @@ NSScreen *QCocoaScreen::nativeScreen() const QCFType uuid = CGDisplayCreateUUIDFromDisplayID(m_displayId); for (NSScreen *screen in [NSScreen screens]) { - if (CGDisplayCreateUUIDFromDisplayID(screen.qt_displayId) == uuid) + if (QCFType(CGDisplayCreateUUIDFromDisplayID(screen.qt_displayId)) == uuid) return screen; } -- cgit v1.2.3 From 5982451ac60057948f19af9adcf2b9ebb611cdfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sun, 27 Oct 2019 18:28:03 +0100 Subject: macOS: Class initialize QCocoaScreen members Change-Id: I163858400da28668b8a85241e9e6b1d989227a3e Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoascreen.h | 8 ++++---- src/plugins/platforms/cocoa/qcocoascreen.mm | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoascreen.h b/src/plugins/platforms/cocoa/qcocoascreen.h index 60243b79be..7ec9a2b5af 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.h +++ b/src/plugins/platforms/cocoa/qcocoascreen.h @@ -99,18 +99,18 @@ private: static void add(CGDirectDisplayID displayId); void remove(); - CGDirectDisplayID m_displayId = 0; + CGDirectDisplayID m_displayId = kCGNullDirectDisplay; QRect m_geometry; QRect m_availableGeometry; QDpi m_logicalDpi; - qreal m_refreshRate; - int m_depth; + qreal m_refreshRate = 0; + int m_depth = 0; QString m_name; QImage::Format m_format; QSizeF m_physicalSize; QCocoaCursor *m_cursor; - qreal m_devicePixelRatio; + qreal m_devicePixelRatio = 0; CVDisplayLinkRef m_displayLink = nullptr; dispatch_source_t m_displayLinkSource = nullptr; diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index 886198d9d5..7a54f616d0 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -127,7 +127,7 @@ void QCocoaScreen::cleanupScreens() void QCocoaScreen::remove() { - m_displayId = 0; // Prevent stale references during removal + m_displayId = kCGNullDirectDisplay; // Prevent stale references during removal // This may result in the application responding to QGuiApplication::screenRemoved // by moving the window to another screen, either by setGeometry, or by setScreen. -- cgit v1.2.3 From 3ee634d520b28143d4bbbf46c011449bade917de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sun, 27 Oct 2019 18:29:03 +0100 Subject: macOS: Extend QCocoaScreen logging Change-Id: I91f89ff336b3f48aea91e50860264bd8359805cb Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoascreen.mm | 34 ++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index 7a54f616d0..aaaf9d0dcc 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -54,6 +54,23 @@ QT_BEGIN_NAMESPACE +namespace CoreGraphics { + Q_NAMESPACE + enum DisplayChange { + Moved = kCGDisplayMovedFlag, + SetMain = kCGDisplaySetMainFlag, + SetMode = kCGDisplaySetModeFlag, + Added = kCGDisplayAddFlag, + Removed = kCGDisplayRemoveFlag, + Enabled = kCGDisplayEnabledFlag, + Disabled = kCGDisplayDisabledFlag, + Mirrored = kCGDisplayMirrorFlag, + UnMirrored = kCGDisplayUnMirrorFlag, + DesktopShapeChanged = kCGDisplayDesktopShapeChangedFlag + }; + Q_ENUM_NS(DisplayChange) +} + void QCocoaScreen::initializeScreens() { uint32_t displayCount = 0; @@ -73,6 +90,10 @@ void QCocoaScreen::initializeScreens() Q_UNUSED(userInfo); + qCDebug(lcQpaScreen).verbosity(0).nospace() << "Display reconfiguration" + << " (" << QFlags(flags) << ")" + << " for displayId=" << displayId; + QCocoaScreen *cocoaScreen = QCocoaScreen::get(displayId); if ((flags & kCGDisplayAddFlag) || !cocoaScreen) { @@ -99,16 +120,19 @@ void QCocoaScreen::initializeScreens() return; // Already reconfigured cocoaScreen->updateProperties(); - qCInfo(lcQpaScreen) << "Reconfigured" << cocoaScreen; + qCInfo(lcQpaScreen).nospace() << "Reconfigured " << + (primaryScreen() == cocoaScreen ? "primary " : "") + << cocoaScreen; } }, nullptr); } void QCocoaScreen::add(CGDirectDisplayID displayId) { + const bool isPrimary = CGDisplayIsMain(displayId); QCocoaScreen *cocoaScreen = new QCocoaScreen(displayId); - qCInfo(lcQpaScreen) << "Adding" << cocoaScreen; - QWindowSystemInterface::handleScreenAdded(cocoaScreen, CGDisplayIsMain(displayId)); + qCInfo(lcQpaScreen).nospace() << "Adding " << (isPrimary ? "new primary " : "") << cocoaScreen; + QWindowSystemInterface::handleScreenAdded(cocoaScreen, isPrimary); } QCocoaScreen::QCocoaScreen(CGDirectDisplayID displayId) @@ -140,6 +164,7 @@ void QCocoaScreen::remove() // QCocoaWindow::windowDidChangeScreen. At that point the window will appear to have // already changed its screen, but that's only true if comparing the Qt screens, // not when comparing the NSScreens. + qCInfo(lcQpaScreen).nospace() << "Removing " << (primaryScreen() == this ? "current primary " : "") << this; QWindowSystemInterface::handleScreenRemoved(this); } @@ -639,6 +664,7 @@ QDebug operator<<(QDebug debug, const QCocoaScreen *screen) debug << ", geometry=" << screen->geometry(); debug << ", dpr=" << screen->devicePixelRatio(); debug << ", name=" << screen->name(); + debug << ", displayId=" << screen->m_displayId; debug << ", native=" << screen->nativeScreen(); } debug << ')'; @@ -646,6 +672,8 @@ QDebug operator<<(QDebug debug, const QCocoaScreen *screen) } #endif // !QT_NO_DEBUG_STREAM +#include "qcocoascreen.moc" + QT_END_NAMESPACE @implementation NSScreen (QtExtras) -- cgit v1.2.3 From dcbe25bbbb603bc335d7cf0982a80293289b0d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sun, 27 Oct 2019 18:57:56 +0100 Subject: macOS: Only skip screen reconfigure if primary screen changed Change-Id: Ia5d208ace5086e8e92f95f859383773894a18768 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoascreen.mm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index aaaf9d0dcc..40273bac84 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -114,11 +114,10 @@ void QCocoaScreen::initializeScreens() mainDisplay->updateProperties(); qCInfo(lcQpaScreen) << "Primary screen changed to" << mainDisplay; QWindowSystemInterface::handlePrimaryScreenChanged(mainDisplay); + if (cocoaScreen == mainDisplay) + return; // Already reconfigured } - if (cocoaScreen == mainDisplay) - return; // Already reconfigured - cocoaScreen->updateProperties(); qCInfo(lcQpaScreen).nospace() << "Reconfigured " << (primaryScreen() == cocoaScreen ? "primary " : "") -- cgit v1.2.3 From 4b346aedf82bc600c1e2be998460ef9657178b49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 23 Oct 2019 12:56:19 +0200 Subject: macOS: Deliver update requests even when view or layer needs display This was a workaround to prevent visual artefacts from flushing GL during window resizing, but now that we skip the flush entirely in this situation we don't need to limit the update request delivery. Change-Id: I84bd48e4e2fc5a03e9d27d5f9b4b32b8098e56a5 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.mm | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index a744a86695..15329ca708 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1512,17 +1512,6 @@ bool QCocoaWindow::updatesWithDisplayLink() const void QCocoaWindow::deliverUpdateRequest() { - // Don't send update requests for views that need display, as the update - // request doesn't carry any information about dirty rects, so the app - // may end up painting a smaller region than required. (For some reason - // the layer and view's needsDisplay status isn't always in sync, even if - // the view is layer-backed, not layer-hosted, so we check both). - if (m_view.layer.needsDisplay || m_view.needsDisplay) { - qCDebug(lcQpaDrawing) << "View needs display, deferring update request for" << window(); - requestUpdate(); - return; - } - qCDebug(lcQpaDrawing) << "Delivering update request to" << window(); QPlatformWindow::deliverUpdateRequest(); } -- cgit v1.2.3 From b56e856d218976bf39d981468267337d8d6223f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 18 Mar 2019 12:25:14 +0100 Subject: Cocoa: rename IsMouseOrKeyEvent -> isUserInputEvent This matches the intended use of this function. Reformat to modern Qt style. Change-Id: I076d2bdb3ac14b346f0dc6934f7a47765badc6b0 Reviewed-by: Timur Pocheptsov --- .../platforms/cocoa/qcocoaeventdispatcher.mm | 68 ++++++++++------------ 1 file changed, 32 insertions(+), 36 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index e87fc39c42..b3ce9e45dc 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -293,46 +293,42 @@ bool QCocoaEventDispatcher::hasPendingEvents() return qGlobalPostedEventsCount() || (qt_is_gui_used && !CFRunLoopIsWaiting(CFRunLoopGetMain())); } -static bool IsMouseOrKeyEvent( NSEvent* event ) +static bool isUserInputEvent(NSEvent* event) { - bool result = false; - - switch( [event type] ) - { - case NSEventTypeLeftMouseDown: - case NSEventTypeLeftMouseUp: - case NSEventTypeRightMouseDown: - case NSEventTypeRightMouseUp: - case NSEventTypeMouseMoved: // ?? - case NSEventTypeLeftMouseDragged: - case NSEventTypeRightMouseDragged: - case NSEventTypeMouseEntered: - case NSEventTypeMouseExited: - case NSEventTypeKeyDown: - case NSEventTypeKeyUp: - case NSEventTypeFlagsChanged: // key modifiers changed? - case NSEventTypeCursorUpdate: // ?? - case NSEventTypeScrollWheel: - case NSEventTypeTabletPoint: - case NSEventTypeTabletProximity: - case NSEventTypeOtherMouseDown: - case NSEventTypeOtherMouseUp: - case NSEventTypeOtherMouseDragged: + switch ([event type]) { + case NSEventTypeLeftMouseDown: + case NSEventTypeLeftMouseUp: + case NSEventTypeRightMouseDown: + case NSEventTypeRightMouseUp: + case NSEventTypeMouseMoved: // ?? + case NSEventTypeLeftMouseDragged: + case NSEventTypeRightMouseDragged: + case NSEventTypeMouseEntered: + case NSEventTypeMouseExited: + case NSEventTypeKeyDown: + case NSEventTypeKeyUp: + case NSEventTypeFlagsChanged: // key modifiers changed? + case NSEventTypeCursorUpdate: // ?? + case NSEventTypeScrollWheel: + case NSEventTypeTabletPoint: + case NSEventTypeTabletProximity: + case NSEventTypeOtherMouseDown: + case NSEventTypeOtherMouseUp: + case NSEventTypeOtherMouseDragged: #ifndef QT_NO_GESTURES - case NSEventTypeGesture: // touch events - case NSEventTypeMagnify: - case NSEventTypeSwipe: - case NSEventTypeRotate: - case NSEventTypeBeginGesture: - case NSEventTypeEndGesture: + case NSEventTypeGesture: // touch events + case NSEventTypeMagnify: + case NSEventTypeSwipe: + case NSEventTypeRotate: + case NSEventTypeBeginGesture: + case NSEventTypeEndGesture: #endif // QT_NO_GESTURES - result = true; + return true; break; - - default: + default: break; } - return result; + return false; } static inline void qt_mac_waitForMoreEvents(NSString *runLoopMode = NSDefaultRunLoopMode) @@ -465,7 +461,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) dequeue: YES]; if (event) { - if (IsMouseOrKeyEvent(event)) { + if (isUserInputEvent(event)) { [event retain]; d->queuedUserInputEvents.append(event); continue; @@ -485,7 +481,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) if (event) { if (flags & QEventLoop::ExcludeUserInputEvents) { - if (IsMouseOrKeyEvent(event)) { + if (isUserInputEvent(event)) { [event retain]; d->queuedUserInputEvents.append(event); continue; -- cgit v1.2.3 From d157292f1632e58f06fa0728c3b606b1d1fe7885 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 28 Oct 2019 17:58:09 +0100 Subject: Wasm: Fix the markup in wasm_shell.html MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Img width and height are separate tags. Alternatively, they could be defined in the style tag. Change-Id: I0a4a93b63a99a7b644e9096bb9238739f408c0df Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/wasm_shell.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/wasm_shell.html b/src/plugins/platforms/wasm/wasm_shell.html index a118c217f3..d4bf632830 100644 --- a/src/plugins/platforms/wasm/wasm_shell.html +++ b/src/plugins/platforms/wasm/wasm_shell.html @@ -17,7 +17,7 @@
- + Qt for WebAssembly: @APPNAME@
-- cgit v1.2.3 From 41226c4c483aaad628cd1ae9733959d2a9389c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 28 Oct 2019 18:32:05 +0100 Subject: macOS: Don't skip display link delivery via GCD during live resizing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We now avoid flushing GL if the exposed size does not match the window size, so we don't need to halt update request delivery during resize. Change-Id: Iaa89e67d50c987757a586b5958e08edf71a5dd0c Reviewed-by: Morten Johan Sørvig Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoascreen.mm | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index 40273bac84..bd5c95b9d0 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -375,15 +375,6 @@ void QCocoaScreen::deliverUpdateRequests() // it on the main thread yet, because the processing of the update request is taking // too long, or because the update request was deferred due to window live resizing. qDeferredDebug(screenUpdates) << ", " << framesAheadOfDelivery << " frame(s) ahead"; - - // We skip the frame completely if we're live-resizing, to not put any extra - // strain on the main thread runloop. Otherwise we assume we should push frames - // as fast as possible, and hopefully the callback will be delivered on the - // main thread just when the previous finished. - if (qt_apple_sharedApplication().keyWindow.inLiveResize) { - qDeferredDebug(screenUpdates) << "; waiting for main thread to catch up"; - return; - } } qDeferredDebug(screenUpdates) << "; signaling dispatch source"; -- cgit v1.2.3