From e00d888daefbfbd5f17e0772421773f8e295087b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 2 Oct 2019 15:03:35 +0200 Subject: iOS: Prevent UIKit from adding UITextInteraction to our view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's added automatically when some languages such as Japanese are the active input language/keyboard, which results in UIKit triggering the edit menu for any tap in the UI, regardless of whether it hits the focus object or not. Adopting the protocol is a much larger effort and needs to be coordinated so that we still support text interaction on iOS versions pre 13.0. Even with this patch the UITextSelectionView will still blink its own cursor, which doesn't seem to sync up with the UITextInput protocol's view of where the cursor is. Fixes: QTBUG-78496 Change-Id: I61500ad7ab9c8577f71188c0c99ead39465e3839 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/quiview.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index e64c05d099..4e3657ec37 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -628,6 +628,18 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") #endif } +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(130000) +- (void)addInteraction:(id)interaction +{ + if (__builtin_available(iOS 13.0, *)) { + if ([interaction isKindOfClass:UITextInteraction.class]) + return; // Prevent iOS from adding UITextInteraction + } + + [super addInteraction:interaction]; +} +#endif + @end @implementation UIView (QtHelpers) -- cgit v1.2.3 From b7aaee002677caf411190bbc6ea7f18a28a71360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 7 Oct 2019 16:56:19 +0200 Subject: iOS: Remove assert when doing GL rendering in the background MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-76961 Change-Id: If2212601dbb867dd7ceb826b867bb24d302f86df Reviewed-by: Volker Hilsheimer Reviewed-by: Timur Pocheptsov Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qioscontext.mm | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm index 535e7d7aa6..cecbb17039 100644 --- a/src/plugins/platforms/ios/qioscontext.mm +++ b/src/plugins/platforms/ios/qioscontext.mm @@ -332,11 +332,8 @@ bool QIOSContext::verifyGraphicsHardwareAvailability() ); }); - if (applicationBackgrounded) { - static const char warning[] = "OpenGL ES calls are not allowed while an application is backgrounded"; - Q_ASSERT_X(!applicationBackgrounded, "QIOSContext", warning); - qCWarning(lcQpaGLContext, warning); - } + if (applicationBackgrounded) + qCWarning(lcQpaGLContext, "OpenGL ES calls are not allowed while an application is backgrounded"); return !applicationBackgrounded; } -- cgit v1.2.3 From 631efee29371246ba1a1d9d007b23ca08b867191 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 16 Oct 2019 12:35:11 +0200 Subject: iOS: Account for when the older SDK is used when building MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the pre-built versions of Qt at this point are still built against the iOS 12.x SDKs, then we need to account for this in order to have the workaround implemented in e00d888daefbfbd5f17e0772421773f8e295087b still working when deployed to an iOS 13 based device. Change-Id: I649a453c549ee272de64624d68f9382276fcba64 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/quiview.h | 5 +++++ src/plugins/platforms/ios/quiview.mm | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/quiview.h b/src/plugins/platforms/ios/quiview.h index e1d5d5af0c..343f102971 100644 --- a/src/plugins/platforms/ios/quiview.h +++ b/src/plugins/platforms/ios/quiview.h @@ -70,3 +70,8 @@ QT_END_NAMESPACE @property (nonatomic, readonly) UIEdgeInsets qt_safeAreaInsets; @end +#if !QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(130000) +@interface UITextInteraction : NSObject +@end +#endif + diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 4e3657ec37..962b1d929f 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -628,7 +628,6 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") #endif } -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(130000) - (void)addInteraction:(id)interaction { if (__builtin_available(iOS 13.0, *)) { @@ -638,7 +637,6 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") [super addInteraction:interaction]; } -#endif @end -- cgit v1.2.3 From a7a24784eeba6747d319eb911583bdd99ef38cdb Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 25 Oct 2019 06:57:32 +0000 Subject: Revert "iOS: Account for when the older SDK is used when building" This reverts commit 631efee29371246ba1a1d9d007b23ca08b867191. Reason for revert: This causes a problem when running on iOS 11 devices. Change-Id: If5194989b8d7a9f4cf2d72e770fdaad754d7e236 Reviewed-by: Jani Heikkinen --- src/plugins/platforms/ios/quiview.h | 5 ----- src/plugins/platforms/ios/quiview.mm | 2 ++ 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/quiview.h b/src/plugins/platforms/ios/quiview.h index 343f102971..e1d5d5af0c 100644 --- a/src/plugins/platforms/ios/quiview.h +++ b/src/plugins/platforms/ios/quiview.h @@ -70,8 +70,3 @@ QT_END_NAMESPACE @property (nonatomic, readonly) UIEdgeInsets qt_safeAreaInsets; @end -#if !QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(130000) -@interface UITextInteraction : NSObject -@end -#endif - diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 962b1d929f..4e3657ec37 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -628,6 +628,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") #endif } +#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(130000) - (void)addInteraction:(id)interaction { if (__builtin_available(iOS 13.0, *)) { @@ -637,6 +638,7 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") [super addInteraction:interaction]; } +#endif @end -- cgit v1.2.3 From be73bdc5d2491d036e5a6334dada453ed808dbc0 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 18 Oct 2019 12:28:13 +0200 Subject: Only call ShowCaret if Windows 10 1709 or later is used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This amends cc873ec23a98ac32d10ac5fa569792fde2f6b2c8 which worked around a problem that was showing up on earlier versions of Windows. This extends the workaround up to Windows 10 1703 as the problem was still occurring up to that version. Fixes: QTBUG-79143 Change-Id: Ib7eace17fb8e3817c556e2bcd462e37834b1cbcf Reviewed-by: Friedemann Kleint Reviewed-by: André de la Rocha --- src/plugins/platforms/windows/qwindowsinputcontext.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index 8054f9fe83..bbfad7d712 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -280,13 +280,15 @@ void QWindowsInputContext::showInputPanel() // with Windows 10 if the Windows IME is (re)enabled _after_ the caret is shown. if (m_caretCreated) { cursorRectChanged(); - // We only call ShowCaret() on Windows 10 as in earlier versions the caret - // would actually be visible (QTBUG-74492) and the workaround for the - // Surface seems unnecessary there anyway. But leave it hidden for IME. - if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10) + // We only call ShowCaret() on Windows 10 after 1703 as in earlier versions + // the caret would actually be visible (QTBUG-74492) and the workaround for + // the Surface seems unnecessary there anyway. But leave it hidden for IME. + if (QOperatingSystemVersion::current() >= + QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 16299)) { ShowCaret(platformWindow->handle()); - else + } else { HideCaret(platformWindow->handle()); + } setWindowsImeEnabled(platformWindow, false); setWindowsImeEnabled(platformWindow, true); } -- cgit v1.2.3 From 26f9cb7ce5a81eac9743d0dd183f59ceb7e73569 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Thu, 17 Oct 2019 08:43:49 +1000 Subject: wasm: take canvas offset into account MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes issue with dialogs when the canvas is not at 0,0 in the browser window Change-Id: I14f6754746e064921635d6b3af3353bf3620ac44 Fixes: QTBUG-79160 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/qwasmscreen.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/qwasmscreen.cpp b/src/plugins/platforms/wasm/qwasmscreen.cpp index e536bc0ee3..37f1ea832a 100644 --- a/src/plugins/platforms/wasm/qwasmscreen.cpp +++ b/src/plugins/platforms/wasm/qwasmscreen.cpp @@ -186,8 +186,12 @@ void QWasmScreen::updateQScreenAndCanvasRenderSize() canvas.set("width", canvasSize.width()); canvas.set("height", canvasSize.height()); + QPoint offset; + offset.setX(emscripten::val::global(canvasId.constData())["offsetTop"].as()); + offset.setY(emscripten::val::global(canvasId.constData())["offsetLeft"].as()); + emscripten::val rect = canvas.call("getBoundingClientRect"); - QPoint position(rect["left"].as(), rect["top"].as()); + QPoint position(rect["left"].as() - offset.x(), rect["top"].as() - offset.y()); setGeometry(QRect(position, cssSize.toSize())); m_compositor->redrawWindowContent(); -- cgit v1.2.3 From 39ed657b6393c850735857e367303800f1a04413 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 21 Oct 2019 10:23:27 +0200 Subject: Query the mouse buttons initially in case the middle button was used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I99a3ef598bdaaba1afb6bf6521d1ceafcc9b603c Reviewed-by: André de la Rocha --- src/plugins/platforms/windows/qwindowspointerhandler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp index 71a09304c5..fae01c9147 100644 --- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp +++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp @@ -579,7 +579,9 @@ bool QWindowsPointerHandler::translatePenEvent(QWindow *window, HWND hwnd, QtWin const QTabletEvent::TabletDevice device = QTabletEvent::Stylus; QTabletEvent::PointerType type; - Qt::MouseButtons mouseButtons; + // Since it may be the middle button, so if the checks fail then it should + // be set to Middle if it was used. + Qt::MouseButtons mouseButtons = queryMouseButtons(); const bool pointerInContact = IS_POINTER_INCONTACT_WPARAM(msg.wParam); if (pointerInContact) -- cgit v1.2.3 From 7f0aaa88ef1db3840bd504d63a38d53032b8f802 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia5d208ace5086e8e92f95f859383773894a18768 Reviewed-by: Timur Pocheptsov (cherry picked from commit dcbe25bbbb603bc335d7cf0982a80293289b0d8f) Reviewed-by: Tor Arne Vestbø --- 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 392099d083..16b11b3835 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -93,11 +93,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) << "Reconfigured" << cocoaScreen; } -- cgit v1.2.3 From bc4c2382aacbb33fad4a2d06fc631e4859f12a33 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 5 Nov 2019 10:15:59 +0100 Subject: QMdiArea: On macOS, render inactive subwindow controls grayed out MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The controls were correctly grayed out when the entire window was not active, but inactive subwindows showed their controls in color, and only the titlebar had a slightly paler gradient to indicate that they are not active. MDI is not a concept on macOS and there is no clear style guide for how such windows are supposed to behave, but the look of the inactive titlebar before this change is too similar to the active state for it to be useful. This change restores the pre-5.11 state, prior to the removal of HITheme based styling in 8633e1a7b48f71e91f81ef5c667d6eb7a8db3adb. Change-Id: If009bf085a87fe2610d888636348dc8b13a93ec1 Fixes: QTBUG-79648 Reviewed-by: Tor Arne Vestbø --- src/plugins/styles/mac/qmacstyle_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 63dc49fd18..610329a350 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -5539,7 +5539,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex const auto ct = d->windowButtonCocoaControl(sc); const auto cw = QMacStylePrivate::CocoaControl(ct, QStyleHelper::SizeLarge); auto *wb = static_cast(d->cocoaControl(cw)); - wb.enabled = (sc & titlebar->subControls); + wb.enabled = (sc & titlebar->subControls) && isActive; [wb highlight:(titlebar->state & State_Sunken) && (sc & titlebar->activeSubControls)]; Q_UNUSED(isHovered); // FIXME No public API for this -- cgit v1.2.3 From 3916b8a28bc9c55e10f4de611ed76e17017494aa Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 24 Oct 2019 08:34:46 +0200 Subject: iOS: Account for UITextInteraction when building against 12.x or lower MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In iOS 13.0 we can handle UITextInteraction as normal, but in lower versions it is not available to utilize at compile time. So we have to check for the other types instead and return if it is not one of those. Change-Id: Icbc5558e677ed40c03f30a174e2d79b87f489f68 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/quiview.mm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 4e3657ec37..91a186bace 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -628,17 +628,13 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") #endif } -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(130000) - (void)addInteraction:(id)interaction { - if (__builtin_available(iOS 13.0, *)) { - if ([interaction isKindOfClass:UITextInteraction.class]) - return; // Prevent iOS from adding UITextInteraction - } + if ([NSStringFromClass(interaction.class) isEqualToString:@"UITextInteraction"]) + return; [super addInteraction:interaction]; } -#endif @end -- cgit v1.2.3 From ef54abae43db79792b40dfdca30ac0fa1b582354 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Tue, 29 Oct 2019 20:42:00 +0100 Subject: Windows QPA: Fix missing update when the display is sleeping If an item was updated while the display was in sleep mode then when the display came back from sleep it would not be updated. This change detects when the display returns from sleep and repaints the windows to ensure the updated items are presented. Fixes: QTBUG-76307 Change-Id: I5fff5209e8a5c359d06ba1df61944690e9475ea6 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowscontext.cpp | 58 ++++++++++++++++++++++ src/plugins/platforms/windows/qwindowscontext.h | 2 + .../platforms/windows/qwindowsintegration.cpp | 2 + 3 files changed, 62 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 38b9823d6b..5c1b00a1c9 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -273,6 +273,8 @@ struct QWindowsContextPrivate { const HRESULT m_oleInitializeResult; QWindow *m_lastActiveWindow = nullptr; bool m_asyncExpose = false; + HPOWERNOTIFY m_powerNotification = nullptr; + HWND m_powerDummyWindow = nullptr; }; QWindowsContextPrivate::QWindowsContextPrivate() @@ -313,6 +315,13 @@ QWindowsContext::~QWindowsContext() #if QT_CONFIG(tabletevent) d->m_tabletSupport.reset(); // Destroy internal window before unregistering classes. #endif + + if (d->m_powerNotification) + UnregisterPowerSettingNotification(d->m_powerNotification); + + if (d->m_powerDummyWindow) + DestroyWindow(d->m_powerDummyWindow); + unregisterWindowClasses(); if (d->m_oleInitializeResult == S_OK || d->m_oleInitializeResult == S_FALSE) OleUninitialize(); @@ -380,6 +389,55 @@ bool QWindowsContext::initPointer(unsigned integrationOptions) return true; } +extern "C" LRESULT QT_WIN_CALLBACK qWindowsPowerWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + if (message != WM_POWERBROADCAST || wParam != PBT_POWERSETTINGCHANGE) + return DefWindowProc(hwnd, message, wParam, lParam); + + static bool initialized = false; // ignore the initial change + if (!initialized) { + initialized = true; + return DefWindowProc(hwnd, message, wParam, lParam); + } + + auto setting = reinterpret_cast(lParam); + if (setting) { + auto data = reinterpret_cast(&setting->Data); + if (*data == 1) { + // Repaint the windows when returning from sleeping display mode. + const auto tlw = QGuiApplication::topLevelWindows(); + for (auto w : tlw) { + if (w->isVisible() && w->windowState() != Qt::WindowMinimized) { + if (auto tw = QWindowsWindow::windowsWindowOf(w)) { + if (HWND hwnd = tw->handle()) { + InvalidateRect(hwnd, nullptr, false); + } + } + } + } + } + } + return DefWindowProc(hwnd, message, wParam, lParam); +} + +bool QWindowsContext::initPowerNotificationHandler() +{ + if (d->m_powerNotification) + return false; + + d->m_powerDummyWindow = createDummyWindow(QStringLiteral("QtPowerDummyWindow"), L"QtPowerDummyWindow", qWindowsPowerWindowProc); + if (!d->m_powerDummyWindow) + return false; + + d->m_powerNotification = RegisterPowerSettingNotification(d->m_powerDummyWindow, &GUID_MONITOR_POWER_ON, DEVICE_NOTIFY_WINDOW_HANDLE); + if (!d->m_powerNotification) { + DestroyWindow(d->m_powerDummyWindow); + d->m_powerDummyWindow = nullptr; + return false; + } + return true; +} + void QWindowsContext::setTabletAbsoluteRange(int a) { #if QT_CONFIG(tabletevent) diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h index 4908f14629..04290379db 100644 --- a/src/plugins/platforms/windows/qwindowscontext.h +++ b/src/plugins/platforms/windows/qwindowscontext.h @@ -176,6 +176,8 @@ public: bool initTablet(unsigned integrationOptions); bool initPointer(unsigned integrationOptions); + bool initPowerNotificationHandler(); + int defaultDPI() const; QString registerWindowClass(const QWindow *w); diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 5c1fa00088..849e6cf2d0 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -256,6 +256,8 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mL m_context.initTouch(m_options); QPlatformCursor::setCapability(QPlatformCursor::OverrideCursor); + + m_context.initPowerNotificationHandler(); } QWindowsIntegrationPrivate::~QWindowsIntegrationPrivate() -- cgit v1.2.3 From 26f8adb1eefd1a8822413e036f2878b8cc1e7029 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Thu, 7 Nov 2019 16:52:10 +0100 Subject: Windows QPA: Avoid returning UI Automation ValueProvider for static text Static text controls should not return a ValueProvider. Otherwise, Narrator reads out static texts and announces whether they are editable or not, which is confusing to users. It should only read out the text itself. Fixes: QTBUG-79613 Change-Id: I080cd6a5db10f6f673b50c40ac7d87c3737d9b55 Reviewed-by: Friedemann Kleint --- .../platforms/windows/uiautomation/qwindowsuiamainprovider.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index 5a05adbf81..96d64acc32 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -277,8 +277,9 @@ HRESULT QWindowsUiaMainProvider::GetPatternProvider(PATTERNID idPattern, IUnknow } break; case UIA_ValuePatternId: - // All accessible controls return text(QAccessible::Value) (which may be empty). - *pRetVal = new QWindowsUiaValueProvider(id()); + // All non-static controls support the Value pattern. + if (accessible->role() != QAccessible::StaticText) + *pRetVal = new QWindowsUiaValueProvider(id()); break; case UIA_RangeValuePatternId: // Controls providing a numeric value within a range (e.g., sliders, scroll bars, dials). -- cgit v1.2.3 From c17a5cec1901dd23f4c39ec2ae47a060fbb06895 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 7 Nov 2019 08:57:59 +0100 Subject: Android: Implement MaximizeUsingFullscreenGeometryHint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This flag tells the app to use as much of the screen as possible while still keeping system UI visible, and can be supported on Android by using translucent system UI, similar to iOS. What this does: 1. It changes the current fullscreen/not-fullscreen logic to allow three states: fullscreen, fullscreen with translucent decorations and not-fullscreen. 2. In order for it to work, we have to send the actual screen geometry and available geometry, at least in the case where the user needs to know the available geometry to know the safe area of the window. So we get the real screen metrics and pass these to the QPA plugin (API level 17, so we can do that now that the minimum version is 21.) 3. Note that getting the insets and calculating the useable area does not work for non-fullscreen windows, since Android is quite inconsistent in this respect. So in this case we just use the window size and origin of 0,0 for the available geometry. 4. Since we are touching this code anyway, this patch also tries to use more consistent wording (calling it "available geometry" everywhere instead of desktop geometry in some places and just geometry in others, etc.) [ChangeLog][Android] Qt::MaximizeUsingFullscreenGeometryHint window flag is now supported, and will make the window fullscreen, but keep the system UI on-screen, with a translucent background color. Fixes: QTBUG-74202 Change-Id: I7a59a6c6fb51ebbdb86e7149e794726e67001279 Reviewed-by: Tor Arne Vestbø Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/androidjniinput.cpp | 4 +- src/plugins/platforms/android/androidjnimain.cpp | 69 +++++++++------------- src/plugins/platforms/android/androidjnimain.h | 13 ++-- .../android/qandroidplatformintegration.cpp | 54 ++++++++--------- .../android/qandroidplatformintegration.h | 28 ++++----- .../platforms/android/qandroidplatformscreen.cpp | 11 ++-- .../platforms/android/qandroidplatformwindow.cpp | 32 +++++++--- .../platforms/android/qandroidplatformwindow.h | 4 +- 8 files changed, 108 insertions(+), 107 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index 56885f2e23..049f9b0b13 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -247,8 +247,8 @@ namespace QtAndroidInput break; } - const int dw = desktopWidthPixels(); - const int dh = desktopHeightPixels(); + const int dw = availableWidthPixels(); + const int dh = availableHeightPixels(); QWindowSystemInterface::TouchPoint touchPoint; touchPoint.id = id; touchPoint.pressure = pressure; diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index fd2644717e..bdbd3517bd 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -111,8 +111,8 @@ static int m_surfaceId = 1; static QAndroidPlatformIntegration *m_androidPlatformIntegration = nullptr; -static int m_desktopWidthPixels = 0; -static int m_desktopHeightPixels = 0; +static int m_availableWidthPixels = 0; +static int m_availableHeightPixels = 0; static double m_scaledDensity = 0; static double m_density = 1.0; @@ -155,14 +155,14 @@ namespace QtAndroid : 0; } - int desktopWidthPixels() + int availableWidthPixels() { - return m_desktopWidthPixels; + return m_availableWidthPixels; } - int desktopHeightPixels() + int availableHeightPixels() { - return m_desktopHeightPixels; + return m_availableHeightPixels; } double scaledDensity() @@ -200,22 +200,9 @@ namespace QtAndroid return m_serviceObject; } - void showStatusBar() + void setSystemUiVisibility(SystemUiVisibility uiVisibility) { - if (m_statusBarShowing) - return; - - QJNIObjectPrivate::callStaticMethod(m_applicationClass, "setFullScreen", "(Z)V", false); - m_statusBarShowing = true; - } - - void hideStatusBar() - { - if (!m_statusBarShowing) - return; - - QJNIObjectPrivate::callStaticMethod(m_applicationClass, "setFullScreen", "(Z)V", true); - m_statusBarShowing = false; + QJNIObjectPrivate::callStaticMethod(m_applicationClass, "setSystemUiVisibility", "(I)V", jint(uiVisibility)); } jobject createBitmap(QImage img, JNIEnv *env) @@ -620,35 +607,33 @@ static void setSurface(JNIEnv *env, jobject /*thiz*/, jint id, jobject jSurface, } static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/, - jint widthPixels, jint heightPixels, - jint desktopWidthPixels, jint desktopHeightPixels, + jint screenWidthPixels, jint screenHeightPixels, + jint availableLeftPixels, jint availableTopPixels, + jint availableWidthPixels, jint availableHeightPixels, jdouble xdpi, jdouble ydpi, jdouble scaledDensity, jdouble density) { - // Android does not give us the correct screen size for immersive mode, but - // the surface does have the right size - - widthPixels = qMax(widthPixels, desktopWidthPixels); - heightPixels = qMax(heightPixels, desktopHeightPixels); - - m_desktopWidthPixels = desktopWidthPixels; - m_desktopHeightPixels = desktopHeightPixels; + m_availableWidthPixels = availableWidthPixels; + m_availableHeightPixels = availableHeightPixels; m_scaledDensity = scaledDensity; m_density = density; QMutexLocker lock(&m_platformMutex); if (!m_androidPlatformIntegration) { - QAndroidPlatformIntegration::setDefaultDisplayMetrics(desktopWidthPixels, - desktopHeightPixels, - qRound(double(widthPixels) / xdpi * 25.4), - qRound(double(heightPixels) / ydpi * 25.4), - widthPixels, - heightPixels); + QAndroidPlatformIntegration::setDefaultDisplayMetrics(availableLeftPixels, + availableTopPixels, + availableWidthPixels, + availableHeightPixels, + qRound(double(screenWidthPixels) / xdpi * 25.4), + qRound(double(screenHeightPixels) / ydpi * 25.4), + screenWidthPixels, + screenHeightPixels); } else { - m_androidPlatformIntegration->setDisplayMetrics(qRound(double(widthPixels) / xdpi * 25.4), - qRound(double(heightPixels) / ydpi * 25.4)); - m_androidPlatformIntegration->setScreenSize(widthPixels, heightPixels); - m_androidPlatformIntegration->setDesktopSize(desktopWidthPixels, desktopHeightPixels); + m_androidPlatformIntegration->setPhysicalSize(qRound(double(screenWidthPixels) / xdpi * 25.4), + qRound(double(screenHeightPixels) / ydpi * 25.4)); + m_androidPlatformIntegration->setScreenSize(screenWidthPixels, screenHeightPixels); + m_androidPlatformIntegration->setAvailableGeometry(QRect(availableLeftPixels, availableTopPixels, + availableWidthPixels, availableHeightPixels)); } } @@ -774,7 +759,7 @@ static JNINativeMethod methods[] = { {"quitQtCoreApplication", "()V", (void *)quitQtCoreApplication}, {"terminateQt", "()V", (void *)terminateQt}, {"waitForServiceSetup", "()V", (void *)waitForServiceSetup}, - {"setDisplayMetrics", "(IIIIDDDD)V", (void *)setDisplayMetrics}, + {"setDisplayMetrics", "(IIIIIIDDDD)V", (void *)setDisplayMetrics}, {"setSurface", "(ILjava/lang/Object;II)V", (void *)setSurface}, {"updateWindow", "()V", (void *)updateWindow}, {"updateApplicationState", "(I)V", (void *)updateApplicationState}, diff --git a/src/plugins/platforms/android/androidjnimain.h b/src/plugins/platforms/android/androidjnimain.h index 17ae30a1be..63be5910f9 100644 --- a/src/plugins/platforms/android/androidjnimain.h +++ b/src/plugins/platforms/android/androidjnimain.h @@ -77,8 +77,8 @@ namespace QtAndroid void bringChildToBack(int surfaceId); QWindow *topLevelWindowAt(const QPoint &globalPos); - int desktopWidthPixels(); - int desktopHeightPixels(); + int availableWidthPixels(); + int availableHeightPixels(); double scaledDensity(); double pixelDensity(); JavaVM *javaVM(); @@ -88,8 +88,13 @@ namespace QtAndroid jobject activity(); jobject service(); - void showStatusBar(); - void hideStatusBar(); + // Keep synchronized with flags in ActivityDelegate.java + enum SystemUiVisibility { + SYSTEM_UI_VISIBILITY_NORMAL = 0, + SYSTEM_UI_VISIBILITY_FULLSCREEN = 1, + SYSTEM_UI_VISIBILITY_TRANSLUCENT = 2 + }; + void setSystemUiVisibility(SystemUiVisibility uiVisibility); jobject createBitmap(QImage img, JNIEnv *env = 0); jobject createBitmap(int width, int height, QImage::Format format, JNIEnv *env); diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index e0c437be27..48f330680b 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -76,12 +76,9 @@ QT_BEGIN_NAMESPACE -int QAndroidPlatformIntegration::m_defaultGeometryWidth = 320; -int QAndroidPlatformIntegration::m_defaultGeometryHeight = 455; -int QAndroidPlatformIntegration::m_defaultScreenWidth = 320; -int QAndroidPlatformIntegration::m_defaultScreenHeight = 455; -int QAndroidPlatformIntegration::m_defaultPhysicalSizeWidth = 50; -int QAndroidPlatformIntegration::m_defaultPhysicalSizeHeight = 71; +QSize QAndroidPlatformIntegration::m_defaultScreenSize = QSize(320, 455); +QRect QAndroidPlatformIntegration::m_defaultAvailableGeometry = QRect(0, 0, 320, 455); +QSize QAndroidPlatformIntegration::m_defaultPhysicalSize = QSize(50, 71); Qt::ScreenOrientation QAndroidPlatformIntegration::m_orientation = Qt::PrimaryOrientation; Qt::ScreenOrientation QAndroidPlatformIntegration::m_nativeOrientation = Qt::PrimaryOrientation; @@ -174,9 +171,9 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_primaryScreen = new QAndroidPlatformScreen(); QWindowSystemInterface::handleScreenAdded(m_primaryScreen); - m_primaryScreen->setPhysicalSize(QSize(m_defaultPhysicalSizeWidth, m_defaultPhysicalSizeHeight)); - m_primaryScreen->setSize(QSize(m_defaultScreenWidth, m_defaultScreenHeight)); - m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight)); + m_primaryScreen->setPhysicalSize(m_defaultPhysicalSize); + m_primaryScreen->setSize(m_defaultScreenSize); + m_primaryScreen->setAvailableGeometry(m_defaultAvailableGeometry); m_mainThread = QThread::currentThread(); @@ -266,6 +263,7 @@ bool QAndroidPlatformIntegration::hasCapability(Capability cap) const case ThreadedOpenGL: return !needsBasicRenderloopWorkaround() && QtAndroid::activity(); case RasterGLSurface: return QtAndroid::activity(); case TopStackedNativeChildWindows: return false; + case MaximizeUsingFullscreenGeometry: return true; default: return QPlatformIntegration::hasCapability(cap); } @@ -415,20 +413,19 @@ QPlatformTheme *QAndroidPlatformIntegration::createPlatformTheme(const QString & return 0; } -void QAndroidPlatformIntegration::setDefaultDisplayMetrics(int gw, int gh, int sw, int sh, int screenWidth, int screenHeight) +void QAndroidPlatformIntegration::setDefaultDisplayMetrics(int availableLeft, + int availableTop, + int availableWidth, + int availableHeight, + int physicalWidth, + int physicalHeight, + int screenWidth, + int screenHeight) { - m_defaultGeometryWidth = gw; - m_defaultGeometryHeight = gh; - m_defaultPhysicalSizeWidth = sw; - m_defaultPhysicalSizeHeight = sh; - m_defaultScreenWidth = screenWidth; - m_defaultScreenHeight = screenHeight; -} - -void QAndroidPlatformIntegration::setDefaultDesktopSize(int gw, int gh) -{ - m_defaultGeometryWidth = gw; - m_defaultGeometryHeight = gh; + m_defaultAvailableGeometry = QRect(availableLeft, availableTop, + availableWidth, availableHeight); + m_defaultPhysicalSize = QSize(physicalWidth, physicalHeight); + m_defaultScreenSize = QSize(screenWidth, screenHeight); } void QAndroidPlatformIntegration::setScreenOrientation(Qt::ScreenOrientation currentOrientation, @@ -440,10 +437,9 @@ void QAndroidPlatformIntegration::setScreenOrientation(Qt::ScreenOrientation cur void QAndroidPlatformIntegration::flushPendingUpdates() { - m_primaryScreen->setPhysicalSize(QSize(m_defaultPhysicalSizeWidth, - m_defaultPhysicalSizeHeight)); - m_primaryScreen->setSize(QSize(m_defaultScreenWidth, m_defaultScreenHeight)); - m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight)); + m_primaryScreen->setPhysicalSize(m_defaultPhysicalSize); + m_primaryScreen->setSize(m_defaultScreenSize); + m_primaryScreen->setAvailableGeometry(m_defaultAvailableGeometry); } #ifndef QT_NO_ACCESSIBILITY @@ -453,13 +449,13 @@ QPlatformAccessibility *QAndroidPlatformIntegration::accessibility() const } #endif -void QAndroidPlatformIntegration::setDesktopSize(int width, int height) +void QAndroidPlatformIntegration::setAvailableGeometry(const QRect &availableGeometry) { if (m_primaryScreen) - QMetaObject::invokeMethod(m_primaryScreen, "setAvailableGeometry", Qt::AutoConnection, Q_ARG(QRect, QRect(0,0,width, height))); + QMetaObject::invokeMethod(m_primaryScreen, "setAvailableGeometry", Qt::AutoConnection, Q_ARG(QRect, availableGeometry)); } -void QAndroidPlatformIntegration::setDisplayMetrics(int width, int height) +void QAndroidPlatformIntegration::setPhysicalSize(int width, int height) { if (m_primaryScreen) QMetaObject::invokeMethod(m_primaryScreen, "setPhysicalSize", Qt::AutoConnection, Q_ARG(QSize, QSize(width, height))); diff --git a/src/plugins/platforms/android/qandroidplatformintegration.h b/src/plugins/platforms/android/qandroidplatformintegration.h index c795c499bc..d607ec0064 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/qandroidplatformintegration.h @@ -91,8 +91,8 @@ public: QAndroidPlatformScreen *screen() { return m_primaryScreen; } QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override; - virtual void setDesktopSize(int width, int height); - virtual void setDisplayMetrics(int width, int height); + void setAvailableGeometry(const QRect &availableGeometry); + void setPhysicalSize(int width, int height); void setScreenSize(int width, int height); bool isVirtualDesktop() { return true; } @@ -116,16 +116,17 @@ public: QStringList themeNames() const override; QPlatformTheme *createPlatformTheme(const QString &name) const override; - static void setDefaultDisplayMetrics(int gw, int gh, int sw, int sh, int width, int height); - static void setDefaultDesktopSize(int gw, int gh); + static void setDefaultDisplayMetrics(int availableLeft, + int availableTop, + int availableWidth, + int availableHeight, + int physicalWidth, + int physicalHeight, + int screenWidth, + int screenHeight); static void setScreenOrientation(Qt::ScreenOrientation currentOrientation, Qt::ScreenOrientation nativeOrientation); - static QSize defaultDesktopSize() - { - return QSize(m_defaultGeometryWidth, m_defaultGeometryHeight); - } - QTouchDevice *touchDevice() const { return m_touchDevice; } void setTouchDevice(QTouchDevice *touchDevice) { m_touchDevice = touchDevice; } @@ -143,12 +144,9 @@ private: QThread *m_mainThread; - static int m_defaultGeometryWidth; - static int m_defaultGeometryHeight; - static int m_defaultPhysicalSizeWidth; - static int m_defaultPhysicalSizeHeight; - static int m_defaultScreenWidth; - static int m_defaultScreenHeight; + static QRect m_defaultAvailableGeometry; + static QSize m_defaultPhysicalSize; + static QSize m_defaultScreenSize; static Qt::ScreenOrientation m_orientation; static Qt::ScreenOrientation m_nativeOrientation; diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp index 80757c2135..5f8486a7a2 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.cpp +++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp @@ -90,8 +90,8 @@ private: QAndroidPlatformScreen::QAndroidPlatformScreen() : QObject(), QPlatformScreen() { - m_availableGeometry = QRect(0, 0, QAndroidPlatformIntegration::m_defaultGeometryWidth, QAndroidPlatformIntegration::m_defaultGeometryHeight); - m_size = QSize(QAndroidPlatformIntegration::m_defaultScreenWidth, QAndroidPlatformIntegration::m_defaultScreenHeight); + m_availableGeometry = QAndroidPlatformIntegration::m_defaultAvailableGeometry; + m_size = QAndroidPlatformIntegration::m_defaultScreenSize; // Raster only apps should set QT_ANDROID_RASTER_IMAGE_DEPTH to 16 // is way much faster than 32 if (qEnvironmentVariableIntValue("QT_ANDROID_RASTER_IMAGE_DEPTH") == 16) { @@ -101,8 +101,7 @@ QAndroidPlatformScreen::QAndroidPlatformScreen() m_format = QImage::Format_ARGB32_Premultiplied; m_depth = 32; } - m_physicalSize.setHeight(QAndroidPlatformIntegration::m_defaultPhysicalSizeHeight); - m_physicalSize.setWidth(QAndroidPlatformIntegration::m_defaultPhysicalSizeWidth); + m_physicalSize = QAndroidPlatformIntegration::m_defaultPhysicalSize; connect(qGuiApp, &QGuiApplication::applicationStateChanged, this, &QAndroidPlatformScreen::applicationStateChanged); } @@ -294,7 +293,7 @@ void QAndroidPlatformScreen::topWindowChanged(QWindow *w) if (w != 0) { QAndroidPlatformWindow *platformWindow = static_cast(w->handle()); if (platformWindow != 0) - platformWindow->updateStatusBarVisibility(); + platformWindow->updateSystemUiVisibility(); } } @@ -334,7 +333,7 @@ void QAndroidPlatformScreen::doRedraw() } QMutexLocker lock(&m_surfaceMutex); if (m_id == -1 && m_rasterSurfaces) { - m_id = QtAndroid::createSurface(this, m_availableGeometry, true, m_depth); + m_id = QtAndroid::createSurface(this, geometry(), true, m_depth); AndroidDeadlockProtector protector; if (!protector.acquire()) return; diff --git a/src/plugins/platforms/android/qandroidplatformwindow.cpp b/src/plugins/platforms/android/qandroidplatformwindow.cpp index 4f691ce112..a88cb9b823 100644 --- a/src/plugins/platforms/android/qandroidplatformwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformwindow.cpp @@ -67,25 +67,39 @@ void QAndroidPlatformWindow::lower() void QAndroidPlatformWindow::raise() { - updateStatusBarVisibility(); + updateSystemUiVisibility(); platformScreen()->raise(this); } +QMargins QAndroidPlatformWindow::safeAreaMargins() const +{ + if ((m_windowState & Qt::WindowMaximized) && (window()->flags() & Qt::MaximizeUsingFullscreenGeometryHint)) { + QRect availableGeometry = platformScreen()->availableGeometry(); + return QMargins(availableGeometry.left(), availableGeometry.top(), + availableGeometry.right(), availableGeometry.bottom()); + } else { + return QPlatformWindow::safeAreaMargins(); + } +} + void QAndroidPlatformWindow::setGeometry(const QRect &rect) { + QPlatformWindow::setGeometry(rect); QWindowSystemInterface::handleGeometryChange(window(), rect); } void QAndroidPlatformWindow::setVisible(bool visible) { if (visible) - updateStatusBarVisibility(); + updateSystemUiVisibility(); if (visible) { - if (m_windowState & Qt::WindowFullScreen) + if ((m_windowState & Qt::WindowFullScreen) + || ((m_windowState & Qt::WindowMaximized) && (window()->flags() & Qt::MaximizeUsingFullscreenGeometryHint))) { setGeometry(platformScreen()->geometry()); - else if (m_windowState & Qt::WindowMaximized) + } else if (m_windowState & Qt::WindowMaximized) { setGeometry(platformScreen()->availableGeometry()); + } } if (visible) @@ -107,7 +121,7 @@ void QAndroidPlatformWindow::setWindowState(Qt::WindowStates state) m_windowState = state; if (window()->isVisible()) - updateStatusBarVisibility(); + updateSystemUiVisibility(); } void QAndroidPlatformWindow::setWindowFlags(Qt::WindowFlags flags) @@ -143,15 +157,17 @@ void QAndroidPlatformWindow::requestActivateWindow() platformScreen()->topWindowChanged(window()); } -void QAndroidPlatformWindow::updateStatusBarVisibility() +void QAndroidPlatformWindow::updateSystemUiVisibility() { Qt::WindowFlags flags = window()->flags(); bool isNonRegularWindow = flags & (Qt::Popup | Qt::Dialog | Qt::Sheet) & ~Qt::Window; if (!isNonRegularWindow) { if (m_windowState & Qt::WindowFullScreen) - QtAndroid::hideStatusBar(); + QtAndroid::setSystemUiVisibility(QtAndroid::SYSTEM_UI_VISIBILITY_FULLSCREEN); + else if (flags & Qt::MaximizeUsingFullscreenGeometryHint) + QtAndroid::setSystemUiVisibility(QtAndroid::SYSTEM_UI_VISIBILITY_TRANSLUCENT); else - QtAndroid::showStatusBar(); + QtAndroid::setSystemUiVisibility(QtAndroid::SYSTEM_UI_VISIBILITY_NORMAL); } } diff --git a/src/plugins/platforms/android/qandroidplatformwindow.h b/src/plugins/platforms/android/qandroidplatformwindow.h index d8eb6b7b7f..f83ad7bea3 100644 --- a/src/plugins/platforms/android/qandroidplatformwindow.h +++ b/src/plugins/platforms/android/qandroidplatformwindow.h @@ -70,9 +70,11 @@ public: QAndroidPlatformScreen *platformScreen() const; + QMargins safeAreaMargins() const override; + void propagateSizeHints() override; void requestActivateWindow() override; - void updateStatusBarVisibility(); + void updateSystemUiVisibility(); inline bool isRaster() const { if (isForeignWindow()) return false; -- cgit v1.2.3 From 8f2db974ab594125301aac62594510e146125cb4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 1 Nov 2019 11:15:32 +0100 Subject: Windows QPA: Fix wrong scaling of fixed size in window creation phase MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a fixed size the window is moved to another screen by QPlatformWindow::initialGeometry(), the size constraints would be incorrectly scaled using the initial screen in the handling of WM_GETMINMAXINFO. To fix this, pass the resulting screen out of QPlatformWindow::initialGeometry() and use it during the window creation phase. Fixes: QTBUG-77307 Change-Id: I149a2a65e816da841a32abc14a495925bf9cc6f6 Reviewed-by: André de la Rocha Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/windows/qwindowswindow.cpp | 35 +++++++++++++++++------- src/plugins/platforms/windows/qwindowswindow.h | 10 +++++-- 2 files changed, 33 insertions(+), 12 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index a4f4099aa6..ea91e3bb2d 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -759,7 +759,10 @@ QWindowsWindowData const QString windowClassName = QWindowsContext::instance()->registerWindowClass(w); - const QRect rect = QPlatformWindow::initialGeometry(w, data.geometry, defaultWindowWidth, defaultWindowHeight); + const QScreen *screen{}; + const QRect rect = QPlatformWindow::initialGeometry(w, data.geometry, + defaultWindowWidth, defaultWindowHeight, + &screen); if (title.isEmpty() && (result.flags & Qt::WindowTitleHint)) title = topLevel ? qAppName() : w->objectName(); @@ -769,7 +772,9 @@ QWindowsWindowData // Capture events before CreateWindowEx() returns. The context is cleared in // the QWindowsWindow constructor. - const QWindowCreationContextPtr context(new QWindowCreationContext(w, data.geometry, rect, data.customMargins, style, exStyle)); + const QWindowCreationContextPtr context(new QWindowCreationContext(w, screen, data.geometry, + rect, data.customMargins, + style, exStyle)); QWindowsContext::instance()->setWindowCreationContext(context); const bool hasFrame = (style & (WS_DLGFRAME | WS_THICKFRAME)); @@ -879,10 +884,10 @@ void WindowCreationData::initialize(const QWindow *w, HWND hwnd, bool frameChang // Scaling helpers for size constraints. -static QSize toNativeSizeConstrained(QSize dip, const QWindow *w) +static QSize toNativeSizeConstrained(QSize dip, const QScreen *s) { if (QHighDpiScaling::isActive()) { - const qreal factor = QHighDpiScaling::factor(w); + const qreal factor = QHighDpiScaling::factor(s); if (!qFuzzyCompare(factor, qreal(1))) { if (dip.width() > 0 && dip.width() < QWINDOWSIZE_MAX) dip.setWidth(qRound(qreal(dip.width()) * factor)); @@ -995,11 +1000,12 @@ bool QWindowsGeometryHint::handleCalculateSize(const QMargins &customMargins, co return true; } -void QWindowsGeometryHint::frameSizeConstraints(const QWindow *w, const QMargins &margins, +void QWindowsGeometryHint::frameSizeConstraints(const QWindow *w, const QScreen *screen, + const QMargins &margins, QSize *minimumSize, QSize *maximumSize) { - *minimumSize = toNativeSizeConstrained(w->minimumSize(), w); - *maximumSize = toNativeSizeConstrained(w->maximumSize(), w); + *minimumSize = toNativeSizeConstrained(w->minimumSize(), screen); + *maximumSize = toNativeSizeConstrained(w->maximumSize(), screen); const int maximumWidth = qMax(maximumSize->width(), minimumSize->width()); const int maximumHeight = qMax(maximumSize->height(), minimumSize->height()); @@ -1017,12 +1023,13 @@ void QWindowsGeometryHint::frameSizeConstraints(const QWindow *w, const QMargins } void QWindowsGeometryHint::applyToMinMaxInfo(const QWindow *w, + const QScreen *screen, const QMargins &margins, MINMAXINFO *mmi) { QSize minimumSize; QSize maximumSize; - frameSizeConstraints(w, margins, &minimumSize, &maximumSize); + frameSizeConstraints(w, screen, margins, &minimumSize, &maximumSize); qCDebug(lcQpaWindows).nospace() << '>' << __FUNCTION__ << '<' << " min=" << minimumSize.width() << ',' << minimumSize.height() << " max=" << maximumSize.width() << ',' << maximumSize.height() @@ -1041,6 +1048,13 @@ void QWindowsGeometryHint::applyToMinMaxInfo(const QWindow *w, qCDebug(lcQpaWindows).nospace() << '<' << __FUNCTION__ << " out " << *mmi; } +void QWindowsGeometryHint::applyToMinMaxInfo(const QWindow *w, + const QMargins &margins, + MINMAXINFO *mmi) +{ + applyToMinMaxInfo(w, w->screen(), margins, mmi); +} + bool QWindowsGeometryHint::positionIncludesFrame(const QWindow *w) { return qt_window_private(const_cast(w))->positionPolicy @@ -1226,11 +1240,12 @@ void QWindowsForeignWindow::setVisible(bool visible) \ingroup qt-lighthouse-win */ -QWindowCreationContext::QWindowCreationContext(const QWindow *w, +QWindowCreationContext::QWindowCreationContext(const QWindow *w, const QScreen *s, const QRect &geometryIn, const QRect &geometry, const QMargins &cm, DWORD style, DWORD exStyle) : window(w), + screen(s), requestedGeometryIn(geometryIn), requestedGeometry(geometry), obtainedPos(geometryIn.topLeft()), @@ -1270,7 +1285,7 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w, void QWindowCreationContext::applyToMinMaxInfo(MINMAXINFO *mmi) const { - QWindowsGeometryHint::applyToMinMaxInfo(window, margins + customMargins, mmi); + QWindowsGeometryHint::applyToMinMaxInfo(window, screen, margins + customMargins, mmi); } /*! diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 7efbcf900c..1f8800272b 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -66,9 +66,12 @@ struct QWindowsGeometryHint static QMargins frame(const QWindow *w, const QRect &geometry, DWORD style, DWORD exStyle); static bool handleCalculateSize(const QMargins &customMargins, const MSG &msg, LRESULT *result); + static void applyToMinMaxInfo(const QWindow *w, const QScreen *screen, + const QMargins &margins, MINMAXINFO *mmi); static void applyToMinMaxInfo(const QWindow *w, const QMargins &margins, MINMAXINFO *mmi); - static void frameSizeConstraints(const QWindow *w, const QMargins &margins, + static void frameSizeConstraints(const QWindow *w, const QScreen *screen, + const QMargins &margins, QSize *minimumSize, QSize *maximumSize); static inline QPoint mapToGlobal(HWND hwnd, const QPoint &); static inline QPoint mapToGlobal(const QWindow *w, const QPoint &); @@ -80,13 +83,16 @@ struct QWindowsGeometryHint struct QWindowCreationContext { - explicit QWindowCreationContext(const QWindow *w, + explicit QWindowCreationContext(const QWindow *w, const QScreen *s, const QRect &geometryIn, const QRect &geometry, const QMargins &customMargins, DWORD style, DWORD exStyle); void applyToMinMaxInfo(MINMAXINFO *mmi) const; const QWindow *window; + // The screen to use to scale size constraints, etc. Might differ from the + // screen of the window after QPlatformWindow::initialGeometry() (QTBUG-77307). + const QScreen *screen; QRect requestedGeometryIn; // QWindow scaled QRect requestedGeometry; // after QPlatformWindow::initialGeometry() QPoint obtainedPos; -- cgit v1.2.3 From 782df5b41dd3ab098fd1d3233339079487e1812f Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 11 Oct 2019 00:42:08 +0200 Subject: Make QObjectPrivate::threadData a proper atomic QObjectPrivate::threadData used to be a QThreadData *, and was read and written from multiple threads without proper synchronization. As an example, it was read from QCoreApplication::postEvent and written from QObject::moveToThread, therefore causing UB. Port threadData to a proper atomic, removing the races. Fix all usage points. In general, QObject is documented to be simply reentrant, not thread-safe, and certain bits (e.g. timers, moveToThread) are not even reentrant. The reasoning therefore is that a given QObject's threadData is not supposed to be touched by multiple threads without some synchronization happening elsewhere, and therefore relaxed loads should be sufficient. As drive-by change: refactor QCoreApplication::postEvent. It was particularly subtle, because it had a loop using a volatile to cope with the possibility of the receiver object switching thread while we tried to lock its thread's event queue. However, volatile does not achieve any synchronization, so drop it, and refactor the algorithm using better locking primitives. Put this algorithm in a common place, and also reuse it from removePostedEvents, which was lacking any synchronization. Change-Id: Icc755f7eb418ff54b33db4bdd87fd8eaf4e82c7a Reviewed-by: Thiago Macieira --- src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm | 4 ++-- src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index 9b0a6b1b86..f1fe2aa98b 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -149,7 +149,7 @@ QT_USE_NAMESPACE if ([reflectionDelegate respondsToSelector:_cmd]) return [reflectionDelegate applicationShouldTerminate:sender]; - if (QGuiApplicationPrivate::instance()->threadData->eventLoops.isEmpty()) { + if (QGuiApplicationPrivate::instance()->threadData.loadRelaxed()->eventLoops.isEmpty()) { // 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. @@ -359,7 +359,7 @@ QT_USE_NAMESPACE if (!platformItem || platformItem->menu()) return; - QScopedScopeLevelCounter scopeLevelCounter(QGuiApplicationPrivate::instance()->threadData); + QScopedScopeLevelCounter scopeLevelCounter(QGuiApplicationPrivate::instance()->threadData.loadRelaxed()); QGuiApplicationPrivate::modifier_buttons = [QNSView convertKeyModifiers:[NSEvent modifierFlags]]; static QMetaMethod activatedSignal = QMetaMethod::fromSignal(&QCocoaMenuItem::activated); diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index b3ce9e45dc..110c82bf1f 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -511,7 +511,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) if (hadModalSession && !d->currentModalSessionCached) interruptLater = true; } - bool canWait = (d->threadData->canWait + bool canWait = (d->threadData.loadRelaxed()->canWait && !retVal && !d->interrupt && (d->processEventsFlags & QEventLoop::WaitForMoreEvents)); @@ -878,7 +878,7 @@ void QCocoaEventDispatcherPrivate::processPostedEvents() } int serial = serialNumber.loadRelaxed(); - if (!threadData->canWait || (serial != lastSerial)) { + if (!threadData.loadRelaxed()->canWait || (serial != lastSerial)) { lastSerial = serial; QCoreApplication::sendPostedEvents(); QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents); -- cgit v1.2.3 From 5bd48047de4abecc47187d938c5e6ed8b8304aaf Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 8 Nov 2019 11:41:16 +0100 Subject: eglfs: kms: Make threaded atomic drm work The atomic modesetting support was not prepared for page flips being issued from different (per-screen) threads. This could be seen with the threaded render loop of Qt Quick: having a QQuickWindow per screen means having a dedicated render thread for each screen. QKmsDevice used simply instance variables to keep track of the request. This leads to the commit failing with EBUSY sooner or later. Make the atomic request and related variables thread local. This prevents failing drmModeAtomicCommit() with 2 or more screens and the threaded render loop. It does not fix other potential issues when waiting for page flips to complete, that is to be tackled separately. Task-number: QTBUG-74953 Change-Id: I2dac10d5e9bdc0cb556ac78c9643c96d40d692e4 Reviewed-by: Johan Helsing --- .../deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp | 16 +++++++--------- .../eglfs_kms_support/qeglfskmsintegration.cpp | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp index 16dbfe1522..333433f666 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp @@ -243,7 +243,7 @@ void QEglFSKmsGbmScreen::ensureModeSet(uint32_t fb) if (device()->hasAtomicSupport()) { #if QT_CONFIG(drm_atomic) - drmModeAtomicReq *request = device()->atomic_request(); + drmModeAtomicReq *request = device()->threadLocalAtomicRequest(); if (request) { drmModeAtomicAddProperty(request, op.connector_id, op.crtcIdPropertyId, op.crtc_id); drmModeAtomicAddProperty(request, op.crtc_id, op.modeIdPropertyId, op.mode_blob_id); @@ -287,8 +287,7 @@ void QEglFSKmsGbmScreen::waitForFlip() } #if QT_CONFIG(drm_atomic) - if (device()->hasAtomicSupport()) - device()->atomicReset(); + device()->threadLocalAtomicReset(); #endif } @@ -324,16 +323,16 @@ void QEglFSKmsGbmScreen::flip() if (device()->hasAtomicSupport()) { #if QT_CONFIG(drm_atomic) - drmModeAtomicReq *request = device()->atomic_request(); + drmModeAtomicReq *request = device()->threadLocalAtomicRequest(); if (request) { drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->framebufferPropertyId, fb->fb); drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcPropertyId, op.crtc_id); drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->srcwidthPropertyId, - output().size.width() << 16); + op.size.width() << 16); drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->srcXPropertyId, 0); drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->srcYPropertyId, 0); drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->srcheightPropertyId, - output().size.height() << 16); + op.size.height() << 16); drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcXPropertyId, 0); drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcYPropertyId, 0); drmModeAtomicAddProperty(request, op.eglfs_plane->id, op.eglfs_plane->crtcwidthPropertyId, @@ -371,7 +370,7 @@ void QEglFSKmsGbmScreen::flip() if (device()->hasAtomicSupport()) { #if QT_CONFIG(drm_atomic) - drmModeAtomicReq *request = device()->atomic_request(); + drmModeAtomicReq *request = device()->threadLocalAtomicRequest(); if (request) { drmModeAtomicAddProperty(request, d.screen->output().eglfs_plane->id, d.screen->output().eglfs_plane->framebufferPropertyId, fb->fb); @@ -394,8 +393,7 @@ void QEglFSKmsGbmScreen::flip() } #if QT_CONFIG(drm_atomic) - if (device()->hasAtomicSupport()) - device()->atomicCommit(this); + device()->threadLocalAtomicCommit(this); #endif } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp index a6aac61506..28b6b7df63 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp @@ -140,7 +140,7 @@ void *QEglFSKmsIntegration::nativeResourceForIntegration(const QByteArray &name) #if QT_CONFIG(drm_atomic) if (name == QByteArrayLiteral("dri_atomic_request") && m_device) - return (void *) (qintptr) m_device->atomic_request(); + return (void *) (qintptr) m_device->threadLocalAtomicRequest(); #endif return nullptr; } -- cgit v1.2.3 From 813e4460de0316f176d03f19f497e52ddc3c859e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 11 Nov 2019 12:24:31 +0100 Subject: eglfs: kms: Fix hw cursor with multiple screens We used to have the assumption that moving the cursor to an out of range position is valid and will result in a hidden cursor. This is apparently not the case. For example, on an RPi4 with Mesa V3D we get lots of funny artifacts after doing drmModeMoveCursor() to invalid positions. To remedy this, start hiding the cursor correctly when the position is clearly out of the screen's bounds. Task-number: QTBUG-79924 Change-Id: I3ef7ad0ce928546399443f21452f0b6deadf8036 Reviewed-by: Andy Nichols --- .../eglfs_kms/qeglfskmsgbmcursor.cpp | 44 ++++++++++++++++------ .../eglfs_kms/qeglfskmsgbmcursor.h | 2 + .../eglfs_kms/qeglfskmsgbmdevice.cpp | 10 +++++ .../eglfs_kms/qeglfskmsgbmdevice.h | 4 ++ .../eglfs_kms_support/qeglfskmsscreen.cpp | 1 + .../eglfs_kms_support/qeglfskmsscreen.h | 4 ++ 6 files changed, 53 insertions(+), 12 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp index 4d0cf0c47e..1125bcb390 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp @@ -214,7 +214,8 @@ void QEglFSKmsGbmCursor::changeCursor(QCursor *windowCursor, QWindow *window) Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) { QEglFSKmsScreen *kmsScreen = static_cast(screen); - + if (kmsScreen->isCursorOutOfRange()) + continue; int status = drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, handle, m_cursorSize.width(), m_cursorSize.height()); if (status != 0) @@ -232,17 +233,36 @@ void QEglFSKmsGbmCursor::setPos(const QPoint &pos) { Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) { QEglFSKmsScreen *kmsScreen = static_cast(screen); - QPoint origin = kmsScreen->geometry().topLeft(); - QPoint localPos = pos - origin; - QPoint adjustedPos = localPos - m_cursorImage.hotspot(); - - int ret = drmModeMoveCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, adjustedPos.x(), adjustedPos.y()); - if (ret == 0) - m_pos = pos; - else - qWarning("Failed to move cursor on screen %s: %d", kmsScreen->name().toLatin1().constData(), ret); - - kmsScreen->handleCursorMove(pos); + const QRect screenGeom = kmsScreen->geometry(); + const QPoint origin = screenGeom.topLeft(); + const QPoint localPos = pos - origin; + const QPoint adjustedLocalPos = localPos - m_cursorImage.hotspot(); + + if (localPos.x() < 0 || localPos.y() < 0 + || localPos.x() >= screenGeom.width() || localPos.y() >= screenGeom.height()) + { + if (!kmsScreen->isCursorOutOfRange()) { + kmsScreen->setCursorOutOfRange(true); + drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, 0, 0, 0); + } + } else { + int ret; + if (kmsScreen->isCursorOutOfRange()) { + kmsScreen->setCursorOutOfRange(false); + uint32_t handle = gbm_bo_get_handle(m_bo).u32; + ret = drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, + handle, m_cursorSize.width(), m_cursorSize.height()); + } else { + ret = drmModeMoveCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, + adjustedLocalPos.x(), adjustedLocalPos.y()); + } + if (ret == 0) + m_pos = pos; + else + qWarning("Failed to move cursor on screen %s: %d", kmsScreen->name().toLatin1().constData(), ret); + + kmsScreen->handleCursorMove(pos); + } } } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h index d47b579238..5d2dfedba2 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h @@ -85,6 +85,8 @@ public: void updateMouseStatus(); + void reevaluateVisibilityForScreens() { setPos(pos()); } + private: void initCursorAtlas(); diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp index 20127ae7f7..f4a69483bd 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp @@ -155,4 +155,14 @@ void QEglFSKmsGbmDevice::registerScreenCloning(QPlatformScreen *screen, gbmScreen->initCloning(screenThisScreenClones, screensCloningThisScreen); } +void QEglFSKmsGbmDevice::registerScreen(QPlatformScreen *screen, + bool isPrimary, + const QPoint &virtualPos, + const QList &virtualSiblings) +{ + QEglFSKmsDevice::registerScreen(screen, isPrimary, virtualPos, virtualSiblings); + if (screenConfig()->hwCursor() && m_globalCursor) + m_globalCursor->reevaluateVisibilityForScreens(); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h index 518e2ce58b..f1476f8ffa 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h @@ -70,6 +70,10 @@ public: void registerScreenCloning(QPlatformScreen *screen, QPlatformScreen *screenThisScreenClones, const QVector &screensCloningThisScreen) override; + void registerScreen(QPlatformScreen *screen, + bool isPrimary, + const QPoint &virtualPos, + const QList &virtualSiblings) override; private: Q_DISABLE_COPY(QEglFSKmsGbmDevice) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp index e5354d97bd..b097f67e93 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp @@ -72,6 +72,7 @@ QEglFSKmsScreen::QEglFSKmsScreen(QKmsDevice *device, const QKmsOutput &output, b : QEglFSScreen(static_cast(QGuiApplicationPrivate::platformIntegration())->display()) , m_device(device) , m_output(output) + , m_cursorOutOfRange(false) , m_powerState(PowerStateOn) , m_interruptHandler(new QEglFSKmsInterruptHandler(this)) , m_headless(headless) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h index 7f395aacb7..93d7e4c1eb 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h @@ -99,12 +99,16 @@ public: QPlatformScreen::PowerState powerState() const override; void setPowerState(QPlatformScreen::PowerState state) override; + bool isCursorOutOfRange() const { return m_cursorOutOfRange; } + void setCursorOutOfRange(bool b) { m_cursorOutOfRange = b; } + protected: QKmsDevice *m_device; QKmsOutput m_output; QEdidParser m_edid; QPoint m_pos; + bool m_cursorOutOfRange; QList m_siblings; -- cgit v1.2.3 From 14bb413309092adc53e8451daff5690c4698c07d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 8 Nov 2019 13:15:53 +0100 Subject: eglfs: kms: Read page flip events on a dedicated thread Task-number: QTBUG-74953 Change-Id: I9a630c9245d8b0afe40ade9199cf4f1d358275da Reviewed-by: Andy Nichols Reviewed-by: Paul Olav Tvete --- .../eglfs_kms/qeglfskmsgbmdevice.cpp | 4 + .../eglfs_kms/qeglfskmsgbmintegration.cpp | 2 - .../eglfs_kms/qeglfskmsgbmscreen.cpp | 28 +-- .../eglfs_kms/qeglfskmsgbmscreen.h | 16 +- .../qeglfskmsegldevicescreen.cpp | 2 +- .../eglfs_kms_egldevice/qeglfskmsegldevicescreen.h | 2 +- .../eglfs_kms_support/eglfs_kms_support.pro | 6 +- .../eglfs_kms_support/qeglfskmsdevice.h | 6 + .../eglfs_kms_support/qeglfskmseventreader.cpp | 218 +++++++++++++++++++++ .../eglfs_kms_support/qeglfskmseventreader.h | 99 ++++++++++ .../eglfs_kms_support/qeglfskmsscreen.cpp | 3 +- .../eglfs_kms_support/qeglfskmsscreen.h | 7 +- .../eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp | 2 +- .../eglfs_kms_vsp2/qeglfskmsvsp2screen.h | 2 +- 14 files changed, 354 insertions(+), 43 deletions(-) create mode 100644 src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp create mode 100644 src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.h (limited to 'src/plugins') diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp index f4a69483bd..503419cf91 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp @@ -83,6 +83,8 @@ bool QEglFSKmsGbmDevice::open() setFd(fd); + m_eventReader.create(this); + return true; } @@ -90,6 +92,8 @@ void QEglFSKmsGbmDevice::close() { // Note: screens are gone at this stage. + m_eventReader.destroy(); + if (m_gbm_device) { gbm_device_destroy(m_gbm_device); m_gbm_device = nullptr; diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp index f154520669..caa1187b40 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp @@ -54,8 +54,6 @@ QT_BEGIN_NAMESPACE -QMutex QEglFSKmsGbmScreen::m_waitForFlipMutex; - QEglFSKmsGbmIntegration::QEglFSKmsGbmIntegration() { qCDebug(qLcEglfsKmsDebug, "New DRM/KMS via GBM integration created"); diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp index 333433f666..6f5c3b6953 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp @@ -110,7 +110,7 @@ QEglFSKmsGbmScreen::FrameBuffer *QEglFSKmsGbmScreen::framebufferForBufferObject( return fb.take(); } -QEglFSKmsGbmScreen::QEglFSKmsGbmScreen(QKmsDevice *device, const QKmsOutput &output, bool headless) +QEglFSKmsGbmScreen::QEglFSKmsGbmScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless) : QEglFSKmsScreen(device, output, headless) , m_gbm_surface(nullptr) , m_gbm_bo_current(nullptr) @@ -276,15 +276,12 @@ void QEglFSKmsGbmScreen::waitForFlip() if (!m_gbm_bo_next) return; - QMutexLocker lock(&m_waitForFlipMutex); - while (m_gbm_bo_next) { - drmEventContext drmEvent; - memset(&drmEvent, 0, sizeof(drmEvent)); - drmEvent.version = 2; - drmEvent.vblank_handler = nullptr; - drmEvent.page_flip_handler = pageFlipHandler; - drmHandleEvent(device()->fd(), &drmEvent); - } + m_flipMutex.lock(); + device()->eventReader()->startWaitFlip(this, &m_flipMutex, &m_flipCond); + m_flipCond.wait(&m_flipMutex); + m_flipMutex.unlock(); + + flipFinished(); #if QT_CONFIG(drm_atomic) device()->threadLocalAtomicReset(); @@ -397,17 +394,6 @@ void QEglFSKmsGbmScreen::flip() #endif } -void QEglFSKmsGbmScreen::pageFlipHandler(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data) -{ - Q_UNUSED(fd); - Q_UNUSED(sequence); - Q_UNUSED(tv_sec); - Q_UNUSED(tv_usec); - - QEglFSKmsGbmScreen *screen = static_cast(user_data); - screen->flipFinished(); -} - void QEglFSKmsGbmScreen::flipFinished() { if (m_cloneSource) { diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h index b94f44b7b1..69feeee703 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h @@ -43,7 +43,8 @@ #define QEGLFSKMSGBMSCREEN_H #include "qeglfskmsscreen.h" -#include +#include +#include #include @@ -54,7 +55,7 @@ class QEglFSKmsGbmCursor; class QEglFSKmsGbmScreen : public QEglFSKmsScreen { public: - QEglFSKmsGbmScreen(QKmsDevice *device, const QKmsOutput &output, bool headless); + QEglFSKmsGbmScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless); ~QEglFSKmsGbmScreen(); QPlatformCursor *cursor() const override; @@ -75,18 +76,15 @@ private: void cloneDestFlipFinished(QEglFSKmsGbmScreen *cloneDestScreen); void updateFlipStatus(); - static void pageFlipHandler(int fd, - unsigned int sequence, - unsigned int tv_sec, - unsigned int tv_usec, - void *user_data); - gbm_surface *m_gbm_surface; gbm_bo *m_gbm_bo_current; gbm_bo *m_gbm_bo_next; bool m_flipPending; + QMutex m_flipMutex; + QWaitCondition m_flipCond; + QScopedPointer m_cursor; struct FrameBuffer { @@ -101,8 +99,6 @@ private: bool cloneFlipPending = false; }; QVector m_cloneDests; - - static QMutex m_waitForFlipMutex; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp index 1626c86239..5a62e437c4 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug) -QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QKmsDevice *device, const QKmsOutput &output) +QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QEglFSKmsDevice *device, const QKmsOutput &output) : QEglFSKmsScreen(device, output) { } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h index 5efe35f8b3..961398ba3e 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE class QEglFSKmsEglDeviceScreen : public QEglFSKmsScreen { public: - QEglFSKmsEglDeviceScreen(QKmsDevice *device, const QKmsOutput &output); + QEglFSKmsEglDeviceScreen(QEglFSKmsDevice *device, const QKmsOutput &output); ~QEglFSKmsEglDeviceScreen(); QPlatformCursor *cursor() const override; diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro index 40806b6a9b..e51903ed96 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro @@ -14,9 +14,11 @@ CONFIG += egl SOURCES += $$PWD/qeglfskmsintegration.cpp \ $$PWD/qeglfskmsdevice.cpp \ - $$PWD/qeglfskmsscreen.cpp + $$PWD/qeglfskmsscreen.cpp \ + $$PWD/qeglfskmseventreader.cpp HEADERS += $$PWD/qeglfskmsintegration.h \ $$PWD/qeglfskmsdevice.h \ $$PWD/qeglfskmsscreen.h \ - $$PWD/qeglfskmshelpers.h + $$PWD/qeglfskmshelpers.h \ + $$PWD/qeglfskmseventreader.h diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h index fc83a620d9..34908aa60f 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h @@ -42,6 +42,7 @@ #define QEGLFSKMSDEVICE_H #include "private/qeglfsglobal_p.h" +#include "qeglfskmseventreader.h" #include QT_BEGIN_NAMESPACE @@ -55,6 +56,11 @@ public: bool isPrimary, const QPoint &virtualPos, const QList &virtualSiblings) override; + + QEglFSKmsEventReader *eventReader() { return &m_eventReader; } + +protected: + QEglFSKmsEventReader m_eventReader; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp new file mode 100644 index 0000000000..645a0ae2e9 --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.cpp @@ -0,0 +1,218 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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 "qeglfskmseventreader.h" +#include "qeglfskmsdevice.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug) + +static void pageFlipHandler(int fd, unsigned int sequence, unsigned int tv_sec, unsigned int tv_usec, void *user_data) +{ + Q_UNUSED(fd); + Q_UNUSED(sequence); + Q_UNUSED(tv_sec); + Q_UNUSED(tv_usec); + + QEglFSKmsEventReaderThread *t = static_cast(QThread::currentThread()); + t->eventHost()->handlePageFlipCompleted(user_data); +} + +class RegisterWaitFlipEvent : public QEvent +{ +public: + static const QEvent::Type TYPE = QEvent::Type(QEvent::User + 1); + RegisterWaitFlipEvent(void *key, QMutex *mutex, QWaitCondition *cond) + : QEvent(TYPE), key(key), mutex(mutex), cond(cond) + { } + void *key; + QMutex *mutex; + QWaitCondition *cond; +}; + +bool QEglFSKmsEventHost::event(QEvent *event) +{ + if (event->type() == RegisterWaitFlipEvent::TYPE) { + RegisterWaitFlipEvent *e = static_cast(event); + PendingFlipWait *p = &pendingFlipWaits[0]; + PendingFlipWait *end = p + MAX_FLIPS; + while (p < end) { + if (!p->key) { + p->key = e->key; + p->mutex = e->mutex; + p->cond = e->cond; + updateStatus(); + return true; + } + ++p; + } + qWarning("Cannot queue page flip wait (more than %d screens?)", MAX_FLIPS); + e->mutex->lock(); + e->cond->wakeOne(); + e->mutex->unlock(); + return true; + } + return QObject::event(event); +} + +void QEglFSKmsEventHost::updateStatus() +{ + void **begin = &completedFlips[0]; + void **end = begin + MAX_FLIPS; + + for (int i = 0; i < MAX_FLIPS; ++i) { + PendingFlipWait *w = pendingFlipWaits + i; + if (!w->key) + continue; + + void **p = begin; + while (p < end) { + if (*p == w->key) { + *p = nullptr; + w->key = nullptr; + w->mutex->lock(); + w->cond->wakeOne(); + w->mutex->unlock(); + return; + } + ++p; + } + } +} + +void QEglFSKmsEventHost::handlePageFlipCompleted(void *key) +{ + void **begin = &completedFlips[0]; + void **end = begin + MAX_FLIPS; + void **p = begin; + while (p < end) { + if (*p == key) { + updateStatus(); + return; + } + ++p; + } + p = begin; + while (p < end) { + if (!*p) { + *p = key; + updateStatus(); + return; + } + ++p; + } + qWarning("Cannot store page flip status (more than %d screens?)", MAX_FLIPS); +} + +void QEglFSKmsEventReaderThread::run() +{ + qCDebug(qLcEglfsKmsDebug, "Event reader thread: entering event loop"); + + QSocketNotifier notifier(m_fd, QSocketNotifier::Read); + QObject::connect(¬ifier, &QSocketNotifier::activated, ¬ifier, [this] { + drmEventContext drmEvent; + memset(&drmEvent, 0, sizeof(drmEvent)); + drmEvent.version = 2; + drmEvent.vblank_handler = nullptr; + drmEvent.page_flip_handler = pageFlipHandler; + drmHandleEvent(m_fd, &drmEvent); + }); + + exec(); + + m_ev.moveToThread(thread()); // move back to the thread where m_ev was created + + qCDebug(qLcEglfsKmsDebug, "Event reader thread: event loop stopped"); +} + +QEglFSKmsEventReader::~QEglFSKmsEventReader() +{ + destroy(); +} + +void QEglFSKmsEventReader::create(QEglFSKmsDevice *device) +{ + destroy(); + + if (!device) + return; + + m_device = device; + + qCDebug(qLcEglfsKmsDebug, "Initalizing event reader for device %p fd %d", + m_device, m_device->fd()); + + m_thread = new QEglFSKmsEventReaderThread(m_device->fd()); + m_thread->start(); + + // Change thread affinity for the event host, so that postEvent() + // goes through the event reader thread's event loop for that object. + m_thread->eventHost()->moveToThread(m_thread); +} + +void QEglFSKmsEventReader::destroy() +{ + if (!m_device) + return; + + qCDebug(qLcEglfsKmsDebug, "Stopping event reader for device %p", m_device); + + if (m_thread) { + m_thread->quit(); + m_thread->wait(); + delete m_thread; + m_thread = nullptr; + } + + m_device = nullptr; +} + +void QEglFSKmsEventReader::startWaitFlip(void *key, QMutex *mutex, QWaitCondition *cond) +{ + if (m_thread) { + QCoreApplication::postEvent(m_thread->eventHost(), + new RegisterWaitFlipEvent(key, mutex, cond)); + } +} + +QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.h new file mode 100644 index 0000000000..4aa285b0fe --- /dev/null +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmseventreader.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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 QEGLFSKKMSEVENTREADER_H +#define QEGLFSKKMSEVENTREADER_H + +#include "private/qeglfsglobal_p.h" +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QEglFSKmsDevice; + +struct QEglFSKmsEventHost : public QObject +{ + struct PendingFlipWait { + void *key; + QMutex *mutex; + QWaitCondition *cond; + }; + + static const int MAX_FLIPS = 32; + void *completedFlips[MAX_FLIPS] = {}; + QEglFSKmsEventHost::PendingFlipWait pendingFlipWaits[MAX_FLIPS] = {}; + + bool event(QEvent *event) override; + void updateStatus(); + void handlePageFlipCompleted(void *key); +}; + +class QEglFSKmsEventReaderThread : public QThread +{ +public: + QEglFSKmsEventReaderThread(int fd) : m_fd(fd) { } + void run() override; + QEglFSKmsEventHost *eventHost() { return &m_ev; } + +private: + int m_fd; + QEglFSKmsEventHost m_ev; +}; + +class Q_EGLFS_EXPORT QEglFSKmsEventReader +{ +public: + ~QEglFSKmsEventReader(); + + void create(QEglFSKmsDevice *device); + void destroy(); + + void startWaitFlip(void *key, QMutex *mutex, QWaitCondition *cond); + +private: + QEglFSKmsDevice *m_device = nullptr; + QEglFSKmsEventReaderThread *m_thread = nullptr; +}; + +QT_END_NAMESPACE + +#endif // QEGLFSKKMSEVENTREADER_H diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp index b097f67e93..959f17eba3 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qeglfskmsscreen.h" +#include "qeglfskmsdevice.h" #include "qeglfsintegration_p.h" #include @@ -68,7 +69,7 @@ private: QEglFSKmsScreen *m_screen; }; -QEglFSKmsScreen::QEglFSKmsScreen(QKmsDevice *device, const QKmsOutput &output, bool headless) +QEglFSKmsScreen::QEglFSKmsScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless) : QEglFSScreen(static_cast(QGuiApplicationPrivate::platformIntegration())->display()) , m_device(device) , m_output(output) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h index 93d7e4c1eb..a5c8f5b4e8 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h @@ -51,12 +51,13 @@ QT_BEGIN_NAMESPACE +class QEglFSKmsDevice; class QEglFSKmsInterruptHandler; class Q_EGLFS_EXPORT QEglFSKmsScreen : public QEglFSScreen { public: - QEglFSKmsScreen(QKmsDevice *device, const QKmsOutput &output, bool headless = false); + QEglFSKmsScreen(QEglFSKmsDevice *device, const QKmsOutput &output, bool headless = false); ~QEglFSKmsScreen(); void setVirtualPosition(const QPoint &pos); @@ -87,7 +88,7 @@ public: int currentMode() const override; int preferredMode() const override; - QKmsDevice *device() const { return m_device; } + QEglFSKmsDevice *device() const { return m_device; } virtual void waitForFlip(); @@ -103,7 +104,7 @@ public: void setCursorOutOfRange(bool b) { m_cursorOutOfRange = b; } protected: - QKmsDevice *m_device; + QEglFSKmsDevice *m_device; QKmsOutput m_output; QEdidParser m_edid; diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp index 475d9d55dd..c255bc84b7 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.cpp @@ -99,7 +99,7 @@ QEglFSKmsVsp2Screen::DmaBuffer *QEglFSKmsVsp2Screen::dmaBufferForGbmBuffer(gbm_b return fb.take(); } -QEglFSKmsVsp2Screen::QEglFSKmsVsp2Screen(QKmsDevice *device, const QKmsOutput &output) +QEglFSKmsVsp2Screen::QEglFSKmsVsp2Screen(QEglFSKmsDevice *device, const QKmsOutput &output) : QEglFSKmsScreen(device, output) , m_blender(new Blender(this)) { diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h index 7618510333..378786643d 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_vsp2/qeglfskmsvsp2screen.h @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE class QEglFSKmsVsp2Screen : public QEglFSKmsScreen { public: - QEglFSKmsVsp2Screen(QKmsDevice *device, const QKmsOutput &output); + QEglFSKmsVsp2Screen(QEglFSKmsDevice *device, const QKmsOutput &output); gbm_surface *createSurface(); void resetSurface(); -- cgit v1.2.3 From 41702d8455a9e88ac70108e500a10e7bd4df2771 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 21 Oct 2019 21:23:08 +0200 Subject: Honor alpha for SH_Table_GridLineColor Make sure to honor the alpha channel for the color returned by SH_Table_GridLineColor. Fixes: QTBUG-74909 Change-Id: If9688329e5e2ab41833dfeb7e6292fdfcbf63aa1 Reviewed-by: Richard Moe Gustavsen --- src/plugins/styles/mac/qmacstyle_mac.mm | 2 +- src/plugins/styles/windowsvista/qwindowsvistastyle.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 610329a350..603c6e93f3 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -2873,7 +2873,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w ret = false; break; case SH_Table_GridLineColor: - ret = int(qt_mac_toQColor(NSColor.gridColor).rgb()); + ret = int(qt_mac_toQColor(NSColor.gridColor).rgba()); break; default: ret = QCommonStyle::styleHint(sh, opt, w, hret); diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp index e213d65946..345267c8fc 100644 --- a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp @@ -2110,7 +2110,7 @@ int QWindowsVistaStyle::styleHint(StyleHint hint, const QStyleOption *option, co break; case SH_Table_GridLineColor: if (option) - ret = int(option->palette.color(QPalette::Base).darker(118).rgb()); + ret = int(option->palette.color(QPalette::Base).darker(118).rgba()); else ret = -1; break; -- cgit v1.2.3 From c3556025951ec9b16c20d215985761a27fad52d4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 12 Nov 2019 12:45:36 +0100 Subject: Windows QPA: Port from QList to QVector Use a QVector where possible. Otherwise, try to introduce auto to make migration easier. Change-Id: I9deadb363fabd1755deca180ed5cb771390fcb30 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowsdialoghelpers.cpp | 4 ++-- src/plugins/platforms/windows/qwindowsdropdataobject.cpp | 2 +- src/plugins/platforms/windows/qwindowskeymapper.cpp | 2 +- src/plugins/platforms/windows/qwindowsmime.cpp | 10 +++++----- src/plugins/platforms/windows/qwindowsmime.h | 3 +-- src/plugins/platforms/windows/qwindowsscreen.cpp | 6 +++--- src/plugins/platforms/windows/qwindowsscreen.h | 2 +- src/plugins/platforms/windows/qwindowswindow.cpp | 2 +- .../windows/uiautomation/qwindowsuiaselectionprovider.cpp | 3 ++- .../windows/uiautomation/qwindowsuiatableitemprovider.cpp | 4 ++-- 10 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index b7ab952a1d..cdb4e407d1 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -466,14 +466,14 @@ inline void QWindowsFileDialogSharedData::setSelectedNameFilter(const QString &f inline QList QWindowsFileDialogSharedData::selectedFiles() const { m_data->mutex.lock(); - const QList result = m_data->selectedFiles; + const auto result = m_data->selectedFiles; m_data->mutex.unlock(); return result; } inline QString QWindowsFileDialogSharedData::selectedFile() const { - const QList files = selectedFiles(); + const auto files = selectedFiles(); return files.isEmpty() ? QString() : files.front().toLocalFile(); } diff --git a/src/plugins/platforms/windows/qwindowsdropdataobject.cpp b/src/plugins/platforms/windows/qwindowsdropdataobject.cpp index e1a41c0ede..c9dd1c7c17 100644 --- a/src/plugins/platforms/windows/qwindowsdropdataobject.cpp +++ b/src/plugins/platforms/windows/qwindowsdropdataobject.cpp @@ -95,7 +95,7 @@ bool QWindowsDropDataObject::shouldIgnore(LPFORMATETC pformatetc) const || pformatetc->cfFormat == CF_TEXT || formatName == QStringLiteral("UniformResourceLocator") || formatName == QStringLiteral("UniformResourceLocatorW")) { - QList urls = dropData->urls(); + const auto urls = dropData->urls(); return std::all_of(urls.cbegin(), urls.cend(), [] (const QUrl &u) { return u.isLocalFile(); }); } } diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 4f0f846749..0509403267 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -1388,7 +1388,7 @@ QList QWindowsKeyMapper::possibleKeys(const QKeyEvent *e) const if (key && key != baseKey && ((keyMods & neededMods) == neededMods)) { const Qt::KeyboardModifiers missingMods = keyMods & ~neededMods; const int matchedKey = int(key) + missingMods; - const QList::iterator it = + const auto it = std::find_if(result.begin(), result.end(), [key] (int k) { return (k & ~Qt::KeyboardModifierMask) == key; }); // QTBUG-67200: Use the match with the least modifiers (prefer diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index b9d8b191f5..1c6c999f05 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -107,7 +107,7 @@ static inline QByteArray msgConversionError(const char *func, const char *format msg += ": Unable to convert DIB image. The image converter plugin for '"; msg += format; msg += "' is not available. Available formats: "; - const QList &formats = QImageReader::supportedImageFormats(); + const auto &formats = QImageReader::supportedImageFormats(); for (const QByteArray &af : formats) { msg += af; msg += ' '; @@ -747,7 +747,7 @@ QWindowsMimeURI::QWindowsMimeURI() bool QWindowsMimeURI::canConvertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData) const { if (mimeData->hasUrls() && getCf(formatetc) == CF_HDROP) { - const QList urls = mimeData->urls(); + const auto urls = mimeData->urls(); for (const QUrl &url : urls) { if (url.isLocalFile()) return true; @@ -760,7 +760,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat { if (canConvertFromMime(formatetc, mimeData)) { if (getCf(formatetc) == CF_HDROP) { - const QList &urls = mimeData->urls(); + const auto &urls = mimeData->urls(); QStringList fileNames; int size = sizeof(DROPFILES)+2; for (const QUrl &url : urls) { @@ -791,7 +791,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat return setData(result, pmedium); } if (getCf(formatetc) == CF_INETURL_W) { - QList urls = mimeData->urls(); + const auto urls = mimeData->urls(); QByteArray result; if (!urls.isEmpty()) { QString url = urls.at(0).toString(); @@ -803,7 +803,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat return setData(result, pmedium); } if (getCf(formatetc) == CF_INETURL) { - QList urls = mimeData->urls(); + const auto urls = mimeData->urls(); QByteArray result; if (!urls.isEmpty()) result = urls.at(0).toString().toLocal8Bit(); diff --git a/src/plugins/platforms/windows/qwindowsmime.h b/src/plugins/platforms/windows/qwindowsmime.h index 1c389e8800..f8708f1259 100644 --- a/src/plugins/platforms/windows/qwindowsmime.h +++ b/src/plugins/platforms/windows/qwindowsmime.h @@ -43,7 +43,6 @@ #include #include -#include #include QT_BEGIN_NAMESPACE @@ -95,7 +94,7 @@ public: private: void ensureInitialized() const; - mutable QList m_mimes; + mutable QVector m_mimes; mutable int m_internalMimeCount = 0; }; diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index df63adf558..4f76a82544 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -73,7 +73,7 @@ static inline QDpi monitorDPI(HMONITOR hMonitor) return {0, 0}; } -using WindowsScreenDataList = QList; +using WindowsScreenDataList = QVector; static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data) { @@ -467,7 +467,7 @@ bool QWindowsScreenManager::handleDisplayChange(WPARAM wParam, LPARAM lParam) return false; } -static inline int indexOfMonitor(const QList &screens, +static inline int indexOfMonitor(const QWindowsScreenManager::WindowsScreenList &screens, const QString &monitorName) { for (int i= 0; i < screens.size(); ++i) @@ -476,7 +476,7 @@ static inline int indexOfMonitor(const QList &screens, return -1; } -static inline int indexOfMonitor(const QList &screenData, +static inline int indexOfMonitor(const WindowsScreenDataList &screenData, const QString &monitorName) { for (int i = 0; i < screenData.size(); ++i) diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h index 2fd56f53cf..5c095808f2 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.h +++ b/src/plugins/platforms/windows/qwindowsscreen.h @@ -127,7 +127,7 @@ private: class QWindowsScreenManager { public: - using WindowsScreenList = QList; + using WindowsScreenList = QVector; QWindowsScreenManager(); diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index ea91e3bb2d..5a4f879d0f 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -592,7 +592,7 @@ static QPoint calcPosition(const QWindow *w, const QWindowCreationContextPtr &co return posFrame; // Find the original screen containing the coordinates. - const QList screens = screenForGL->virtualSiblings(); + const auto screens = screenForGL->virtualSiblings(); const QScreen *orgScreen = nullptr; for (QScreen *screen : screens) { if (screen->handle()->availableGeometry().contains(posFrame)) { diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp index 3305e9c5c4..fb41012cf4 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaselectionprovider.cpp @@ -49,6 +49,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -78,7 +79,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaSelectionProvider::GetSelection(SAFEARRAY * return UIA_E_ELEMENTNOTAVAILABLE; // First put selected items in a list, then build a safe array with the right size. - QList selectedList; + QVector selectedList; for (int i = 0; i < accessible->childCount(); ++i) { if (QAccessibleInterface *child = accessible->child(i)) { if (child->state().selected) { diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp index 2a94012590..1348ec7cc0 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiatableitemprovider.cpp @@ -80,7 +80,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetRowHeaderItems(SAFEAR if (!tableCellInterface) return UIA_E_ELEMENTNOTAVAILABLE; - QList headers = tableCellInterface->rowHeaderCells(); + const auto headers = tableCellInterface->rowHeaderCells(); if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) { for (LONG i = 0; i < headers.size(); ++i) { @@ -110,7 +110,7 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaTableItemProvider::GetColumnHeaderItems(SAF if (!tableCellInterface) return UIA_E_ELEMENTNOTAVAILABLE; - QList headers = tableCellInterface->columnHeaderCells(); + const auto headers = tableCellInterface->columnHeaderCells(); if ((*pRetVal = SafeArrayCreateVector(VT_UNKNOWN, 0, headers.size()))) { for (LONG i = 0; i < headers.size(); ++i) { -- cgit v1.2.3 From 3b98fe7f773668ed8b35478fa3a8ca0590acc450 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 18 Nov 2019 18:53:59 +0300 Subject: xcb: Simplify code by using helper QXcbIntegration::defaultConnection() Change-Id: Ieb0e21d85fcd0c168b1bb090e967d02a8a6a6083 Reviewed-by: Mikhail Svetkin --- src/plugins/platforms/xcb/qxcbintegration.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 95ca40fc95..efda6b67ce 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -317,8 +317,7 @@ bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const case OpenGL: case ThreadedOpenGL: { - const auto *connection = qAsConst(m_connections).first(); - if (const auto *integration = connection->glIntegration()) + if (const auto *integration = defaultConnection()->glIntegration()) return cap != ThreadedOpenGL || integration->supportsThreadedOpenGL(); return false; } -- cgit v1.2.3 From 8bc4ea1e97c138034d08c705a75f75763361400b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 13 Nov 2019 10:27:25 +0100 Subject: Windows QPA: Fix deprecation warnings Fix warnings introduced by qtbase/72f57cc84244633ca69ede9a1fd510b9b1881c1d: qwindowstheme.cpp:167:62: warning: 'bool QWaitCondition::wait(QMutex*, long unsigned int)' is deprecated: Use wait(QMutex *lockedMutex, QDeadlineTimer deadline) instead [-Wdeprecated-declarations]qwindowstheme.cpp: In member function 'bool QShGetFileInfoThread::runWithParams(QShGetFileInfoParams*, long unsigned int)': qwindowstheme.cpp:201:63: warning: 'bool QWaitCondition::wait(QMutex*, long unsigned int)' is deprecated: Use wait(QMutex *lockedMutex, QDeadlineTimer deadline) instead [-Wdeprecated-declarations] Change-Id: Ie33f8b0e1e742f972d2a8065eba9e16a13ec43ee Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowstheme.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 40f9652cbd..32a65109af 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -164,7 +164,7 @@ public: QMutexLocker readyLocker(&m_readyMutex); while (!m_cancelled.loadRelaxed()) { if (!m_params && !m_cancelled.loadRelaxed() - && !m_readyCondition.wait(&m_readyMutex, 1000)) + && !m_readyCondition.wait(&m_readyMutex, QDeadlineTimer(1000ll))) continue; if (m_params) { @@ -189,7 +189,7 @@ public: CoUninitialize(); } - bool runWithParams(QShGetFileInfoParams *params, unsigned long timeOutMSecs) + bool runWithParams(QShGetFileInfoParams *params, qint64 timeOutMSecs) { QMutexLocker doneLocker(&m_doneMutex); @@ -198,7 +198,7 @@ public: m_readyCondition.wakeAll(); m_readyMutex.unlock(); - return m_doneCondition.wait(&m_doneMutex, timeOutMSecs); + return m_doneCondition.wait(&m_doneMutex, QDeadlineTimer(timeOutMSecs)); } void cancel() @@ -220,7 +220,7 @@ private: static bool shGetFileInfoBackground(const QString &fileName, DWORD attributes, SHFILEINFO *info, UINT flags, - unsigned long timeOutMSecs = 5000) + qint64 timeOutMSecs = 5000) { static QShGetFileInfoThread *getFileInfoThread = nullptr; if (!getFileInfoThread) { -- cgit v1.2.3 From af2daafde72db02454d24b7d691aa6861525ab99 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 18 Nov 2019 17:01:26 +0100 Subject: Deprecate constructing QFlags from a pointer This was used to support QFlags f = 0 initialization, but with 0 used as a pointer literal now considered bad form, it had been changed many places to QFlags f = nullptr, which is meaningless and confusing. Change-Id: I4bc592151c255dc5cab1a232615caecc520f02e8 Reviewed-by: Thiago Macieira --- src/plugins/imageformats/gif/main.cpp | 2 +- src/plugins/imageformats/ico/main.cpp | 4 ++-- src/plugins/imageformats/jpeg/main.cpp | 4 ++-- .../platforminputcontexts/ibus/qibusplatforminputcontext.h | 2 +- src/plugins/platforms/eglfs/api/qeglfsintegration.cpp | 2 +- src/plugins/platforms/eglfs/api/qeglfswindow.cpp | 2 +- .../optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm | 2 +- src/plugins/platforms/xcb/qxcbconnection.cpp | 2 +- src/plugins/platforms/xcb/qxcbconnection.h | 8 ++++---- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 2 +- src/plugins/platforms/xcb/qxcbdrag.cpp | 2 +- src/plugins/platforms/xcb/qxcbdrag.h | 4 ++-- src/plugins/platforms/xcb/qxcbwindow.cpp | 2 +- .../platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h | 2 +- 14 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/imageformats/gif/main.cpp b/src/plugins/imageformats/gif/main.cpp index c171111fac..993871420c 100644 --- a/src/plugins/imageformats/gif/main.cpp +++ b/src/plugins/imageformats/gif/main.cpp @@ -62,7 +62,7 @@ QImageIOPlugin::Capabilities QGifPlugin::capabilities(QIODevice *device, const Q { if (format == "gif" || (device && device->isReadable() && QGifHandler::canRead(device))) return Capabilities(CanRead); - return 0; + return { }; } QImageIOHandler *QGifPlugin::create(QIODevice *device, const QByteArray &format) const diff --git a/src/plugins/imageformats/ico/main.cpp b/src/plugins/imageformats/ico/main.cpp index baaf33e1fc..b00d8c7fd3 100644 --- a/src/plugins/imageformats/ico/main.cpp +++ b/src/plugins/imageformats/ico/main.cpp @@ -46,9 +46,9 @@ QImageIOPlugin::Capabilities QICOPlugin::capabilities(QIODevice *device, const Q if (format == "ico" || format == "cur") return Capabilities(CanRead | CanWrite); if (!format.isEmpty()) - return 0; + return { }; if (!device->isOpen()) - return 0; + return { }; Capabilities cap; if (device->isReadable() && QtIcoHandler::canRead(device)) diff --git a/src/plugins/imageformats/jpeg/main.cpp b/src/plugins/imageformats/jpeg/main.cpp index 58442053a1..83f13c4a9d 100644 --- a/src/plugins/imageformats/jpeg/main.cpp +++ b/src/plugins/imageformats/jpeg/main.cpp @@ -51,9 +51,9 @@ QImageIOPlugin::Capabilities QJpegPlugin::capabilities(QIODevice *device, const if (format == "jpeg" || format == "jpg") return Capabilities(CanRead | CanWrite); if (!format.isEmpty()) - return 0; + return { }; if (!device->isOpen()) - return 0; + return { }; Capabilities cap; if (device->isReadable() && QJpegHandler::canRead(device)) diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h index 8e7b8df120..e9c9c55f6a 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h @@ -61,7 +61,7 @@ public: explicit QIBusFilterEventWatcher(const QDBusPendingCall &call, QObject *parent = nullptr, QWindow *window = nullptr, - const Qt::KeyboardModifiers modifiers = nullptr, + const Qt::KeyboardModifiers modifiers = { }, const QVariantList arguments = QVariantList()) : QDBusPendingCallWatcher(call, parent) , m_window(window) diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp index 674f579b4f..d3f51c0d0e 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp @@ -236,7 +236,7 @@ QPlatformOffscreenSurface *QEglFSIntegration::createPlatformOffscreenSurface(QOf EGLDisplay dpy = surface->screen() ? static_cast(surface->screen()->handle())->display() : display(); QSurfaceFormat fmt = qt_egl_device_integration()->surfaceFormatFor(surface->requestedFormat()); if (qt_egl_device_integration()->supportsPBuffers()) { - QEGLPlatformContext::Flags flags = 0; + QEGLPlatformContext::Flags flags; if (!qt_egl_device_integration()->supportsSurfacelessContexts()) flags |= QEGLPlatformContext::NoSurfaceless; return new QEGLPbuffer(dpy, fmt, surface, flags); diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp index 1fed182882..e6b25c02fd 100644 --- a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp @@ -186,7 +186,7 @@ void QEglFSWindow::destroy() #endif } - m_flags = 0; + m_flags = { }; } void QEglFSWindow::invalidateSurface() diff --git a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm index 54152aebf7..c5244a51ad 100644 --- a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm +++ b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm @@ -373,7 +373,7 @@ bool QIOSFileEngineAssetsLibrary::close() QAbstractFileEngine::FileFlags QIOSFileEngineAssetsLibrary::fileFlags(QAbstractFileEngine::FileFlags type) const { - QAbstractFileEngine::FileFlags flags = 0; + QAbstractFileEngine::FileFlags flags; const bool isDir = (m_assetUrl == QLatin1String("assets-library://")); const bool exists = isDir || m_assetUrl == g_iteratorCurrentUrl.localData() || loadAsset(); diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index e51c3d0502..cbc930387f 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -455,7 +455,7 @@ void QXcbConnection::printXcbError(const char *message, xcb_generic_error_t *err static Qt::MouseButtons translateMouseButtons(int s) { - Qt::MouseButtons ret = 0; + Qt::MouseButtons ret; if (s & XCB_BUTTON_MASK_1) ret |= Qt::LeftButton; if (s & XCB_BUTTON_MASK_2) diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index a894944096..62c5e5d79e 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -294,7 +294,7 @@ private: int deviceId = 0; QTabletEvent::PointerType pointerType = QTabletEvent::UnknownPointer; QTabletEvent::TabletDevice tool = QTabletEvent::Stylus; - Qt::MouseButtons buttons = 0; + Qt::MouseButtons buttons; qint64 serialId = 0; bool inProximity = false; struct ValuatorClassInfo { @@ -318,8 +318,8 @@ private: int horizontalIndex = 0; double verticalIncrement = 0; double horizontalIncrement = 0; - Qt::Orientations orientations = 0; - Qt::Orientations legacyOrientations = 0; + Qt::Orientations orientations; + Qt::Orientations legacyOrientations; QPointF lastScrollPosition; }; QHash m_scrollingDevices; @@ -360,7 +360,7 @@ private: WindowMapper m_mapper; - Qt::MouseButtons m_buttonState = nullptr; + Qt::MouseButtons m_buttonState; Qt::MouseButton m_button = Qt::NoButton; QXcbWindow *m_focusWindow = nullptr; diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 4639185416..fdf59c5ef4 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -424,7 +424,7 @@ QXcbConnection::TouchDeviceData *QXcbConnection::touchDeviceForId(int id) QXcbConnection::TouchDeviceData *QXcbConnection::populateTouchDevices(void *info) { auto *deviceinfo = reinterpret_cast(info); - QTouchDevice::Capabilities caps = 0; + QTouchDevice::Capabilities caps; int type = -1; int maxTouchPoints = 1; bool isTouchDevice = false; diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 3d525598ca..eb5b8f808e 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -883,7 +883,7 @@ void QXcbDrag::handleLeave(QPlatformWindow *w, const xcb_client_message_event_t event->data.data32[0], xdnd_dragsource); } - QWindowSystemInterface::handleDrag(w->window(), nullptr, QPoint(), Qt::IgnoreAction, 0, 0); + QWindowSystemInterface::handleDrag(w->window(), nullptr, QPoint(), Qt::IgnoreAction, { }, { }); } void QXcbDrag::send_leave() diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h index 1388e68acc..7bef7a818a 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.h +++ b/src/plugins/platforms/xcb/qxcbdrag.h @@ -86,7 +86,7 @@ public: void handlePosition(QPlatformWindow *w, const xcb_client_message_event_t *event); void handleLeave(QPlatformWindow *w, const xcb_client_message_event_t *event); void handleDrop(QPlatformWindow *, const xcb_client_message_event_t *event, - Qt::MouseButtons b = nullptr, Qt::KeyboardModifiers mods = nullptr); + Qt::MouseButtons b = { }, Qt::KeyboardModifiers mods = { }); void handleStatus(const xcb_client_message_event_t *event); void handleSelectionRequest(const xcb_selection_request_event_t *event); @@ -109,7 +109,7 @@ private: void init(); void handle_xdnd_position(QPlatformWindow *w, const xcb_client_message_event_t *event, - Qt::MouseButtons b = nullptr, Qt::KeyboardModifiers mods = nullptr); + Qt::MouseButtons b = { }, Qt::KeyboardModifiers mods = { }); void handle_xdnd_status(const xcb_client_message_event_t *event); void send_leave(); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 76d3545d35..840bcfd3bb 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -927,7 +927,7 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags) xcb_change_window_attributes(xcb_connection(), xcb_window(), mask, values); - QXcbWindowFunctions::WmWindowTypes wmWindowTypes = 0; + QXcbWindowFunctions::WmWindowTypes wmWindowTypes; if (window()->dynamicPropertyNames().contains(wm_window_type_property_id)) { wmWindowTypes = static_cast( window()->property(wm_window_type_property_id).value()); diff --git a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h index 5cfc4df0d0..d38b3ddda3 100644 --- a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h +++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportaltheme.h @@ -72,7 +72,7 @@ public: QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const override; QIcon fileIcon(const QFileInfo &fileInfo, - QPlatformTheme::IconOptions iconOptions = nullptr) const override; + QPlatformTheme::IconOptions iconOptions = { }) const override; QIconEngine *createIconEngine(const QString &iconName) const override; -- cgit v1.2.3 From 2c871dfd38d89d6415c2c25d47b4a0e9c8b2ef11 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 22 Nov 2019 15:34:38 +0100 Subject: Avoid initializing QFlags with 0 or nullptr in further cases Amends qtbase/af2daafde72db02454d24b7d691aa6861525ab99. Where applicable, port over to member initialization, thus also fixing nullptr warnings. Change-Id: Iaaf2dbbbcf2952253390b8839fd15a1b17be32c0 Reviewed-by: Allan Sandfeld Jensen --- src/plugins/platforms/windows/qwindowsglcontext.h | 2 +- src/plugins/platforms/windows/qwindowskeymapper.cpp | 4 ++-- src/plugins/platforms/windows/qwindowsmousehandler.cpp | 4 ++-- src/plugins/platforms/windows/qwindowspointerhandler.cpp | 2 +- src/plugins/platforms/windows/qwindowstheme.h | 2 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsglcontext.h b/src/plugins/platforms/windows/qwindowsglcontext.h index e5f6fefd5a..8794368fe4 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.h +++ b/src/plugins/platforms/windows/qwindowsglcontext.h @@ -89,7 +89,7 @@ struct QWindowsOpenGLContextFormat QSurfaceFormat::OpenGLContextProfile profile = QSurfaceFormat::NoProfile; int version = 0; //! majorVersion<<8 + minorVersion - QSurfaceFormat::FormatOptions options = nullptr; + QSurfaceFormat::FormatOptions options; }; #ifndef QT_NO_DEBUG_STREAM diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 0509403267..e3edf7e81e 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -1019,14 +1019,14 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, MSG msg, if (dirStatus == VK_LSHIFT && ((msg.wParam == VK_SHIFT && GetKeyState(VK_LCONTROL)) || (msg.wParam == VK_CONTROL && GetKeyState(VK_LSHIFT)))) { - sendExtendedPressRelease(receiver, Qt::Key_Direction_L, nullptr, + sendExtendedPressRelease(receiver, Qt::Key_Direction_L, {}, scancode, vk_key, nModifiers, QString(), false); result = true; dirStatus = 0; } else if (dirStatus == VK_RSHIFT && ( (msg.wParam == VK_SHIFT && GetKeyState(VK_RCONTROL)) || (msg.wParam == VK_CONTROL && GetKeyState(VK_RSHIFT)))) { - sendExtendedPressRelease(receiver, Qt::Key_Direction_R, nullptr, + sendExtendedPressRelease(receiver, Qt::Key_Direction_R, {}, scancode, vk_key, nModifiers, QString(), false); result = true; dirStatus = 0; diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 6df5e6aa27..b776efc942 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -165,7 +165,7 @@ void QWindowsMouseHandler::clearEvents() Qt::MouseButtons QWindowsMouseHandler::queryMouseButtons() { - Qt::MouseButtons result = nullptr; + Qt::MouseButtons result; const bool mouseSwapped = GetSystemMetrics(SM_SWAPBUTTON); if (GetAsyncKeyState(VK_LBUTTON) < 0) result |= mouseSwapped ? Qt::RightButton: Qt::LeftButton; @@ -630,7 +630,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, QTouchPointList touchPoints; touchPoints.reserve(winTouchPointCount); - Qt::TouchPointStates allStates = nullptr; + Qt::TouchPointStates allStates; GetTouchInputInfo(reinterpret_cast(msg.lParam), UINT(msg.wParam), winTouchInputs.data(), sizeof(TOUCHINPUT)); diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp index b477147da7..fba24d8696 100644 --- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp +++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp @@ -482,7 +482,7 @@ bool QWindowsPointerHandler::translateTouchEvent(QWindow *window, HWND hwnd, << " message=" << Qt::hex << msg.message << " count=" << Qt::dec << count; - Qt::TouchPointStates allStates = nullptr; + Qt::TouchPointStates allStates; for (quint32 i = 0; i < count; ++i) { if (QWindowsContext::verbose > 1) diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h index 07120230ce..7a8c321da4 100644 --- a/src/plugins/platforms/windows/qwindowstheme.h +++ b/src/plugins/platforms/windows/qwindowstheme.h @@ -71,7 +71,7 @@ public: QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const override; - QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions = nullptr) const override; + QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions = {}) const override; void windowsThemeChanged(QWindow *window); void displayChanged() { refreshIconPixmapSizes(); } diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 840bcfd3bb..f505ddbd1e 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -876,7 +876,7 @@ enum { QXcbWindow::NetWmStates QXcbWindow::netWmStates() { - NetWmStates result(0); + NetWmStates result; auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, xcb_connection(), 0, m_window, atom(QXcbAtom::_NET_WM_STATE), @@ -1063,7 +1063,7 @@ void QXcbWindow::setNetWmStateOnUnmappedWindow() if (Q_UNLIKELY(m_mapped)) qCWarning(lcQpaXcb()) << "internal error: " << Q_FUNC_INFO << "called on mapped window"; - NetWmStates states(0); + NetWmStates states; const Qt::WindowFlags flags = window()->flags(); if (flags & Qt::WindowStaysOnTopHint) { states |= NetWmStateAbove; @@ -1477,7 +1477,7 @@ uint QXcbWindow::visualIdStatic(QWindow *window) QXcbWindowFunctions::WmWindowTypes QXcbWindow::wmWindowTypes() const { - QXcbWindowFunctions::WmWindowTypes result(0); + QXcbWindowFunctions::WmWindowTypes result; auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, xcb_connection(), 0, m_window, atom(QXcbAtom::_NET_WM_WINDOW_TYPE), -- cgit v1.2.3 From 3c90ac02d1a6dc383c21d3911f0db881f9341802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sun, 24 Nov 2019 21:40:13 +0100 Subject: macOS: Replace use of deprecated NSDragPboard enum Change-Id: I90128abe310f971a89ecb6551e31950211adda77 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoadrag.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm index 09433194a6..95808b8a11 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.mm +++ b/src/plugins/platforms/cocoa/qcocoadrag.mm @@ -134,7 +134,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o) NSImage *nsimage = qt_mac_create_nsimage(pm); [nsimage setSize:NSSizeFromCGSize(pmDeviceIndependentSize.toCGSize())]; - QMacPasteboard dragBoard((CFStringRef) NSDragPboard, QMacInternalPasteboardMime::MIME_DND); + QMacPasteboard dragBoard(CFStringRef(NSPasteboardNameDrag), QMacInternalPasteboardMime::MIME_DND); m_drag->mimeData()->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray("dummy")); dragBoard.setMimeData(m_drag->mimeData(), QMacPasteboard::LazyRequest); @@ -145,7 +145,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o) CGFloat flippedY = pmDeviceIndependentSize.height() - hotSpot.y(); event_location.y -= flippedY; NSSize mouseOffset_unused = NSMakeSize(0.0, 0.0); - NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; + NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSPasteboardNameDrag]; [theWindow dragImage:nsimage at:event_location -- cgit v1.2.3 From 770a1d71560f7195fed0ada523884784bc89f791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sun, 24 Nov 2019 21:57:35 +0100 Subject: macOS: Replace use of deprecated acceptsTouchEvents API The equivalent of setting acceptsTouchEvents to YES is enabling indirect touches. Direct touches are enabled by default by AppKit, but can be explicitly disabled by clearing the NSTouchTypeMaskDirect bit. Change-Id: I5ba09d36f6ee2ce962e3ce21bab06537dd1fa5ad Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 15329ca708..6e2d446898 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1692,9 +1692,9 @@ void QCocoaWindow::registerTouch(bool enable) { m_registerTouchCount += enable ? 1 : -1; if (enable && m_registerTouchCount == 1) - [m_view setAcceptsTouchEvents:YES]; + m_view.allowedTouchTypes |= NSTouchTypeMaskIndirect; else if (m_registerTouchCount == 0) - [m_view setAcceptsTouchEvents:NO]; + m_view.allowedTouchTypes &= ~NSTouchTypeMaskIndirect; } void QCocoaWindow::setContentBorderThickness(int topThickness, int bottomThickness) -- cgit v1.2.3 From b8cf3c35002affe9f1876dd3940d75171be43f64 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Fri, 22 Nov 2019 19:44:48 +0100 Subject: Windows QPA: Disable the native Windows OSK if Qt Virtual Keyboard is in use This change detects that the Qt Virtual Keyboard is in use through the QT_IM_MODULE environment variable and disables the native Windows OSK accordingly, to avoid showing both virtual keyboards at the same time. Task-number: QTBUG-76088 Change-Id: I2715b337e6de729f0514ea1892b94b3c4f9cd984 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowsinputcontext.cpp | 7 +++++-- .../windows/uiautomation/qwindowsuiamainprovider.cpp | 12 +++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index 079c25f9eb..19d632dc10 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -283,8 +283,11 @@ void QWindowsInputContext::showInputPanel() // We only call ShowCaret() on Windows 10 after 1703 as in earlier versions // the caret would actually be visible (QTBUG-74492) and the workaround for // the Surface seems unnecessary there anyway. But leave it hidden for IME. - if (QOperatingSystemVersion::current() >= - QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 16299)) { + // Only trigger the native OSK if the Qt OSK is not in use. + static bool imModuleEmpty = qEnvironmentVariableIsEmpty("QT_IM_MODULE"); + if (imModuleEmpty + && QOperatingSystemVersion::current() + >= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 16299)) { ShowCaret(platformWindow->handle()); } else { HideCaret(platformWindow->handle()); diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index f589fd6b10..e5a9f275ae 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -390,7 +390,17 @@ HRESULT QWindowsUiaMainProvider::GetPropertyValue(PROPERTYID idProp, VARIANT *pR setVariantI4(UIA_WindowControlTypeId, pRetVal); } else { // Control type converted from role. - setVariantI4(roleToControlTypeId(accessible->role()), pRetVal); + auto controlType = roleToControlTypeId(accessible->role()); + + // The native OSK should be disbled if the Qt OSK is in use. + static bool imModuleEmpty = qEnvironmentVariableIsEmpty("QT_IM_MODULE"); + + // If we want to disable the native OSK auto-showing + // we have to report text fields as non-editable. + if (controlType == UIA_EditControlTypeId && !imModuleEmpty) + controlType = UIA_TextControlTypeId; + + setVariantI4(controlType, pRetVal); } break; case UIA_HelpTextPropertyId: -- cgit v1.2.3 From f3c37c839c5350c9d9c14074ea1cccd881281850 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 12 Nov 2019 17:13:58 +0100 Subject: Enable QRhi Metal backend on iOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While we are at it, remove the Border and MirrorOnce wrap modes that have not been supported on OpenGL, because they are unsupported with Metal+iOS as well. Task-number: QTBUG-78580 Change-Id: I0db94b9d3a6125b3bb5d7b1db5d02a42cd94d2c2 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qioswindow.mm | 11 ++++++++++- src/plugins/platforms/ios/quiview.h | 4 ++++ src/plugins/platforms/ios/quiview.mm | 35 ++++++++++++++++++++++++++------- 3 files changed, 42 insertions(+), 8 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index cdec57de71..1b6a802ca2 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -51,6 +51,9 @@ #include #import +#ifdef Q_OS_IOS +#import +#endif #include @@ -58,9 +61,15 @@ QT_BEGIN_NAMESPACE QIOSWindow::QIOSWindow(QWindow *window) : QPlatformWindow(window) - , m_view([[QUIView alloc] initWithQIOSWindow:this]) , m_windowLevel(0) { +#ifdef Q_OS_IOS + if (window->surfaceType() == QSurface::MetalSurface) + m_view = [[QUIMetalView alloc] initWithQIOSWindow:this]; + else +#endif + m_view = [[QUIView alloc] initWithQIOSWindow:this]; + connect(qGuiApp, &QGuiApplication::applicationStateChanged, this, &QIOSWindow::applicationStateChanged); setParent(QPlatformWindow::parent()); diff --git a/src/plugins/platforms/ios/quiview.h b/src/plugins/platforms/ios/quiview.h index e1d5d5af0c..1ab9481dd6 100644 --- a/src/plugins/platforms/ios/quiview.h +++ b/src/plugins/platforms/ios/quiview.h @@ -70,3 +70,7 @@ QT_END_NAMESPACE @property (nonatomic, readonly) UIEdgeInsets qt_safeAreaInsets; @end +#ifdef Q_OS_IOS +@interface QUIMetalView : QUIView +@end +#endif diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 91a186bace..59eae07388 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -100,13 +100,15 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") - (instancetype)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { - // Set up EAGL layer - CAEAGLLayer *eaglLayer = static_cast(self.layer); - eaglLayer.opaque = TRUE; - eaglLayer.drawableProperties = @{ - kEAGLDrawablePropertyRetainedBacking: @(YES), - kEAGLDrawablePropertyColorFormat: kEAGLColorFormatRGBA8 - }; + if ([self.layer isKindOfClass:[CAEAGLLayer class]]) { + // Set up EAGL layer + CAEAGLLayer *eaglLayer = static_cast(self.layer); + eaglLayer.opaque = TRUE; + eaglLayer.drawableProperties = @{ + kEAGLDrawablePropertyRetainedBacking: @(YES), + kEAGLDrawablePropertyColorFormat: kEAGLColorFormatRGBA8 + }; + } if (isQtApplication()) self.hidden = YES; @@ -675,6 +677,25 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet") @end +#ifdef Q_OS_IOS +@implementation QUIMetalView + ++ (Class)layerClass +{ +#ifdef TARGET_IPHONE_SIMULATOR + if (@available(ios 13.0, *)) +#endif + + return [CAMetalLayer class]; + +#ifdef TARGET_IPHONE_SIMULATOR + return nil; +#endif +} + +@end +#endif + #ifndef QT_NO_ACCESSIBILITY // Include category as an alternative to using -ObjC (Apple QA1490) #include "quiview_accessibility.mm" -- cgit v1.2.3 From 512c1febbd9d5b8af767b2604d6ee97f1fdee4d9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 28 Nov 2019 12:25:40 +0100 Subject: QtWidgets/Windows: Simplify .pro files Remove the include path for wintab which is no longer needed in Qt 5 (the code is in the QPA plugin). Remove the inclusion of win.pri for the Windows vista styles plugin and specify the theme library directly. This should result in simpler CMakeList.txt files. Change-Id: I736db5c965982cdf79a234a94fc723f0556c1717 Reviewed-by: Alexandru Croitor --- src/plugins/styles/windowsvista/windowsvista.pro | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/styles/windowsvista/windowsvista.pro b/src/plugins/styles/windowsvista/windowsvista.pro index c08db7f533..483914c13d 100644 --- a/src/plugins/styles/windowsvista/windowsvista.pro +++ b/src/plugins/styles/windowsvista/windowsvista.pro @@ -11,9 +11,7 @@ HEADERS += qwindowsxpstyle_p.h qwindowsxpstyle_p_p.h SOURCES += qwindowsxpstyle.cpp QMAKE_USE_PRIVATE += user32 gdi32 - -# DEFINES/LIBS needed for qwizard_win.cpp and the styles -include(../../../widgets/kernel/win.pri) +LIBS_PRIVATE *= -luxtheme DISTFILES += windowsvistastyle.json -- cgit v1.2.3 From cc5c47d85f106356e290a95f2cca2c38b1b3c42d Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Thu, 21 Nov 2019 16:37:06 +0100 Subject: macOS Accessibility: Fix role for comboboxes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise combobox with editable text field won't work. Change-Id: I135c3a63cf8fba66d724e140a5a63828853e154e Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaaccessibility.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm index db4ec251ae..106c226adc 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm @@ -133,7 +133,7 @@ static void populateRoleMap() roleMap[QAccessible::SpinBox] = NSAccessibilityIncrementorRole; roleMap[QAccessible::Slider] = NSAccessibilitySliderRole; roleMap[QAccessible::ProgressBar] = NSAccessibilityProgressIndicatorRole; - roleMap[QAccessible::ComboBox] = NSAccessibilityPopUpButtonRole; + roleMap[QAccessible::ComboBox] = NSAccessibilityComboBoxRole; roleMap[QAccessible::RadioButton] = NSAccessibilityRadioButtonRole; roleMap[QAccessible::CheckBox] = NSAccessibilityCheckBoxRole; roleMap[QAccessible::StaticText] = NSAccessibilityStaticTextRole; -- cgit v1.2.3 From 6ec5a97ebbf65a9283a57b8e5f4192e7ec84a759 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 28 Nov 2019 17:46:34 +0100 Subject: macOS: Harden screen handling logic when reconfiguring displays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When connecting/disconnecting/reconfiguring screens Qt needs to know about the changes before they are propagated by the OS in other ways, so that we can reflect the changes in the list of QScreens as soon as they happen. Unfortunately the canonical notifications for this in AppKit, NSApplicationDidChangeScreenParametersNotification, is delivered after AppKit itself reacts to the change, which results in receiving NSWindowDidChangeScreenNotification, NSWindowWillMoveNotification, and others, while the list of QScreens is stale. To work around this we adopted the lower layer Quartz Display Services API in 3976df2805 to notify us when there are changes to the screen configuration. Unfortunately the window server on macOS is not consistent in how it orders events during screen reconfiguration, and we can't rely on the NSScreen list being up to date when we get our callbacks from Quartz. To work around this we still hook into Quartz, so that we get the callbacks as early as possible, but then track the state of the AppKit NSScreen list and update our own QScreens as soon as we see a change. We now also include sleeping displays in the list of QScreens, which matches the behavior of NSScreen.screens. Similarly we exclude displays that are mirroring another display. Task-number: QTBUG-80193 Change-Id: I6b1958d6ee61373b2861e05a0d971d2300596f3e Reviewed-by: Timur Pocheptsov Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoascreen.h | 21 ++- src/plugins/platforms/cocoa/qcocoascreen.mm | 272 +++++++++++++++++++++------- 2 files changed, 225 insertions(+), 68 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoascreen.h b/src/plugins/platforms/cocoa/qcocoascreen.h index 7ec9a2b5af..dcf6f1c753 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.h +++ b/src/plugins/platforms/cocoa/qcocoascreen.h @@ -53,9 +53,6 @@ class QCocoaIntegration; class QCocoaScreen : public QPlatformScreen { public: - static void initializeScreens(); - static void cleanupScreens(); - ~QCocoaScreen(); // ---------------------------------------------------- @@ -79,7 +76,6 @@ public: // ---------------------------------------------------- NSScreen *nativeScreen() const; - void updateProperties(); void requestUpdate(); void deliverUpdateRequests(); @@ -88,6 +84,7 @@ public: static QCocoaScreen *primaryScreen(); static QCocoaScreen *get(NSScreen *nsScreen); static QCocoaScreen *get(CGDirectDisplayID displayId); + static QCocoaScreen *get(CFUUIDRef uuid); static CGPoint mapToNative(const QPointF &pos, QCocoaScreen *screen = QCocoaScreen::primaryScreen()); static CGRect mapToNative(const QRectF &rect, QCocoaScreen *screen = QCocoaScreen::primaryScreen()); @@ -95,11 +92,23 @@ public: static QRectF mapFromNative(CGRect rect, QCocoaScreen *screen = QCocoaScreen::primaryScreen()); private: - QCocoaScreen(CGDirectDisplayID displayId); + static void initializeScreens(); + static void updateScreens(); + static void cleanupScreens(); + + static bool updateScreensIfNeeded(); + static NSArray *s_screenConfigurationBeforeUpdate; + static void add(CGDirectDisplayID displayId); + QCocoaScreen(CGDirectDisplayID displayId); + void update(CGDirectDisplayID displayId); void remove(); + bool isOnline() const; + bool isMirroring() const; + CGDirectDisplayID m_displayId = kCGNullDirectDisplay; + CGDirectDisplayID displayId() const { return m_displayId; } QRect m_geometry; QRect m_availableGeometry; @@ -116,6 +125,8 @@ private: dispatch_source_t m_displayLinkSource = nullptr; QAtomicInt m_pendingUpdates; + friend class QCocoaIntegration; + friend class QCocoaWindow; friend QDebug operator<<(QDebug debug, const QCocoaScreen *screen); }; diff --git a/src/plugins/platforms/cocoa/qcocoascreen.mm b/src/plugins/platforms/cocoa/qcocoascreen.mm index bd5c95b9d0..e4dd4cf6c6 100644 --- a/src/plugins/platforms/cocoa/qcocoascreen.mm +++ b/src/plugins/platforms/cocoa/qcocoascreen.mm @@ -57,6 +57,7 @@ QT_BEGIN_NAMESPACE namespace CoreGraphics { Q_NAMESPACE enum DisplayChange { + ReconfiguredWithFlagsMissing = 0, Moved = kCGDisplayMovedFlag, SetMain = kCGDisplaySetMainFlag, SetMode = kCGDisplaySetModeFlag, @@ -71,73 +72,165 @@ namespace CoreGraphics { Q_ENUM_NS(DisplayChange) } +NSArray *QCocoaScreen::s_screenConfigurationBeforeUpdate = nil; + void QCocoaScreen::initializeScreens() { - uint32_t displayCount = 0; - if (CGGetActiveDisplayList(0, nullptr, &displayCount) != kCGErrorSuccess) - qFatal("Failed to get number of active displays"); - - CGDirectDisplayID activeDisplays[displayCount]; - if (CGGetActiveDisplayList(displayCount, &activeDisplays[0], &displayCount) != kCGErrorSuccess) - qFatal("Failed to get active displays"); - - for (CGDirectDisplayID displayId : activeDisplays) - QCocoaScreen::add(displayId); + updateScreens(); CGDisplayRegisterReconfigurationCallback([](CGDirectDisplayID displayId, CGDisplayChangeSummaryFlags flags, void *userInfo) { - if (flags & kCGDisplayBeginConfigurationFlag) - return; // Wait for changes to apply - Q_UNUSED(userInfo); - qCDebug(lcQpaScreen).verbosity(0).nospace() << "Display reconfiguration" - << " (" << QFlags(flags) << ")" - << " for displayId=" << displayId; - - QCocoaScreen *cocoaScreen = QCocoaScreen::get(displayId); + // Displays are reconfigured in batches, and we want to update our screens + // once a batch ends, so that all the states of the displays are up to date. + static int displayReconfigurationsInProgress = 0; + + const bool beforeReconfigure = flags & kCGDisplayBeginConfigurationFlag; + qCDebug(lcQpaScreen).verbosity(0).nospace() << "Display " << displayId + << (beforeReconfigure ? " about to reconfigure" : " was ") + << QFlags(flags) + << " with " << displayReconfigurationsInProgress + << " display configuration(s) in progress"; + + if (!flags) { + // CGDisplayRegisterReconfigurationCallback has been observed to be called + // with flags unset. This seems like a bug. The callback is not paired with + // a matching "completion" callback either, so we don't know whether to treat + // it as a begin or end of reconfigure. + return; + } - if ((flags & kCGDisplayAddFlag) || !cocoaScreen) { - if (!CGDisplayIsActive(displayId)) { - qCDebug(lcQpaScreen) << "Not adding inactive display" << displayId; - return; // Will be added when activated + if (beforeReconfigure) { + if (!displayReconfigurationsInProgress++) { + // There might have been a screen reconfigure before this that + // we didn't process yet, so do that now if that's the case. + updateScreensIfNeeded(); + + Q_ASSERT(!s_screenConfigurationBeforeUpdate); + s_screenConfigurationBeforeUpdate = NSScreen.screens; + qCDebug(lcQpaScreen, "Display reconfigure transaction started" + " with screen configuration %p", s_screenConfigurationBeforeUpdate); + + static void (^tryScreenUpdate)(); + tryScreenUpdate = ^void () { + qCDebug(lcQpaScreen) << "Attempting screen update from runloop block"; + if (!updateScreensIfNeeded()) + CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopCommonModes, tryScreenUpdate); + }; + CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopCommonModes, tryScreenUpdate); } - QCocoaScreen::add(displayId); - } else if ((flags & kCGDisplayRemoveFlag) || !CGDisplayIsActive(displayId)) { - cocoaScreen->remove(); } else { - // Detect changes to the primary screen immediately, instead of - // waiting for a display reconfigure with kCGDisplaySetMainFlag. - // This ensures that any property updates to the other screens - // will be in reference to the correct primary screen. - QCocoaScreen *mainDisplay = QCocoaScreen::get(CGMainDisplayID()); - if (QGuiApplication::primaryScreen()->handle() != mainDisplay) { - mainDisplay->updateProperties(); - qCInfo(lcQpaScreen) << "Primary screen changed to" << mainDisplay; - QWindowSystemInterface::handlePrimaryScreenChanged(mainDisplay); - if (cocoaScreen == mainDisplay) - return; // Already reconfigured - } + Q_ASSERT_X(displayReconfigurationsInProgress, "QCococaScreen", + "Display configuration transactions are expected to be balanced"); - cocoaScreen->updateProperties(); - qCInfo(lcQpaScreen).nospace() << "Reconfigured " << - (primaryScreen() == cocoaScreen ? "primary " : "") - << cocoaScreen; + if (!--displayReconfigurationsInProgress) { + qCDebug(lcQpaScreen) << "Display reconfigure transaction completed"; + // We optimistically update now, in case the NSScreens have changed + updateScreensIfNeeded(); + } } }, nullptr); + + static QMacNotificationObserver screenParameterObserver(NSApplication.sharedApplication, + NSApplicationDidChangeScreenParametersNotification, [&]() { + qCDebug(lcQpaScreen) << "Received screen parameter change notification"; + updateScreensIfNeeded(); // As a last resort we update screens here + }); +} + +bool QCocoaScreen::updateScreensIfNeeded() +{ + if (!s_screenConfigurationBeforeUpdate) { + qCDebug(lcQpaScreen) << "QScreens have already been updated, all good"; + return true; + } + + if (s_screenConfigurationBeforeUpdate == NSScreen.screens) { + qCDebug(lcQpaScreen) << "Still waiting for NSScreen configuration change"; + return false; + } + + qCDebug(lcQpaScreen, "NSScreen configuration changed to %p", NSScreen.screens); + updateScreens(); + + s_screenConfigurationBeforeUpdate = nil; + return true; +} + +/* + Update the list of available QScreens, and the properties of existing screens. + + At this point we rely on the NSScreen.screens to be up to date. +*/ +void QCocoaScreen::updateScreens() +{ + uint32_t displayCount = 0; + if (CGGetOnlineDisplayList(0, nullptr, &displayCount) != kCGErrorSuccess) + qFatal("Failed to get number of online displays"); + + QVector onlineDisplays(displayCount); + if (CGGetOnlineDisplayList(displayCount, onlineDisplays.data(), &displayCount) != kCGErrorSuccess) + qFatal("Failed to get online displays"); + + qCInfo(lcQpaScreen) << "Updating screens with" << displayCount + << "online displays:" << onlineDisplays; + + // TODO: Verify whether we can always assume the main display is first + int mainDisplayIndex = onlineDisplays.indexOf(CGMainDisplayID()); + if (mainDisplayIndex < 0) { + qCWarning(lcQpaScreen) << "Main display not in list of online displays!"; + } else if (mainDisplayIndex > 0) { + qCWarning(lcQpaScreen) << "Main display not first display, making sure it is"; + onlineDisplays.move(mainDisplayIndex, 0); + } + + for (CGDirectDisplayID displayId : onlineDisplays) { + Q_ASSERT(CGDisplayIsOnline(displayId)); + + if (CGDisplayMirrorsDisplay(displayId)) + continue; + + // A single physical screen can map to multiple displays IDs, + // depending on which GPU is in use or which physical port the + // screen is connected to. By mapping the display ID to a UUID, + // which are shared between displays that target the same screen, + // we can pick an existing QScreen to update instead of needlessly + // adding and removing QScreens. + QCFType uuid = CGDisplayCreateUUIDFromDisplayID(displayId); + Q_ASSERT(uuid); + + if (QCocoaScreen *existingScreen = QCocoaScreen::get(uuid)) { + existingScreen->update(displayId); + qCInfo(lcQpaScreen) << "Updated" << existingScreen; + if (CGDisplayIsMain(displayId) && existingScreen != qGuiApp->primaryScreen()->handle()) { + qCInfo(lcQpaScreen) << "Primary screen changed to" << existingScreen; + QWindowSystemInterface::handlePrimaryScreenChanged(existingScreen); + } + } else { + QCocoaScreen::add(displayId); + } + } + + for (QScreen *screen : QGuiApplication::screens()) { + QCocoaScreen *platformScreen = static_cast(screen->handle()); + if (!platformScreen->isOnline() || platformScreen->isMirroring()) + platformScreen->remove(); + } } void QCocoaScreen::add(CGDirectDisplayID displayId) { const bool isPrimary = CGDisplayIsMain(displayId); QCocoaScreen *cocoaScreen = new QCocoaScreen(displayId); - qCInfo(lcQpaScreen).nospace() << "Adding " << (isPrimary ? "new primary " : "") << cocoaScreen; + qCInfo(lcQpaScreen) << "Adding" << cocoaScreen + << (isPrimary ? "as new primary screen" : ""); QWindowSystemInterface::handleScreenAdded(cocoaScreen, isPrimary); } QCocoaScreen::QCocoaScreen(CGDirectDisplayID displayId) : QPlatformScreen(), m_displayId(displayId) { - updateProperties(); + update(m_displayId); m_cursor = new QCocoaCursor; } @@ -150,8 +243,6 @@ void QCocoaScreen::cleanupScreens() void QCocoaScreen::remove() { - 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. // If the window isn't moved by the application, Qt will as a fallback move it to @@ -163,7 +254,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; + qCInfo(lcQpaScreen) << "Removing " << this; QWindowSystemInterface::handleScreenRemoved(this); } @@ -210,9 +301,14 @@ static QString displayName(CGDirectDisplayID displayID) return QString(); } -void QCocoaScreen::updateProperties() +void QCocoaScreen::update(CGDirectDisplayID displayId) { - Q_ASSERT(m_displayId); + if (displayId != m_displayId) { + qCDebug(lcQpaScreen) << "Reconnecting" << this << "as display" << displayId; + m_displayId = displayId; + } + + Q_ASSERT(isOnline()); const QRect previousGeometry = m_geometry; const QRect previousAvailableGeometry = m_availableGeometry; @@ -350,8 +446,8 @@ struct DeferredDebugHelper void QCocoaScreen::deliverUpdateRequests() { - if (!m_displayId) - return; // Screen removed + if (!isOnline()) + return; QMacAutoReleasePool pool; @@ -562,6 +658,29 @@ QPixmap QCocoaScreen::grabWindow(WId view, int x, int y, int width, int height) return windowPixmap; } +bool QCocoaScreen::isOnline() const +{ + // When a display is disconnected CGDisplayIsOnline and other CGDisplay + // functions that take a displayId will not return false, but will start + // returning -1 to signal that the displayId is invalid. Some functions + // will also assert or even crash in this case, so it's important that + // we double check if a display is online before calling other functions. + auto isOnline = CGDisplayIsOnline(m_displayId); + static const uint32_t kCGDisplayIsDisconnected = int32_t(-1); + return isOnline != kCGDisplayIsDisconnected && isOnline; +} + +/* + Returns true if a screen is mirroring another screen +*/ +bool QCocoaScreen::isMirroring() const +{ + if (!isOnline()) + return false; + + return CGDisplayMirrorsDisplay(m_displayId); +} + /*! The screen used as a reference for global window geometry */ @@ -586,6 +705,12 @@ QList QCocoaScreen::virtualSiblings() const QCocoaScreen *QCocoaScreen::get(NSScreen *nsScreen) { + if (s_screenConfigurationBeforeUpdate) { + qCWarning(lcQpaScreen) << "Trying to resolve screen while waiting for screen reconfigure!"; + if (!updateScreensIfNeeded()) + qCWarning(lcQpaScreen) << "Failed to do last minute screen update. Expect crashes."; + } + return get(nsScreen.qt_displayId); } @@ -600,23 +725,34 @@ QCocoaScreen *QCocoaScreen::get(CGDirectDisplayID displayId) return nullptr; } +QCocoaScreen *QCocoaScreen::get(CFUUIDRef uuid) +{ + for (QScreen *screen : QGuiApplication::screens()) { + auto *platformScreen = static_cast(screen->handle()); + if (!platformScreen->isOnline()) + continue; + + auto displayId = platformScreen->displayId(); + QCFType candidateUuid(CGDisplayCreateUUIDFromDisplayID(displayId)); + Q_ASSERT(candidateUuid); + + if (candidateUuid == uuid) + return platformScreen; + } + + return nullptr; +} + NSScreen *QCocoaScreen::nativeScreen() const { if (!m_displayId) return nil; // The display has been disconnected - // A single display may have different displayIds depending on - // which GPU is in use or which physical port the display is - // connected to. By comparing UUIDs instead of display IDs we - // ensure that we always pick up the appropriate NSScreen. - QCFType uuid = CGDisplayCreateUUIDFromDisplayID(m_displayId); - - for (NSScreen *screen in [NSScreen screens]) { - if (QCFType(CGDisplayCreateUUIDFromDisplayID(screen.qt_displayId)) == uuid) + for (NSScreen *screen in NSScreen.screens) { + if (screen.qt_displayId == m_displayId) return screen; } - qCWarning(lcQpaScreen) << "Could not find NSScreen for display ID" << m_displayId; return nil; } @@ -651,11 +787,21 @@ QDebug operator<<(QDebug debug, const QCocoaScreen *screen) debug.nospace(); debug << "QCocoaScreen(" << (const void *)screen; if (screen) { - debug << ", geometry=" << screen->geometry(); + debug << ", " << screen->name(); + if (screen->isOnline()) { + if (CGDisplayIsAsleep(screen->displayId())) + debug << ", Sleeping"; + if (auto mirroring = CGDisplayMirrorsDisplay(screen->displayId())) + debug << ", mirroring=" << mirroring; + } else { + debug << ", Offline"; + } + debug << ", " << screen->geometry(); debug << ", dpr=" << screen->devicePixelRatio(); - debug << ", name=" << screen->name(); - debug << ", displayId=" << screen->m_displayId; - debug << ", native=" << screen->nativeScreen(); + debug << ", displayId=" << screen->displayId(); + + if (auto nativeScreen = screen->nativeScreen()) + debug << ", " << nativeScreen; } debug << ')'; return debug; -- cgit v1.2.3 From 57f44068394d015b8f6d6428c91385b2a4f81897 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Fri, 29 Nov 2019 12:27:54 +0100 Subject: Remove QFlags(0), QFlags() does the same and is not deprecated Change-Id: I254d37d37f5583e0f7a76fb42b83d234afa29b77 Reviewed-by: Allan Sandfeld Jensen --- src/plugins/platforms/eglfs/api/qeglfscontext.cpp | 2 +- src/plugins/platforms/eglfs/api/qeglfswindow.cpp | 3 +-- src/plugins/platforms/vnc/qvncclient.cpp | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/eglfs/api/qeglfscontext.cpp b/src/plugins/platforms/eglfs/api/qeglfscontext.cpp index c5cef34d8e..c10b6facbb 100644 --- a/src/plugins/platforms/eglfs/api/qeglfscontext.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfscontext.cpp @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, EGLConfig *config, const QVariant &nativeHandle) : QEGLPlatformContext(format, share, display, config, nativeHandle, - qt_egl_device_integration()->supportsSurfacelessContexts() ? Flags(0) : QEGLPlatformContext::NoSurfaceless), + qt_egl_device_integration()->supportsSurfacelessContexts() ? Flags() : QEGLPlatformContext::NoSurfaceless), m_tempWindow(0) { } diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp index e6b25c02fd..3457be116a 100644 --- a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp @@ -66,8 +66,7 @@ QEglFSWindow::QEglFSWindow(QWindow *w) #endif m_winId(0), m_surface(EGL_NO_SURFACE), - m_window(0), - m_flags(0) + m_window(0) { } diff --git a/src/plugins/platforms/vnc/qvncclient.cpp b/src/plugins/platforms/vnc/qvncclient.cpp index 3a373a5e4b..2450f7dad5 100644 --- a/src/plugins/platforms/vnc/qvncclient.cpp +++ b/src/plugins/platforms/vnc/qvncclient.cpp @@ -65,7 +65,6 @@ QVncClient::QVncClient(QTcpSocket *clientSocket, QVncServer *server) , m_cutTextPending(0) , m_supportHextile(false) , m_wantUpdate(false) - , m_keymod(0) , m_dirtyCursor(false) , m_updatePending(false) , m_protocolVersion(V3_3) -- cgit v1.2.3 From d027860201c55b686b9f8330c559f84799442d68 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 28 Nov 2019 18:36:48 +0200 Subject: Fix assets iterator - start from index -1 each time when we iterate. Each time when we add a FolderIterator to the stack we MUST reset the index (-1) otherwise it will continue from it's last position. To fix it we are cloning the FolderIterator to set the index to -1. The index must be -1 in order to set it to 0 when we first call next() method. - introduce "fileType" static method for a more reliable also much faster file type lookup. The old version of checking if a file exists, is a folder or a file was buggy that's why it skipped some file randomly. Fixes: QTBUG-80178 Change-Id: I4b28e4616399b1bff35d792b55ded1bf19b62dd9 Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../android/qandroidassetsfileenginehandler.cpp | 70 +++++++++++++++++----- 1 file changed, 56 insertions(+), 14 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp index 26e72a480f..3d16f96450 100644 --- a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp +++ b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp @@ -72,9 +72,10 @@ static inline QString prefixedPath(QString path) struct AssetItem { enum class Type { File, - Folder + Folder, + Invalid }; - + AssetItem() = default; AssetItem (const QString &rawName) : name(rawName) { @@ -92,21 +93,47 @@ using AssetItemList = QVector; class FolderIterator : public AssetItemList { public: - static QSharedPointer fromCache(const QString &path) + static QSharedPointer fromCache(const QString &path, bool clone) { QMutexLocker lock(&m_assetsCacheMutex); QSharedPointer *folder = m_assetsCache.object(path); if (!folder) { folder = new QSharedPointer{new FolderIterator{path}}; - if (!m_assetsCache.insert(path, folder)) { + if ((*folder)->empty() || !m_assetsCache.insert(path, folder)) { QSharedPointer res = *folder; delete folder; return res; } } - return *folder; + return clone ? QSharedPointer{new FolderIterator{*(*folder)}} : *folder; + } + + static AssetItem::Type fileType(const QString &filePath) + { + const QStringList paths = filePath.split(QLatin1Char('/')); + QString fullPath; + AssetItem::Type res = AssetItem::Type::Invalid; + for (const auto &path: paths) { + auto folder = fromCache(fullPath, false); + auto it = std::lower_bound(folder->begin(), folder->end(), AssetItem{path}, [](const AssetItem &val, const AssetItem &assetItem) { + return val.name < assetItem.name; + }); + if (it == folder->end() || it->name != path) + return AssetItem::Type::Invalid; + if (!fullPath.isEmpty()) + fullPath.append(QLatin1Char('/')); + fullPath += path; + res = it->type; + } + return res; } + FolderIterator(const FolderIterator &other) + : AssetItemList(other) + , m_index(-1) + , m_path(other.m_path) + {} + FolderIterator(const QString &path) : m_path(path) { @@ -118,8 +145,12 @@ public: QJNIEnvironmentPrivate env; jobjectArray jFiles = static_cast(files.object()); const jint nFiles = env->GetArrayLength(jFiles); - for (int i = 0; i < nFiles; ++i) - push_back({QJNIObjectPrivate(env->GetObjectArrayElement(jFiles, i)).toString()}); + for (int i = 0; i < nFiles; ++i) { + AssetItem item{QJNIObjectPrivate(env->GetObjectArrayElement(jFiles, i)).toString()}; + insert(std::upper_bound(begin(), end(), item, [](const auto &a, const auto &b){ + return a.name < b.name; + }), item); + } } m_path = assetsPrefix + QLatin1Char('/') + m_path + QLatin1Char('/'); m_path.replace(QLatin1String("//"), QLatin1String("/")); @@ -169,7 +200,7 @@ public: const QString &path) : QAbstractFileEngineIterator(filters, nameFilters) { - m_stack.push_back(FolderIterator::fromCache(cleanedAssetPath(path))); + m_stack.push_back(FolderIterator::fromCache(cleanedAssetPath(path), true)); if (m_stack.last()->empty()) m_stack.pop_back(); } @@ -215,7 +246,7 @@ public: if (!res) return {}; if (res->second.type == AssetItem::Type::Folder) { - m_stack.push_back(FolderIterator::fromCache(cleanedAssetPath(currentFilePath()))); + m_stack.push_back(FolderIterator::fromCache(cleanedAssetPath(currentFilePath()), true)); if (m_stack.last()->empty()) m_stack.pop_back(); } @@ -305,12 +336,12 @@ public: FileFlags fileFlags(FileFlags type = FileInfoAll) const override { - FileFlags flags(ReadOwnerPerm|ReadUserPerm|ReadGroupPerm|ReadOtherPerm|ExistsFlag); + FileFlags commonFlags(ReadOwnerPerm|ReadUserPerm|ReadGroupPerm|ReadOtherPerm|ExistsFlag); + FileFlags flags; if (m_assetFile) - flags |= FileType; + flags = FileType | commonFlags; else if (m_isFolder) - flags |= DirectoryType; - + flags = DirectoryType | commonFlags; return type & flags; } @@ -341,9 +372,20 @@ public: void setFileName(const QString &file) override { + if (m_fileName == cleanedAssetPath(file)) + return; close(); m_fileName = cleanedAssetPath(file); - m_isFolder = !open(QIODevice::ReadOnly) && !FolderIterator::fromCache(m_fileName)->empty(); + switch (FolderIterator::fileType(m_fileName)) { + case AssetItem::Type::File: + open(QIODevice::ReadOnly); + break; + case AssetItem::Type::Folder: + m_isFolder = true; + break; + case AssetItem::Type::Invalid: + break; + } } Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) override -- cgit v1.2.3 From f81f21151d30a37f955aa4af2398a96507626b15 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Mon, 2 Mar 2015 21:13:35 +0100 Subject: Session management for macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch aims to implement the session management available on macOS. Currently applicationShouldTerminate is just a go through that closes everything and ends the application. The new implementation calls first appCommitData and cancels the termination properly if required. This means that if a user wishes to logout, Qt applications can now cancel that like e.g. answering to Safari asking whether it is ok to close because of a number of opened tab/window. Fixes: QTBUG-33034 Change-Id: Id5d7416cb74c762c5424a77c9c7664f0749da7f6 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/cocoa.pro | 5 ++ .../platforms/cocoa/qcocoaapplicationdelegate.mm | 16 +++- src/plugins/platforms/cocoa/qcocoaintegration.h | 4 + src/plugins/platforms/cocoa/qcocoaintegration.mm | 10 +++ .../platforms/cocoa/qcocoasessionmanager.cpp | 88 ++++++++++++++++++++++ src/plugins/platforms/cocoa/qcocoasessionmanager.h | 81 ++++++++++++++++++++ 6 files changed, 203 insertions(+), 1 deletion(-) create mode 100644 src/plugins/platforms/cocoa/qcocoasessionmanager.cpp create mode 100644 src/plugins/platforms/cocoa/qcocoasessionmanager.h (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 4cf9e64447..8f2956e7d4 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -87,6 +87,11 @@ qtConfig(accessibility) { qcocoaaccessibility.h } +qtConfig(sessionmanager) { + SOURCES += qcocoasessionmanager.cpp + HEADERS += qcocoasessionmanager.h +} + RESOURCES += qcocoaresources.qrc LIBS += -framework AppKit -framework CoreServices -framework Carbon -framework IOKit -framework QuartzCore -framework CoreVideo -framework Metal -framework IOSurface -lcups diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index f1fe2aa98b..3fb9e83d35 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -79,11 +79,14 @@ #include "qcocoamenuitem.h" #include "qcocoansmenu.h" +#if QT_CONFIG(sessionmanager) +# include "qcocoasessionmanager.h" +#endif + #include #include #include #include -#include #include "qt_mac_p.h" #include #include @@ -157,6 +160,17 @@ QT_USE_NAMESPACE return NSTerminateNow; } +#if QT_CONFIG(sessionmanager) + QCocoaSessionManager *cocoaSessionManager = QCocoaSessionManager::instance(); + cocoaSessionManager->resetCancellation(); + cocoaSessionManager->appCommitData(); + + if (cocoaSessionManager->wasCanceled()) { + qCDebug(lcQpaApplication) << "Session management canceled application termination"; + return NSTerminateCancel; + } +#endif + if (!QWindowSystemInterface::handleApplicationTermination()) { qCDebug(lcQpaApplication) << "Application termination canceled"; return NSTerminateCancel; diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index bfc3bfe9de..0c14e07551 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -92,6 +92,10 @@ public: QCocoaVulkanInstance *getCocoaVulkanInstance() const; #endif +#if QT_CONFIG(sessionmanager) + QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const override; +#endif + QCoreTextFontDatabase *fontDatabase() const override; QCocoaNativeInterface *nativeInterface() const override; QPlatformInputContext *inputContext() const override; diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 9a2f19c2f2..75d428c16f 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -52,6 +52,9 @@ #include "qcocoamimetypes.h" #include "qcocoaaccessibility.h" #include "qcocoascreen.h" +#if QT_CONFIG(sessionmanager) +# include "qcocoasessionmanager.h" +#endif #include #include @@ -255,6 +258,13 @@ QCocoaIntegration::Options QCocoaIntegration::options() const return mOptions; } +#if QT_CONFIG(sessionmanager) +QPlatformSessionManager *QCocoaIntegration::createPlatformSessionManager(const QString &id, const QString &key) const +{ + return new QCocoaSessionManager(id, key); +} +#endif + bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) const { switch (cap) { diff --git a/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp b/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp new file mode 100644 index 0000000000..74e318b5be --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoasessionmanager.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Samuel Gaist +** 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 QT_NO_SESSIONMANAGER +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +QCocoaSessionManager::QCocoaSessionManager(const QString &id, const QString &key) + : QPlatformSessionManager(id, key), + m_canceled(false) +{ +} + +QCocoaSessionManager::~QCocoaSessionManager() +{ +} + +bool QCocoaSessionManager::allowsInteraction() +{ + return false; +} + +void QCocoaSessionManager::resetCancellation() +{ + m_canceled = false; +} + +void QCocoaSessionManager::cancel() +{ + m_canceled = true; +} + +bool QCocoaSessionManager::wasCanceled() const +{ + return m_canceled; +} + +QCocoaSessionManager *QCocoaSessionManager::instance() +{ + auto *qGuiAppPriv = QGuiApplicationPrivate::instance(); + auto *managerPrivate = static_cast(QObjectPrivate::get(qGuiAppPriv->session_manager)); + return static_cast(managerPrivate->platformSessionManager); +} + +QT_END_NAMESPACE + +#endif // QT_NO_SESSIONMANAGER diff --git a/src/plugins/platforms/cocoa/qcocoasessionmanager.h b/src/plugins/platforms/cocoa/qcocoasessionmanager.h new file mode 100644 index 0000000000..89ab7bd157 --- /dev/null +++ b/src/plugins/platforms/cocoa/qcocoasessionmanager.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Samuel Gaist +** 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 QCOCOASESSIONMANAGER_H +#define QCOCOASESSIONMANAGER_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#ifndef QT_NO_SESSIONMANAGER + +#include + +QT_BEGIN_NAMESPACE + +class QCocoaSessionManager : public QPlatformSessionManager +{ +public: + QCocoaSessionManager(const QString &id, const QString &key); + virtual ~QCocoaSessionManager(); + + bool allowsInteraction() override; + void cancel() override; + void resetCancellation(); + bool wasCanceled() const; + + static QCocoaSessionManager *instance(); + +private: + bool m_canceled; + + Q_DISABLE_COPY(QCocoaSessionManager) +}; + +QT_END_NAMESPACE + +#endif // QT_NO_SESSIONMANAGER + +#endif // QCOCOASESSIONMANAGER_H -- cgit v1.2.3 From 438702ac5f592573dbb9ed5fac84b241eb2d767a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sun, 24 Nov 2019 22:06:27 +0100 Subject: macOS: Don't tweak NSApp presentationOptions on startup AppKit will initialize NSScreens nowadays, so we don't need to manually trigger it. Task-number: QTBUG-80193 Change-Id: Ic0251a1b978b9d4ff53f20e67902787cf529fa87 Reviewed-by: Timur Pocheptsov Reviewed-by: Volker Hilsheimer --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 9a2f19c2f2..b7f15a2bf1 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -197,16 +197,6 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) [cocoaApplication setMenu:[qtMenuLoader menu]]; } - // The presentation options such as whether or not the dock and/or menu bar is - // hidden (automatically by the system) affects the main screen's available - // geometry. Since we're initializing the screens synchronously at application - // startup we need to ensure that the presentation options have been propagated - // to the screen before we read out its properties. Normally OS X does this in - // an asynchronous callback, but that's too late for us. We force the propagation - // by explicitly setting the presentation option to the magic 'default value', - // which will resolve to an actual value and result in screen invalidation. - cocoaApplication.presentationOptions = NSApplicationPresentationDefault; - QCocoaScreen::initializeScreens(); QMacInternalPasteboardMime::initializeMimeTypes(); -- cgit v1.2.3 From 9ac156c90b92a981f70929e081c64083b14e9a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 2 Dec 2019 13:33:30 +0100 Subject: iOS: Guard against request for textInputView without focus window Change-Id: I7b8df07fffef1cc948f6720685234540a20ccc81 Fixes: QTBUG-79316 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/ios/qiostextresponder.mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index 396c769be8..1bc9744528 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -781,12 +781,16 @@ - (UIView *)textInputView { + auto *focusWindow = QGuiApplication::focusWindow(); + if (!focusWindow) + return nil; + // iOS expects rects we return from other UITextInput methods // to be relative to the view this method returns. // Since QInputMethod returns rects relative to the top level // QWindow, that is also the view we need to return. - Q_ASSERT(qApp->focusWindow()->handle()); - QPlatformWindow *topLevel = qApp->focusWindow()->handle(); + Q_ASSERT(focusWindow->handle()); + QPlatformWindow *topLevel = focusWindow->handle(); while (QPlatformWindow *p = topLevel->parent()) topLevel = p; return reinterpret_cast(topLevel->winId()); -- cgit v1.2.3 From a966a7b7df18ebf7b92409b1199386df7f872b6c Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Tue, 3 Dec 2019 09:25:06 +0200 Subject: Initialize all variables Set m_isFolder = false also in "close" method Fixes: QTBUG-80468 Change-Id: I5449692d61d4d340e83bdca337b86e054e8bf561 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp index 3d16f96450..fcc08ea00d 100644 --- a/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp +++ b/src/plugins/platforms/android/qandroidassetsfileenginehandler.cpp @@ -288,6 +288,7 @@ public: m_assetFile = 0; return true; } + m_isFolder = false; return false; } @@ -397,9 +398,9 @@ public: private: AAsset *m_assetFile = nullptr; - AAssetManager *m_assetManager; + AAssetManager *m_assetManager = nullptr; QString m_fileName; - bool m_isFolder; + bool m_isFolder = false; }; -- cgit v1.2.3 From 4d796cbf17da28e72ad25760a2ee8c27af96c202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 8 Nov 2019 02:19:02 +0100 Subject: Prevent emscripten_webgl_destroy_context from removing event handlers The JavaScript implementation of that function has the following code: if (typeof JSEvents === 'object') JSEvents.removeAllHandlersOnTarget(GL.contexts[contextHandle].GLctx.canvas); // Release all // JS event handlers on the DOM element that the GL context is associated with since the context // is now deleted. This breaks mouse/keyboard events, etc. Disable this logic by temporarily setting the JSEvents object to undefined, for the duration of the emscripten_webgl_destroy_context call. Fixes: QTBUG-74850 Change-Id: Ied3177b0ca6e63e8ea07143bf7d6a850b0bce35a Reviewed-by: Lorn Potter --- src/plugins/platforms/wasm/qwasmopenglcontext.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp index 62087f54bd..0532b7e726 100644 --- a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp +++ b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp @@ -30,6 +30,7 @@ #include "qwasmopenglcontext.h" #include "qwasmintegration.h" #include +#include QT_BEGIN_NAMESPACE @@ -50,7 +51,13 @@ QWasmOpenGLContext::QWasmOpenGLContext(const QSurfaceFormat &format) QWasmOpenGLContext::~QWasmOpenGLContext() { if (m_context) { + // Destroy GL context. Work around bug in emscripten_webgl_destroy_context + // which removes all event handlers on the canvas by temporarily removing + // emscripten's JSEvents global object. + emscripten::val jsEvents = emscripten::val::global("window")["JSEvents"]; + emscripten::val::global("window").set("JSEvents", emscripten::val::undefined()); emscripten_webgl_destroy_context(m_context); + emscripten::val::global("window").set("JSEvents", jsEvents); m_context = 0; } } -- cgit v1.2.3 From 2ed59f0d42d2817a5855be167f5e3ccf23563e39 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 3 Dec 2019 11:25:27 +0100 Subject: QMdiArea: on macOS using tabs, render document icons next to the text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is closer to what titles of documents look like in macOS apps, even though MDI is not a well-defined concept on this platform. To implement this, the QCommonStylePrivate::tabLayout method had to be made virtual, as it is called by the QCommonStyle class. It was already reimplemented in QMacStylePrivate, but didn't get called in all cases. Now that it is called as an override, adjust the icon placement to include the padding so that we get identical results to 5.13 for normal tab widgets. Change-Id: I7a63f6d76891146ca713259096a7737a86584d81 Fixes: QTBUG-63445 Reviewed-by: Tor Arne Vestbø --- src/plugins/styles/mac/qmacstyle_mac.mm | 18 +++++++++++++----- src/plugins/styles/mac/qmacstyle_mac_p_p.h | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 603c6e93f3..3c97db44ad 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -1388,14 +1388,22 @@ void QMacStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *widg // High-dpi icons do not need adjustment; make sure tabIconSize is not larger than iconSize tabIconSize = QSize(qMin(tabIconSize.width(), iconSize.width()), qMin(tabIconSize.height(), iconSize.height())); - *iconRect = QRect(tr.left(), tr.center().y() - tabIconSize.height() / 2, - tabIconSize.width(), tabIconSize.height()); + const int stylePadding = proxyStyle->pixelMetric(QStyle::PM_TabBarTabHSpace, opt, widget) / 2 - hpadding; + + if (opt->documentMode) { + // documents show the icon as part of the the text + const int textWidth = + opt->fontMetrics.boundingRect(tr, Qt::AlignCenter | Qt::TextShowMnemonic, opt->text).width(); + *iconRect = QRect(tr.center().x() - textWidth / 2 - stylePadding - tabIconSize.width(), + tr.center().y() - tabIconSize.height() / 2, + tabIconSize.width(), tabIconSize.height()); + } else { + *iconRect = QRect(tr.left() + stylePadding, tr.center().y() - tabIconSize.height() / 2, + tabIconSize.width(), tabIconSize.height()); + } if (!verticalTabs) *iconRect = proxyStyle->visualRect(opt->direction, opt->rect, *iconRect); - int stylePadding = proxyStyle->pixelMetric(QStyle::PM_TabBarTabHSpace, opt, widget) / 2; - stylePadding -= hpadding; - tr.setLeft(tr.left() + stylePadding + tabIconSize.width() + 4); tr.setRight(tr.right() - stylePadding - tabIconSize.width() - 4); } diff --git a/src/plugins/styles/mac/qmacstyle_mac_p_p.h b/src/plugins/styles/mac/qmacstyle_mac_p_p.h index d6af18f01f..274936bd79 100644 --- a/src/plugins/styles/mac/qmacstyle_mac_p_p.h +++ b/src/plugins/styles/mac/qmacstyle_mac_p_p.h @@ -284,7 +284,7 @@ public: CocoaControlType windowButtonCocoaControl(QStyle::SubControl sc) const; #if QT_CONFIG(tabbar) - void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const; + void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const override; static Direction tabDirection(QTabBar::Shape shape); static bool verticalTabs(QMacStylePrivate::Direction tabDirection); #endif -- cgit v1.2.3 From e4d1a03df00b7fb9528f4cd600038515a07196db Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 3 Dec 2019 15:14:59 +0100 Subject: QMacStyle: correct placement of edit field in combobox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dark edit field is now centered within the frame around it, with a thin border on all sides, including between input field and button. Change-Id: I27e853289e9048c21fdc81e45fadacba9665b49e Fixes: QTBUG-63454 Reviewed-by: Tor Arne Vestbø --- src/plugins/styles/mac/qmacstyle_mac.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 610329a350..ecdde06bb8 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -1740,16 +1740,16 @@ QRectF QMacStylePrivate::comboboxEditBounds(const QRectF &outerBounds, const Coc if (cw.type == ComboBox) { switch (cw.size) { case QStyleHelper::SizeLarge: - ret = ret.adjusted(0, 0, -28, 0).translated(3, 4.5); + ret = ret.adjusted(0, 0, -25, 0).translated(2, 4.5); ret.setHeight(16); break; case QStyleHelper::SizeSmall: - ret = ret.adjusted(0, 0, -24, 0).translated(3, 2); + ret = ret.adjusted(0, 0, -22, 0).translated(2, 3); ret.setHeight(14); break; case QStyleHelper::SizeMini: - ret = ret.adjusted(0, 0, -21, 0).translated(2, 3); - ret.setHeight(11); + ret = ret.adjusted(0, 0, -19, 0).translated(2, 2.5); + ret.setHeight(10.5); break; default: break; -- cgit v1.2.3 From 92cf38018afe8f598f2c337c0d202f3767b04ead Mon Sep 17 00:00:00 2001 From: Jan Niklas Hasse Date: Wed, 4 Dec 2019 10:40:20 +0100 Subject: Quit application when QWindowsSystemTrayIcon receives WM_CLOSE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an application only has a trayicon and is killed by `taskkill /IM binary.exe` the trayicon's HWND will receive a WM_CLOSE message. If we don't handle this, the tray icon will close anyway, but the app still runs in the task manager. Fixes: QTBUG-43855 Change-Id: I5f82a068df9c40360bd565a2681e1b37ff114e44 Reviewed-by: Tor Arne Vestbø Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowssystemtrayicon.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp index f2dba4d06b..22cdefbbbc 100644 --- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp +++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp @@ -62,6 +62,7 @@ #include #include #include +#include #include #include @@ -136,7 +137,7 @@ extern "C" LRESULT QT_WIN_CALLBACK qWindowsTrayIconWndProc(HWND hwnd, UINT messa { if (message == MYWM_TASKBARCREATED || message == MYWM_NOTIFYICON || message == WM_INITMENU || message == WM_INITMENUPOPUP - || message == WM_COMMAND) { + || message == WM_CLOSE || message == WM_COMMAND) { const int index = indexOfHwnd(hwnd); if (index >= 0) { MSG msg; @@ -439,6 +440,9 @@ bool QWindowsSystemTrayIcon::winEvent(const MSG &message, long *result) case WM_INITMENUPOPUP: QWindowsPopupMenu::notifyAboutToShow(reinterpret_cast(message.wParam)); break; + case WM_CLOSE: + QWindowSystemInterface::handleApplicationTermination(); + break; case WM_COMMAND: QWindowsPopupMenu::notifyTriggered(LOWORD(message.wParam)); break; -- cgit v1.2.3 From c7fec68e1936576070d0fbac6cf40b818366d298 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 2 Dec 2019 14:08:29 +0100 Subject: Do not read Xft.dpi on platforms that shouldn't be using Xft settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We only read this for desktop environments that have traditionally used these to set settings for other toolkits. Fixes: QTBUG-80323 Change-Id: Ifa8c2682301e69c2770d3734115080a0e6b4e85c Reviewed-by: Morten Johan Sørvig Reviewed-by: Gatis Paeglis --- src/plugins/platforms/xcb/qxcbscreen.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 8da299d491..7c60ca06f9 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -41,6 +41,7 @@ #include "qxcbwindow.h" #include "qxcbcursor.h" #include "qxcbimage.h" +#include "qxcbintegration.h" #include "qnamespace.h" #include "qxcbxsettings.h" @@ -49,6 +50,7 @@ #include #include +#include #include #include #include @@ -356,6 +358,15 @@ static QFontEngine::SubpixelAntialiasingType parseXftRgba(const QByteArray& stri void QXcbVirtualDesktop::readXResources() { + const QPlatformServices *services = QXcbIntegration::instance()->services(); + bool useXftConf = false; + if (services) { + const QList desktopEnv = services->desktopEnvironment().split(':'); + useXftConf = desktopEnv.contains("GNOME") || desktopEnv.contains("UNITY") || desktopEnv.contains("XFCE"); + } + if (!useXftConf) + return; + int offset = 0; QByteArray resources; while (true) { -- cgit v1.2.3 From 35da2b87e3d04e4f7eb0895590be6952eeeb4a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 4 Dec 2019 19:50:28 +0100 Subject: macOS: Enable fullscreen for windows by default This matches the default collection behavior of NSWindows. Change-Id: I363ed211daf6c6c2e579eb11c7294ff509d53e91 Fixes: QTBUG-63829 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 6e2d446898..69d192b4f5 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -567,7 +567,10 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags) Qt::WindowType type = static_cast(int(flags & Qt::WindowType_Mask)); if ((type & Qt::Popup) != Qt::Popup && (type & Qt::Dialog) != Qt::Dialog) { NSWindowCollectionBehavior behavior = m_view.window.collectionBehavior; - if ((flags & Qt::WindowFullscreenButtonHint) || m_view.window.qt_fullScreen) { + const bool enableFullScreen = m_view.window.qt_fullScreen + || !(flags & Qt::CustomizeWindowHint) + || (flags & Qt::WindowFullscreenButtonHint); + if (enableFullScreen) { behavior |= NSWindowCollectionBehaviorFullScreenPrimary; behavior &= ~NSWindowCollectionBehaviorFullScreenAuxiliary; } else { -- cgit v1.2.3 From aabf4fbbe932cbf5554062ed973f9b52388b5352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 3 Dec 2019 15:41:55 +0100 Subject: macOS: Improve QCocoaGLContext logging Change-Id: I27d0abe0eb5b0f0ba64b8787b430484c48b131c0 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoaglcontext.h | 4 ++++ src/plugins/platforms/cocoa/qcocoaglcontext.mm | 20 +++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h index 4210a4ed3f..238067568b 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.h +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -86,6 +86,10 @@ private: QSurfaceFormat m_format; QVarLengthArray m_updateObservers; QAtomicInt m_needsUpdate = false; + +#ifndef QT_NO_DEBUG_STREAM + friend QDebug operator<<(QDebug debug, const QCocoaGLContext *screen); +#endif }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index b312e033cd..6db4bdb9fd 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -158,6 +158,8 @@ void QCocoaGLContext::initialize() [m_context setValues:&order forParameter:NSOpenGLCPSurfaceOrder]; updateSurfaceFormat(); + + qCDebug(lcQpaOpenGLContext).verbosity(3) << "Created" << this << "based on requested" << context()->format(); } NSOpenGLPixelFormat *QCocoaGLContext::pixelFormatForSurfaceFormat(const QSurfaceFormat &format) @@ -355,7 +357,7 @@ QCocoaGLContext::~QCocoaGLContext() bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface) { - qCDebug(lcQpaOpenGLContext) << "Making" << m_context << "current" + qCDebug(lcQpaOpenGLContext) << "Making" << this << "current" << "in" << QThread::currentThread() << "for" << surface; Q_ASSERT(surface->surface()->supportsOpenGL()); @@ -555,4 +557,20 @@ QFunctionPointer QCocoaGLContext::getProcAddress(const char *procName) return (QFunctionPointer)dlsym(RTLD_DEFAULT, procName); } +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug debug, const QCocoaGLContext *context) +{ + QDebugStateSaver saver(debug); + debug.nospace(); + debug << "QCocoaGLContext(" << (const void *)context; + if (context) { + if (debug.verbosity() > QDebug::DefaultVerbosity) + debug << ", " << context->format(); + debug << ", " << context->nativeContext(); + } + debug << ')'; + return debug; +} +#endif // !QT_NO_DEBUG_STREAM + QT_END_NAMESPACE -- cgit v1.2.3 From 455e9e5be35b36d79b9541a6e014c5c9026d685b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 2 Dec 2019 13:53:35 +0100 Subject: Windows QPA: Fix tray geometry not updating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The application does not update its screens when there are no windows on which a WM_DPICHANGE could be received. Add a check for it to the tray window procedure and trigger an update from there if no top levels are present. Fixes: QTBUG-79248 Change-Id: I0b1c4db560662ecf2b473304942da373be6fdc73 Reviewed-by: André de la Rocha Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/windows/qwindowssystemtrayicon.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp index 22cdefbbbc..ab830e1461 100644 --- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp +++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp @@ -57,6 +57,7 @@ #include "qwindowsmenu.h" #include "qwindowsscreen.h" +#include #include #include #include @@ -135,6 +136,9 @@ static int indexOfHwnd(HWND hwnd) extern "C" LRESULT QT_WIN_CALLBACK qWindowsTrayIconWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { + // QTBUG-79248: Trigger screen update if there are no other windows. + if (message == WM_DPICHANGED && QGuiApplication::topLevelWindows().isEmpty()) + QWindowsContext::instance()->screenManager().handleScreenChanges(); if (message == MYWM_TASKBARCREATED || message == MYWM_NOTIFYICON || message == WM_INITMENU || message == WM_INITMENUPOPUP || message == WM_CLOSE || message == WM_COMMAND) { -- cgit v1.2.3 From ece0c0a5e7e0b18beb58ccd868bde54c7be64f78 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 22 Nov 2019 14:46:58 +0100 Subject: Tidy nullptr usage Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/plugins/bearer/qnetworksession_impl.cpp | 6 +-- src/plugins/imageformats/gif/qgifhandler.cpp | 12 ++--- src/plugins/imageformats/jpeg/qjpeghandler.cpp | 8 ++-- src/plugins/platforms/eglfs/api/qeglfscontext.cpp | 2 +- src/plugins/platforms/eglfs/api/qeglfscursor.cpp | 2 +- .../platforms/eglfs/api/qeglfsintegration.cpp | 18 ++++---- .../platforms/eglfs/api/qeglfsoffscreenwindow.cpp | 2 +- src/plugins/platforms/eglfs/api/qeglfsscreen.cpp | 4 +- src/plugins/platforms/eglfs/api/qeglfswindow.cpp | 8 ++-- .../eglfs_kms/qeglfskmsgbmcursor.cpp | 4 +- .../eglfs_x11/qeglfsx11integration.cpp | 16 +++---- .../eglfs_x11/qeglfsx11integration.h | 2 +- src/plugins/platforms/eglfs/qeglfsmain.cpp | 2 +- src/plugins/platforms/offscreen/main.cpp | 2 +- .../platforms/offscreen/qoffscreencommon.cpp | 10 ++--- .../platforms/offscreen/qoffscreenintegration.cpp | 2 +- .../offscreen/qoffscreenintegration_x11.cpp | 12 ++--- .../platforms/offscreen/qoffscreenwindow.cpp | 2 +- src/plugins/platforms/vnc/main.cpp | 2 +- src/plugins/platforms/vnc/qvnc.cpp | 4 +- src/plugins/platforms/vnc/qvncclient.cpp | 2 +- src/plugins/platforms/vnc/qvncscreen.cpp | 2 +- .../xcb/gl_integrations/xcb_egl/qxcbeglcontext.h | 2 +- .../xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp | 2 +- .../gl_integrations/xcb_glx/qglxintegration.cpp | 52 +++++++++++----------- .../gl_integrations/xcb_glx/qxcbglxintegration.cpp | 4 +- src/plugins/platforms/xcb/qxcbatom.cpp | 2 +- src/plugins/platforms/xcb/qxcbbackingstore.cpp | 12 ++--- src/plugins/platforms/xcb/qxcbclipboard.cpp | 22 ++++----- src/plugins/platforms/xcb/qxcbconnection.cpp | 16 +++---- src/plugins/platforms/xcb/qxcbconnection.h | 2 +- src/plugins/platforms/xcb/qxcbconnection_basic.cpp | 4 +- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 4 +- src/plugins/platforms/xcb/qxcbcursor.cpp | 36 +++++++-------- src/plugins/platforms/xcb/qxcbdrag.cpp | 20 ++++----- src/plugins/platforms/xcb/qxcbimage.cpp | 8 ++-- src/plugins/platforms/xcb/qxcbintegration.cpp | 4 +- src/plugins/platforms/xcb/qxcbkeyboard.cpp | 4 +- src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 10 ++--- src/plugins/platforms/xcb/qxcbscreen.cpp | 10 ++--- src/plugins/platforms/xcb/qxcbsessionmanager.cpp | 24 +++++----- .../platforms/xcb/qxcbsystemtraytracker.cpp | 4 +- src/plugins/platforms/xcb/qxcbvulkaninstance.cpp | 2 +- src/plugins/platforms/xcb/qxcbvulkanwindow.cpp | 2 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 18 ++++---- src/plugins/platforms/xcb/qxcbxsettings.cpp | 2 +- src/plugins/platformthemes/gtk3/main.cpp | 2 +- .../platformthemes/gtk3/qgtk3dialoghelpers.cpp | 8 ++-- src/plugins/platformthemes/gtk3/qgtk3menu.cpp | 4 +- src/plugins/platformthemes/gtk3/qgtk3theme.cpp | 10 ++--- src/plugins/sqldrivers/mysql/qsql_mysql_p.h | 4 +- src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h | 4 +- src/plugins/sqldrivers/tds/qsql_tds_p.h | 4 +- 53 files changed, 213 insertions(+), 213 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/bearer/qnetworksession_impl.cpp b/src/plugins/bearer/qnetworksession_impl.cpp index c6b678ab20..8eba9ccc42 100644 --- a/src/plugins/bearer/qnetworksession_impl.cpp +++ b/src/plugins/bearer/qnetworksession_impl.cpp @@ -65,7 +65,7 @@ static QBearerEngineImpl *getEngineFromId(const QString &id) } } - return 0; + return nullptr; } class QNetworkSessionManagerPrivate : public QObject @@ -73,7 +73,7 @@ class QNetworkSessionManagerPrivate : public QObject Q_OBJECT public: - QNetworkSessionManagerPrivate(QObject *parent = 0) : QObject(parent) {} + QNetworkSessionManagerPrivate(QObject *parent = nullptr) : QObject(parent) {} ~QNetworkSessionManagerPrivate() {} inline void forceSessionClose(const QNetworkConfiguration &config) @@ -119,7 +119,7 @@ void QNetworkSessionPrivateImpl::syncStateWithInterface() // Defer setting serviceConfig and activeConfig until open(). Q_FALLTHROUGH(); default: - engine = 0; + engine = nullptr; } networkConfigurationsChanged(); diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp index a6029b691c..c92cc3ea61 100644 --- a/src/plugins/imageformats/gif/qgifhandler.cpp +++ b/src/plugins/imageformats/gif/qgifhandler.cpp @@ -147,8 +147,8 @@ private: */ QGIFFormat::QGIFFormat() { - globalcmap = 0; - localcmap = 0; + globalcmap = nullptr; + localcmap = nullptr; lncols = 0; gncols = 0; disposal = NoDisposal; @@ -160,9 +160,9 @@ QGIFFormat::QGIFFormat() lcmap = false; newFrame = false; partialNewFrame = false; - table[0] = 0; - table[1] = 0; - stack = 0; + table[0] = nullptr; + table[1] = nullptr; + stack = nullptr; } /*! @@ -550,7 +550,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, } oldcode=incode; const int h = image->height(); - QRgb *line = 0; + QRgb *line = nullptr; if (!out_of_bounds && h > y) line = (QRgb*)FAST_SCAN_LINE(bits, bpl, y); while (sp>stack) { diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp index dd01138722..c31e2db3c5 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp +++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp @@ -729,7 +729,7 @@ static bool write_jpeg_image(const QImage &image, // do_write_jpeg_image (by making them non-local). struct jpeg_compress_struct cinfo; JSAMPROW row_pointer[1]; - row_pointer[0] = 0; + row_pointer[0] = nullptr; const bool success = do_write_jpeg_image(cinfo, row_pointer, image, device, @@ -751,7 +751,7 @@ public: }; QJpegHandlerPrivate(QJpegHandler *qq) - : quality(75), transformation(QImageIOHandler::TransformationNone), iod_src(0), + : quality(75), transformation(QImageIOHandler::TransformationNone), iod_src(nullptr), rgb888ToRgb32ConverterPtr(qt_convert_rgb888_to_rgb32), state(Ready), optimize(false), progressive(false), q(qq) {} @@ -761,7 +761,7 @@ public: { jpeg_destroy_decompress(&info); delete iod_src; - iod_src = 0; + iod_src = nullptr; } } @@ -954,7 +954,7 @@ bool QJpegHandlerPrivate::readJpegHeader(QIODevice *device) QByteArray exifData; - for (jpeg_saved_marker_ptr marker = info.marker_list; marker != NULL; marker = marker->next) { + for (jpeg_saved_marker_ptr marker = info.marker_list; marker != nullptr; marker = marker->next) { if (marker->marker == JPEG_COM) { QString key, value; QString s = QString::fromUtf8((const char *)marker->data, marker->data_length); diff --git a/src/plugins/platforms/eglfs/api/qeglfscontext.cpp b/src/plugins/platforms/eglfs/api/qeglfscontext.cpp index c10b6facbb..48fafbda8d 100644 --- a/src/plugins/platforms/eglfs/api/qeglfscontext.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfscontext.cpp @@ -78,7 +78,7 @@ EGLSurface QEglFSContext::createTemporaryOffscreenSurface() } } EGLConfig config = q_configFromGLFormat(eglDisplay(), format()); - return eglCreateWindowSurface(eglDisplay(), config, m_tempWindow, 0); + return eglCreateWindowSurface(eglDisplay(), config, m_tempWindow, nullptr); } void QEglFSContext::destroyTemporaryOffscreenSurface(EGLSurface surface) diff --git a/src/plugins/platforms/eglfs/api/qeglfscursor.cpp b/src/plugins/platforms/eglfs/api/qeglfscursor.cpp index 22319fcc66..98e05195ee 100644 --- a/src/plugins/platforms/eglfs/api/qeglfscursor.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfscursor.cpp @@ -62,7 +62,7 @@ QEglFSCursor::QEglFSCursor(QPlatformScreen *screen) : m_visible(true), m_screen(static_cast(screen)), m_activeScreen(nullptr), - m_deviceListener(0), + m_deviceListener(nullptr), m_updateRequested(false) { QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR"); diff --git a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp index d3f51c0d0e..d9a3545a95 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsintegration.cpp @@ -109,10 +109,10 @@ QT_BEGIN_NAMESPACE QEglFSIntegration::QEglFSIntegration() : m_display(EGL_NO_DISPLAY), - m_inputContext(0), + m_inputContext(nullptr), m_fontDb(new QGenericUnixFontDatabase), m_services(new QGenericUnixServices), - m_kbdMgr(0), + m_kbdMgr(nullptr), m_disableInputHandlers(false) { m_disableInputHandlers = qEnvironmentVariableIntValue("QT_QPA_EGLFS_DISABLE_INPUT"); @@ -223,7 +223,7 @@ QPlatformOpenGLContext *QEglFSIntegration::createPlatformOpenGLContext(QOpenGLCo EGLConfig config = QEglFSDeviceIntegration::chooseConfig(dpy, adjustedFormat); ctx = new QEglFSContext(adjustedFormat, share, dpy, &config, QVariant()); } else { - ctx = new QEglFSContext(adjustedFormat, share, dpy, 0, nativeHandle); + ctx = new QEglFSContext(adjustedFormat, share, dpy, nullptr, nativeHandle); } nativeHandle = QVariant::fromValue(QEGLNativeContext(ctx->eglContext(), dpy)); @@ -307,7 +307,7 @@ static int resourceType(const QByteArray &key) void *QEglFSIntegration::nativeResourceForIntegration(const QByteArray &resource) { - void *result = 0; + void *result = nullptr; switch (resourceType(resource)) { case EglDisplay: @@ -329,7 +329,7 @@ void *QEglFSIntegration::nativeResourceForIntegration(const QByteArray &resource void *QEglFSIntegration::nativeResourceForScreen(const QByteArray &resource, QScreen *screen) { - void *result = 0; + void *result = nullptr; switch (resourceType(resource)) { case XlibDisplay: @@ -347,7 +347,7 @@ void *QEglFSIntegration::nativeResourceForScreen(const QByteArray &resource, QSc void *QEglFSIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window) { - void *result = 0; + void *result = nullptr; switch (resourceType(resource)) { case EglDisplay: @@ -374,7 +374,7 @@ void *QEglFSIntegration::nativeResourceForWindow(const QByteArray &resource, QWi #ifndef QT_NO_OPENGL void *QEglFSIntegration::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) { - void *result = 0; + void *result = nullptr; switch (resourceType(resource)) { case EglContext: @@ -402,7 +402,7 @@ static void *eglContextForContext(QOpenGLContext *context) QEglFSContext *handle = static_cast(context->handle()); if (!handle) - return 0; + return nullptr; return handle->eglContext(); } @@ -416,7 +416,7 @@ QPlatformNativeInterface::NativeResourceForContextFunction QEglFSIntegration::na #else Q_UNUSED(resource); #endif - return 0; + return nullptr; } QFunctionPointer QEglFSIntegration::platformFunction(const QByteArray &function) const diff --git a/src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow.cpp b/src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow.cpp index 864271cd3a..c96e329816 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsoffscreenwindow.cpp @@ -67,7 +67,7 @@ QEglFSOffscreenWindow::QEglFSOffscreenWindow(EGLDisplay display, const QSurfaceF return; } EGLConfig config = q_configFromGLFormat(m_display, m_format); - m_surface = eglCreateWindowSurface(m_display, config, m_window, 0); + m_surface = eglCreateWindowSurface(m_display, config, m_window, nullptr); if (m_surface != EGL_NO_SURFACE) m_format = q_glFormatFromConfig(m_display, config); } diff --git a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp index 11b68c0589..8a8e8cd563 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE QEglFSScreen::QEglFSScreen(EGLDisplay dpy) : m_dpy(dpy), m_surface(EGL_NO_SURFACE), - m_cursor(0) + m_cursor(nullptr) { m_cursor = qt_egl_device_integration()->createCursor(this); } @@ -164,7 +164,7 @@ void QEglFSScreen::handleCursorMove(const QPoint &pos) return; } - QWindow *enter = 0, *leave = 0; + QWindow *enter = nullptr, *leave = nullptr; for (int i = windows.count() - 1; i >= 0; --i) { QWindow *window = windows[i]->sourceWindow(); const QRect geom = window->geometry(); diff --git a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp index 3457be116a..f7e116eb88 100644 --- a/src/plugins/platforms/eglfs/api/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp @@ -61,8 +61,8 @@ QT_BEGIN_NAMESPACE QEglFSWindow::QEglFSWindow(QWindow *w) : QPlatformWindow(w), #ifndef QT_NO_OPENGL - m_backingStore(0), - m_rasterCompositingContext(0), + m_backingStore(nullptr), + m_rasterCompositingContext(nullptr), #endif m_winId(0), m_surface(EGL_NO_SURFACE), @@ -207,7 +207,7 @@ void QEglFSWindow::resetSurface() m_format = q_glFormatFromConfig(display, m_config, platformFormat); const QSize surfaceSize = screen()->rawGeometry().size(); m_window = qt_egl_device_integration()->createNativeWindow(this, surfaceSize, m_format); - m_surface = eglCreateWindowSurface(display, m_config, m_window, NULL); + m_surface = eglCreateWindowSurface(display, m_config, m_window, nullptr); } void QEglFSWindow::setVisible(bool visible) @@ -337,7 +337,7 @@ const QPlatformTextureList *QEglFSWindow::textures() const if (m_backingStore) return m_backingStore->textures(); - return 0; + return nullptr; } void QEglFSWindow::endCompositing() diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp index 1125bcb390..dc98cdce4b 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp @@ -69,7 +69,7 @@ QEglFSKmsGbmCursor::QEglFSKmsGbmCursor(QEglFSKmsGbmScreen *screen) : m_screen(screen) , m_cursorSize(64, 64) // 64x64 is the old standard size, we now try to query the real size below , m_bo(nullptr) - , m_cursorImage(0, 0, 0, 0, 0, 0) + , m_cursorImage(nullptr, nullptr, 0, 0, 0, 0) , m_state(CursorPendingVisible) , m_deviceListener(nullptr) { @@ -102,7 +102,7 @@ QEglFSKmsGbmCursor::QEglFSKmsGbmCursor(QEglFSKmsGbmScreen *screen) #ifndef QT_NO_CURSOR QCursor cursor(Qt::ArrowCursor); - changeCursor(&cursor, 0); + changeCursor(&cursor, nullptr); #endif setPos(QPoint(0, 0)); } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp index 07b2de7c58..ce5a721906 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp @@ -75,7 +75,7 @@ void EventReader::run() if (client->format == 32 && client->type == atoms[Atoms::WM_PROTOCOLS] && client->data.data32[0] == atoms[Atoms::WM_DELETE_WINDOW]) { - QWindow *window = m_integration->platformWindow() ? m_integration->platformWindow()->window() : 0; + QWindow *window = m_integration->platformWindow() ? m_integration->platformWindow()->window() : nullptr; if (window) QWindowSystemInterface::handleCloseEvent(window); } @@ -106,7 +106,7 @@ void QEglFSX11Integration::sendConnectionEvent(xcb_atom_t a) void QEglFSX11Integration::platformInit() { - m_display = XOpenDisplay(0); + m_display = XOpenDisplay(nullptr); if (Q_UNLIKELY(!m_display)) qFatal("Could not open display"); @@ -121,7 +121,7 @@ void QEglFSX11Integration::platformInit() xcb_create_window(m_connection, XCB_COPY_FROM_PARENT, m_connectionEventListener, it.data->root, 0, 0, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_ONLY, - it.data->root_visual, 0, 0); + it.data->root_visual, 0, nullptr); m_eventReader = new EventReader(this); m_eventReader->start(); @@ -135,11 +135,11 @@ void QEglFSX11Integration::platformDestroy() m_eventReader->wait(); delete m_eventReader; - m_eventReader = 0; + m_eventReader = nullptr; XCloseDisplay(DISPLAY); - m_display = 0; - m_connection = 0; + m_display = nullptr; + m_connection = nullptr; } EGLNativeDisplayType QEglFSX11Integration::platformDisplay() const @@ -175,7 +175,7 @@ EGLNativeWindowType QEglFSX11Integration::createNativeWindow(QPlatformWindow *pl xcb_create_window(m_connection, XCB_COPY_FROM_PARENT, m_window, it.data->root, 0, 0, size.width(), size.height(), 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, it.data->root_visual, - 0, 0); + 0, nullptr); xcb_intern_atom_cookie_t cookies[Atoms::N_ATOMS]; static const char *atomNames[Atoms::N_ATOMS] = { @@ -189,7 +189,7 @@ EGLNativeWindowType QEglFSX11Integration::createNativeWindow(QPlatformWindow *pl for (int i = 0; i < Atoms::N_ATOMS; ++i) { cookies[i] = xcb_intern_atom(m_connection, false, strlen(atomNames[i]), atomNames[i]); - xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(m_connection, cookies[i], 0); + xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(m_connection, cookies[i], nullptr); m_atoms[i] = reply->atom; free(reply); } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h index bf431caaac..ebcc19b682 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h @@ -67,7 +67,7 @@ class EventReader; class QEglFSX11Integration : public QEglFSDeviceIntegration { public: - QEglFSX11Integration() : m_connection(0), m_window(0), m_eventReader(0) {} + QEglFSX11Integration() : m_connection(nullptr), m_window(0), m_eventReader(nullptr) {} void platformInit() override; void platformDestroy() override; diff --git a/src/plugins/platforms/eglfs/qeglfsmain.cpp b/src/plugins/platforms/eglfs/qeglfsmain.cpp index 4f77b7cd17..b41bbec27d 100644 --- a/src/plugins/platforms/eglfs/qeglfsmain.cpp +++ b/src/plugins/platforms/eglfs/qeglfsmain.cpp @@ -56,7 +56,7 @@ QPlatformIntegration* QEglFSIntegrationPlugin::create(const QString& system, con if (!system.compare(QLatin1String("eglfs"), Qt::CaseInsensitive)) return new QEglFSIntegration; - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/offscreen/main.cpp b/src/plugins/platforms/offscreen/main.cpp index 207db60f3a..f364d9f004 100644 --- a/src/plugins/platforms/offscreen/main.cpp +++ b/src/plugins/platforms/offscreen/main.cpp @@ -57,7 +57,7 @@ QPlatformIntegration *QOffscreenIntegrationPlugin::create(const QString& system, if (!system.compare(QLatin1String("offscreen"), Qt::CaseInsensitive)) return QOffscreenIntegration::createOffscreenIntegration(); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/offscreen/qoffscreencommon.cpp b/src/plugins/platforms/offscreen/qoffscreencommon.cpp index eae25012c1..de75a3e012 100644 --- a/src/plugins/platforms/offscreen/qoffscreencommon.cpp +++ b/src/plugins/platforms/offscreen/qoffscreencommon.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE -QPlatformWindow *QOffscreenScreen::windowContainingCursor = 0; +QPlatformWindow *QOffscreenScreen::windowContainingCursor = nullptr; class QOffscreenCursor : public QPlatformCursor { @@ -60,7 +60,7 @@ public: { m_pos = pos; const QWindowList wl = QGuiApplication::topLevelWindows(); - QWindow *containing = 0; + QWindow *containing = nullptr; for (QWindow *w : wl) { if (w->type() != Qt::Desktop && w->isExposed() && w->geometry().contains(pos)) { containing = w; @@ -72,7 +72,7 @@ public: if (containing) local -= containing->position(); - QWindow *previous = QOffscreenScreen::windowContainingCursor ? QOffscreenScreen::windowContainingCursor->window() : 0; + QWindow *previous = QOffscreenScreen::windowContainingCursor ? QOffscreenScreen::windowContainingCursor->window() : nullptr; if (containing != previous) QWindowSystemInterface::handleEnterLeaveEvent(containing, previous, local, pos); @@ -80,7 +80,7 @@ public: QWindowSystemInterface::handleMouseEvent(containing, local, pos, QGuiApplication::mouseButtons(), Qt::NoButton, QEvent::MouseMove, QGuiApplication::keyboardModifiers(), Qt::MouseEventSynthesizedByQt); - QOffscreenScreen::windowContainingCursor = containing ? containing->handle() : 0; + QOffscreenScreen::windowContainingCursor = containing ? containing->handle() : nullptr; } #ifndef QT_NO_CURSOR void changeCursor(QCursor *windowCursor, QWindow *window) override @@ -106,7 +106,7 @@ QPixmap QOffscreenScreen::grabWindow(WId id, int x, int y, int width, int height QOffscreenWindow *window = QOffscreenWindow::windowForWinId(id); if (!window || window->window()->type() == Qt::Desktop) { const QWindowList wl = QGuiApplication::topLevelWindows(); - QWindow *containing = 0; + QWindow *containing = nullptr; for (QWindow *w : wl) { if (w->type() != Qt::Desktop && w->isExposed() && w->geometry().contains(rect)) { containing = w; diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp index 869e9228cd..3a4494fc2e 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration.cpp @@ -79,7 +79,7 @@ template class QOffscreenEventDispatcher : public BaseEventDispatcher { public: - explicit QOffscreenEventDispatcher(QObject *parent = 0) + explicit QOffscreenEventDispatcher(QObject *parent = nullptr) : BaseEventDispatcher(parent) { } diff --git a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp index 92fc8aa57a..84991d751f 100644 --- a/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenintegration_x11.cpp @@ -206,7 +206,7 @@ QOffscreenX11GLXContext::QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGL if (d->format.renderableType() != QSurfaceFormat::OpenGL) return; - d->shareContext = 0; + d->shareContext = nullptr; if (context->shareHandle()) d->shareContext = static_cast(context->shareHandle())->d->context; @@ -216,9 +216,9 @@ QOffscreenX11GLXContext::QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGL if (config) { d->context = glXCreateNewContext(x11->display(), config, GLX_RGBA_TYPE, d->shareContext, true); if (!d->context && d->shareContext) { - d->shareContext = 0; + d->shareContext = nullptr; // re-try without a shared glx context - d->context = glXCreateNewContext(x11->display(), config, GLX_RGBA_TYPE, 0, true); + d->context = glXCreateNewContext(x11->display(), config, GLX_RGBA_TYPE, nullptr, true); } // Get the basic surface format details @@ -234,8 +234,8 @@ QOffscreenX11GLXContext::QOffscreenX11GLXContext(QOffscreenX11Info *x11, QOpenGL d->context = glXCreateContext(x11->display(), visualInfo, d->shareContext, true); if (!d->context && d->shareContext) { // re-try without a shared glx context - d->shareContext = 0; - d->context = glXCreateContext(x11->display(), visualInfo, 0, true); + d->shareContext = nullptr; + d->context = glXCreateContext(x11->display(), visualInfo, nullptr, true); } d->window = createDummyWindow(x11, visualInfo); @@ -269,7 +269,7 @@ bool QOffscreenX11GLXContext::makeCurrent(QPlatformSurface *surface) void QOffscreenX11GLXContext::doneCurrent() { - glXMakeCurrent(d->x11->display(), 0, 0); + glXMakeCurrent(d->x11->display(), 0, nullptr); } void QOffscreenX11GLXContext::swapBuffers(QPlatformSurface *) diff --git a/src/plugins/platforms/offscreen/qoffscreenwindow.cpp b/src/plugins/platforms/offscreen/qoffscreenwindow.cpp index 832e94034d..53880c877e 100644 --- a/src/plugins/platforms/offscreen/qoffscreenwindow.cpp +++ b/src/plugins/platforms/offscreen/qoffscreenwindow.cpp @@ -69,7 +69,7 @@ QOffscreenWindow::QOffscreenWindow(QWindow *window) QOffscreenWindow::~QOffscreenWindow() { if (QOffscreenScreen::windowContainingCursor == this) - QOffscreenScreen::windowContainingCursor = 0; + QOffscreenScreen::windowContainingCursor = nullptr; m_windowForWinIdHash.remove(m_winId); } diff --git a/src/plugins/platforms/vnc/main.cpp b/src/plugins/platforms/vnc/main.cpp index 3ec0f0b78d..ac7e18e03f 100644 --- a/src/plugins/platforms/vnc/main.cpp +++ b/src/plugins/platforms/vnc/main.cpp @@ -56,7 +56,7 @@ QPlatformIntegration* QVncIntegrationPlugin::create(const QString& system, const if (!system.compare(QLatin1String("vnc"), Qt::CaseInsensitive)) return new QVncIntegration(paramList); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/vnc/qvnc.cpp b/src/plugins/platforms/vnc/qvnc.cpp index 32114c6443..8390fa19cd 100644 --- a/src/plugins/platforms/vnc/qvnc.cpp +++ b/src/plugins/platforms/vnc/qvnc.cpp @@ -537,7 +537,7 @@ QVncClientCursor::QVncClientCursor() { QWindow *w = QGuiApplication::focusWindow(); QCursor c = w ? w->cursor() : QCursor(Qt::ArrowCursor); - changeCursor(&c, 0); + changeCursor(&c, nullptr); } QVncClientCursor::~QVncClientCursor() @@ -595,7 +595,7 @@ void QVncClientCursor::changeCursor(QCursor *widgetCursor, QWindow *window) cursor = widgetCursor->pixmap().toImage(); } else { // system cursor - QPlatformCursorImage platformImage(0, 0, 0, 0, 0, 0); + QPlatformCursorImage platformImage(nullptr, nullptr, 0, 0, 0, 0); platformImage.set(shape); cursor = *platformImage.image(); hotspot = platformImage.hotspot(); diff --git a/src/plugins/platforms/vnc/qvncclient.cpp b/src/plugins/platforms/vnc/qvncclient.cpp index 2450f7dad5..c5caddc58d 100644 --- a/src/plugins/platforms/vnc/qvncclient.cpp +++ b/src/plugins/platforms/vnc/qvncclient.cpp @@ -617,7 +617,7 @@ void QVncClient::keyEvent() m_keymod = ev.down ? m_keymod | Qt::AltModifier : m_keymod & ~Qt::AltModifier; if (ev.unicode || ev.keycode) - QWindowSystemInterface::handleKeyEvent(0, ev.down ? QEvent::KeyPress : QEvent::KeyRelease, ev.keycode, m_keymod, QString(ev.unicode)); + QWindowSystemInterface::handleKeyEvent(nullptr, ev.down ? QEvent::KeyPress : QEvent::KeyRelease, ev.keycode, m_keymod, QString(ev.unicode)); m_handleMsg = false; } } diff --git a/src/plugins/platforms/vnc/qvncscreen.cpp b/src/plugins/platforms/vnc/qvncscreen.cpp index 2eca18fb4d..5dc3919ff5 100644 --- a/src/plugins/platforms/vnc/qvncscreen.cpp +++ b/src/plugins/platforms/vnc/qvncscreen.cpp @@ -101,7 +101,7 @@ bool QVncScreen::initialize() default: qWarning("QVNCScreen::initDevice: No support for screen depth %d", depth()); - dirty = 0; + dirty = nullptr; return false; } diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h index c3ce8d8745..fda53f17a1 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglcontext.h @@ -52,7 +52,7 @@ class QXcbEglContext : public QEGLPlatformContext public: QXcbEglContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share, EGLDisplay display, const QVariant &nativeHandle) - : QEGLPlatformContext(glFormat, share, display, 0, nativeHandle) + : QEGLPlatformContext(glFormat, share, display, nullptr, nativeHandle) { } diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp index 65beac227c..30e3381993 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_egl/qxcbeglwindow.cpp @@ -93,7 +93,7 @@ void QXcbEglWindow::create() { QXcbWindow::create(); - m_surface = eglCreateWindowSurface(m_glIntegration->eglDisplay(), m_config, m_window, 0); + m_surface = eglCreateWindowSurface(m_glIntegration->eglDisplay(), m_config, m_window, nullptr); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp index 2b77062b16..57805d5571 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -223,13 +223,13 @@ QGLXContext::QGLXContext(QXcbScreen *screen, const QSurfaceFormat &format, QPlat const QVariant &nativeHandle) : QPlatformOpenGLContext() , m_display(static_cast(screen->connection()->xlib_display())) - , m_config(0) - , m_context(0) - , m_shareContext(0) + , m_config(nullptr) + , m_context(nullptr) + , m_shareContext(nullptr) , m_format(format) , m_isPBufferCurrent(false) , m_ownsContext(nativeHandle.isNull()) - , m_getGraphicsResetStatus(0) + , m_getGraphicsResetStatus(nullptr) , m_lost(false) { if (nativeHandle.isNull()) @@ -254,14 +254,14 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) GLXFBConfig config = qglx_findConfig(m_display, screen->screenNumber(), m_format); m_config = config; - XVisualInfo *visualInfo = 0; + XVisualInfo *visualInfo = nullptr; Window window = 0; // Temporary window used to query OpenGL context if (config) { const QByteArrayList glxExt = QByteArray(glXQueryExtensionsString(m_display, screen->screenNumber())).split(' '); // Resolve entry point for glXCreateContextAttribsARB - glXCreateContextAttribsARBProc glXCreateContextAttribsARB = 0; + glXCreateContextAttribsARBProc glXCreateContextAttribsARB = nullptr; if (glxExt.contains("GLX_ARB_create_context")) glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc) glXGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB"); @@ -271,7 +271,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) // Use glXCreateContextAttribsARB if available // Also, GL ES context creation requires GLX_EXT_create_context_es2_profile - if (glXCreateContextAttribsARB != 0 + if (glXCreateContextAttribsARB != nullptr && (m_format.renderableType() != QSurfaceFormat::OpenGLES || (supportsProfiles && glxExt.contains("GLX_EXT_create_context_es2_profile")))) { // Try to create an OpenGL context for each known OpenGL version in descending // order from the requested version. @@ -358,9 +358,9 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) m_context = glXCreateContextAttribsARB(m_display, config, m_shareContext, true, contextAttributes.data()); if (!m_context && m_shareContext) { // re-try without a shared glx context - m_context = glXCreateContextAttribsARB(m_display, config, 0, true, contextAttributes.data()); + m_context = glXCreateContextAttribsARB(m_display, config, nullptr, true, contextAttributes.data()); if (m_context) - m_shareContext = 0; + m_shareContext = nullptr; } } } @@ -375,9 +375,9 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) m_context = glXCreateNewContext(m_display, config, GLX_RGBA_TYPE, m_shareContext, true); if (!m_context && m_shareContext) { // re-try without a shared glx context - m_context = glXCreateNewContext(m_display, config, GLX_RGBA_TYPE, 0, true); + m_context = glXCreateNewContext(m_display, config, GLX_RGBA_TYPE, nullptr, true); if (m_context) - m_shareContext = 0; + m_shareContext = nullptr; } } @@ -399,7 +399,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share) m_context = glXCreateContext(m_display, visualInfo, m_shareContext, true); if (!m_context && m_shareContext) { // re-try without a shared glx context - m_shareContext = 0; + m_shareContext = nullptr; m_context = glXCreateContext(m_display, visualInfo, nullptr, true); } @@ -444,7 +444,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share, const // Legacy contexts created using glXCreateContext are created using a visual // and the FBConfig cannot be queried. The only way to adapt these contexts // is to figure out the visual id. - XVisualInfo *vinfo = 0; + XVisualInfo *vinfo = nullptr; // If the VisualID is provided use it. VisualID vid = handle.visualId(); if (!vid) { @@ -464,13 +464,13 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share, const vinfo = XGetVisualInfo(dpy, VisualScreenMask | VisualIDMask, &v, &n); if (n < 1) { XFree(vinfo); - vinfo = 0; + vinfo = nullptr; } } // For contexts created with an FBConfig using the modern functions providing the // visual or window is not mandatory. Just query the config from the context. - GLXFBConfig config = 0; + GLXFBConfig config = nullptr; if (!vinfo) { int configId = 0; if (glXQueryContext(dpy, context, GLX_FBCONFIG_ID, &configId) != Success) { @@ -595,8 +595,8 @@ bool QGLXContext::makeCurrent(QPlatformSurface *surface) if (interval >= 0 && interval != window->swapInterval() && screen) { typedef void (*qt_glXSwapIntervalEXT)(Display *, GLXDrawable, int); typedef void (*qt_glXSwapIntervalMESA)(unsigned int); - static qt_glXSwapIntervalEXT glXSwapIntervalEXT = 0; - static qt_glXSwapIntervalMESA glXSwapIntervalMESA = 0; + static qt_glXSwapIntervalEXT glXSwapIntervalEXT = nullptr; + static qt_glXSwapIntervalMESA glXSwapIntervalMESA = nullptr; static bool resolved = false; if (!resolved) { resolved = true; @@ -621,9 +621,9 @@ bool QGLXContext::makeCurrent(QPlatformSurface *surface) void QGLXContext::doneCurrent() { if (m_isPBufferCurrent) - glXMakeContextCurrent(m_display, 0, 0, 0); + glXMakeContextCurrent(m_display, 0, 0, nullptr); else - glXMakeCurrent(m_display, 0, 0); + glXMakeCurrent(m_display, 0, nullptr); m_isPBufferCurrent = false; } @@ -658,12 +658,12 @@ QSurfaceFormat QGLXContext::format() const bool QGLXContext::isSharing() const { - return m_shareContext != 0; + return m_shareContext != nullptr; } bool QGLXContext::isValid() const { - return m_context != 0 && !m_lost; + return m_context != nullptr && !m_lost; } bool QGLXContext::m_queriedDummyContext = false; @@ -675,7 +675,7 @@ bool QGLXContext::m_supportsThreading = true; // binary search. static const char *qglx_threadedgl_blacklist_renderer[] = { "Chromium", // QTBUG-32225 (initialization fails) - 0 + nullptr }; static const char *qglx_threadedgl_blacklist_vendor[] = { @@ -695,7 +695,7 @@ void QGLXContext::queryDummyContext() return; QOpenGLContext *oldContext = QOpenGLContext::currentContext(); - QSurface *oldSurface = 0; + QSurface *oldSurface = nullptr; if (oldContext) oldSurface = oldContext->surface(); @@ -732,7 +732,7 @@ void QGLXContext::queryDummyContext() if (const char *renderer = (const char *) glGetString(GL_RENDERER)) { for (int i = 0; qglx_threadedgl_blacklist_renderer[i]; ++i) { - if (strstr(renderer, qglx_threadedgl_blacklist_renderer[i]) != 0) { + if (strstr(renderer, qglx_threadedgl_blacklist_renderer[i]) != nullptr) { qCDebug(lcQpaGl).nospace() << "Multithreaded OpenGL disabled: " "blacklisted renderer \"" << qglx_threadedgl_blacklist_renderer[i] @@ -744,7 +744,7 @@ void QGLXContext::queryDummyContext() } if (const char *vendor = (const char *) glGetString(GL_VENDOR)) { for (int i = 0; qglx_threadedgl_blacklist_vendor[i]; ++i) { - if (strstr(vendor, qglx_threadedgl_blacklist_vendor[i]) != 0) { + if (strstr(vendor, qglx_threadedgl_blacklist_vendor[i]) != nullptr) { qCDebug(lcQpaGl).nospace() << "Multithreaded OpenGL disabled: " "blacklisted vendor \"" << qglx_threadedgl_blacklist_vendor[i] @@ -759,7 +759,7 @@ void QGLXContext::queryDummyContext() // Blacklist Mesa drivers due to QTCREATORBUG-10875 (crash in creator), // QTBUG-34492 (flickering in fullscreen) and QTBUG-38221 const char *mesaVersionStr = nullptr; - if (strstr(glxvendor, "Mesa Project") != 0) { + if (strstr(glxvendor, "Mesa Project") != nullptr) { mesaVersionStr = (const char *) glGetString(GL_VERSION); m_supportsThreading = false; } diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp index 34895caaa2..6814dbd844 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qxcbglxintegration.cpp @@ -133,7 +133,7 @@ bool QXcbGlxIntegration::handleXcbEvent(xcb_generic_event_t *event, uint respons Display *xdisplay = static_cast(m_connection->xlib_display()); XLockDisplay(xdisplay); bool locked = true; - Bool (*proc)(Display*, XEvent*, xEvent*) = XESetWireToEvent(xdisplay, responseType, 0); + Bool (*proc)(Display*, XEvent*, xEvent*) = XESetWireToEvent(xdisplay, responseType, nullptr); if (proc) { XESetWireToEvent(xdisplay, responseType, proc); XEvent dummy; @@ -212,7 +212,7 @@ QPlatformOffscreenSurface *QXcbGlxIntegration::createPlatformOffscreenSurface(QO if (glxPbufferUsable) return new QGLXPbuffer(surface); else - return 0; // trigger fallback to hidden QWindow + return nullptr; // trigger fallback to hidden QWindow } diff --git a/src/plugins/platforms/xcb/qxcbatom.cpp b/src/plugins/platforms/xcb/qxcbatom.cpp index ecb73cb90b..79b5ba06e6 100644 --- a/src/plugins/platforms/xcb/qxcbatom.cpp +++ b/src/plugins/platforms/xcb/qxcbatom.cpp @@ -265,7 +265,7 @@ void QXcbAtom::initializeAllAtoms(xcb_connection_t *connection) { cookies[i] = xcb_intern_atom(connection, false, strlen(names[i]), names[i]); for (i = 0; i < QXcbAtom::NAtoms; ++i) { - xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, cookies[i], 0); + xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, cookies[i], nullptr); m_allAtoms[i] = reply->atom; free(reply); } diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index 741317d766..8f55bc2e96 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -229,7 +229,7 @@ void QXcbBackingStoreImage::resize(const QSize &size) m_xcb_format->bits_per_pixel, 0, byteOrder, XCB_IMAGE_ORDER_MSB_FIRST, - 0, ~0, 0); + nullptr, ~0, nullptr); const size_t segmentSize = imageDataSize(m_xcb_image); @@ -412,13 +412,13 @@ bool QXcbBackingStoreImage::createSystemVShmSegment(xcb_connection_t *c, size_t return false; } - void *addr = shmat(id, 0, 0); + void *addr = shmat(id, nullptr, 0); if (addr == (void *)-1) { qCWarning(lcQpaXcb, "shmat() failed (%d: %s) for id %d", errno, strerror(errno), id); return false; } - if (shmctl(id, IPC_RMID, 0) == -1) + if (shmctl(id, IPC_RMID, nullptr) == -1) qCWarning(lcQpaXcb, "Error while marking the shared memory segment to be destroyed"); const auto seg = xcb_generate_id(c); @@ -780,7 +780,7 @@ QXcbBackingStore::~QXcbBackingStore() QPaintDevice *QXcbBackingStore::paintDevice() { if (!m_image) - return 0; + return nullptr; return m_rgbImage.isNull() ? m_image->image() : &m_rgbImage; } @@ -1036,7 +1036,7 @@ void QXcbSystemTrayBackingStore::recreateImage(QXcbWindow *win, const QSize &siz xcb_create_pixmap(xcb_connection(), 32, m_xrenderPixmap, screen->root(), size.width(), size.height()); m_xrenderPicture = xcb_generate_id(xcb_connection()); - xcb_render_create_picture(xcb_connection(), m_xrenderPicture, m_xrenderPixmap, m_xrenderPictFormat, 0, 0); + xcb_render_create_picture(xcb_connection(), m_xrenderPicture, m_xrenderPixmap, m_xrenderPictFormat, 0, nullptr); // XRender expects premultiplied alpha if (m_image) @@ -1077,7 +1077,7 @@ void QXcbSystemTrayBackingStore::initXRenderMode() m_windowPicture = xcb_generate_id(conn); xcb_void_cookie_t cookie = - xcb_render_create_picture_checked(conn, m_windowPicture, platformWindow->xcb_window(), vfmt->format, 0, 0); + xcb_render_create_picture_checked(conn, m_windowPicture, platformWindow->xcb_window(), vfmt->format, 0, nullptr); xcb_generic_error_t *error = xcb_request_check(conn, cookie); if (error) { qWarning("QXcbSystemTrayBackingStore: Failed to create Picture with format %x for window %x, error code %d", diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp index 2cb6720d40..c2d9d060fb 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.cpp +++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp @@ -226,8 +226,8 @@ QXcbClipboard::QXcbClipboard(QXcbConnection *c) { Q_ASSERT(QClipboard::Clipboard == 0); Q_ASSERT(QClipboard::Selection == 1); - m_clientClipboard[QClipboard::Clipboard] = 0; - m_clientClipboard[QClipboard::Selection] = 0; + m_clientClipboard[QClipboard::Clipboard] = nullptr; + m_clientClipboard[QClipboard::Selection] = nullptr; m_timestamp[QClipboard::Clipboard] = XCB_CURRENT_TIME; m_timestamp[QClipboard::Selection] = XCB_CURRENT_TIME; m_owner = connection()->getQtSelectionOwner(); @@ -316,7 +316,7 @@ QClipboard::Mode QXcbClipboard::modeForAtom(xcb_atom_t a) const QMimeData * QXcbClipboard::mimeData(QClipboard::Mode mode) { if (mode > QClipboard::Selection) - return 0; + return nullptr; xcb_window_t clipboardOwner = getSelectionOwner(atomForMode(mode)); if (clipboardOwner == owner()) { @@ -334,7 +334,7 @@ void QXcbClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) if (mode > QClipboard::Selection) return; - QXcbClipboardMime *xClipboard = 0; + QXcbClipboardMime *xClipboard = nullptr; // verify if there is data to be cleared on global X Clipboard. if (!data) { xClipboard = qobject_cast(mimeData(mode)); @@ -353,7 +353,7 @@ void QXcbClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) if (m_clientClipboard[mode]) { if (m_clientClipboard[QClipboard::Clipboard] != m_clientClipboard[QClipboard::Selection]) delete m_clientClipboard[mode]; - m_clientClipboard[mode] = 0; + m_clientClipboard[mode] = nullptr; m_timestamp[mode] = XCB_CURRENT_TIME; } @@ -416,7 +416,7 @@ xcb_window_t QXcbClipboard::requestor() const XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class platformScreen->screen()->root_visual, // visual 0, // value mask - 0); // value list + nullptr); // value list QXcbWindow::setWindowTitle(connection(), window, QStringLiteral("Qt Clipboard Requestor Window")); @@ -529,7 +529,7 @@ void QXcbClipboard::handleSelectionClearRequest(xcb_selection_clear_event_t *eve if (newOwner != XCB_NONE) { if (m_clientClipboard[QClipboard::Clipboard] != m_clientClipboard[QClipboard::Selection]) delete m_clientClipboard[mode]; - m_clientClipboard[mode] = 0; + m_clientClipboard[mode] = nullptr; m_timestamp[mode] = XCB_CURRENT_TIME; } } @@ -576,7 +576,7 @@ void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req) xcb_atom_t multipleAtom = atom(QXcbAtom::MULTIPLE); xcb_atom_t timestampAtom = atom(QXcbAtom::TIMESTAMP); - struct AtomPair { xcb_atom_t target; xcb_atom_t property; } *multi = 0; + struct AtomPair { xcb_atom_t target; xcb_atom_t property; } *multi = nullptr; xcb_atom_t multi_type = XCB_NONE; int multi_format = 0; int nmulti = 0; @@ -587,7 +587,7 @@ void QXcbClipboard::handleSelectionRequest(xcb_selection_request_event_t *req) QByteArray multi_data; if (req->property == XCB_NONE || !clipboardReadProperty(req->requestor, req->property, false, &multi_data, - 0, &multi_type, &multi_format) + nullptr, &multi_type, &multi_format) || multi_format != 32) { // MULTIPLE property not formatted correctly xcb_send_event(xcb_connection(), false, req->requestor, XCB_EVENT_MASK_NO_EVENT, (const char *)&event); @@ -842,7 +842,7 @@ QByteArray QXcbClipboard::clipboardReadIncrementalProperty(xcb_window_t win, xcb continue; prev_time = event->time; - if (clipboardReadProperty(win, property, true, &tmp_buf, &length, 0, 0)) { + if (clipboardReadProperty(win, property, true, &tmp_buf, &length, nullptr, nullptr)) { if (length == 0) { // no more data, we're done if (nullterm) { buf.resize(offset+1); @@ -900,7 +900,7 @@ QByteArray QXcbClipboard::getSelection(xcb_atom_t selection, xcb_atom_t target, return buf; xcb_atom_t type; - if (clipboardReadProperty(win, property, true, &buf, 0, &type, 0)) { + if (clipboardReadProperty(win, property, true, &buf, nullptr, &type, nullptr)) { if (type == atom(QXcbAtom::INCR)) { int nbytes = buf.size() >= 4 ? *((int*)buf.data()) : 0; buf = clipboardReadIncrementalProperty(win, property, nbytes, false); diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index cbc930387f..435c4aee93 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -184,7 +184,7 @@ QXcbWindow *QXcbConnection::platformWindowFromId(xcb_window_t id) QXcbWindowEventListener *listener = m_mapper.value(id, 0); if (listener) return listener->toWindow(); - return 0; + return nullptr; } #define HANDLE_PLATFORM_WINDOW_EVENT(event_t, windowMember, handler) \ @@ -803,7 +803,7 @@ xcb_window_t QXcbConnection::getQtSelectionOwner() XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class xcbScreen->root_visual, // visual 0, // value mask - 0); // value list + nullptr); // value list QXcbWindow::setWindowTitle(connection(), m_qtSelectionOwner, QLatin1String("Qt Selection Owner for ") + QCoreApplication::applicationName()); @@ -830,7 +830,7 @@ xcb_window_t QXcbConnection::clientLeader() 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->screen()->root_visual, - 0, 0); + 0, nullptr); QXcbWindow::setWindowTitle(connection(), m_clientLeader, @@ -1031,7 +1031,7 @@ void QXcbConnection::sync() { // from xcb_aux_sync xcb_get_input_focus_cookie_t cookie = xcb_get_input_focus(xcb_connection()); - free(xcb_get_input_focus_reply(xcb_connection(), cookie, 0)); + free(xcb_get_input_focus_reply(xcb_connection(), cookie, nullptr)); } QXcbSystemTrayTracker *QXcbConnection::systemTrayTracker() const @@ -1049,14 +1049,14 @@ QXcbSystemTrayTracker *QXcbConnection::systemTrayTracker() const Qt::MouseButtons QXcbConnection::queryMouseButtons() const { int stateMask = 0; - QXcbCursor::queryPointer(connection(), 0, 0, &stateMask); + QXcbCursor::queryPointer(connection(), nullptr, nullptr, &stateMask); return translateMouseButtons(stateMask); } Qt::KeyboardModifiers QXcbConnection::queryKeyboardModifiers() const { int stateMask = 0; - QXcbCursor::queryPointer(connection(), 0, 0, &stateMask); + QXcbCursor::queryPointer(connection(), nullptr, nullptr, &stateMask); return keyboard()->translateModifiers(stateMask); } @@ -1114,7 +1114,7 @@ void QXcbSyncWindowRequest::invalidate() { if (m_window) { m_window->clearSyncWindowRequest(); - m_window = 0; + m_window = nullptr; } } @@ -1134,7 +1134,7 @@ void QXcbConnectionGrabber::release() { if (m_connection) { m_connection->ungrabServer(); - m_connection = 0; + m_connection = nullptr; } } diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 62c5e5d79e..2d89b971dc 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -127,7 +127,7 @@ class Q_XCB_EXPORT QXcbConnection : public QXcbBasicConnection { Q_OBJECT public: - QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, xcb_visualid_t defaultVisualId, const char *displayName = 0); + QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, xcb_visualid_t defaultVisualId, const char *displayName = nullptr); ~QXcbConnection(); QXcbConnection *connection() const { return const_cast(this); } diff --git a/src/plugins/platforms/xcb/qxcbconnection_basic.cpp b/src/plugins/platforms/xcb/qxcbconnection_basic.cpp index 1ba4b4a1b9..18dee89adb 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_basic.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_basic.cpp @@ -93,7 +93,7 @@ static int nullErrorHandler(Display *dpy, XErrorEvent *err) static int ioErrorHandler(Display *dpy) { xcb_connection_t *conn = XGetXCBConnection(dpy); - if (conn != NULL) { + if (conn != nullptr) { /* Print a message with a textual description of the error */ int code = xcb_connection_has_error(conn); const char *str = "Unknown error"; @@ -134,7 +134,7 @@ QXcbBasicConnection::QXcbBasicConnection(const char *displayName) xcb_extension_t *extensions[] = { &xcb_shm_id, &xcb_xfixes_id, &xcb_randr_id, &xcb_shape_id, &xcb_sync_id, - &xcb_render_id, &xcb_xkb_id, &xcb_input_id, 0 + &xcb_render_id, &xcb_xkb_id, &xcb_input_id, nullptr }; for (xcb_extension_t **ext_it = extensions; *ext_it; ++ext_it) diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index fdf59c5ef4..bd62460b96 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -166,7 +166,7 @@ void QXcbConnection::xi2SetupDevice(void *info, bool removeExisting) } case XCB_INPUT_DEVICE_CLASS_TYPE_BUTTON: { auto *bci = reinterpret_cast(classinfo); - xcb_atom_t *labels = 0; + xcb_atom_t *labels = nullptr; if (bci->num_buttons >= 5) { labels = xcb_input_button_class_labels(bci); xcb_atom_t label4 = labels[3]; @@ -527,7 +527,7 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event) int sourceDeviceId = xiEvent->deviceid; // may be the master id qt_xcb_input_device_event_t *xiDeviceEvent = nullptr; xcb_input_enter_event_t *xiEnterEvent = nullptr; - QXcbWindowEventListener *eventListener = 0; + QXcbWindowEventListener *eventListener = nullptr; switch (xiEvent->event_type) { case XCB_INPUT_BUTTON_PRESS: diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp index fbadab4d50..639e4f039c 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.cpp +++ b/src/plugins/platforms/xcb/qxcbcursor.cpp @@ -67,10 +67,10 @@ enum { }; #undef CursorShape -static PtrXcursorLibraryLoadCursor ptrXcursorLibraryLoadCursor = 0; -static PtrXcursorLibraryGetTheme ptrXcursorLibraryGetTheme = 0; -static PtrXcursorLibrarySetTheme ptrXcursorLibrarySetTheme = 0; -static PtrXcursorLibraryGetDefaultSize ptrXcursorLibraryGetDefaultSize = 0; +static PtrXcursorLibraryLoadCursor ptrXcursorLibraryLoadCursor = nullptr; +static PtrXcursorLibraryGetTheme ptrXcursorLibraryGetTheme = nullptr; +static PtrXcursorLibrarySetTheme ptrXcursorLibrarySetTheme = nullptr; +static PtrXcursorLibraryGetDefaultSize ptrXcursorLibraryGetDefaultSize = nullptr; #endif static xcb_font_t cursorFont = 0; @@ -118,7 +118,7 @@ static const uint8_t mcur_fdiag_bits[] = { static const uint8_t *cursor_bits16[] = { cur_ver_bits, mcur_ver_bits, cur_hor_bits, mcur_hor_bits, cur_bdiag_bits, mcur_bdiag_bits, cur_fdiag_bits, mcur_fdiag_bits, - 0, 0, cur_blank_bits, cur_blank_bits }; + nullptr, nullptr, cur_blank_bits, cur_blank_bits }; static const uint8_t vsplit_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -219,7 +219,7 @@ static const uint8_t busym_bits[] = { static const uint8_t * const cursor_bits32[] = { vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits, - 0, 0, 0, 0, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits + nullptr, nullptr, nullptr, nullptr, whatsthis_bits, whatsthism_bits, busy_bits, busym_bits }; static const uint8_t forbidden_bits[] = { @@ -452,19 +452,19 @@ xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape) if (cshape == Qt::BlankCursor) { xcb_pixmap_t cp = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), cur_blank_bits, 16, 16, - 1, 0, 0, 0); + 1, 0, 0, nullptr); xcb_pixmap_t mp = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), cur_blank_bits, 16, 16, - 1, 0, 0, 0); + 1, 0, 0, nullptr); cursor = xcb_generate_id(conn); xcb_create_cursor(conn, cursor, cp, mp, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8); } else if (cshape >= Qt::SizeVerCursor && cshape < Qt::SizeAllCursor) { int i = (cshape - Qt::SizeVerCursor) * 2; xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), const_cast(cursor_bits16[i]), - 16, 16, 1, 0, 0, 0); + 16, 16, 1, 0, 0, nullptr); xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), const_cast(cursor_bits16[i + 1]), - 16, 16, 1, 0, 0, 0); + 16, 16, 1, 0, 0, nullptr); cursor = xcb_generate_id(conn); xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8); } else if ((cshape >= Qt::SplitVCursor && cshape <= Qt::SplitHCursor) @@ -472,10 +472,10 @@ xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape) int i = (cshape - Qt::SplitVCursor) * 2; xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), const_cast(cursor_bits32[i]), - 32, 32, 1, 0, 0, 0); + 32, 32, 1, 0, 0, nullptr); xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), const_cast(cursor_bits32[i + 1]), - 32, 32, 1, 0, 0, 0); + 32, 32, 1, 0, 0, nullptr); int hs = (cshape == Qt::PointingHandCursor || cshape == Qt::WhatsThisCursor || cshape == Qt::BusyCursor) ? 0 : 16; cursor = xcb_generate_id(conn); @@ -484,20 +484,20 @@ xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape) int i = (cshape - Qt::ForbiddenCursor) * 2; xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), const_cast(cursor_bits20[i]), - 20, 20, 1, 0, 0, 0); + 20, 20, 1, 0, 0, nullptr); xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), const_cast(cursor_bits20[i + 1]), - 20, 20, 1, 0, 0, 0); + 20, 20, 1, 0, 0, nullptr); cursor = xcb_generate_id(conn); xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 10, 10); } else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) { bool open = cshape == Qt::OpenHandCursor; xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), const_cast(open ? openhand_bits : closedhand_bits), - 16, 16, 1, 0, 0, 0); + 16, 16, 1, 0, 0, nullptr); xcb_pixmap_t pmm = xcb_create_pixmap_from_bitmap_data(conn, m_screen->root(), const_cast(open ? openhandm_bits : closedhandm_bits), - 16, 16, 1, 0, 0, 0); + 16, 16, 1, 0, 0, nullptr); cursor = xcb_generate_id(conn); xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8); } else if (cshape == Qt::DragCopyCursor || cshape == Qt::DragMoveCursor @@ -660,14 +660,14 @@ void QXcbCursor::queryPointer(QXcbConnection *c, QXcbVirtualDesktop **virtualDes QPoint QXcbCursor::pos() const { QPoint p; - queryPointer(connection(), 0, &p); + queryPointer(connection(), nullptr, &p); return p; } void QXcbCursor::setPos(const QPoint &pos) { QXcbVirtualDesktop *virtualDesktop = nullptr; - queryPointer(connection(), &virtualDesktop, 0); + queryPointer(connection(), &virtualDesktop, nullptr); xcb_warp_pointer(xcb_connection(), XCB_NONE, virtualDesktop->root(), 0, 0, 0, 0, pos.x(), pos.y()); xcb_flush(xcb_connection()); } diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index eb5b8f808e..47d58fa880 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -148,7 +148,7 @@ void QXcbDrag::init() source_time = XCB_CURRENT_TIME; target_time = XCB_CURRENT_TIME; - QXcbCursor::queryPointer(connection(), ¤t_virtual_desktop, 0); + QXcbCursor::queryPointer(connection(), ¤t_virtual_desktop, nullptr); drag_types.clear(); //current_embedding_widget = 0; @@ -384,13 +384,13 @@ void QXcbDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardMod if (!findXdndAwareTarget(globalPos, &target)) return; - QXcbWindow *w = 0; + QXcbWindow *w = nullptr; if (target) { w = connection()->platformWindowFromId(target); if (w && (w->window()->type() == Qt::Desktop) /*&& !w->acceptDrops()*/) - w = 0; + w = nullptr; } else { - w = 0; + w = nullptr; target = current_virtual_desktop->root(); } @@ -522,7 +522,7 @@ void QXcbDrag::drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardMod QXcbWindow *w = connection()->platformWindowFromId(current_proxy_target); if (w && w->window()->type() == Qt::Desktop) // && !w->acceptDrops() - w = 0; + w = nullptr; Transaction t = { connection()->time(), @@ -716,7 +716,7 @@ void QXcbDrag::handle_xdnd_position(QPlatformWindow *w, const xcb_client_message target_time = e->data.data32[3]; } - QMimeData *dropData = 0; + QMimeData *dropData = nullptr; Qt::DropActions supported_actions = Qt::IgnoreAction; if (currentDrag()) { dropData = currentDrag()->mimeData(); @@ -911,7 +911,7 @@ void QXcbDrag::send_leave() QXcbWindow *w = connection()->platformWindowFromId(current_proxy_target); if (w && (w->window()->type() == Qt::Desktop) /*&& !w->acceptDrops()*/) - w = 0; + w = nullptr; qCDebug(lcQpaXDnd) << "sending XdndLeave to target:" << current_target; @@ -945,7 +945,7 @@ void QXcbDrag::handleDrop(QPlatformWindow *, const xcb_client_message_event_t *e target_time = l[2]; Qt::DropActions supported_drop_actions; - QMimeData *dropData = 0; + QMimeData *dropData = nullptr; if (currentDrag()) { dropData = currentDrag()->mimeData(); supported_drop_actions = Qt::DropActions(l[4]); @@ -1152,7 +1152,7 @@ void QXcbDrag::handleSelectionRequest(const xcb_selection_request_event_t *event } } - QDrag *transactionDrag = 0; + QDrag *transactionDrag = nullptr; if (at >= 0) { transactionDrag = transactions.at(at).drag; } else if (at == -2) { @@ -1222,7 +1222,7 @@ bool QXcbDrag::dndEnable(QXcbWindow *w, bool on) if (w->window()->type() == Qt::Desktop) { xcb_delete_property(xcb_connection(), w->xcb_window(), atom(QXcbAtom::XdndProxy)); delete desktop_proxy; - desktop_proxy = 0; + desktop_proxy = nullptr; } else { qCDebug(lcQpaXDnd) << "not deleting XDndAware"; } diff --git a/src/plugins/platforms/xcb/qxcbimage.cpp b/src/plugins/platforms/xcb/qxcbimage.cpp index 8f33e6ed31..b0e610dd51 100644 --- a/src/plugins/platforms/xcb/qxcbimage.cpp +++ b/src/plugins/platforms/xcb/qxcbimage.cpp @@ -221,7 +221,7 @@ xcb_pixmap_t qt_xcb_XPixmapFromBitmap(QXcbScreen *screen, const QImage &image) for (int i = 0; i < height; i++) memcpy(buf + (destLineSize * i), map + (bytesPerLine * i), destLineSize); xcb_pixmap_t pm = xcb_create_pixmap_from_bitmap_data(conn, screen->root(), buf, - width, height, 1, 0, 0, 0); + width, height, 1, 0, 0, nullptr); delete[] buf; return pm; } @@ -249,7 +249,7 @@ xcb_cursor_t qt_xcb_createCursorXRender(QXcbScreen *screen, const QImage &image, 32, 32, 32, 32, QSysInfo::ByteOrder == QSysInfo::BigEndian ? XCB_IMAGE_ORDER_MSB_FIRST : XCB_IMAGE_ORDER_LSB_FIRST, XCB_IMAGE_ORDER_MSB_FIRST, - 0, 0, 0); + nullptr, 0, nullptr); if (!xi) { qWarning("qt_xcb_createCursorXRender: xcb_image_create failed"); return XCB_NONE; @@ -266,10 +266,10 @@ xcb_cursor_t qt_xcb_createCursorXRender(QXcbScreen *screen, const QImage &image, xcb_create_pixmap(conn, 32, pix, screen->root(), w, h); xcb_render_picture_t pic = xcb_generate_id(conn); - xcb_render_create_picture(conn, pic, pix, fmt->id, 0, 0); + xcb_render_create_picture(conn, pic, pix, fmt->id, 0, nullptr); xcb_gcontext_t gc = xcb_generate_id(conn); - xcb_create_gc(conn, gc, pix, 0, 0); + xcb_create_gc(conn, gc, pix, 0, nullptr); xcb_image_put(conn, pix, gc, xi, 0, 0, 0); xcb_free_gc(conn, gc); diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index efda6b67ce..3fd989e1f9 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -130,7 +130,7 @@ QXcbIntegration *QXcbIntegration::m_instance = nullptr; QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char **argv) : m_services(new QGenericUnixServices) - , m_instanceName(0) + , m_instanceName(nullptr) , m_canGrab(true) , m_defaultVisualId(UINT_MAX) { @@ -146,7 +146,7 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char m_nativeInterface.reset(new QXcbNativeInterface); // Parse arguments - const char *displayName = 0; + const char *displayName = nullptr; bool noGrabArg = false; bool doGrabArg = false; if (argc) { diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 3caee3f409..e8286381a2 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -579,7 +579,7 @@ void QXcbKeyboard::selectEvents() required_events, required_map_parts, required_map_parts, - 0); + nullptr); xcb_generic_error_t *error = xcb_request_check(xcb_connection(), select); if (error) { @@ -620,7 +620,7 @@ void QXcbKeyboard::updateVModMapping() vmod_mask = name_reply->virtualMods; // find the virtual modifiers for which names are defined. for (bit = 1; vmod_mask; bit <<= 1) { - vmod_name = 0; + vmod_name = nullptr; if (!(vmod_mask & bit)) continue; diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index 81b889a80f..30fa6864ac 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -268,7 +268,7 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QXcbNativeInterfa if (lowerCaseResource == "peekeventqueue") return NativeResourceForIntegrationFunction(reinterpret_cast(peekEventQueue)); - return 0; + return nullptr; } QPlatformNativeInterface::NativeResourceForContextFunction QXcbNativeInterface::nativeResourceFunctionForContext(const QByteArray &resource) @@ -291,7 +291,7 @@ QPlatformNativeInterface::NativeResourceForScreenFunction QXcbNativeInterface::n return NativeResourceForScreenFunction(reinterpret_cast(setAppTime)); else if (lowerCaseResource == "setappusertime") return NativeResourceForScreenFunction(reinterpret_cast(setAppUserTime)); - return 0; + return nullptr; } QPlatformNativeInterface::NativeResourceForWindowFunction QXcbNativeInterface::nativeResourceFunctionForWindow(const QByteArray &resource) @@ -365,7 +365,7 @@ void *QXcbNativeInterface::startupId() QXcbConnection *defaultConnection = integration->defaultConnection(); if (defaultConnection) return reinterpret_cast(const_cast(defaultConnection->startupId().constData())); - return 0; + return nullptr; } void *QXcbNativeInterface::x11Screen() @@ -374,7 +374,7 @@ void *QXcbNativeInterface::x11Screen() QXcbConnection *defaultConnection = integration->defaultConnection(); if (defaultConnection) return reinterpret_cast(defaultConnection->primaryScreenNumber()); - return 0; + return nullptr; } void *QXcbNativeInterface::rootWindow() @@ -383,7 +383,7 @@ void *QXcbNativeInterface::rootWindow() QXcbConnection *defaultConnection = integration->defaultConnection(); if (defaultConnection) return reinterpret_cast(defaultConnection->rootWindow()); - return 0; + return nullptr; } void *QXcbNativeInterface::display() diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 8da299d491..8bcaa78122 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -318,7 +318,7 @@ bool QXcbVirtualDesktop::xResource(const QByteArray &identifier, static bool parseXftInt(const QByteArray& stringValue, int *value) { - Q_ASSERT(value != 0); + Q_ASSERT(value != nullptr); bool ok; *value = stringValue.toInt(&ok); return ok; @@ -457,7 +457,7 @@ const xcb_visualtype_t *QXcbVirtualDesktop::visualForId(xcb_visualid_t visualid) { QMap::const_iterator it = m_visuals.find(visualid); if (it == m_visuals.constEnd()) - return 0; + return nullptr; return &*it; } @@ -577,7 +577,7 @@ QWindow *QXcbScreen::topLevelAt(const QPoint &p) const do { auto translate_reply = Q_XCB_REPLY_UNCHECKED(xcb_translate_coordinates, xcb_connection(), parent, child, x, y); if (!translate_reply) { - return 0; + return nullptr; } parent = child; @@ -586,14 +586,14 @@ QWindow *QXcbScreen::topLevelAt(const QPoint &p) const y = translate_reply->dst_y; if (!child || child == root) - return 0; + return nullptr; QPlatformWindow *platformWindow = connection()->platformWindowFromId(child); if (platformWindow) return platformWindow->window(); } while (parent != child); - return 0; + return nullptr; } void QXcbScreen::windowShown(QXcbWindow *window) diff --git a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp index f880d4d722..2eb32c069e 100644 --- a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp +++ b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp @@ -69,7 +69,7 @@ public Q_SLOTS: }; -static SmcConn smcConnection = 0; +static SmcConn smcConnection = nullptr; static bool sm_interactionActive; static bool sm_smActive; static int sm_interactStyle; @@ -81,7 +81,7 @@ static bool sm_phase2; static bool sm_in_phase2; bool qt_sm_blockUserInput = false; -static QSmSocketReceiver* sm_receiver = 0; +static QSmSocketReceiver* sm_receiver = nullptr; static void resetSmState(); static void sm_setProperty(const char *name, const char *type, @@ -191,7 +191,7 @@ static void sm_performSaveYourself(QXcbSessionManager *sm) // generate a new session key timeval tv; - gettimeofday(&tv, 0); + gettimeofday(&tv, nullptr); sm->setSessionKey(QString::number(qulonglong(tv.tv_sec)) + QLatin1Char('_') + QString::number(qulonglong(tv.tv_usec))); @@ -203,7 +203,7 @@ static void sm_performSaveYourself(QXcbSessionManager *sm) // tell the session manager about our program in best POSIX style sm_setProperty(QString::fromLatin1(SmProgram), argument0); // tell the session manager about our user as well. - struct passwd *entryPtr = 0; + struct passwd *entryPtr = nullptr; #if defined(_POSIX_THREAD_SAFE_FUNCTIONS) && (_POSIX_THREAD_SAFE_FUNCTIONS - 0 > 0) QVarLengthArray buf(qMax(sysconf(_SC_GETPW_R_SIZE_MAX), 1024L)); struct passwd entry; @@ -329,7 +329,7 @@ static void sm_saveYourselfPhase2Callback(SmcConn smcConn, SmPointer clientData) void QSmSocketReceiver::socketActivated(int) { - IceProcessMessages(SmcGetIceConnection(smcConnection), 0, 0); + IceProcessMessages(SmcGetIceConnection(smcConnection), nullptr, nullptr); } @@ -337,11 +337,11 @@ void QSmSocketReceiver::socketActivated(int) QXcbSessionManager::QXcbSessionManager(const QString &id, const QString &key) : QPlatformSessionManager(id, key) - , m_eventLoop(0) + , m_eventLoop(nullptr) { resetSmState(); char cerror[256]; - char* myId = 0; + char* myId = nullptr; QByteArray b_id = id.toLatin1(); char* prevId = b_id.data(); @@ -359,7 +359,7 @@ QXcbSessionManager::QXcbSessionManager(const QString &id, const QString &key) if (!qEnvironmentVariableIsSet("SESSION_MANAGER")) return; - smcConnection = SmcOpenConnection(0, 0, 1, 0, + smcConnection = SmcOpenConnection(nullptr, nullptr, 1, 0, SmcSaveYourselfProcMask | SmcDieProcMask | SmcSaveCompleteProcMask | @@ -382,8 +382,8 @@ QXcbSessionManager::QXcbSessionManager(const QString &id, const QString &key) QXcbSessionManager::~QXcbSessionManager() { if (smcConnection) - SmcCloseConnection(smcConnection, 0, 0); - smcConnection = 0; + SmcCloseConnection(smcConnection, 0, nullptr); + smcConnection = nullptr; delete sm_receiver; } @@ -411,7 +411,7 @@ bool QXcbSessionManager::allowsInteraction() QEventLoop eventLoop; m_eventLoop = &eventLoop; eventLoop.exec(); - m_eventLoop = 0; + m_eventLoop = nullptr; sm_waitingForInteraction = false; if (sm_smActive) { // not cancelled @@ -441,7 +441,7 @@ bool QXcbSessionManager::allowsErrorInteraction() QEventLoop eventLoop; m_eventLoop = &eventLoop; eventLoop.exec(); - m_eventLoop = 0; + m_eventLoop = nullptr; sm_waitingForInteraction = false; if (sm_smActive) { // not cancelled diff --git a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp index 684e603fab..ff5ad98cd2 100644 --- a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp +++ b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp @@ -64,11 +64,11 @@ QXcbSystemTrayTracker *QXcbSystemTrayTracker::create(QXcbConnection *connection) // Selection, tray atoms for GNOME, NET WM Specification const xcb_atom_t trayAtom = connection->atom(QXcbAtom::_NET_SYSTEM_TRAY_OPCODE); if (!trayAtom) - return 0; + return nullptr; const QByteArray netSysTray = QByteArrayLiteral("_NET_SYSTEM_TRAY_S") + QByteArray::number(connection->primaryScreenNumber()); const xcb_atom_t selection = connection->internAtom(netSysTray.constData()); if (!selection) - return 0; + return nullptr; return new QXcbSystemTrayTracker(connection, trayAtom, selection); } diff --git a/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp b/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp index b3f8a5832d..7c15882768 100644 --- a/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp +++ b/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp @@ -93,7 +93,7 @@ bool QXcbVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevice, VkSurfaceKHR QXcbVulkanInstance::createSurface(QXcbWindow *window) { - VkSurfaceKHR surface = 0; + VkSurfaceKHR surface = nullptr; if (!m_createSurface) { m_createSurface = reinterpret_cast( diff --git a/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp b/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp index 25bc340f97..17d7d9791e 100644 --- a/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE QXcbVulkanWindow::QXcbVulkanWindow(QWindow *window) : QXcbWindow(window), - m_surface(0) + m_surface(nullptr) { } diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index f505ddbd1e..66030b9ad4 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -174,13 +174,13 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s) { #include - static XTextProperty tp = { 0, 0, 0, 0 }; + static XTextProperty tp = { nullptr, 0, 0, 0 }; static bool free_prop = true; // we can't free tp.value in case it references // the data of the static QByteArray below. if (tp.value) { if (free_prop) XFree(tp.value); - tp.value = 0; + tp.value = nullptr; free_prop = true; } @@ -191,7 +191,7 @@ static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s) QByteArray mapped = mapper->fromUnicode(s); char* tl[2]; tl[0] = mapped.data(); - tl[1] = 0; + tl[1] = nullptr; errCode = XmbTextListToTextProperty(dpy, tl, 1, XStdICCTextStyle, &tp); if (errCode < 0) qCDebug(lcQpaXcb, "XmbTextListToTextProperty result code %d", errCode); @@ -280,7 +280,7 @@ void QXcbWindow::create() m_window = platformScreen->root(); m_depth = platformScreen->screen()->root_depth; m_visualId = platformScreen->screen()->root_visual; - const xcb_visualtype_t *visual = 0; + const xcb_visualtype_t *visual = nullptr; if (connection()->hasDefaultVisualId()) { visual = platformScreen->visualForId(connection()->defaultVisualId()); if (visual) @@ -819,7 +819,7 @@ bool QXcbWindow::relayFocusToModalWindow() const while (w && w->parent()) w = w->parent(); - QWindow *modalWindow = 0; + QWindow *modalWindow = nullptr; const bool blocked = QGuiApplicationPrivate::instance()->isWindowBlocked(w, &modalWindow); if (blocked && modalWindow != w) { modalWindow->requestActivate(); @@ -1193,7 +1193,7 @@ void QXcbWindow::updateNetWmUserTime(xcb_timestamp_t timestamp) XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class m_visualId, // visual 0, // value mask - 0); // value list + nullptr); // value list wid = m_netWmUserTimeWindow; xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_USER_TIME_WINDOW), XCB_ATOM_WINDOW, 32, 1, &m_netWmUserTimeWindow); @@ -1223,7 +1223,7 @@ void QXcbWindow::setTransparentForMouseEvents(bool transparent) xcb_rectangle_t rectangle; - xcb_rectangle_t *rect = 0; + xcb_rectangle_t *rect = nullptr; int nrect = 0; if (!transparent) { @@ -1882,7 +1882,7 @@ void QXcbWindow::handleButtonPressEvent(int event_x, int event_y, int root_x, in if (m_embedded && !m_trayIconWindow) { if (window() != QGuiApplication::focusWindow()) { const QXcbWindow *container = static_cast(parent()); - Q_ASSERT(container != 0); + Q_ASSERT(container != nullptr); sendXEmbedMessage(container->xcb_window(), XEMBED_REQUEST_FOCUS); } @@ -2087,7 +2087,7 @@ void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource const Qt::MouseButton button = conn->xiToQtMouseButton(ev->detail); - const char *sourceName = 0; + const char *sourceName = nullptr; if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) { const QMetaObject *metaObject = qt_getEnumMetaObject(source); const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(source))); diff --git a/src/plugins/platforms/xcb/qxcbxsettings.cpp b/src/plugins/platforms/xcb/qxcbxsettings.cpp index 88f15e344f..902f196ba9 100644 --- a/src/plugins/platforms/xcb/qxcbxsettings.cpp +++ b/src/plugins/platforms/xcb/qxcbxsettings.cpp @@ -256,7 +256,7 @@ QXcbXSettings::QXcbXSettings(QXcbVirtualDesktop *screen) QXcbXSettings::~QXcbXSettings() { delete d_ptr; - d_ptr = 0; + d_ptr = nullptr; } bool QXcbXSettings::initialized() const diff --git a/src/plugins/platformthemes/gtk3/main.cpp b/src/plugins/platformthemes/gtk3/main.cpp index fb1c425d8e..860fc3a26e 100644 --- a/src/plugins/platformthemes/gtk3/main.cpp +++ b/src/plugins/platformthemes/gtk3/main.cpp @@ -57,7 +57,7 @@ QPlatformTheme *QGtk3ThemePlugin::create(const QString &key, const QStringList & if (!key.compare(QLatin1String(QGtk3Theme::name), Qt::CaseInsensitive)) return new QGtk3Theme; - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp index c64a02fa0c..65564b59a1 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp @@ -165,12 +165,12 @@ void QGtk3Dialog::onResponse(QGtk3Dialog *dialog, int response) void QGtk3Dialog::onParentWindowDestroyed() { // The QGtk3*DialogHelper classes own this object. Make sure the parent doesn't delete it. - setParent(0); + setParent(nullptr); } QGtk3ColorDialogHelper::QGtk3ColorDialogHelper() { - d.reset(new QGtk3Dialog(gtk_color_chooser_dialog_new("", 0))); + d.reset(new QGtk3Dialog(gtk_color_chooser_dialog_new("", nullptr))); connect(d.data(), SIGNAL(accept()), this, SLOT(onAccepted())); connect(d.data(), SIGNAL(reject()), this, SIGNAL(reject())); @@ -238,7 +238,7 @@ void QGtk3ColorDialogHelper::applyOptions() QGtk3FileDialogHelper::QGtk3FileDialogHelper() { - d.reset(new QGtk3Dialog(gtk_file_chooser_dialog_new("", 0, + d.reset(new QGtk3Dialog(gtk_file_chooser_dialog_new("", nullptr, GTK_FILE_CHOOSER_ACTION_OPEN, qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Cancel)), GTK_RESPONSE_CANCEL, qUtf8Printable(QGtk3Theme::defaultStandardButtonText(QPlatformDialogHelper::Ok)), GTK_RESPONSE_OK, @@ -497,7 +497,7 @@ void QGtk3FileDialogHelper::setNameFilters(const QStringList &filters) QGtk3FontDialogHelper::QGtk3FontDialogHelper() { - d.reset(new QGtk3Dialog(gtk_font_chooser_dialog_new("", 0))); + d.reset(new QGtk3Dialog(gtk_font_chooser_dialog_new("", nullptr))); connect(d.data(), SIGNAL(accept()), this, SLOT(onAccepted())); connect(d.data(), SIGNAL(reject()), this, SIGNAL(reject())); diff --git a/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/src/plugins/platformthemes/gtk3/qgtk3menu.cpp index 4f0bd9d9a0..d9d117faeb 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3menu.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3menu.cpp @@ -200,7 +200,7 @@ void QGtk3MenuItem::setMenu(QPlatformMenu *menu) { m_menu = qobject_cast(menu); if (GTK_IS_MENU_ITEM(m_item)) - gtk_menu_item_set_submenu(GTK_MENU_ITEM(m_item), m_menu ? m_menu->handle() : NULL); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(m_item), m_menu ? m_menu->handle() : nullptr); } bool QGtk3MenuItem::isVisible() const @@ -436,7 +436,7 @@ void QGtk3Menu::showPopup(const QWindow *parentWindow, const QRect &targetRect, if (pw) m_targetPos = pw->mapToGlobal(m_targetPos); - gtk_menu_popup(GTK_MENU(m_menu), NULL, NULL, qt_gtk_menu_position_func, this, 0, gtk_get_current_event_time()); + gtk_menu_popup(GTK_MENU(m_menu), nullptr, nullptr, qt_gtk_menu_position_func, this, 0, gtk_get_current_event_time()); } void QGtk3Menu::dismiss() diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp index 077955eb4e..93520344f8 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp @@ -86,9 +86,9 @@ QGtk3Theme::QGtk3Theme() { // gtk_init will reset the Xlib error handler, and that causes // Qt applications to quit on X errors. Therefore, we need to manually restore it. - int (*oldErrorHandler)(Display *, XErrorEvent *) = XSetErrorHandler(NULL); + int (*oldErrorHandler)(Display *, XErrorEvent *) = XSetErrorHandler(nullptr); - gtk_init(0, 0); + gtk_init(nullptr, nullptr); XSetErrorHandler(oldErrorHandler); @@ -99,7 +99,7 @@ QGtk3Theme::QGtk3Theme() g_type_ensure(PANGO_TYPE_FONT_FACE); /* Use our custom log handler. */ - g_log_set_handler("Gtk", G_LOG_LEVEL_MESSAGE, gtkMessageHandler, NULL); + g_log_set_handler("Gtk", G_LOG_LEVEL_MESSAGE, gtkMessageHandler, nullptr); } static inline QVariant gtkGetLongPressTime() @@ -173,7 +173,7 @@ QPlatformDialogHelper *QGtk3Theme::createPlatformDialogHelper(DialogType type) c case FontDialog: return new QGtk3FontDialogHelper; default: - return 0; + return nullptr; } } @@ -197,7 +197,7 @@ bool QGtk3Theme::useNativeFileDialog() * dialogs entirely since we can't avoid creation of a platform * dialog helper. */ - return gtk_check_version(3, 15, 5) == 0; + return gtk_check_version(3, 15, 5) == nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql_p.h b/src/plugins/sqldrivers/mysql/qsql_mysql_p.h index 48b04fb1f5..9ccc8f4e4f 100644 --- a/src/plugins/sqldrivers/mysql/qsql_mysql_p.h +++ b/src/plugins/sqldrivers/mysql/qsql_mysql_p.h @@ -75,8 +75,8 @@ class Q_EXPORT_SQLDRIVER_MYSQL QMYSQLDriver : public QSqlDriver Q_DECLARE_PRIVATE(QMYSQLDriver) Q_OBJECT public: - explicit QMYSQLDriver(QObject *parent=0); - explicit QMYSQLDriver(MYSQL *con, QObject * parent=0); + explicit QMYSQLDriver(QObject *parent=nullptr); + explicit QMYSQLDriver(MYSQL *con, QObject * parent=nullptr); ~QMYSQLDriver(); bool hasFeature(DriverFeature f) const override; bool open(const QString & db, diff --git a/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h b/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h index 48c64536f1..57db0a4d47 100644 --- a/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h +++ b/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h @@ -76,8 +76,8 @@ class Q_EXPORT_SQLDRIVER_SQLITE2 QSQLite2Driver : public QSqlDriver Q_DECLARE_PRIVATE(QSQLite2Driver) Q_OBJECT public: - explicit QSQLite2Driver(QObject *parent = 0); - explicit QSQLite2Driver(sqlite *connection, QObject *parent = 0); + explicit QSQLite2Driver(QObject *parent = nullptr); + explicit QSQLite2Driver(sqlite *connection, QObject *parent = nullptr); ~QSQLite2Driver(); bool hasFeature(DriverFeature f) const override; bool open(const QString &db, diff --git a/src/plugins/sqldrivers/tds/qsql_tds_p.h b/src/plugins/sqldrivers/tds/qsql_tds_p.h index 948e3c7024..b72fababbb 100644 --- a/src/plugins/sqldrivers/tds/qsql_tds_p.h +++ b/src/plugins/sqldrivers/tds/qsql_tds_p.h @@ -85,8 +85,8 @@ class Q_EXPORT_SQLDRIVER_TDS QTDSDriver : public QSqlDriver Q_OBJECT friend class QTDSResultPrivate; public: - explicit QTDSDriver(QObject* parent = 0); - QTDSDriver(LOGINREC* rec, const QString& host, const QString &db, QObject* parent = 0); + explicit QTDSDriver(QObject* parent = nullptr); + QTDSDriver(LOGINREC* rec, const QString& host, const QString &db, QObject* parent = nullptr); ~QTDSDriver(); bool hasFeature(DriverFeature f) const override; bool open(const QString &db, -- cgit v1.2.3 From 10f39c908db2e3df933de8fbc553204e9bee65d7 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 7 Dec 2019 20:34:12 +0100 Subject: PSQL: set correct empty QVariant in QPSQLResult::record() Since the QSqlField used to retrieve the data is reused in the loop, the default empty value of the QSqlField is not set for all except the first field since it was implicitly set by QSqlField::setType() only when the value is invalid. Therefore we have to call QSqlField::setValue() directly. Change-Id: I1d3abe4e3c46f6378f9ff25529a79bbe33bb7b74 Reviewed-by: Robert Szefner Reviewed-by: Andy Shaw --- src/plugins/sqldrivers/psql/qsql_psql.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/plugins') diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index 760685f64b..78ede6a0d3 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -838,6 +838,7 @@ QSqlRecord QPSQLResult::record() const } int ptype = PQftype(d->result, i); f.setType(qDecodePSQLType(ptype)); + f.setValue(QVariant(f.type())); // only set in setType() when it's invalid before int len = PQfsize(d->result, i); int precision = PQfmod(d->result, i); -- cgit v1.2.3 From e0a43e348c7af9e8bc5519e7e8a4b7502ad89f3f Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Thu, 21 Nov 2019 11:09:24 -0500 Subject: Register the screen pulse event Future versions of QNX will, by default, require the use of registered events. Currently, event registration is supported but optional. Change-Id: Ie45484d5ca9fa832a28ccf08cb1764cf24262dcc Reviewed-by: Dan Cape Reviewed-by: Samuli Piippo --- .../platforms/qnx/qqnxscreeneventthread.cpp | 24 +++++++++++++++++++--- src/plugins/platforms/qnx/qqnxscreeneventthread.h | 2 ++ 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp b/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp index 1b5f3b4954..491c314488 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventthread.cpp @@ -60,6 +60,18 @@ static const int c_screenCode = _PULSE_CODE_MINAVAIL + 0; static const int c_armCode = _PULSE_CODE_MINAVAIL + 1; static const int c_quitCode = _PULSE_CODE_MINAVAIL + 2; +#if !defined(screen_register_event) +int screen_register_event(screen_context_t, struct sigevent *event) +{ + return MsgRegisterEvent(event, -1); +} + +int screen_unregister_event(struct sigevent *event) +{ + return MsgUnregisterEvent(event); +} +#endif + QQnxScreenEventThread::QQnxScreenEventThread(screen_context_t context) : QThread() , m_screenContext(context) @@ -75,10 +87,14 @@ QQnxScreenEventThread::QQnxScreenEventThread(screen_context_t context) qFatal("QQnxScreenEventThread: Can't continue without a channel connection"); } - struct sigevent screenEvent; - SIGEV_PULSE_INIT(&screenEvent, m_connectionId, SIGEV_PULSE_PRIO_INHERIT, c_screenCode, 0); + SIGEV_PULSE_INIT(&m_screenEvent, m_connectionId, SIGEV_PULSE_PRIO_INHERIT, c_screenCode, 0); + if (screen_register_event(m_screenContext, &m_screenEvent) == -1) { + ConnectDetach(m_connectionId); + ChannelDestroy(m_channelId); + qFatal("QQnxScreenEventThread: Can't continue without a registered event"); + } - screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, &screenEvent); + screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, &m_screenEvent); } QQnxScreenEventThread::~QQnxScreenEventThread() @@ -86,6 +102,8 @@ QQnxScreenEventThread::~QQnxScreenEventThread() // block until thread terminates shutdown(); + screen_notify(m_screenContext, SCREEN_NOTIFY_EVENT, nullptr, nullptr); + screen_unregister_event(&m_screenEvent); ConnectDetach(m_connectionId); ChannelDestroy(m_channelId); } diff --git a/src/plugins/platforms/qnx/qqnxscreeneventthread.h b/src/plugins/platforms/qnx/qqnxscreeneventthread.h index 3c8d197545..e5b762369c 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventthread.h +++ b/src/plugins/platforms/qnx/qqnxscreeneventthread.h @@ -45,6 +45,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -73,6 +74,7 @@ private: int m_channelId; int m_connectionId; + struct sigevent m_screenEvent; screen_context_t m_screenContext; bool m_emitNeededOnNextScreenPulse = true; int m_screenPulsesSinceLastArmPulse = 0; -- cgit v1.2.3 From baed8534bc1dac36a9d0ef4240fc14398076a192 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 5 Nov 2019 14:06:46 +0100 Subject: Move the tooltip out of the way of very large mouse cursors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users that have large mouse pointers configured in their settings can not see tooltips, as they are obscured by the pointer. Native applications on Windows and macOS have the same problem, which includes the tooltips for the minimize/maximize/close controls in the window frame of e.g. Explorer. Introduce QPlatformCursor::size that returns a value that is based on the user's settings, or a default value. We can then use that value to move the tooltip out of the way. On Windows, the calculation of the cursor size is based on experimenting with the settings, which are in logical independent pixels. The placement of the tooltip attempts to keep existing behavior, and to not end up with a tooltip that's very far away from the tip of the arrow even for very large mouse cursors. [ChangeLog][QtWidgets][QToolTip] Make sure that the tooltip is not obscured by very large mouse pointers on Windows and macOS. Change-Id: I8e13b7a166bfe8b59cef4765c950f90fefeaef9d Fixes: QTBUG-79627 Reviewed-by: Friedemann Kleint Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoacursor.h | 3 +++ src/plugins/platforms/cocoa/qcocoacursor.mm | 25 ++++++++++++++++++++++++ src/plugins/platforms/windows/qwindowscursor.cpp | 25 ++++++++++++++++++++++++ src/plugins/platforms/windows/qwindowscursor.h | 2 ++ 4 files changed, 55 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoacursor.h b/src/plugins/platforms/cocoa/qcocoacursor.h index 58b9ef2151..5b008eff35 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.h +++ b/src/plugins/platforms/cocoa/qcocoacursor.h @@ -56,6 +56,9 @@ public: void changeCursor(QCursor *cursor, QWindow *window) override; QPoint pos() const override; void setPos(const QPoint &position) override; + + QSize size() const override; + private: QHash m_cursors; NSCursor *convertCursor(QCursor *cursor); diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm index 87a57c78c8..e0d623fc4c 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.mm +++ b/src/plugins/platforms/cocoa/qcocoacursor.mm @@ -85,6 +85,31 @@ void QCocoaCursor::setPos(const QPoint &position) CFRelease(e); } + +QSize QCocoaCursor::size() const +{ + NSCursor *cocoaCursor = NSCursor.currentSystemCursor; + if (!cocoaCursor) + return QPlatformCursor::size(); + NSImage *cursorImage = cocoaCursor.image; + if (!cursorImage) + return QPlatformCursor::size(); + + QSizeF size = QSizeF::fromCGSize(cursorImage.size); + NSUserDefaults *defaults = NSUserDefaults.standardUserDefaults; + NSDictionary *accessSettings = [defaults persistentDomainForName:@"com.apple.universalaccess"]; + if (accessSettings == nil) + return size.toSize(); + + float sizeScale = [accessSettings[@"mouseDriverCursorSize"] floatValue]; + if (sizeScale > 0) { + size.rwidth() *= sizeScale; + size.rheight() *= sizeScale; + } + + return size.toSize(); +} + NSCursor *QCocoaCursor::convertCursor(QCursor *cursor) { if (!cursor) diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp index 17e8cffb76..59457f1720 100644 --- a/src/plugins/platforms/windows/qwindowscursor.cpp +++ b/src/plugins/platforms/windows/qwindowscursor.cpp @@ -50,6 +50,7 @@ #include #include // getPixmapCursor() #include +#include #include #include @@ -686,6 +687,30 @@ void QWindowsCursor::setPos(const QPoint &pos) SetCursorPos(pos.x() , pos.y()); } +/* + The standard size is 32x32, even though the cursor is actually just + 16 pixels large. If a large cursor is set in the accessibility settings, + then the cursor increases with 8 pixels for each step. +*/ +QSize QWindowsCursor::size() const +{ + const QPair cursorSizeSetting = + QWinRegistryKey(HKEY_CURRENT_USER, LR"(Control Panel\Cursors)") + .dwordValue(L"CursorBaseSize"); + const int baseSize = screenCursorSize(m_screen).width() / 2; + if (!cursorSizeSetting.second) + return QSize(baseSize / 2, baseSize / 2); + + // The registry values are dpi-independent, so we need to scale the result. + int cursorSizeValue = cursorSizeSetting.first * m_screen->logicalDpi().first + / m_screen->logicalBaseDpi().first; + + // map from registry value 32-256 to 0-14, and from there to pixels + cursorSizeValue = (cursorSizeValue - 2 * baseSize) / baseSize; + const int cursorSize = baseSize + cursorSizeValue * (baseSize / 2); + return QSize(cursorSize, cursorSize); +} + QPixmap QWindowsCursor::dragDefaultCursor(Qt::DropAction action) const { switch (action) { diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h index b896f4c7a9..cf3635bd6b 100644 --- a/src/plugins/platforms/windows/qwindowscursor.h +++ b/src/plugins/platforms/windows/qwindowscursor.h @@ -113,6 +113,8 @@ public: QPoint pos() const override; void setPos(const QPoint &pos) override; + QSize size() const override; + static HCURSOR createPixmapCursor(QPixmap pixmap, const QPoint &hotSpot, qreal scaleFactor = 1); static HCURSOR createPixmapCursor(const PixmapCursor &pc, qreal scaleFactor = 1) { return createPixmapCursor(pc.pixmap, pc.hotSpot, scaleFactor); } static PixmapCursor customCursor(Qt::CursorShape cursorShape, const QPlatformScreen *screen = nullptr); -- cgit v1.2.3 From c978de990b6c448184e13a3c45d9aa268492b48a Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Wed, 26 Jun 2019 13:23:12 +1000 Subject: wasm: set focus on canvas on new screen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows user to utilize the application without having to click on it first to cause the focus-in event. Change-Id: Ibc9582254dda91eb14ebcdf4b8ea4a4f862aa88d Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/qwasmscreen.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/qwasmscreen.cpp b/src/plugins/platforms/wasm/qwasmscreen.cpp index 37f1ea832a..b6c9b9e377 100644 --- a/src/plugins/platforms/wasm/qwasmscreen.cpp +++ b/src/plugins/platforms/wasm/qwasmscreen.cpp @@ -54,6 +54,8 @@ QWasmScreen::QWasmScreen(const QString &canvasId) m_compositor = new QWasmCompositor(this); m_eventTranslator = new QWasmEventTranslator(this); updateQScreenAndCanvasRenderSize(); + emscripten::val canvas = emscripten::val::global(m_canvasId.toUtf8().constData()); + canvas.call("focus"); } QWasmScreen::~QWasmScreen() -- cgit v1.2.3 From c69a2448ab129d88411a4778f2350dcf971dc623 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 4 Dec 2019 15:06:36 +0100 Subject: macOS: support copying lazily provided data to the clipboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using always EagerRequest type forces the application to provide the data at copy or drag-begin time, even though the data might never be requested (pasted or dropped into another application). For data that is expensive to generate, this is wasteful, and on other platforms Qt uses the functionality provided by the native clipboard to allow for on-demand retrieval of data. Changing the request type to LazyRequest for the cocoa clipboard works, but then we need to make sure that we resolve all promises at shutdown time so that the data is available (which is what the end user expects). Commit ad0d2f463a0905c4705660d96e8a514539c51d36 disabled this for lazy requests to prevent crashes when using drag'n'drop, where the QMacPasteboard object is short-lived and stack allocated. We definitely don't need to worry about lazy data that is not yet retrieved at the end of a drag'n'drop operation, so limit the fix from the previous commit to the drag'n'drop scenario. [ChangeLog][QtGui][QClipboard] Support lazily provided copying of data to the clipboard on macOS Change-Id: Id2203999024a0d9d854d6933d39077cc4af925d0 Fixes: QTBUG-76263 Reviewed-by: Tomi Korpipää Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaclipboard.mm | 2 +- src/plugins/platforms/cocoa/qmacclipboard.mm | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaclipboard.mm b/src/plugins/platforms/cocoa/qcocoaclipboard.mm index a35c153084..141940cc50 100644 --- a/src/plugins/platforms/cocoa/qcocoaclipboard.mm +++ b/src/plugins/platforms/cocoa/qcocoaclipboard.mm @@ -67,7 +67,7 @@ void QCocoaClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) } pasteBoard->sync(); - pasteBoard->setMimeData(data); + pasteBoard->setMimeData(data, QMacPasteboard::LazyRequest); emitChanged(mode); } } diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm index 358a6b49fd..654647b35a 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.mm +++ b/src/plugins/platforms/cocoa/qmacclipboard.mm @@ -138,8 +138,12 @@ QMacPasteboard::QMacPasteboard(CFStringRef name, uchar mt) QMacPasteboard::~QMacPasteboard() { - // commit all promises for paste after exit close - resolvingBeforeDestruction = true; + /* + Commit all promises for paste when shutting down, + unless we are the stack-allocated clipboard used by QCocoaDrag. + */ + if (mime_type == QMacInternalPasteboardMime::MIME_DND) + resolvingBeforeDestruction = true; PasteboardResolvePromises(paste); if (paste) CFRelease(paste); -- cgit v1.2.3 From b209270825cc2c3345d094e3dd547604c64e0b26 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Fri, 6 Dec 2019 20:21:41 +0100 Subject: Windows QPA: Export "checkable" info for menu items through UI Automation In order to allow screen readers to say checked/unchecked for checkable menu items, this information has to be provided through UI Automation. Checkable menu items should implement the "Toggle" UI Automation pattern. The "checkable" state must also be supported by QAccessibleMenuItem, which is being added by a separated change. Task-number: QTBUG-80551 Change-Id: I661668310d1b6b4701d0c0efdb1dcfd15d0db729 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index e5a9f275ae..cc293b777c 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -289,7 +289,8 @@ HRESULT QWindowsUiaMainProvider::GetPatternProvider(PATTERNID idPattern, IUnknow break; case UIA_TogglePatternId: // Checkbox controls. - if (accessible->role() == QAccessible::CheckBox) { + if (accessible->role() == QAccessible::CheckBox + || (accessible->role() == QAccessible::MenuItem && accessible->state().checkable)) { *pRetVal = new QWindowsUiaToggleProvider(id()); } break; -- cgit v1.2.3 From 30e32870a052fda1a23099e46864242e52d94a17 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 4 Dec 2019 14:58:27 +0100 Subject: QCocoaEventDispatcher: make 'interrupt' work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit even if we are currently inside processEvents (apparently called manually and not from QEventLoop::exec()). A carefully crafted application (see, for example, the linked QTBUG or even updated auto-test) can trigger itself into failing to exit the current (potentially nested) event loop. We can harden our Cocoa event dispatcher to detect such condition and properly propagate 'interrupt' to where it'll do its job, indeed, interrupting the real event loop (aka [NSApp run]). This mainly means we have to undo what bool blocker would erroneously do. Also, long live (as people love to say these days) to another tricky (somewhat) auto-test (surely, it's not flaky!). Fixes: QTBUG-79477 Change-Id: I794f0cda23e24d36be67f2bb63d52b74be057c31 Reviewed-by: Volker Hilsheimer Reviewed-by: Qt CI Bot Reviewed-by: Tor Arne Vestbø --- .../platforms/cocoa/qcocoaeventdispatcher.h | 1 + .../platforms/cocoa/qcocoaeventdispatcher.mm | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h index 69587a24be..b8d2532b8e 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.h @@ -186,6 +186,7 @@ public: QAtomicInt serialNumber; int lastSerial; bool interrupt; + bool propagateInterrupt = false; static void postedEventsSourceCallback(void *info); static void waitingObserverCallback(CFRunLoopObserverRef observer, diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index 110c82bf1f..94b9e62eab 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -84,13 +84,12 @@ #include "private/qthread_p.h" #include "private/qguiapplication_p.h" #include +#include #include QT_BEGIN_NAMESPACE -QT_USE_NAMESPACE - static inline CFRunLoopRef mainRunLoop() { return CFRunLoopGetMain(); @@ -348,6 +347,16 @@ static inline void qt_mac_waitForMoreEvents(NSString *runLoopMode = NSDefaultRun bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) { Q_D(QCocoaEventDispatcher); + + // In rare rather corner cases a user's application messes with + // QEventLoop::exec()/exit() and QCoreApplication::processEvents(), + // we have to undo what bool blocker normally does. + d->propagateInterrupt = false; + const auto boolBlockerUndo = qScopeGuard([d](){ + if (d->propagateInterrupt) + d->interrupt = true; + d->propagateInterrupt = false; + }); QBoolBlocker interruptBlocker(d->interrupt, false); bool interruptLater = false; @@ -496,7 +505,16 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) if ((d->processEventsFlags & QEventLoop::EventLoopExec) == 0) { // When called "manually", always process posted events and timers + bool oldInterrupt = d->interrupt; d->processPostedEvents(); + if (!oldInterrupt && d->interrupt && !d->currentModalSession()) { + // We had direct processEvent call, coming not from QEventLoop::exec(). + // One of the posted events triggered an application to interrupt the loop. + // But bool blocker will reset d->interrupt to false, so the real event + // loop will never notice it was interrupted. Now we'll have to fix it by + // enforcing the value of d->interrupt. + d->propagateInterrupt = true; + } retVal = d->processTimers() || retVal; } -- cgit v1.2.3 From 6ffedc07a77a8e3d46851b74cf9456d5abf6f612 Mon Sep 17 00:00:00 2001 From: Robert Szefner Date: Sat, 7 Dec 2019 00:05:47 +0100 Subject: PSQL: Optimize QPSQLResult::data() function for date and time types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Minor performance optimalizations: - No need to check if the date and time are correct because the QDate, QTime and QDateTime parsing functions already perform these checks - No need to add minute part to the UTC offset before parsing the date, because the QDateTime class can parse time zone offset both in form ±hh:mm and ±hh Change-Id: Id74b7ae075135c5c8cf420247c49b5f12fe88899 Reviewed-by: Edward Welbourne --- src/plugins/sqldrivers/psql/qsql_psql.cpp | 34 ++++++++----------------------- 1 file changed, 9 insertions(+), 25 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index 78ede6a0d3..e0f82eee73 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -692,40 +692,24 @@ QVariant QPSQLResult::data(int i) return dbl; } case QVariant::Date: - if (val[0] == '\0') { - return QVariant(QDate()); - } else { #if QT_CONFIG(datestring) - return QVariant(QDate::fromString(QString::fromLatin1(val), Qt::ISODate)); + return QVariant(QDate::fromString(QString::fromLatin1(val), Qt::ISODate)); #else - return QVariant(QString::fromLatin1(val)); + return QVariant(QString::fromLatin1(val)); #endif - } - case QVariant::Time: { - const QString str = QString::fromLatin1(val); + case QVariant::Time: #if QT_CONFIG(datestring) - if (str.isEmpty()) - return QVariant(QTime()); - else - return QVariant(QTime::fromString(str, Qt::ISODate)); + return QVariant(QTime::fromString(QString::fromLatin1(val), Qt::ISODate)); #else - return QVariant(str); + return QVariant(QString::fromLatin1(val)); #endif - } - case QVariant::DateTime: { - QString dtval = QString::fromLatin1(val); + case QVariant::DateTime: #if QT_CONFIG(datestring) - if (dtval.length() < 10) { - return QVariant(QDateTime()); - } else { - QChar sign = dtval[dtval.size() - 3]; - if (sign == QLatin1Char('-') || sign == QLatin1Char('+')) dtval += QLatin1String(":00"); - return QVariant(QDateTime::fromString(dtval, Qt::ISODate).toLocalTime()); - } + return QVariant(QDateTime::fromString(QString::fromLatin1(val), + Qt::ISODate).toLocalTime()); #else - return QVariant(dtval); + return QVariant(QString::fromLatin1(val)); #endif - } case QVariant::ByteArray: { size_t len; unsigned char *data = PQunescapeBytea((const unsigned char*)val, &len); -- cgit v1.2.3 From 5a26bf9d65b75db3abefa967beb13b2510719bd5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 11 Dec 2019 09:30:26 +0100 Subject: Avoid initializing QFlags with 0 or nullptr in macOS-specific code It is being deprecated. Change-Id: If1b0b058140e197d41efae93025c4eefc2ed9bbd Reviewed-by: Allan Sandfeld Jensen --- src/plugins/platforms/cocoa/qcocoatheme.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoatheme.h b/src/plugins/platforms/cocoa/qcocoatheme.h index a00cbdfea3..50e56ef1bf 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.h +++ b/src/plugins/platforms/cocoa/qcocoatheme.h @@ -70,7 +70,7 @@ public: const QPalette *palette(Palette type = SystemPalette) const override; const QFont *font(Font type = SystemFont) const override; QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const override; - QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions options = 0) const override; + QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions options = {}) const override; QVariant themeHint(ThemeHint hint) const override; QString standardButtonText(int button) const override; -- cgit v1.2.3 From 07838840e86a5fb7f81520bb2a31d16f80e51e4c Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 30 Nov 2019 15:06:20 +0100 Subject: Doc/SQL: update sql driver creation instructions Update the instructions on how to build and distribute the mysql and postgresql drivers on windows. Change-Id: Ie4d50c1c34820680d7496b9544eb00fcee17f8e7 Reviewed-by: Andy Shaw --- src/plugins/sqldrivers/README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/sqldrivers/README b/src/plugins/sqldrivers/README index 7000fb5613..26418c5e36 100644 --- a/src/plugins/sqldrivers/README +++ b/src/plugins/sqldrivers/README @@ -1,5 +1,5 @@ -Please note that the DB2, Oracle and TDS client drivers are not distributed -with the Qt Open Source Editions. +Please note that the DB2, MySQL, Oracle and TDS client drivers are not +distributed with the Qt Open Source Editions. This is because the client libraries are distributed under a license which is not compatible with the GPL license. -- cgit v1.2.3 From e076965542148b8c2341fd4418733febbf9ae1ec Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Fri, 16 Aug 2019 15:38:54 -0400 Subject: Move QQnxGLContext::ms_eglDisplay to the integration object In part, this is a continuation of https://codereview.qt-project.org/c/qt/qtbase/+/227953. It also paves the way toward implementing the EglDisplay integration resource needed by QtWayland. For the code that's being moved around and modified, switch from !QT_NO_OPENGL to QT_CONFIG(opengl). Change-Id: I5046e8caf5df7cf326f8e697d7d41cf802250414 Reviewed-by: Dan Cape Reviewed-by: Samuli Piippo --- src/plugins/platforms/qnx/qqnxglcontext.cpp | 27 ++----------------- src/plugins/platforms/qnx/qqnxglcontext.h | 7 ----- src/plugins/platforms/qnx/qqnxintegration.cpp | 37 ++++++++++++++++++++++----- src/plugins/platforms/qnx/qqnxintegration.h | 13 +++++++++- 4 files changed, 45 insertions(+), 39 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/qnx/qqnxglcontext.cpp b/src/plugins/platforms/qnx/qqnxglcontext.cpp index 1d030ba1aa..69391c4fec 100644 --- a/src/plugins/platforms/qnx/qqnxglcontext.cpp +++ b/src/plugins/platforms/qnx/qqnxglcontext.cpp @@ -58,8 +58,6 @@ QT_BEGIN_NAMESPACE -EGLDisplay QQnxGLContext::ms_eglDisplay = EGL_NO_DISPLAY; - static QEGLPlatformContext::Flags makeFlags() { QEGLPlatformContext::Flags result = 0; @@ -71,7 +69,8 @@ static QEGLPlatformContext::Flags makeFlags() } QQnxGLContext::QQnxGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share) - : QEGLPlatformContext(format, share, ms_eglDisplay, 0, QVariant(), makeFlags()) + : QEGLPlatformContext(format, share, QQnxIntegration::instance()->eglDisplay(), 0, QVariant(), + makeFlags()) { } @@ -79,28 +78,6 @@ QQnxGLContext::~QQnxGLContext() { } -void QQnxGLContext::initializeContext() -{ - qGLContextDebug(); - - // Initialize connection to EGL - ms_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (Q_UNLIKELY(ms_eglDisplay == EGL_NO_DISPLAY)) - qFatal("QQnxGLContext: failed to obtain EGL display: %x", eglGetError()); - - EGLBoolean eglResult = eglInitialize(ms_eglDisplay, 0, 0); - if (Q_UNLIKELY(eglResult != EGL_TRUE)) - qFatal("QQnxGLContext: failed to initialize EGL display, err=%d", eglGetError()); -} - -void QQnxGLContext::shutdownContext() -{ - qGLContextDebug(); - - // Close connection to EGL - eglTerminate(ms_eglDisplay); -} - EGLSurface QQnxGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface) { QQnxEglWindow *window = static_cast(surface); diff --git a/src/plugins/platforms/qnx/qqnxglcontext.h b/src/plugins/platforms/qnx/qqnxglcontext.h index 19179a80e2..5d807ee9e4 100644 --- a/src/plugins/platforms/qnx/qqnxglcontext.h +++ b/src/plugins/platforms/qnx/qqnxglcontext.h @@ -58,19 +58,12 @@ public: QQnxGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share); virtual ~QQnxGLContext(); - static void initializeContext(); - static void shutdownContext(); - bool makeCurrent(QPlatformSurface *surface) override; void swapBuffers(QPlatformSurface *surface) override; void doneCurrent() override; protected: EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) override; - -private: - //Can be static because different displays returne the same handle - static EGLDisplay ms_eglDisplay; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp index f479e94988..84baa6ec44 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.cpp +++ b/src/plugins/platforms/qnx/qqnxintegration.cpp @@ -170,6 +170,9 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) #if QT_CONFIG(draganddrop) , m_drag(new QSimpleDrag()) #endif +#if QT_CONFIG(opengl) + , m_eglDisplay(EGL_NO_DISPLAY) +#endif { ms_instance = this; m_options = parseOptions(paramList); @@ -195,9 +198,8 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList) QMetaObject::invokeMethod(m_navigatorEventNotifier, "start", Qt::QueuedConnection); #endif -#if !defined(QT_NO_OPENGL) - // Initialize global OpenGL resources - QQnxGLContext::initializeContext(); +#if QT_CONFIG(opengl) + createEglDisplay(); #endif // Create/start event thread @@ -284,9 +286,8 @@ QQnxIntegration::~QQnxIntegration() // Close connection to QNX composition manager screen_destroy_context(m_screenContext); -#if !defined(QT_NO_OPENGL) - // Cleanup global OpenGL resources - QQnxGLContext::shutdownContext(); +#if QT_CONFIG(opengl) + destroyEglDisplay(); #endif #if QT_CONFIG(qqnx_pps) @@ -741,4 +742,28 @@ bool QQnxIntegration::supportsNavigatorEvents() const return m_navigator != 0; } +#if QT_CONFIG(opengl) +void QQnxIntegration::createEglDisplay() +{ + qIntegrationDebug(); + + // Initialize connection to EGL + m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); + if (Q_UNLIKELY(m_eglDisplay == EGL_NO_DISPLAY)) + qFatal("QQnxiIntegration: failed to obtain EGL display: %x", eglGetError()); + + EGLBoolean eglResult = eglInitialize(m_eglDisplay, 0, 0); + if (Q_UNLIKELY(eglResult != EGL_TRUE)) + qFatal("QQnxIntegration: failed to initialize EGL display, err=%d", eglGetError()); +} + +void QQnxIntegration::destroyEglDisplay() +{ + qIntegrationDebug(); + + // Close connection to EGL + eglTerminate(m_eglDisplay); +} +#endif + QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxintegration.h b/src/plugins/platforms/qnx/qqnxintegration.h index 0bf37880d1..2596af3c45 100644 --- a/src/plugins/platforms/qnx/qqnxintegration.h +++ b/src/plugins/platforms/qnx/qqnxintegration.h @@ -46,6 +46,10 @@ #include +#if QT_CONFIG(opengl) +#include +#endif + QT_BEGIN_NAMESPACE class QQnxScreenEventThread; @@ -96,7 +100,8 @@ public: QPlatformWindow *createPlatformWindow(QWindow *window) const override; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override; -#if !defined(QT_NO_OPENGL) +#if QT_CONFIG(opengl) + EGLDisplay eglDisplay() const { return m_eglDisplay; } QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override; #endif @@ -175,6 +180,12 @@ private: Options m_options; +#if QT_CONFIG(opengl) + EGLDisplay m_eglDisplay; + void createEglDisplay(); + void destroyEglDisplay(); +#endif + static QQnxIntegration *ms_instance; friend class QQnxWindow; -- cgit v1.2.3 From 127533637e4ff4d3301fe02c88a2a506dd24c199 Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Wed, 30 Oct 2019 10:22:07 -0400 Subject: Provide repeat parameter to handleExtendedKeyEvent QtWayland uses this to discard key repeats. Modifier key repeats confuse xkbcommon. Change-Id: I3ea384aa7b750ff83520bfb2440e61b91bb6e354 Reviewed-by: Dan Cape Reviewed-by: Johan Helsing --- src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp index a9b5860187..e3a6aea99f 100644 --- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp +++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp @@ -257,7 +257,7 @@ void QQnxScreenEventHandler::injectKeyboardEvent(int flags, int sym, int modifie capKeyString(cap, modifiers, key); QWindowSystemInterface::handleExtendedKeyEvent(QGuiApplication::focusWindow(), type, key, qtMod, - scan, virtualKey, modifiers, keyStr); + scan, virtualKey, modifiers, keyStr, flags & KEY_REPEAT); qScreenEventDebug() << "Qt key t=" << type << ", k=" << key << ", s=" << keyStr; } -- cgit v1.2.3 From d6266c757d2f2ea4ff1e71dc8545f9bf97aa3bb1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 6 Dec 2019 13:19:37 +0100 Subject: Replace usages of QVariant::value by qvariant_cast This is done automatically with a clazy check Change-Id: I3b59511d3d36d416c8eda74858ead611d327b116 Reviewed-by: Lars Knoll --- .../bearer/networkmanager/qnetworkmanagerengine.cpp | 2 +- .../bearer/networkmanager/qnetworkmanagerservice.cpp | 16 ++++++++-------- .../ibus/qibusplatforminputcontext.cpp | 4 ++-- src/plugins/platforminputcontexts/ibus/qibusproxy.cpp | 4 ++-- src/plugins/platforminputcontexts/ibus/qibustypes.cpp | 6 +++--- .../xcb/gl_integrations/xcb_glx/qglxintegration.cpp | 2 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 2 +- src/plugins/printsupport/cups/qcupsprintengine.cpp | 4 ++-- 8 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index e74b1cf744..85a9f9b9e0 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -250,7 +250,7 @@ void QNetworkManagerEngine::interfacePropertiesChanged(const QMap >(i.value().value()); + const auto activeConnections = qdbus_cast >(qvariant_cast(i.value())); QStringList identifiers = accessPointConfigurations.keys(); QStringList priorActiveConnections = activeConnectionsList.keys(); diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp index 35199eb7a2..2d6cba1791 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp @@ -193,7 +193,7 @@ QList QNetworkManagerInterface::activeConnections() const { if (propertyMap.contains("ActiveConnections")) { - const QDBusArgument &dbusArgs = propertyMap.value("ActiveConnections").value(); + const QDBusArgument &dbusArgs = qvariant_cast(propertyMap.value("ActiveConnections")); QDBusObjectPath path; QList list; @@ -403,7 +403,7 @@ quint32 QNetworkManagerInterfaceDevice::deviceType() const QDBusObjectPath QNetworkManagerInterfaceDevice::ip4config() const { if (propertyMap.contains("Ip4Config")) - return propertyMap.value("Ip4Config").value(); + return qvariant_cast(propertyMap.value("Ip4Config")); return QDBusObjectPath(); } @@ -411,7 +411,7 @@ void QNetworkManagerInterfaceDevice::propertiesSwap(QMap map) { for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) { if (i.key() == QLatin1String("AvailableConnections")) { //Device - const QDBusArgument &dbusArgs = i.value().value(); + const QDBusArgument &dbusArgs = qvariant_cast(i.value()); QDBusObjectPath path; QStringList paths; dbusArgs.beginArray(); @@ -489,7 +489,7 @@ QStringList QNetworkManagerInterfaceDeviceWired::availableConnections() { QStringList list; if (propertyMap.contains("AvailableConnections")) { - const QDBusArgument &dbusArgs = propertyMap.value("Carrier").value(); + const QDBusArgument &dbusArgs = qvariant_cast(propertyMap.value("Carrier")); QDBusObjectPath path; dbusArgs.beginArray(); while (!dbusArgs.atEnd()) { @@ -598,7 +598,7 @@ quint32 QNetworkManagerInterfaceDeviceWireless::bitrate() const QDBusObjectPath QNetworkManagerInterfaceDeviceWireless::activeAccessPoint() const { if (propertyMap.contains("ActiveAccessPoint")) - return propertyMap.value("ActiveAccessPoint").value(); + return qvariant_cast(propertyMap.value("ActiveAccessPoint")); return QDBusObjectPath(); } @@ -931,14 +931,14 @@ QNetworkManagerConnectionActive::~QNetworkManagerConnectionActive() QDBusObjectPath QNetworkManagerConnectionActive::connection() const { if (propertyMap.contains("Connection")) - return propertyMap.value("Connection").value(); + return qvariant_cast(propertyMap.value("Connection")); return QDBusObjectPath(); } QDBusObjectPath QNetworkManagerConnectionActive::specificObject() const { if (propertyMap.contains("SpecificObject")) - return propertyMap.value("SpecificObject").value(); + return qvariant_cast(propertyMap.value("SpecificObject")); return QDBusObjectPath(); } @@ -946,7 +946,7 @@ QStringList QNetworkManagerConnectionActive::devices() const { QStringList list; if (propertyMap.contains("Devices")) { - const QDBusArgument &dbusArgs = propertyMap.value("Devices").value(); + const QDBusArgument &dbusArgs = qvariant_cast(propertyMap.value("Devices")); QDBusObjectPath path; dbusArgs.beginArray(); diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp index f2429f24ff..47ac54927b 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp @@ -285,7 +285,7 @@ void QIBusPlatformInputContext::commitText(const QDBusVariant &text) if (!input) return; - const QDBusArgument arg = text.variant().value(); + const QDBusArgument arg = qvariant_cast(text.variant()); QIBusText t; if (debug) @@ -311,7 +311,7 @@ void QIBusPlatformInputContext::updatePreeditText(const QDBusVariant &text, uint if (!input) return; - const QDBusArgument arg = text.variant().value(); + const QDBusArgument arg = qvariant_cast(text.variant()); QIBusText t; arg >> t; diff --git a/src/plugins/platforminputcontexts/ibus/qibusproxy.cpp b/src/plugins/platforminputcontexts/ibus/qibusproxy.cpp index 156e9b7c90..6b46e106ab 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusproxy.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusproxy.cpp @@ -83,10 +83,10 @@ QIBusEngineDesc QIBusProxy::getGlobalEngine() QVariant variant = reply.value().variant(); if (!variant.isValid()) return desc; - QVariant child = variant.value().variant(); + QVariant child = qvariant_cast(variant).variant(); if (!child.isValid()) return desc; - const QDBusArgument argument = child.value(); + const QDBusArgument argument = qvariant_cast(child); argument >> desc; return desc; } diff --git a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp index a2551f1320..443df271a8 100644 --- a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp @@ -62,7 +62,7 @@ void QIBusSerializable::deserializeFrom(const QDBusArgument &argument) argument >> key; argument >> value; argument.endMapEntry(); - attachments[key] = value.variant().value(); + attachments[key] = qvariant_cast(value.variant()); } argument.endMap(); } @@ -201,7 +201,7 @@ void QIBusAttributeList::deserializeFrom(const QDBusArgument &arg) arg >> var; QIBusAttribute attr; - var.variant().value() >> attr; + qvariant_cast(var.variant()) >> attr; attributes.append(std::move(attr)); } arg.endArray(); @@ -268,7 +268,7 @@ void QIBusText::deserializeFrom(const QDBusArgument &argument) argument >> text; QDBusVariant variant; argument >> variant; - variant.variant().value() >> attributes; + qvariant_cast(variant.variant()) >> attributes; argument.endStructure(); } diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp index 57805d5571..75189a9c80 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp @@ -429,7 +429,7 @@ void QGLXContext::init(QXcbScreen *screen, QPlatformOpenGLContext *share, const qWarning("QGLXContext: Requires a QGLXNativeContext"); return; } - QGLXNativeContext handle = nativeHandle.value(); + QGLXNativeContext handle = qvariant_cast(nativeHandle); GLXContext context = handle.context(); if (!context) { qWarning("QGLXContext: No GLXContext given"); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 66030b9ad4..23ed80ab5a 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -930,7 +930,7 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags) QXcbWindowFunctions::WmWindowTypes wmWindowTypes; if (window()->dynamicPropertyNames().contains(wm_window_type_property_id)) { wmWindowTypes = static_cast( - window()->property(wm_window_type_property_id).value()); + qvariant_cast(window()->property(wm_window_type_property_id))); } setWmWindowType(wmWindowTypes, flags); diff --git a/src/plugins/printsupport/cups/qcupsprintengine.cpp b/src/plugins/printsupport/cups/qcupsprintengine.cpp index c9683eb99d..43d5e119ad 100644 --- a/src/plugins/printsupport/cups/qcupsprintengine.cpp +++ b/src/plugins/printsupport/cups/qcupsprintengine.cpp @@ -100,10 +100,10 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v d->cupsOptions = value.toStringList(); break; case PPK_QPageSize: - d->setPageSize(value.value()); + d->setPageSize(qvariant_cast(value)); break; case PPK_QPageLayout: { - QPageLayout pageLayout = value.value(); + QPageLayout pageLayout = qvariant_cast(value); if (pageLayout.isValid() && (d->m_printDevice.isValidPageLayout(pageLayout, d->resolution) || d->m_printDevice.supportsCustomPageSizes() || d->m_printDevice.supportedPageSizes().isEmpty())) { -- cgit v1.2.3 From 313c2b46fe2830de981c94d07c5ef5ced9cb3257 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 27 Nov 2019 15:00:50 +0100 Subject: Windows QPA: Use UTF-16 literals where possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should minimize diffs to Qt 6. Change-Id: Id74c0b4085085984bd51251765420718d16e9fc7 Reviewed-by: André de la Rocha --- .../platforms/windows/qwindowsclipboard.cpp | 4 +- .../platforms/windows/qwindowsdialoghelpers.cpp | 60 +++++++++++----------- .../platforms/windows/qwindowseglcontext.cpp | 2 +- .../platforms/windows/qwindowsintegration.cpp | 32 ++++++------ src/plugins/platforms/windows/qwindowsmenu.cpp | 2 +- src/plugins/platforms/windows/qwindowsmime.cpp | 44 ++++++++-------- .../platforms/windows/qwindowsopengltester.cpp | 4 +- src/plugins/platforms/windows/qwindowsscreen.cpp | 2 +- src/plugins/platforms/windows/qwindowsservices.cpp | 6 +-- .../platforms/windows/qwindowssystemtrayicon.cpp | 2 +- src/plugins/platforms/windows/qwindowstheme.cpp | 14 ++--- src/plugins/platforms/windows/qwindowswindow.cpp | 2 +- .../uiautomation/qwindowsuiamainprovider.cpp | 2 +- 13 files changed, 89 insertions(+), 87 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp index 4e6d3306e1..ccd4e50a8b 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.cpp +++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp @@ -82,7 +82,7 @@ static QDebug operator<<(QDebug d, const QMimeData *mimeData) d << "QMimeData("; if (mimeData) { const QStringList formats = mimeData->formats(); - d << "formats=" << formats.join(QLatin1String(", ")); + d << "formats=" << formats.join(u", "); if (mimeData->hasText()) d << ", text=" << mimeData->text(); if (mimeData->hasHtml()) @@ -339,7 +339,7 @@ void QWindowsClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode) if (src != S_OK) { QString mimeDataFormats = mimeData ? - mimeData->formats().join(QLatin1String(", ")) : QString(QStringLiteral("NULL")); + mimeData->formats().join(u", ") : QString(QStringLiteral("NULL")); qErrnoWarning("OleSetClipboard: Failed to set mime data (%s) on clipboard: %s", qPrintable(mimeDataFormats), QWindowsContext::comErrorString(src).constData()); diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index cdb4e407d1..b038e19689 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -91,7 +91,7 @@ static inline QString guidToString(const GUID &g) str << '{' << g.Data1 << ", " << g.Data2 << ", " << g.Data3; str.setFieldWidth(2); str.setFieldAlignment(QTextStream::AlignRight); - str.setPadChar(QLatin1Char('0')); + str.setPadChar(u'0'); str << ",{" << g.Data4[0] << ", " << g.Data4[1] << ", " << g.Data4[2] << ", " << g.Data4[3] << ", " << g.Data4[4] << ", " << g.Data4[5] << ", " << g.Data4[6] << ", " << g.Data4[7] << "}};"; @@ -915,7 +915,7 @@ IShellItem *QWindowsNativeFileDialogBase::shellItem(const QUrl &url) return nullptr; } return result; - } else if (url.scheme() == QLatin1String("clsid")) { + } else if (url.scheme() == u"clsid") { // Support for virtual folders via GUID // (see https://msdn.microsoft.com/en-us/library/windows/desktop/dd378457(v=vs.85).aspx) // specified as "clsid:" (without '{', '}'). @@ -1040,20 +1040,20 @@ static QList filterSpecs(const QStringList &filters, // Split filter specification as 'Texts (*.txt[;] *.doc)', '*.txt[;] *.doc' // into description and filters specification as '*.txt;*.doc' for (const QString &filterString : filters) { - const int openingParenPos = filterString.lastIndexOf(QLatin1Char('(')); + const int openingParenPos = filterString.lastIndexOf(u'('); const int closingParenPos = openingParenPos != -1 ? - filterString.indexOf(QLatin1Char(')'), openingParenPos + 1) : -1; + filterString.indexOf(u')', openingParenPos + 1) : -1; FilterSpec filterSpec; filterSpec.filter = closingParenPos == -1 ? filterString : filterString.mid(openingParenPos + 1, closingParenPos - openingParenPos - 1).trimmed(); if (filterSpec.filter.isEmpty()) - filterSpec.filter += QLatin1Char('*'); + filterSpec.filter += u'*'; filterSpec.filter.replace(filterSeparatorRE, separator); filterSpec.description = filterString; if (hideFilterDetails && openingParenPos != -1) { // Do not show pattern in description filterSpec.description.truncate(openingParenPos); - while (filterSpec.description.endsWith(QLatin1Char(' '))) + while (filterSpec.description.endsWith(u' ')) filterSpec.description.truncate(filterSpec.description.size() - 1); } *totalStringLength += filterSpec.filter.size() + filterSpec.description.size(); @@ -1084,8 +1084,8 @@ void QWindowsNativeFileDialogBase::setNameFilters(const QStringList &filters) // 'AAA files (a.*) (a.*)' QString description = specs[i].description; const QString &filter = specs[i].filter; - if (!m_hideFiltersDetails && !filter.startsWith(QLatin1String("*."))) { - const int pos = description.lastIndexOf(QLatin1Char('(')); + if (!m_hideFiltersDetails && !filter.startsWith(u"*.")) { + const int pos = description.lastIndexOf(u'('); if (pos > 0) description.truncate(pos); } @@ -1151,8 +1151,8 @@ static bool isHexRange(const QString& s, int start, int end) for (;start < end; ++start) { QChar ch = s.at(start); if (!(ch.isDigit() - || (ch >= QLatin1Char('a') && ch <= QLatin1Char('f')) - || (ch >= QLatin1Char('A') && ch <= QLatin1Char('F')))) + || (ch >= u'a' && ch <= u'f') + || (ch >= u'A' && ch <= u'F'))) return false; } return true; @@ -1161,7 +1161,7 @@ static bool isHexRange(const QString& s, int start, int end) static inline bool isClsid(const QString &s) { // detect "374DE290-123F-4565-9164-39C4925E467B". - const QChar dash(QLatin1Char('-')); + const QChar dash(u'-'); return s.size() == 36 && isHexRange(s, 0, 8) && s.at(8) == dash @@ -1204,7 +1204,7 @@ void QWindowsNativeFileDialogBase::selectNameFilter(const QString &filter) if (index < 0) { qWarning("%s: Invalid parameter '%s' not found in '%s'.", __FUNCTION__, qPrintable(filter), - qPrintable(m_nameFilters.join(QLatin1String(", ")))); + qPrintable(m_nameFilters.join(u", "))); return; } m_fileDialog->SetFileTypeIndex(index + 1); // one-based. @@ -1313,15 +1313,15 @@ public: // Also handles the simple name filter case "*.txt" -> "txt" static inline QString suffixFromFilter(const QString &filter) { - int suffixPos = filter.indexOf(QLatin1String("*.")); + int suffixPos = filter.indexOf(u"*."); if (suffixPos < 0) return QString(); suffixPos += 2; - int endPos = filter.indexOf(QLatin1Char(' '), suffixPos + 1); + int endPos = filter.indexOf(u' ', suffixPos + 1); if (endPos < 0) - endPos = filter.indexOf(QLatin1Char(';'), suffixPos + 1); + endPos = filter.indexOf(u';', suffixPos + 1); if (endPos < 0) - endPos = filter.indexOf(QLatin1Char(')'), suffixPos + 1); + endPos = filter.indexOf(u')', suffixPos + 1); if (endPos < 0) endPos = filter.size(); return filter.mid(suffixPos, endPos - suffixPos); @@ -1406,27 +1406,27 @@ static void cleanupTemporaryItemCopies() static bool validFileNameCharacter(QChar c) { - return c.isLetterOrNumber() || c == QLatin1Char('_') || c == QLatin1Char('-'); + return c.isLetterOrNumber() || c == u'_' || c == u'-'; } QString tempFilePattern(QString name) { - const int lastSlash = qMax(name.lastIndexOf(QLatin1Char('/')), - name.lastIndexOf(QLatin1Char('\\'))); + const int lastSlash = qMax(name.lastIndexOf(u'/'), + name.lastIndexOf(u'\\')); if (lastSlash != -1) name.remove(0, lastSlash + 1); - int lastDot = name.lastIndexOf(QLatin1Char('.')); + int lastDot = name.lastIndexOf(u'.'); if (lastDot < 0) lastDot = name.size(); name.insert(lastDot, QStringLiteral("_XXXXXX")); for (int i = lastDot - 1; i >= 0; --i) { if (!validFileNameCharacter(name.at(i))) - name[i] = QLatin1Char('_'); + name[i] = u'_'; } - name.prepend(QDir::tempPath() + QLatin1Char('/')); + name.prepend(QDir::tempPath() + u'/'); return name; } @@ -1456,7 +1456,7 @@ static QString createTemporaryItemCopy(QWindowsShellItem &qItem, QString *errorM static QUrl itemToDialogUrl(QWindowsShellItem &qItem, QString *errorMessage) { QUrl url = qItem.url(); - if (url.isLocalFile() || url.scheme().startsWith(QLatin1String("http"))) + if (url.isLocalFile() || url.scheme().startsWith(u"http")) return url; const QString path = qItem.path(); if (path.isEmpty() && !qItem.isDir() && qItem.canStream()) { @@ -1859,10 +1859,12 @@ void QWindowsXpNativeFileDialog::populateOpenFileName(OPENFILENAME *ofn, HWND ow // for the target. If it contains any invalid character, the dialog // will not show. ofn->nMaxFile = 65535; - const QString initiallySelectedFile = - QDir::toNativeSeparators(m_data.selectedFile()).remove(QLatin1Char('<')). - remove(QLatin1Char('>')).remove(QLatin1Char('"')).remove(QLatin1Char('|')); - ofn->lpstrFile = qStringToWCharArray(initiallySelectedFile, ofn->nMaxFile); + QString initiallySelectedFile = m_data.selectedFile(); + initiallySelectedFile.remove(u'<'); + initiallySelectedFile.remove(u'>'); + initiallySelectedFile.remove(u'"'); + initiallySelectedFile.remove(u'|'); + ofn->lpstrFile = qStringToWCharArray(QDir::toNativeSeparators(initiallySelectedFile), ofn->nMaxFile); ofn->lpstrInitialDir = qStringToWCharArray(QDir::toNativeSeparators(m_data.directory().toLocalFile())); ofn->lpstrTitle = (wchar_t*)m_title.utf16(); // Determine lpstrDefExt. Note that the current MSDN docs document this @@ -1872,7 +1874,7 @@ void QWindowsXpNativeFileDialog::populateOpenFileName(OPENFILENAME *ofn, HWND ow // the extension of the current filter". if (m_options->acceptMode() == QFileDialogOptions::AcceptSave) { QString defaultSuffix = m_options->defaultSuffix(); - if (defaultSuffix.startsWith(QLatin1Char('.'))) + if (defaultSuffix.startsWith(u'.')) defaultSuffix.remove(0, 1); // QTBUG-33156, also create empty strings to trigger the appending mechanism. ofn->lpstrDefExt = qStringToWCharArray(defaultSuffix); @@ -1905,7 +1907,7 @@ QList QWindowsXpNativeFileDialog::execFileNames(HWND owner, int *selectedF wchar_t *ptr = ofn.lpstrFile + dir.size() + 1; if (*ptr) { result.pop_front(); - const QString path = dir + QLatin1Char('/'); + const QString path = dir + u'/'; while (*ptr) { const QString fileName = QString::fromWCharArray(ptr); result.push_back(QUrl::fromLocalFile(path + fileName)); diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index e9f3dc5189..76baa93d98 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -88,7 +88,7 @@ static void *resolveFunc(HMODULE lib, const char *name) while (!proc && argSize <= 64) { nameStr = baseNameStr; if (argSize >= 0) - nameStr += QLatin1Char('@') + QString::number(argSize); + nameStr += u'@' + QString::number(argSize); argSize = argSize < 0 ? 0 : argSize + 4; proc = (void *) ::GetProcAddress(lib, nameStr.toLatin1().constData()); } diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 09117f663d..32bd29a842 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -162,7 +162,7 @@ bool parseIntOption(const QString ¶meter,const QLatin1String &option, IntType minimumValue, IntType maximumValue, IntType *target) { const int valueLength = parameter.size() - option.size() - 1; - if (valueLength < 1 || !parameter.startsWith(option) || parameter.at(option.size()) != QLatin1Char('=')) + if (valueLength < 1 || !parameter.startsWith(option) || parameter.at(option.size()) != u'=') return false; bool ok; const QStringRef valueRef = parameter.rightRef(valueLength); @@ -186,38 +186,38 @@ static inline unsigned parseOptions(const QStringList ¶mList, { unsigned options = 0; for (const QString ¶m : paramList) { - if (param.startsWith(QLatin1String("fontengine="))) { - if (param.endsWith(QLatin1String("freetype"))) { + if (param.startsWith(u"fontengine=")) { + if (param.endsWith(u"freetype")) { options |= QWindowsIntegration::FontDatabaseFreeType; - } else if (param.endsWith(QLatin1String("native"))) { + } else if (param.endsWith(u"native")) { options |= QWindowsIntegration::FontDatabaseNative; } - } else if (param.startsWith(QLatin1String("dialogs="))) { - if (param.endsWith(QLatin1String("xp"))) { + } else if (param.startsWith(u"dialogs=")) { + if (param.endsWith(u"xp")) { options |= QWindowsIntegration::XpNativeDialogs; - } else if (param.endsWith(QLatin1String("none"))) { + } else if (param.endsWith(u"none")) { options |= QWindowsIntegration::NoNativeDialogs; } - } else if (param == QLatin1String("altgr")) { + } else if (param == u"altgr") { options |= QWindowsIntegration::DetectAltGrModifier; - } else if (param == QLatin1String("gl=gdi")) { + } else if (param == u"gl=gdi") { options |= QWindowsIntegration::DisableArb; - } else if (param == QLatin1String("nodirectwrite")) { + } else if (param == u"nodirectwrite") { options |= QWindowsIntegration::DontUseDirectWriteFonts; - } else if (param == QLatin1String("nocolorfonts")) { + } else if (param == u"nocolorfonts") { options |= QWindowsIntegration::DontUseColorFonts; - } else if (param == QLatin1String("nomousefromtouch")) { + } else if (param == u"nomousefromtouch") { options |= QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch; } else if (parseIntOption(param, QLatin1String("verbose"), 0, INT_MAX, &QWindowsContext::verbose) || parseIntOption(param, QLatin1String("tabletabsoluterange"), 0, INT_MAX, tabletAbsoluteRange) || parseIntOption(param, QLatin1String("dpiawareness"), QtWindows::ProcessDpiUnaware, QtWindows::ProcessPerMonitorDpiAware, dpiAwareness)) { - } else if (param == QLatin1String("menus=native")) { + } else if (param == u"menus=native") { options |= QWindowsIntegration::AlwaysUseNativeMenus; - } else if (param == QLatin1String("menus=none")) { + } else if (param == u"menus=none") { options |= QWindowsIntegration::NoNativeMenus; - } else if (param == QLatin1String("nowmpointer")) { + } else if (param == u"nowmpointer") { options |= QWindowsIntegration::DontUseWMPointer; - } else if (param == QLatin1String("reverse")) { + } else if (param == u"reverse") { options |= QWindowsIntegration::RtlEnabled; } else { qWarning() << "Unknown option" << param; diff --git a/src/plugins/platforms/windows/qwindowsmenu.cpp b/src/plugins/platforms/windows/qwindowsmenu.cpp index d20edd685e..7c3e87eec1 100644 --- a/src/plugins/platforms/windows/qwindowsmenu.cpp +++ b/src/plugins/platforms/windows/qwindowsmenu.cpp @@ -445,7 +445,7 @@ QString QWindowsMenuItem::nativeText() const QString result = m_text; #if QT_CONFIG(shortcut) if (!m_shortcut.isEmpty()) { - result += QLatin1Char('\t'); + result += u'\t'; result += m_shortcut.toString(QKeySequence::NativeText); } #endif diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index 1c6c999f05..fe9e1fe31f 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -635,11 +635,11 @@ bool QWindowsMimeText::convertFromMime(const FORMATETC &formatetc, const QMimeDa int ri = 0; bool cr = false; for (int i=0; i < s; ++i) { - if (*u == QLatin1Char('\r')) + if (*u == u'\r') cr = true; else { - if (*u == QLatin1Char('\n') && !cr) - res[ri++] = QLatin1Char('\r'); + if (*u == u'\n' && !cr) + res[ri++] = u'\r'; cr = false; } res[ri++] = *u; @@ -663,7 +663,7 @@ bool QWindowsMimeText::convertFromMime(const FORMATETC &formatetc, const QMimeDa bool QWindowsMimeText::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const { - return mimeType.startsWith(QLatin1String("text/plain")) + return mimeType.startsWith(u"text/plain") && (canGetData(CF_UNICODETEXT, pDataObj) || canGetData(CF_TEXT, pDataObj)); } @@ -680,7 +680,7 @@ QString QWindowsMimeText::mimeForFormat(const FORMATETC &formatetc) const QVector QWindowsMimeText::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const { QVector formatics; - if (mimeType.startsWith(QLatin1String("text/plain")) && mimeData->hasText()) { + if (mimeType.startsWith(u"text/plain") && mimeData->hasText()) { formatics += setCf(CF_UNICODETEXT); formatics += setCf(CF_TEXT); } @@ -816,7 +816,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat bool QWindowsMimeURI::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const { - return mimeType == QLatin1String("text/uri-list") + return mimeType == u"text/uri-list" && (canGetData(CF_HDROP, pDataObj) || canGetData(CF_INETURL_W, pDataObj) || canGetData(CF_INETURL, pDataObj)); } @@ -831,7 +831,7 @@ QString QWindowsMimeURI::mimeForFormat(const FORMATETC &formatetc) const QVector QWindowsMimeURI::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const { QVector formatics; - if (mimeType == QLatin1String("text/uri-list")) { + if (mimeType == u"text/uri-list") { if (canConvertFromMime(setCf(CF_HDROP), mimeData)) formatics += setCf(CF_HDROP); if (canConvertFromMime(setCf(CF_INETURL_W), mimeData)) @@ -844,7 +844,7 @@ QVector QWindowsMimeURI::formatsForMime(const QString &mimeType, cons QVariant QWindowsMimeURI::convertToMime(const QString &mimeType, LPDATAOBJECT pDataObj, QVariant::Type preferredType) const { - if (mimeType == QLatin1String("text/uri-list")) { + if (mimeType == u"text/uri-list") { if (canGetData(CF_HDROP, pDataObj)) { QList urls; @@ -916,7 +916,7 @@ QWindowsMimeHtml::QWindowsMimeHtml() QVector QWindowsMimeHtml::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const { QVector formatetcs; - if (mimeType == QLatin1String("text/html") && (!mimeData->html().isEmpty())) + if (mimeType == u"text/html" && (!mimeData->html().isEmpty())) formatetcs += setCf(CF_HTML); return formatetcs; } @@ -930,7 +930,7 @@ QString QWindowsMimeHtml::mimeForFormat(const FORMATETC &formatetc) const bool QWindowsMimeHtml::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const { - return mimeType == QLatin1String("text/html") && canGetData(CF_HTML, pDataObj); + return mimeType == u"text/html" && canGetData(CF_HTML, pDataObj); } @@ -1053,7 +1053,7 @@ QWindowsMimeImage::QWindowsMimeImage() QVector QWindowsMimeImage::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const { QVector formatetcs; - if (mimeData->hasImage() && mimeType == QLatin1String("application/x-qt-image")) { + if (mimeData->hasImage() && mimeType == u"application/x-qt-image") { //add DIBV5 if image has alpha channel. Do not add CF_PNG here as it will confuse MS Office (QTBUG47656). auto image = qvariant_cast(mimeData->imageData()); if (!image.isNull() && image.hasAlphaChannel()) @@ -1075,7 +1075,7 @@ QString QWindowsMimeImage::mimeForFormat(const FORMATETC &formatetc) const bool QWindowsMimeImage::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const { - return mimeType == QLatin1String("application/x-qt-image") + return mimeType == u"application/x-qt-image" && (canGetData(CF_DIB, pDataObj) || canGetData(CF_PNG, pDataObj)); } @@ -1149,7 +1149,7 @@ QVariant QWindowsMimeImage::convertToMime(const QString &mimeType, IDataObject * { Q_UNUSED(preferredType); QVariant result; - if (mimeType != QLatin1String("application/x-qt-image")) + if (mimeType != u"application/x-qt-image") return result; //Try to convert from a format which has more data //DIBV5, use only if its is not synthesized @@ -1220,7 +1220,7 @@ bool QBuiltInMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData { if (canConvertFromMime(formatetc, mimeData)) { QByteArray data; - if (outFormats.value(getCf(formatetc)) == QLatin1String("text/html")) { + if (outFormats.value(getCf(formatetc)) == u"text/html") { // text/html is in wide chars on windows (compatible with mozillia) QString html = mimeData->html(); // same code as in the text converter up above @@ -1232,11 +1232,11 @@ bool QBuiltInMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData int ri = 0; bool cr = false; for (int i=0; i < s; ++i) { - if (*u == QLatin1Char('\r')) + if (*u == u'\r') cr = true; else { - if (*u == QLatin1Char('\n') && !cr) - res[ri++] = QLatin1Char('\r'); + if (*u == u'\n' && !cr) + res[ri++] = u'\r'; cr = false; } res[ri++] = *u; @@ -1285,7 +1285,7 @@ QVariant QBuiltInMimes::convertToMime(const QString &mimeType, IDataObject *pDat QByteArray data = getData(inFormats.key(mimeType), pDataObj); if (!data.isEmpty()) { qCDebug(lcQpaMime) << __FUNCTION__; - if (mimeType == QLatin1String("text/html") && preferredType == QVariant::String) { + if (mimeType == u"text/html" && preferredType == QVariant::String) { // text/html is in wide chars on windows (compatible with Mozilla) val = QString::fromWCharArray(reinterpret_cast(data.constData())); } else { @@ -1404,12 +1404,12 @@ static bool isCustomMimeType(const QString &mimeType) static QString customMimeType(const QString &mimeType, int *lindex = nullptr) { int len = sizeof(x_qt_windows_mime) - 1; - int n = mimeType.lastIndexOf(QLatin1Char('\"')) - len; + int n = mimeType.lastIndexOf(u'\"') - len; QString ret = mimeType.mid(len, n); - const int beginPos = mimeType.indexOf(QLatin1String(";index=")); + const int beginPos = mimeType.indexOf(u";index="); if (beginPos > -1) { - const int endPos = mimeType.indexOf(QLatin1Char(';'), beginPos + 1); + const int endPos = mimeType.indexOf(u';', beginPos + 1); const int indexStartPos = beginPos + 7; if (lindex) *lindex = mimeType.midRef(indexStartPos, endPos == -1 ? endPos : endPos - indexStartPos).toInt(); @@ -1480,7 +1480,7 @@ QString QLastResortMimes::mimeForFormat(const FORMATETC &formatetc) const } } if (!ianaType) - format = QLatin1String(x_qt_windows_mime) + clipFormat + QLatin1Char('\"'); + format = QLatin1String(x_qt_windows_mime) + clipFormat + u'"'; else format = clipFormat; } diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index afc1991e2c..72092a4481 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -206,7 +206,7 @@ QString GpuDescription::toString() const str << " Card name : " << description << "\n Driver Name : " << driverName << "\n Driver Version : " << driverVersion.toString() - << "\n Vendor ID : 0x" << qSetPadChar(QLatin1Char('0')) + << "\n Vendor ID : 0x" << qSetPadChar(u'0') << Qt::uppercasedigits << Qt::hex << qSetFieldWidth(4) << vendorId << "\n Device ID : 0x" << qSetFieldWidth(4) << deviceId << "\n SubSys ID : 0x" << qSetFieldWidth(8) << subSysId @@ -285,7 +285,7 @@ static inline QString resolveBugListFile(const QString &fileName) // then resolve via QStandardPaths::ConfigLocation. const QString settingsPath = QLibraryInfo::location(QLibraryInfo::SettingsPath); if (!settingsPath.isEmpty()) { // SettingsPath is empty unless specified in qt.conf. - const QFileInfo fi(settingsPath + QLatin1Char('/') + fileName); + const QFileInfo fi(settingsPath + u'/' + fileName); if (fi.isFile()) return fi.absoluteFilePath(); } diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 4f76a82544..c7a0c2e62e 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -87,7 +87,7 @@ static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data) data->geometry = QRect(QPoint(info.rcMonitor.left, info.rcMonitor.top), QPoint(info.rcMonitor.right - 1, info.rcMonitor.bottom - 1)); data->availableGeometry = QRect(QPoint(info.rcWork.left, info.rcWork.top), QPoint(info.rcWork.right - 1, info.rcWork.bottom - 1)); data->name = QString::fromWCharArray(info.szDevice); - if (data->name == QLatin1String("WinDisc")) { + if (data->name == u"WinDisc") { data->flags |= QWindowsScreenData::LockScreen; } else { if (const HDC hdc = CreateDC(info.szDevice, nullptr, nullptr, nullptr)) { diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp index 83b052bb49..6a2708ee26 100644 --- a/src/plugins/platforms/windows/qwindowsservices.cpp +++ b/src/plugins/platforms/windows/qwindowsservices.cpp @@ -92,7 +92,7 @@ static inline QString mailCommand() // "rundll32.exe .. url.dll,MailToProtocolHandler %l" is returned. Launching it // silently fails or brings up a broken dialog after a long time, so exclude it and // fall back to ShellExecute() which brings up the URL assocation dialog. - if (command.isEmpty() || command.contains(QLatin1String(",MailToProtocolHandler"))) + if (command.isEmpty() || command.contains(u",MailToProtocolHandler")) return QString(); wchar_t expandedCommand[MAX_PATH] = {0}; return ExpandEnvironmentStrings(reinterpret_cast(command.utf16()), @@ -108,7 +108,7 @@ static inline bool launchMail(const QUrl &url) return false; } //Make sure the path for the process is in quotes - const QChar doubleQuote = QLatin1Char('"'); + const QChar doubleQuote = u'"'; if (!command.startsWith(doubleQuote)) { const int exeIndex = command.indexOf(QStringLiteral(".exe "), 0, Qt::CaseInsensitive); if (exeIndex != -1) { @@ -140,7 +140,7 @@ static inline bool launchMail(const QUrl &url) bool QWindowsServices::openUrl(const QUrl &url) { const QString scheme = url.scheme(); - if (scheme == QLatin1String("mailto") && launchMail(url)) + if (scheme == u"mailto" && launchMail(url)) return true; return shellExecute(url); } diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp index ab830e1461..66c558df1e 100644 --- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp +++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp @@ -261,7 +261,7 @@ void QWindowsSystemTrayIcon::showMessage(const QString &title, const QString &me // For empty messages, ensures that they show when only title is set QString message = messageIn; if (message.isEmpty() && !title.isEmpty()) - message.append(QLatin1Char(' ')); + message.append(u' '); NOTIFYICONDATA tnd; initNotifyIconData(tnd); diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 32a65109af..010aea2068 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -96,7 +96,7 @@ static inline QTextStream& operator<<(QTextStream &str, const QColor &c) { str.setIntegerBase(16); str.setFieldWidth(2); - str.setPadChar(QLatin1Char('0')); + str.setPadChar(u'0'); str << " rgb: #" << c.red() << c.green() << c.blue(); str.setIntegerBase(10); str.setFieldWidth(0); @@ -731,13 +731,13 @@ static QString dirIconPixmapCacheKey(int iIcon, int iconSize, int imageListSize) { QString key = QLatin1String("qt_dir_") + QString::number(iIcon); if (iconSize == SHGFI_LARGEICON) - key += QLatin1Char('l'); + key += u'l'; switch (imageListSize) { case sHIL_EXTRALARGE: - key += QLatin1Char('e'); + key += u'e'; break; case sHIL_JUMBO: - key += QLatin1Char('j'); + key += u'j'; break; } return key; @@ -815,9 +815,9 @@ QString QWindowsFileIconEngine::cacheKey() const // It is faster to just look at the file extensions; // avoiding slow QFileInfo::isExecutable() (QTBUG-13182) QString suffix = fileInfo().suffix(); - if (!suffix.compare(QLatin1String("exe"), Qt::CaseInsensitive) - || !suffix.compare(QLatin1String("lnk"), Qt::CaseInsensitive) - || !suffix.compare(QLatin1String("ico"), Qt::CaseInsensitive)) { + if (!suffix.compare(u"exe", Qt::CaseInsensitive) + || !suffix.compare(u"lnk", Qt::CaseInsensitive) + || !suffix.compare(u"ico", Qt::CaseInsensitive)) { return QString(); } return QLatin1String("qt_.") diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 5a4f879d0f..a7aad15749 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -253,7 +253,7 @@ QDebug operator<<(QDebug d, const GUID &guid) { QDebugStateSaver saver(d); d.nospace(); - d << '{' << Qt::hex << Qt::uppercasedigits << qSetPadChar(QLatin1Char('0')) + d << '{' << Qt::hex << Qt::uppercasedigits << qSetPadChar(u'0') << qSetFieldWidth(8) << guid.Data1 << qSetFieldWidth(0) << '-' << qSetFieldWidth(4) << guid.Data2 << qSetFieldWidth(0) << '-' << qSetFieldWidth(4) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index cc293b777c..a0a976545f 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -473,7 +473,7 @@ QString QWindowsUiaMainProvider::automationIdForAccessible(const QAccessibleInte if (name.isEmpty()) return QString(); if (!result.isEmpty()) - result.prepend(QLatin1Char('.')); + result.prepend(u'.'); result.prepend(name); obj = obj->parent(); } -- cgit v1.2.3 From 18f22fea7c89da59b040da6361026593c8557a74 Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Wed, 13 Nov 2019 16:39:52 +0100 Subject: Windows QPA: Allow the native Windows virtual keyboard to be disabled This change provides a way to disable the automatic showing of the native Windows on-screen virtual keyboard when a text editing widget is selected on a system without a physical keyboard, by enabling the new AA_MSWindowsDisableVirtualKeyboard application attribute, allowing applications to use a custom virtual keyboard implementation. Fixes: QTBUG-76088 Change-Id: Id76f9673a2e4081e5325662f3e3b4b102d133b9a Reviewed-by: Friedemann Kleint Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowsinputcontext.cpp | 3 ++- .../platforms/windows/uiautomation/qwindowsuiamainprovider.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp index 19d632dc10..f1f5d3a96e 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp @@ -285,7 +285,8 @@ void QWindowsInputContext::showInputPanel() // the Surface seems unnecessary there anyway. But leave it hidden for IME. // Only trigger the native OSK if the Qt OSK is not in use. static bool imModuleEmpty = qEnvironmentVariableIsEmpty("QT_IM_MODULE"); - if (imModuleEmpty + bool nativeVKDisabled = QCoreApplication::testAttribute(Qt::AA_MSWindowsDisableVirtualKeyboard); + if ((imModuleEmpty && !nativeVKDisabled) && QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 16299)) { ShowCaret(platformWindow->handle()); diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index a0a976545f..5f564f81c2 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -393,12 +393,14 @@ HRESULT QWindowsUiaMainProvider::GetPropertyValue(PROPERTYID idProp, VARIANT *pR // Control type converted from role. auto controlType = roleToControlTypeId(accessible->role()); - // The native OSK should be disbled if the Qt OSK is in use. + // The native OSK should be disbled if the Qt OSK is in use, + // or if disabled via application attribute. static bool imModuleEmpty = qEnvironmentVariableIsEmpty("QT_IM_MODULE"); + bool nativeVKDisabled = QCoreApplication::testAttribute(Qt::AA_MSWindowsDisableVirtualKeyboard); // If we want to disable the native OSK auto-showing // we have to report text fields as non-editable. - if (controlType == UIA_EditControlTypeId && !imModuleEmpty) + if (controlType == UIA_EditControlTypeId && (!imModuleEmpty || nativeVKDisabled)) controlType = UIA_TextControlTypeId; setVariantI4(controlType, pRetVal); -- cgit v1.2.3 From b2e3a5502afc0398cb8a732c366253e72a64b744 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 6 Dec 2019 13:30:40 +0100 Subject: Parse Xft.dpi with fraction Some versions of GNOME 3 would set Xft.dpi with fraction though that is technically not valid. Change-Id: Ib1027283cc78fd5d9869cd337864a92e28cd7e88 Fixes: QTBUG-64738 Reviewed-by: Gatis Paeglis --- src/plugins/platforms/xcb/qxcbscreen.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 7c60ca06f9..44d0bb3f55 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -320,12 +320,22 @@ bool QXcbVirtualDesktop::xResource(const QByteArray &identifier, static bool parseXftInt(const QByteArray& stringValue, int *value) { - Q_ASSERT(value != 0); + Q_ASSERT(value); bool ok; *value = stringValue.toInt(&ok); return ok; } +static bool parseXftDpi(const QByteArray& stringValue, int *value) +{ + Q_ASSERT(value); + bool ok = parseXftInt(stringValue, value); + // Support GNOME 3 bug that wrote DPI with fraction: + if (!ok) + *value = qRound(stringValue.toDouble(&ok)); + return ok; +} + static QFontEngine::HintStyle parseXftHintStyle(const QByteArray& stringValue) { if (stringValue == "hintfull") @@ -391,7 +401,7 @@ void QXcbVirtualDesktop::readXResources() int value; QByteArray stringValue; if (xResource(r, "Xft.dpi:\t", stringValue)) { - if (parseXftInt(stringValue, &value)) + if (parseXftDpi(stringValue, &value)) m_forcedDpi = value; } else if (xResource(r, "Xft.hintstyle:\t", stringValue)) { m_hintStyle = parseXftHintStyle(stringValue); -- cgit v1.2.3 From 09f19e48ac2a34ea2df9d19267599e05d64d45c6 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 18 Dec 2019 13:16:20 +0100 Subject: Fix unneeded use of QImage invertPixels and createAlphaMask The result of createAlphaMask was mostly overwritten and then inverted, we can write the right values directly instead. Change-Id: I3cdddcc74218a4058bddd20178733688607c8a01 Reviewed-by: Eirik Aavitsland --- src/plugins/imageformats/ico/qicohandler.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index c8e31dceac..6515748bf5 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -615,13 +615,7 @@ bool ICOReader::write(QIODevice *device, const QVector &images) } QImage maskImage(image.width(), image.height(), QImage::Format_Mono); image = image.convertToFormat(QImage::Format_ARGB32); - - if (image.hasAlphaChannel()) { - maskImage = image.createAlphaMask(); - } else { - maskImage.fill(0xff); - } - maskImage = maskImage.convertToFormat(QImage::Format_Mono); + maskImage.fill(Qt::color1); int nbits = 32; int bpl_bmp = ((image.width()*nbits+31)/32)*4; @@ -671,7 +665,7 @@ bool ICOReader::write(QIODevice *device, const QVector &images) *b++ = qRed(*p); *b++ = qAlpha(*p); if (qAlpha(*p) > 0) // Even mostly transparent pixels must not be masked away - maskImage.setPixel(x, y, Qt::color1); // (i.e. createAlphaMask() takes away too much) + maskImage.setPixel(x, y, 0); p++; x++; } @@ -679,7 +673,6 @@ bool ICOReader::write(QIODevice *device, const QVector &images) } delete[] buf; - maskImage.invertPixels(); // seems as though it needs this // NOTE! !! The mask is only flipped vertically - not horizontally !! for (y = maskImage.height() - 1; y >= 0; y--) buffer.write((char*)maskImage.scanLine(y), maskImage.bytesPerLine()); -- cgit v1.2.3 From 9a77beaea36bf6c8b44086a15bed0e9903a06944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 18 Dec 2019 18:01:27 +0100 Subject: macOS: Deliver theme changes synchronously Otherwise the expose event that AppKit triggers will be delivered before we've propagated the theme change, and we fail to draw the UI using the new theme. Change-Id: I502122a2bf02a866d136106d831f0c2a0dfe26f2 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoatheme.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 7c10456824..387df65721 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -129,7 +129,7 @@ void QCocoaTheme::handleSystemThemeChange() QFontCache::instance()->clear(); } - QWindowSystemInterface::handleThemeChange(nullptr); + QWindowSystemInterface::handleThemeChange(nullptr); } bool QCocoaTheme::usePlatformNativeDialog(DialogType dialogType) const -- cgit v1.2.3 From 7e7f76bc553fc29858262ec1946ef413adfad718 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 20 Dec 2019 13:39:24 +0100 Subject: QMacStyle: fix tab widget's tab bar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Alas, this thing strikes back: I have to use clip to remove the part of NSBox coming through the transparent buttons, but this works (as I've noticed recently) only for 'North' and 'West' tab positions. For 'South' and 'East' different geomety adjustments are required. Change-Id: Id1f77bc1869e82e710132a2f4402cc3c8be3ab01 Reviewed-by: Tor Arne Vestbø --- src/plugins/styles/mac/qmacstyle_mac.mm | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 93d2681fd8..5aa7befb84 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -236,6 +236,18 @@ static QLinearGradient titlebarGradientInactive() } #if QT_CONFIG(tabwidget) +/* + Since macOS 10.14 AppKit is using transparency more extensively, especially for the + dark theme. Inactive buttons, for example, are semi-transparent. And we use them to + draw tab widget's tab bar. The combination of NSBox (also a part of tab widget) + and these transparent buttons gives us an undesired side-effect: an outline of + NSBox is visible through transparent buttons. To avoid this, we have this hack below: + we clip the area where the line would be visible through the buttons. The area we + want to clip away can be described as an intersection of the option's rect and + the tab widget's tab bar rect. But some adjustments are required, since those rects + are anyway adjusted during the rendering and they are not exactly what you'll see on + the screen. Thus this switch-statement inside. +*/ static void clipTabBarFrame(const QStyleOption *option, const QMacStyle *style, CGContextRef ctx) { Q_ASSERT(option); @@ -246,7 +258,19 @@ static void clipTabBarFrame(const QStyleOption *option, const QMacStyle *style, QTabWidget *tabWidget = qobject_cast(option->styleObject); Q_ASSERT(tabWidget); - const QRect tabBarRect = style->subElementRect(QStyle::SE_TabWidgetTabBar, option, tabWidget).adjusted(2, 2, -3, -2); + QRect tabBarRect = style->subElementRect(QStyle::SE_TabWidgetTabBar, option, tabWidget).adjusted(2, 0, -3, 0); + switch (tabWidget->tabPosition()) { + case QTabWidget::South: + tabBarRect.setY(tabBarRect.y() + tabBarRect.height() / 2); + break; + case QTabWidget::North: + case QTabWidget::West: + tabBarRect = tabBarRect.adjusted(0, 2, 0, -2); + break; + case QTabWidget::East: + tabBarRect = tabBarRect.adjusted(tabBarRect.width() / 2, 2, tabBarRect.width() / 2, -2); + } + const QRegion clipPath = QRegion(option->rect) - tabBarRect; QVarLengthArray cgRects; for (const QRect &qtRect : clipPath) -- cgit v1.2.3 From 7ac4e55cb979dff890f1575e771e5f2def9e3131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 20 Dec 2019 16:46:24 +0100 Subject: macOS Don't throw away backingstore buffers when backing properties change Clients such as QtWidgets that do their own dirty tracking will assume they can just flush in response to the expose event, without repainting anything. Since we have no way at the moment to inform these clients that the backingstore content might be invalid we can't just throw it away. It turns out that to pick up changes in color spaces we can just tag the existing buffers with the new color space, so we don't need to throw it away. And for the older surface-backed mode we tag the color space on flush, so we didn't need to invalidate anything in the first place. Fixes: QTBUG-80844 Task-number: QTBUG-77749 Change-Id: Icb1ceb178894bb43887cdf03fb855d2d614b5ab0 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoabackingstore.h | 6 ++-- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 36 ++++++++++------------ src/plugins/platforms/cocoa/qcocoaintegration.mm | 2 ++ .../platforms/cocoa/qiosurfacegraphicsbuffer.h | 4 ++- .../platforms/cocoa/qiosurfacegraphicsbuffer.mm | 14 +++++---- 5 files changed, 32 insertions(+), 30 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h index a874936ce6..b57deacb57 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.h +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h @@ -54,8 +54,6 @@ class QCocoaBackingStore : public QRasterBackingStore protected: QCocoaBackingStore(QWindow *window); QCFType colorSpace() const; - QMacNotificationObserver m_backingPropertiesObserver; - virtual void backingPropertiesChanged() = 0; }; class QNSWindowBackingStore : public QCocoaBackingStore @@ -71,7 +69,6 @@ private: bool windowHasUnifiedToolbar() const; QImage::Format format() const override; void redrawRoundedBottomCorners(CGRect) const; - void backingPropertiesChanged() override; }; class QCALayerBackingStore : public QCocoaBackingStore @@ -118,7 +115,8 @@ private: bool recreateBackBufferIfNeeded(); bool prepareForFlush(); - void backingPropertiesChanged() override; + void backingPropertiesChanged(); + QMacNotificationObserver m_backingPropertiesObserver; std::list> m_buffers; }; diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index b17302a640..8a815a7665 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -51,17 +51,6 @@ QT_BEGIN_NAMESPACE QCocoaBackingStore::QCocoaBackingStore(QWindow *window) : QRasterBackingStore(window) { - // Ideally this would be plumbed from the platform layer to QtGui, and - // the QBackingStore would be recreated, but we don't have that code yet, - // so at least make sure we invalidate our backingstore when the backing - // properties (color space e.g.) are changed. - NSView *view = static_cast(window->handle())->view(); - m_backingPropertiesObserver = QMacNotificationObserver(view.window, - NSWindowDidChangeBackingPropertiesNotification, [this]() { - qCDebug(lcQpaBackingStore) << "Backing properties for" - << this->window() << "did change"; - backingPropertiesChanged(); - }); } QCFType QCocoaBackingStore::colorSpace() const @@ -341,11 +330,6 @@ void QNSWindowBackingStore::redrawRoundedBottomCorners(CGRect windowRect) const #endif } -void QNSWindowBackingStore::backingPropertiesChanged() -{ - m_image = QImage(); -} - // ---------------------------------------------------------------------------- QCALayerBackingStore::QCALayerBackingStore(QWindow *window) @@ -353,6 +337,18 @@ QCALayerBackingStore::QCALayerBackingStore(QWindow *window) { qCDebug(lcQpaBackingStore) << "Creating QCALayerBackingStore for" << window; m_buffers.resize(1); + + // Ideally this would be plumbed from the platform layer to QtGui, and + // the QBackingStore would be recreated, but we don't have that code yet, + // so at least make sure we update our backingstore when the backing + // properties (color space e.g.) are changed. + NSView *view = static_cast(window->handle())->view(); + m_backingPropertiesObserver = QMacNotificationObserver(view.window, + NSWindowDidChangeBackingPropertiesNotification, [this]() { + qCDebug(lcQpaBackingStore) << "Backing properties for" + << this->window() << "did change"; + backingPropertiesChanged(); + }); } QCALayerBackingStore::~QCALayerBackingStore() @@ -620,8 +616,9 @@ QImage QCALayerBackingStore::toImage() const void QCALayerBackingStore::backingPropertiesChanged() { - m_buffers.clear(); - m_buffers.resize(1); + qCDebug(lcQpaBackingStore) << "Updating color space of existing buffers"; + for (auto &buffer : m_buffers) + buffer->setColorSpace(colorSpace()); } QPlatformGraphicsBuffer *QCALayerBackingStore::graphicsBuffer() const @@ -698,10 +695,11 @@ bool QCALayerBackingStore::prepareForFlush() QCALayerBackingStore::GraphicsBuffer::GraphicsBuffer(const QSize &size, qreal devicePixelRatio, const QPixelFormat &format, QCFType colorSpace) - : QIOSurfaceGraphicsBuffer(size, format, colorSpace) + : QIOSurfaceGraphicsBuffer(size, format) , dirtyRegion(0, 0, size.width() / devicePixelRatio, size.height() / devicePixelRatio) , m_devicePixelRatio(devicePixelRatio) { + setColorSpace(colorSpace); } QImage *QCALayerBackingStore::GraphicsBuffer::asImage() diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index b7f15a2bf1..d8c931e9a1 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -396,6 +396,8 @@ QVariant QCocoaIntegration::styleHint(StyleHint hint) const return QCoreTextFontEngine::fontSmoothingGamma(); case ShowShortcutsInContextMenus: return QVariant(false); + // case CursorFlashTime: + // return 50000; default: break; } diff --git a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h index 872773cb7a..e070ba977d 100644 --- a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h +++ b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.h @@ -48,9 +48,11 @@ QT_BEGIN_NAMESPACE class QIOSurfaceGraphicsBuffer : public QPlatformGraphicsBuffer { public: - QIOSurfaceGraphicsBuffer(const QSize &size, const QPixelFormat &format, QCFType colorSpace); + QIOSurfaceGraphicsBuffer(const QSize &size, const QPixelFormat &format); ~QIOSurfaceGraphicsBuffer(); + void setColorSpace(QCFType colorSpace); + const uchar *data() const override; uchar *data() override; int bytesPerLine() const override; diff --git a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm index a367487e85..285e316d4a 100644 --- a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm +++ b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcQpaIOSurface, "qt.qpa.backingstore.iosurface"); -QIOSurfaceGraphicsBuffer::QIOSurfaceGraphicsBuffer(const QSize &size, const QPixelFormat &format, QCFType colorSpace) +QIOSurfaceGraphicsBuffer::QIOSurfaceGraphicsBuffer(const QSize &size, const QPixelFormat &format) : QPlatformGraphicsBuffer(size, format) { const size_t width = size.width(); @@ -81,17 +81,19 @@ QIOSurfaceGraphicsBuffer::QIOSurfaceGraphicsBuffer(const QSize &size, const QPix Q_ASSERT(size_t(bytesPerLine()) == bytesPerRow); Q_ASSERT(size_t(byteCount()) == totalBytes); - - if (colorSpace) { - IOSurfaceSetValue(m_surface, CFSTR("IOSurfaceColorSpace"), - QCFType(CGColorSpaceCopyPropertyList(colorSpace))); - } } QIOSurfaceGraphicsBuffer::~QIOSurfaceGraphicsBuffer() { } +void QIOSurfaceGraphicsBuffer::setColorSpace(QCFType colorSpace) +{ + Q_ASSERT(colorSpace); + IOSurfaceSetValue(m_surface, CFSTR("IOSurfaceColorSpace"), + QCFType(CGColorSpaceCopyPropertyList(colorSpace))); +} + const uchar *QIOSurfaceGraphicsBuffer::data() const { return (const uchar *)IOSurfaceGetBaseAddress(m_surface); -- cgit v1.2.3 From a63969081c2f1656636f6fbc24b402a0f72c410b Mon Sep 17 00:00:00 2001 From: Alexandra Cherdantseva Date: Thu, 26 Dec 2019 16:17:20 +0300 Subject: wasm: support all cursor shapes Every Qt::CursorShape is supported. Tested in Chrome, Firefox and Safari. Change-Id: I38c9024dba4af70af789ac84ad7e38f749c847d7 Reviewed-by: Lorn Potter --- src/plugins/platforms/wasm/qwasmcursor.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/qwasmcursor.cpp b/src/plugins/platforms/wasm/qwasmcursor.cpp index 2b3f37300d..28ec3b58dd 100644 --- a/src/plugins/platforms/wasm/qwasmcursor.cpp +++ b/src/plugins/platforms/wasm/qwasmcursor.cpp @@ -68,6 +68,7 @@ QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape) cursorName = "default"; break; case Qt::UpArrowCursor: + cursorName = "n-resize"; break; case Qt::CrossCursor: cursorName = "crosshair"; @@ -91,7 +92,8 @@ QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape) cursorName = "nwse-resize"; break; case Qt::SizeAllCursor: - break; // no equivalent? + cursorName = "move"; + break; case Qt::BlankCursor: cursorName = "none"; break; @@ -111,18 +113,23 @@ QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape) cursorName = "help"; break; case Qt::BusyCursor: - cursorName = "wait"; + cursorName = "progress"; break; case Qt::OpenHandCursor: - break; // no equivalent? + cursorName = "grab"; + break; case Qt::ClosedHandCursor: - break; // no equivalent? + cursorName = "grabbing"; + break; case Qt::DragCopyCursor: - break; // no equivalent? + cursorName = "copy"; + break; case Qt::DragMoveCursor: - break; // no equivalent? + cursorName = "default"; + break; case Qt::DragLinkCursor: - break; // no equivalent? + cursorName = "alias"; + break; default: break; } -- cgit v1.2.3 From 809a96d6d94a93046dc63dd6f52c51ae90c374f8 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Wed, 18 Dec 2019 19:06:18 +1000 Subject: wasm: fix setting translucent background MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to set the requested SurfaceFormat which may contain the alphaBufferSize in order for the GL context to have the alpha attribute Fixes: QTBUG-77303 Change-Id: I39860e24de49a255ab7e73bca78af92e6c074d0d Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/wasm/qwasmcompositor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp index a810880c43..e9c4559971 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.cpp +++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp @@ -694,7 +694,7 @@ void QWasmCompositor::frame() if (m_context.isNull()) { m_context.reset(new QOpenGLContext()); - //mContext->setFormat(mScreen->format()); + m_context->setFormat(someWindow->window()->requestedFormat()); m_context->setScreen(screen()->screen()); m_context->create(); } -- cgit v1.2.3 From c027d9b61e15ab021a6fb5503e3206929055da02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 2 Jan 2020 12:22:02 +0100 Subject: Remove commented out code added by mistake in 7ac4e55cb979d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ibd53518be9d2b29dd880912bdb81c06435543789 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index d8c931e9a1..b7f15a2bf1 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -396,8 +396,6 @@ QVariant QCocoaIntegration::styleHint(StyleHint hint) const return QCoreTextFontEngine::fontSmoothingGamma(); case ShowShortcutsInContextMenus: return QVariant(false); - // case CursorFlashTime: - // return 50000; default: break; } -- cgit v1.2.3 From 105e662221cc90d5002e06c97febf50c5c601336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 2 Jan 2020 13:21:58 +0100 Subject: macOS: Handle missing color space information in IOSurface backingstore Fixes: QTBUG-80972 Change-Id: Iab3f1a9cf03251340e5f32bcc73103428e93282d Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm index 285e316d4a..fc187e0f51 100644 --- a/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm +++ b/src/plugins/platforms/cocoa/qiosurfacegraphicsbuffer.mm @@ -89,9 +89,16 @@ QIOSurfaceGraphicsBuffer::~QIOSurfaceGraphicsBuffer() void QIOSurfaceGraphicsBuffer::setColorSpace(QCFType colorSpace) { - Q_ASSERT(colorSpace); - IOSurfaceSetValue(m_surface, CFSTR("IOSurfaceColorSpace"), - QCFType(CGColorSpaceCopyPropertyList(colorSpace))); + static const auto kIOSurfaceColorSpace = CFSTR("IOSurfaceColorSpace"); + + qCDebug(lcQpaIOSurface) << "Tagging" << this << "with color space" << colorSpace; + + if (colorSpace) { + IOSurfaceSetValue(m_surface, kIOSurfaceColorSpace, + QCFType(CGColorSpaceCopyPropertyList(colorSpace))); + } else { + IOSurfaceRemoveValue(m_surface, kIOSurfaceColorSpace); + } } const uchar *QIOSurfaceGraphicsBuffer::data() const -- cgit v1.2.3 From 77f1d0bfa542e166deaa196b3b3b854d33a3a1b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 3 Jan 2020 13:22:06 +0100 Subject: macOS: Skip uninitialized buffers in IOSurface backingstore Task-number: QTBUG-80972 Change-Id: Ifb8eb84d6b802556ccd52ac129a91e142e265a81 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoabackingstore.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm index 8a815a7665..2e15d11564 100644 --- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm +++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm @@ -617,8 +617,10 @@ QImage QCALayerBackingStore::toImage() const void QCALayerBackingStore::backingPropertiesChanged() { qCDebug(lcQpaBackingStore) << "Updating color space of existing buffers"; - for (auto &buffer : m_buffers) - buffer->setColorSpace(colorSpace()); + for (auto &buffer : m_buffers) { + if (buffer) + buffer->setColorSpace(colorSpace()); + } } QPlatformGraphicsBuffer *QCALayerBackingStore::graphicsBuffer() const -- cgit v1.2.3 From b3f94eba6d4a329b5c64c7fb60ba33e3a8df301e Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 30 Dec 2019 19:42:33 +0100 Subject: SQL: add proper support to build QMYSQL with MariaDB client libraries The QMYSQL plugin can also be build with the MariaDB client libraries since they are source compatible. But the MariaDB libraries could not be found on windows because the library name differs. Therefore add the correct library names and update the documentation to make clear that MariaDB is supported through the QMYSQL plugin. [ChangeLog][Sql][QMYSQL] The QMYSQL plugin can now be build with the MariaDB C connector libs on Windows. Change-Id: Id99f8be96c4179fd2321b3e61c90bb300c53bb82 Reviewed-by: Marius Kittler Reviewed-by: Andy Shaw --- src/plugins/sqldrivers/configure.json | 2 ++ src/plugins/sqldrivers/mysql/main.cpp | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/sqldrivers/configure.json b/src/plugins/sqldrivers/configure.json index cd20eef1df..28ccbeadcd 100644 --- a/src/plugins/sqldrivers/configure.json +++ b/src/plugins/sqldrivers/configure.json @@ -72,7 +72,9 @@ { "type": "mysqlConfig", "query": "--libs_r", "cleanlibs": false }, { "type": "mysqlConfig", "query": "--libs", "cleanlibs": false }, { "libs": "-lmysqlclient_r", "condition": "!config.win32" }, + { "libs": "-llibmariadb", "condition": "config.win32" }, { "libs": "-llibmysql", "condition": "config.win32" }, + { "libs": "-lmariadb", "condition": "!config.win32" }, { "libs": "-lmysqlclient", "condition": "!config.win32" } ] }, diff --git a/src/plugins/sqldrivers/mysql/main.cpp b/src/plugins/sqldrivers/mysql/main.cpp index d8d70483ef..4c6753097f 100644 --- a/src/plugins/sqldrivers/mysql/main.cpp +++ b/src/plugins/sqldrivers/mysql/main.cpp @@ -61,7 +61,9 @@ QMYSQLDriverPlugin::QMYSQLDriverPlugin() QSqlDriver* QMYSQLDriverPlugin::create(const QString &name) { - if (name == QLatin1String("QMYSQL") || name == QLatin1String("QMYSQL3")) { + if (name == QLatin1String("QMYSQL") || + name == QLatin1String("QMYSQL3") || + name == QLatin1String("QMARIADB")) { QMYSQLDriver* driver = new QMYSQLDriver(); return driver; } -- cgit v1.2.3 From aa542be4e005b1feedc2e17fd6ca2387bf2fea1b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 18 Dec 2019 17:23:50 +0100 Subject: Modernize setAlphaChannel(), and deprecated alphaChannel() The two methods have been marked obsolete for a very long time, setAlphaChannel() is still convenient though, so this patch modernizes it and removes obsolete from the API, while marking QImage::alphaChannel() as deprecated. They don't work as getter and setter anyway, since setAlphaChannel() actually does an alpha composition. Change-Id: I634d6463f78c42bb9c5fa3df17500ec01bfcac33 Reviewed-by: Eirik Aavitsland --- src/plugins/imageformats/ico/qicohandler.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index 6515748bf5..eb50f52bd6 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -535,8 +535,6 @@ QImage ICOReader::iconAt(int index) if (!mask.isNull()) { img = image; img.setAlphaChannel(mask); - // (Luckily, it seems that setAlphaChannel() does not ruin the alpha values - // of partially transparent pixels in those icons that have that) } } } -- cgit v1.2.3 From 1535fc9fb9ddbfce1680979c0634b4fdf8d75fca Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 20 Dec 2019 15:41:32 +0100 Subject: tablets on xcb: report correct local coordinates to nested windows Change e4532224145a0a72cde9b40cb7fd39011624d1c1 tried to map global position directly from the desktop to the window that should receive the event. That's fine for single-window applications; but media players like OBS and VLC often use embedded windows to play video. So the mapping needs to traverse the window parent hierarchy somehow. In this patch it's done by calling QWindow::mapFromGlobal(), but that only works with integer coordinates (QPoint). To preserve the fix for QTBUG-48151 (and other jitter bugs), we need sub-pixel accuracy; so we have to add back the fractional part after mapping the int part. Fixes: QTBUG-77826 Change-Id: Ib52ce14138e477182e0ef53b0ff30ce1eff40372 Reviewed-by: Gatis Paeglis --- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 4639185416..0a82bbc7a9 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -1252,14 +1252,16 @@ void QXcbConnection::xi2ReportTabletEvent(const void *event, TabletData *tabletD if (Q_LIKELY(useValuators)) { const qreal value = scaleOneValuator(normalizedValue, physicalScreenArea.x(), physicalScreenArea.width()); global.setX(value); - local.setX(value - window->handle()->geometry().x()); + // mapFromGlobal is ok for nested/embedded windows, but works only with whole-number QPoint; + // so map it first, then add back the sub-pixel position + local.setX(window->mapFromGlobal(QPoint(int(value), 0)).x() + (value - int(value))); } break; case QXcbAtom::AbsY: if (Q_LIKELY(useValuators)) { qreal value = scaleOneValuator(normalizedValue, physicalScreenArea.y(), physicalScreenArea.height()); global.setY(value); - local.setY(value - window->handle()->geometry().y()); + local.setY(window->mapFromGlobal(QPoint(0, int(value))).y() + (value - int(value))); } break; case QXcbAtom::AbsPressure: -- cgit v1.2.3 From 42ecdfe6f3bcbf3e35ca88b24af07249e3936fc7 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 6 Jan 2020 12:33:55 +0100 Subject: Revert "Android: Implement MaximizeUsingFullscreenGeometryHint" This reverts commit c17a5cec1901dd23f4c39ec2ae47a060fbb06895. The patch introduced a call to View.getRootViewInsets() which was introduced in API level 23. We don't want to change the minimum level for Qt 5.x series now, so we will revert the change in 5.15 and reintroduce it in Qt 6, simultaneously setting the minimum API level to 23. Task-number: QTBUG-74202 Change-Id: Ia25bb2cd62287aa80a43bbd294fb757f3f79ff5e Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/androidjniinput.cpp | 4 +- src/plugins/platforms/android/androidjnimain.cpp | 69 +++++++++++++--------- src/plugins/platforms/android/androidjnimain.h | 13 ++-- .../android/qandroidplatformintegration.cpp | 54 +++++++++-------- .../android/qandroidplatformintegration.h | 28 +++++---- .../platforms/android/qandroidplatformscreen.cpp | 11 ++-- .../platforms/android/qandroidplatformwindow.cpp | 32 +++------- .../platforms/android/qandroidplatformwindow.h | 4 +- 8 files changed, 107 insertions(+), 108 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index 049f9b0b13..56885f2e23 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -247,8 +247,8 @@ namespace QtAndroidInput break; } - const int dw = availableWidthPixels(); - const int dh = availableHeightPixels(); + const int dw = desktopWidthPixels(); + const int dh = desktopHeightPixels(); QWindowSystemInterface::TouchPoint touchPoint; touchPoint.id = id; touchPoint.pressure = pressure; diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index bdbd3517bd..fd2644717e 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -111,8 +111,8 @@ static int m_surfaceId = 1; static QAndroidPlatformIntegration *m_androidPlatformIntegration = nullptr; -static int m_availableWidthPixels = 0; -static int m_availableHeightPixels = 0; +static int m_desktopWidthPixels = 0; +static int m_desktopHeightPixels = 0; static double m_scaledDensity = 0; static double m_density = 1.0; @@ -155,14 +155,14 @@ namespace QtAndroid : 0; } - int availableWidthPixels() + int desktopWidthPixels() { - return m_availableWidthPixels; + return m_desktopWidthPixels; } - int availableHeightPixels() + int desktopHeightPixels() { - return m_availableHeightPixels; + return m_desktopHeightPixels; } double scaledDensity() @@ -200,9 +200,22 @@ namespace QtAndroid return m_serviceObject; } - void setSystemUiVisibility(SystemUiVisibility uiVisibility) + void showStatusBar() { - QJNIObjectPrivate::callStaticMethod(m_applicationClass, "setSystemUiVisibility", "(I)V", jint(uiVisibility)); + if (m_statusBarShowing) + return; + + QJNIObjectPrivate::callStaticMethod(m_applicationClass, "setFullScreen", "(Z)V", false); + m_statusBarShowing = true; + } + + void hideStatusBar() + { + if (!m_statusBarShowing) + return; + + QJNIObjectPrivate::callStaticMethod(m_applicationClass, "setFullScreen", "(Z)V", true); + m_statusBarShowing = false; } jobject createBitmap(QImage img, JNIEnv *env) @@ -607,33 +620,35 @@ static void setSurface(JNIEnv *env, jobject /*thiz*/, jint id, jobject jSurface, } static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/, - jint screenWidthPixels, jint screenHeightPixels, - jint availableLeftPixels, jint availableTopPixels, - jint availableWidthPixels, jint availableHeightPixels, + jint widthPixels, jint heightPixels, + jint desktopWidthPixels, jint desktopHeightPixels, jdouble xdpi, jdouble ydpi, jdouble scaledDensity, jdouble density) { - m_availableWidthPixels = availableWidthPixels; - m_availableHeightPixels = availableHeightPixels; + // Android does not give us the correct screen size for immersive mode, but + // the surface does have the right size + + widthPixels = qMax(widthPixels, desktopWidthPixels); + heightPixels = qMax(heightPixels, desktopHeightPixels); + + m_desktopWidthPixels = desktopWidthPixels; + m_desktopHeightPixels = desktopHeightPixels; m_scaledDensity = scaledDensity; m_density = density; QMutexLocker lock(&m_platformMutex); if (!m_androidPlatformIntegration) { - QAndroidPlatformIntegration::setDefaultDisplayMetrics(availableLeftPixels, - availableTopPixels, - availableWidthPixels, - availableHeightPixels, - qRound(double(screenWidthPixels) / xdpi * 25.4), - qRound(double(screenHeightPixels) / ydpi * 25.4), - screenWidthPixels, - screenHeightPixels); + QAndroidPlatformIntegration::setDefaultDisplayMetrics(desktopWidthPixels, + desktopHeightPixels, + qRound(double(widthPixels) / xdpi * 25.4), + qRound(double(heightPixels) / ydpi * 25.4), + widthPixels, + heightPixels); } else { - m_androidPlatformIntegration->setPhysicalSize(qRound(double(screenWidthPixels) / xdpi * 25.4), - qRound(double(screenHeightPixels) / ydpi * 25.4)); - m_androidPlatformIntegration->setScreenSize(screenWidthPixels, screenHeightPixels); - m_androidPlatformIntegration->setAvailableGeometry(QRect(availableLeftPixels, availableTopPixels, - availableWidthPixels, availableHeightPixels)); + m_androidPlatformIntegration->setDisplayMetrics(qRound(double(widthPixels) / xdpi * 25.4), + qRound(double(heightPixels) / ydpi * 25.4)); + m_androidPlatformIntegration->setScreenSize(widthPixels, heightPixels); + m_androidPlatformIntegration->setDesktopSize(desktopWidthPixels, desktopHeightPixels); } } @@ -759,7 +774,7 @@ static JNINativeMethod methods[] = { {"quitQtCoreApplication", "()V", (void *)quitQtCoreApplication}, {"terminateQt", "()V", (void *)terminateQt}, {"waitForServiceSetup", "()V", (void *)waitForServiceSetup}, - {"setDisplayMetrics", "(IIIIIIDDDD)V", (void *)setDisplayMetrics}, + {"setDisplayMetrics", "(IIIIDDDD)V", (void *)setDisplayMetrics}, {"setSurface", "(ILjava/lang/Object;II)V", (void *)setSurface}, {"updateWindow", "()V", (void *)updateWindow}, {"updateApplicationState", "(I)V", (void *)updateApplicationState}, diff --git a/src/plugins/platforms/android/androidjnimain.h b/src/plugins/platforms/android/androidjnimain.h index 63be5910f9..17ae30a1be 100644 --- a/src/plugins/platforms/android/androidjnimain.h +++ b/src/plugins/platforms/android/androidjnimain.h @@ -77,8 +77,8 @@ namespace QtAndroid void bringChildToBack(int surfaceId); QWindow *topLevelWindowAt(const QPoint &globalPos); - int availableWidthPixels(); - int availableHeightPixels(); + int desktopWidthPixels(); + int desktopHeightPixels(); double scaledDensity(); double pixelDensity(); JavaVM *javaVM(); @@ -88,13 +88,8 @@ namespace QtAndroid jobject activity(); jobject service(); - // Keep synchronized with flags in ActivityDelegate.java - enum SystemUiVisibility { - SYSTEM_UI_VISIBILITY_NORMAL = 0, - SYSTEM_UI_VISIBILITY_FULLSCREEN = 1, - SYSTEM_UI_VISIBILITY_TRANSLUCENT = 2 - }; - void setSystemUiVisibility(SystemUiVisibility uiVisibility); + void showStatusBar(); + void hideStatusBar(); jobject createBitmap(QImage img, JNIEnv *env = 0); jobject createBitmap(int width, int height, QImage::Format format, JNIEnv *env); diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index 48f330680b..e0c437be27 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -76,9 +76,12 @@ QT_BEGIN_NAMESPACE -QSize QAndroidPlatformIntegration::m_defaultScreenSize = QSize(320, 455); -QRect QAndroidPlatformIntegration::m_defaultAvailableGeometry = QRect(0, 0, 320, 455); -QSize QAndroidPlatformIntegration::m_defaultPhysicalSize = QSize(50, 71); +int QAndroidPlatformIntegration::m_defaultGeometryWidth = 320; +int QAndroidPlatformIntegration::m_defaultGeometryHeight = 455; +int QAndroidPlatformIntegration::m_defaultScreenWidth = 320; +int QAndroidPlatformIntegration::m_defaultScreenHeight = 455; +int QAndroidPlatformIntegration::m_defaultPhysicalSizeWidth = 50; +int QAndroidPlatformIntegration::m_defaultPhysicalSizeHeight = 71; Qt::ScreenOrientation QAndroidPlatformIntegration::m_orientation = Qt::PrimaryOrientation; Qt::ScreenOrientation QAndroidPlatformIntegration::m_nativeOrientation = Qt::PrimaryOrientation; @@ -171,9 +174,9 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_primaryScreen = new QAndroidPlatformScreen(); QWindowSystemInterface::handleScreenAdded(m_primaryScreen); - m_primaryScreen->setPhysicalSize(m_defaultPhysicalSize); - m_primaryScreen->setSize(m_defaultScreenSize); - m_primaryScreen->setAvailableGeometry(m_defaultAvailableGeometry); + m_primaryScreen->setPhysicalSize(QSize(m_defaultPhysicalSizeWidth, m_defaultPhysicalSizeHeight)); + m_primaryScreen->setSize(QSize(m_defaultScreenWidth, m_defaultScreenHeight)); + m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight)); m_mainThread = QThread::currentThread(); @@ -263,7 +266,6 @@ bool QAndroidPlatformIntegration::hasCapability(Capability cap) const case ThreadedOpenGL: return !needsBasicRenderloopWorkaround() && QtAndroid::activity(); case RasterGLSurface: return QtAndroid::activity(); case TopStackedNativeChildWindows: return false; - case MaximizeUsingFullscreenGeometry: return true; default: return QPlatformIntegration::hasCapability(cap); } @@ -413,19 +415,20 @@ QPlatformTheme *QAndroidPlatformIntegration::createPlatformTheme(const QString & return 0; } -void QAndroidPlatformIntegration::setDefaultDisplayMetrics(int availableLeft, - int availableTop, - int availableWidth, - int availableHeight, - int physicalWidth, - int physicalHeight, - int screenWidth, - int screenHeight) +void QAndroidPlatformIntegration::setDefaultDisplayMetrics(int gw, int gh, int sw, int sh, int screenWidth, int screenHeight) { - m_defaultAvailableGeometry = QRect(availableLeft, availableTop, - availableWidth, availableHeight); - m_defaultPhysicalSize = QSize(physicalWidth, physicalHeight); - m_defaultScreenSize = QSize(screenWidth, screenHeight); + m_defaultGeometryWidth = gw; + m_defaultGeometryHeight = gh; + m_defaultPhysicalSizeWidth = sw; + m_defaultPhysicalSizeHeight = sh; + m_defaultScreenWidth = screenWidth; + m_defaultScreenHeight = screenHeight; +} + +void QAndroidPlatformIntegration::setDefaultDesktopSize(int gw, int gh) +{ + m_defaultGeometryWidth = gw; + m_defaultGeometryHeight = gh; } void QAndroidPlatformIntegration::setScreenOrientation(Qt::ScreenOrientation currentOrientation, @@ -437,9 +440,10 @@ void QAndroidPlatformIntegration::setScreenOrientation(Qt::ScreenOrientation cur void QAndroidPlatformIntegration::flushPendingUpdates() { - m_primaryScreen->setPhysicalSize(m_defaultPhysicalSize); - m_primaryScreen->setSize(m_defaultScreenSize); - m_primaryScreen->setAvailableGeometry(m_defaultAvailableGeometry); + m_primaryScreen->setPhysicalSize(QSize(m_defaultPhysicalSizeWidth, + m_defaultPhysicalSizeHeight)); + m_primaryScreen->setSize(QSize(m_defaultScreenWidth, m_defaultScreenHeight)); + m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight)); } #ifndef QT_NO_ACCESSIBILITY @@ -449,13 +453,13 @@ QPlatformAccessibility *QAndroidPlatformIntegration::accessibility() const } #endif -void QAndroidPlatformIntegration::setAvailableGeometry(const QRect &availableGeometry) +void QAndroidPlatformIntegration::setDesktopSize(int width, int height) { if (m_primaryScreen) - QMetaObject::invokeMethod(m_primaryScreen, "setAvailableGeometry", Qt::AutoConnection, Q_ARG(QRect, availableGeometry)); + QMetaObject::invokeMethod(m_primaryScreen, "setAvailableGeometry", Qt::AutoConnection, Q_ARG(QRect, QRect(0,0,width, height))); } -void QAndroidPlatformIntegration::setPhysicalSize(int width, int height) +void QAndroidPlatformIntegration::setDisplayMetrics(int width, int height) { if (m_primaryScreen) QMetaObject::invokeMethod(m_primaryScreen, "setPhysicalSize", Qt::AutoConnection, Q_ARG(QSize, QSize(width, height))); diff --git a/src/plugins/platforms/android/qandroidplatformintegration.h b/src/plugins/platforms/android/qandroidplatformintegration.h index d607ec0064..c795c499bc 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/qandroidplatformintegration.h @@ -91,8 +91,8 @@ public: QAndroidPlatformScreen *screen() { return m_primaryScreen; } QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override; - void setAvailableGeometry(const QRect &availableGeometry); - void setPhysicalSize(int width, int height); + virtual void setDesktopSize(int width, int height); + virtual void setDisplayMetrics(int width, int height); void setScreenSize(int width, int height); bool isVirtualDesktop() { return true; } @@ -116,17 +116,16 @@ public: QStringList themeNames() const override; QPlatformTheme *createPlatformTheme(const QString &name) const override; - static void setDefaultDisplayMetrics(int availableLeft, - int availableTop, - int availableWidth, - int availableHeight, - int physicalWidth, - int physicalHeight, - int screenWidth, - int screenHeight); + static void setDefaultDisplayMetrics(int gw, int gh, int sw, int sh, int width, int height); + static void setDefaultDesktopSize(int gw, int gh); static void setScreenOrientation(Qt::ScreenOrientation currentOrientation, Qt::ScreenOrientation nativeOrientation); + static QSize defaultDesktopSize() + { + return QSize(m_defaultGeometryWidth, m_defaultGeometryHeight); + } + QTouchDevice *touchDevice() const { return m_touchDevice; } void setTouchDevice(QTouchDevice *touchDevice) { m_touchDevice = touchDevice; } @@ -144,9 +143,12 @@ private: QThread *m_mainThread; - static QRect m_defaultAvailableGeometry; - static QSize m_defaultPhysicalSize; - static QSize m_defaultScreenSize; + static int m_defaultGeometryWidth; + static int m_defaultGeometryHeight; + static int m_defaultPhysicalSizeWidth; + static int m_defaultPhysicalSizeHeight; + static int m_defaultScreenWidth; + static int m_defaultScreenHeight; static Qt::ScreenOrientation m_orientation; static Qt::ScreenOrientation m_nativeOrientation; diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp index 5f8486a7a2..80757c2135 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.cpp +++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp @@ -90,8 +90,8 @@ private: QAndroidPlatformScreen::QAndroidPlatformScreen() : QObject(), QPlatformScreen() { - m_availableGeometry = QAndroidPlatformIntegration::m_defaultAvailableGeometry; - m_size = QAndroidPlatformIntegration::m_defaultScreenSize; + m_availableGeometry = QRect(0, 0, QAndroidPlatformIntegration::m_defaultGeometryWidth, QAndroidPlatformIntegration::m_defaultGeometryHeight); + m_size = QSize(QAndroidPlatformIntegration::m_defaultScreenWidth, QAndroidPlatformIntegration::m_defaultScreenHeight); // Raster only apps should set QT_ANDROID_RASTER_IMAGE_DEPTH to 16 // is way much faster than 32 if (qEnvironmentVariableIntValue("QT_ANDROID_RASTER_IMAGE_DEPTH") == 16) { @@ -101,7 +101,8 @@ QAndroidPlatformScreen::QAndroidPlatformScreen() m_format = QImage::Format_ARGB32_Premultiplied; m_depth = 32; } - m_physicalSize = QAndroidPlatformIntegration::m_defaultPhysicalSize; + m_physicalSize.setHeight(QAndroidPlatformIntegration::m_defaultPhysicalSizeHeight); + m_physicalSize.setWidth(QAndroidPlatformIntegration::m_defaultPhysicalSizeWidth); connect(qGuiApp, &QGuiApplication::applicationStateChanged, this, &QAndroidPlatformScreen::applicationStateChanged); } @@ -293,7 +294,7 @@ void QAndroidPlatformScreen::topWindowChanged(QWindow *w) if (w != 0) { QAndroidPlatformWindow *platformWindow = static_cast(w->handle()); if (platformWindow != 0) - platformWindow->updateSystemUiVisibility(); + platformWindow->updateStatusBarVisibility(); } } @@ -333,7 +334,7 @@ void QAndroidPlatformScreen::doRedraw() } QMutexLocker lock(&m_surfaceMutex); if (m_id == -1 && m_rasterSurfaces) { - m_id = QtAndroid::createSurface(this, geometry(), true, m_depth); + m_id = QtAndroid::createSurface(this, m_availableGeometry, true, m_depth); AndroidDeadlockProtector protector; if (!protector.acquire()) return; diff --git a/src/plugins/platforms/android/qandroidplatformwindow.cpp b/src/plugins/platforms/android/qandroidplatformwindow.cpp index a88cb9b823..4f691ce112 100644 --- a/src/plugins/platforms/android/qandroidplatformwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformwindow.cpp @@ -67,39 +67,25 @@ void QAndroidPlatformWindow::lower() void QAndroidPlatformWindow::raise() { - updateSystemUiVisibility(); + updateStatusBarVisibility(); platformScreen()->raise(this); } -QMargins QAndroidPlatformWindow::safeAreaMargins() const -{ - if ((m_windowState & Qt::WindowMaximized) && (window()->flags() & Qt::MaximizeUsingFullscreenGeometryHint)) { - QRect availableGeometry = platformScreen()->availableGeometry(); - return QMargins(availableGeometry.left(), availableGeometry.top(), - availableGeometry.right(), availableGeometry.bottom()); - } else { - return QPlatformWindow::safeAreaMargins(); - } -} - void QAndroidPlatformWindow::setGeometry(const QRect &rect) { - QPlatformWindow::setGeometry(rect); QWindowSystemInterface::handleGeometryChange(window(), rect); } void QAndroidPlatformWindow::setVisible(bool visible) { if (visible) - updateSystemUiVisibility(); + updateStatusBarVisibility(); if (visible) { - if ((m_windowState & Qt::WindowFullScreen) - || ((m_windowState & Qt::WindowMaximized) && (window()->flags() & Qt::MaximizeUsingFullscreenGeometryHint))) { + if (m_windowState & Qt::WindowFullScreen) setGeometry(platformScreen()->geometry()); - } else if (m_windowState & Qt::WindowMaximized) { + else if (m_windowState & Qt::WindowMaximized) setGeometry(platformScreen()->availableGeometry()); - } } if (visible) @@ -121,7 +107,7 @@ void QAndroidPlatformWindow::setWindowState(Qt::WindowStates state) m_windowState = state; if (window()->isVisible()) - updateSystemUiVisibility(); + updateStatusBarVisibility(); } void QAndroidPlatformWindow::setWindowFlags(Qt::WindowFlags flags) @@ -157,17 +143,15 @@ void QAndroidPlatformWindow::requestActivateWindow() platformScreen()->topWindowChanged(window()); } -void QAndroidPlatformWindow::updateSystemUiVisibility() +void QAndroidPlatformWindow::updateStatusBarVisibility() { Qt::WindowFlags flags = window()->flags(); bool isNonRegularWindow = flags & (Qt::Popup | Qt::Dialog | Qt::Sheet) & ~Qt::Window; if (!isNonRegularWindow) { if (m_windowState & Qt::WindowFullScreen) - QtAndroid::setSystemUiVisibility(QtAndroid::SYSTEM_UI_VISIBILITY_FULLSCREEN); - else if (flags & Qt::MaximizeUsingFullscreenGeometryHint) - QtAndroid::setSystemUiVisibility(QtAndroid::SYSTEM_UI_VISIBILITY_TRANSLUCENT); + QtAndroid::hideStatusBar(); else - QtAndroid::setSystemUiVisibility(QtAndroid::SYSTEM_UI_VISIBILITY_NORMAL); + QtAndroid::showStatusBar(); } } diff --git a/src/plugins/platforms/android/qandroidplatformwindow.h b/src/plugins/platforms/android/qandroidplatformwindow.h index f83ad7bea3..d8eb6b7b7f 100644 --- a/src/plugins/platforms/android/qandroidplatformwindow.h +++ b/src/plugins/platforms/android/qandroidplatformwindow.h @@ -70,11 +70,9 @@ public: QAndroidPlatformScreen *platformScreen() const; - QMargins safeAreaMargins() const override; - void propagateSizeHints() override; void requestActivateWindow() override; - void updateSystemUiVisibility(); + void updateStatusBarVisibility(); inline bool isRaster() const { if (isForeignWindow()) return false; -- cgit v1.2.3 From 8040f11f1d82cbaa44071fc8c6cf7244022146cf Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 1 Dec 2019 20:15:10 +0100 Subject: SQL: cleanup private classes Cleanup private SQL classes: - use nullptr - use member initialization - adjust style - remove deprecated functions Change-Id: I845f5b1081649fdd40f4f80e1052331806230cf7 Reviewed-by: Andy Shaw --- src/plugins/sqldrivers/psql/qsql_psql.cpp | 6 ------ src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp | 9 +-------- 2 files changed, 1 insertion(+), 14 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index d735d29fc7..27841d9494 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -1683,12 +1683,6 @@ void QPSQLDriver::_q_handleNotification(int) #if defined PG_VERSION_NUM && PG_VERSION_NUM-0 >= 70400 if (notify->extra) payload = d->isUtf8 ? QString::fromUtf8(notify->extra) : QString::fromLatin1(notify->extra); -#endif -#if QT_DEPRECATED_SINCE(5, 15) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - emit notification(name); -QT_WARNING_POP #endif QSqlDriver::NotificationSource source = (notify->be_pid == PQbackendPID(d->connection)) ? QSqlDriver::SelfSource : QSqlDriver::OtherSource; emit notification(name, source, payload); diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp index 65d3f0a580..5ef76eec21 100644 --- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp +++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp @@ -1043,15 +1043,8 @@ QStringList QSQLiteDriver::subscribedToNotifications() const void QSQLiteDriver::handleNotification(const QString &tableName, qint64 rowid) { Q_D(const QSQLiteDriver); - if (d->notificationid.contains(tableName)) { -#if QT_DEPRECATED_SINCE(5, 15) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - emit notification(tableName); -QT_WARNING_POP -#endif + if (d->notificationid.contains(tableName)) emit notification(tableName, QSqlDriver::UnknownSource, QVariant(rowid)); - } } QT_END_NAMESPACE -- cgit v1.2.3 From f2a61f2ce2fa81acb526965d55e5f22d47673b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Mon, 2 Dec 2019 18:17:35 +0100 Subject: xcb: Propagate size hints when window changes its scaling factor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Properly scale size hints to the new scaling factor. Fixes: QTBUG-80476 Change-Id: I1081c9b01560f7e434f0f1de0199ef3d3cae787c Reviewed-by: Tor Arne Vestbø Reviewed-by: Friedemann Kleint Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/xcb/qxcbwindow.cpp | 5 +++++ src/plugins/platforms/xcb/qxcbwindow.h | 2 ++ 2 files changed, 7 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 97da420798..cfe048d5c4 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1398,6 +1398,8 @@ void QXcbWindow::propagateSizeHints() } xcb_icccm_set_wm_normal_hints(xcb_connection(), m_window, &hints); + + m_sizeHintsScaleFactor = QHighDpiScaling::scaleAndOrigin(screen()).factor; } void QXcbWindow::requestActivateWindow() @@ -1789,6 +1791,9 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t * // will make the comparison later. QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->screen()); + if (!qFuzzyCompare(QHighDpiScaling::scaleAndOrigin(newScreen).factor, m_sizeHintsScaleFactor)) + propagateSizeHints(); + // Send the synthetic expose event on resize only when the window is shrinked, // because the "XCB_GRAVITY_NORTH_WEST" flag doesn't send it automatically. if (!m_oldWindowSize.isEmpty() diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 5de5974ca7..a808437c5a 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -280,6 +280,8 @@ protected: QXcbSyncWindowRequest *m_pendingSyncRequest = nullptr; int m_swapInterval = -1; + + qreal m_sizeHintsScaleFactor = 1.0; }; class QXcbForeignWindow : public QXcbWindow -- cgit v1.2.3 From c2687d1e5d26a7e9409bc0e226ebb802011702f9 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Fri, 3 Jan 2020 13:13:28 +1000 Subject: wasm: futureproof EmscriptenMouseEvent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Future versions of emscripten will remove the timestamp, so we need to replace this with the current timestamp See https://github.com/emscripten-core/emscripten/commit/a7f058a1e6e4b72b4446a3b36f8e96f9f8f41f2d#diff-9a5d68085dc7db2938b37a2b7b05c1f5 Change-Id: Ieba323ad54933626d90ac7cbae5a2c471c52628e Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/qwasmeventtranslator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index ad94ba9c77..a4ec78f27b 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -544,7 +544,7 @@ void resizeWindow(QWindow *window, QWasmWindow::ResizeMode mode, void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEvent *mouseEvent) { - auto timestamp = mouseEvent->timestamp; + auto timestamp = emscripten_date_now(); QPoint targetPoint(mouseEvent->targetX, mouseEvent->targetY); QPoint globalPoint = screen()->geometry().topLeft() + targetPoint; @@ -670,7 +670,7 @@ int QWasmEventTranslator::wheel_cb(int eventType, const EmscriptenWheelEvent *wh QWasmEventTranslator *translator = (QWasmEventTranslator*)userData; Qt::KeyboardModifiers modifiers = translator->translateMouseEventModifier(&mouseEvent); - auto timestamp = mouseEvent.timestamp; + auto timestamp = emscripten_date_now(); QPoint targetPoint(mouseEvent.targetX, mouseEvent.targetY); QPoint globalPoint = eventTranslator->screen()->geometry().topLeft() + targetPoint; -- cgit v1.2.3 From 1c75f59588694557caba69c2fc173dd8f1d7f514 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 8 Jan 2020 14:48:12 +0100 Subject: iOS: Handle positionFromPosition out of bounds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on the documentation for positionFromPosition, if the resulting position is less than 0 or longer than the text, then we should return nil. This fixes problems with placement of the cursor and selection rectangle when auto-completion is used. Fixes: QTBUG-79445 Change-Id: I44a18881527a8a22012fe5fcbbc3216e60c48bc9 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiostextresponder.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index 1bc9744528..a3350bda87 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -745,7 +745,11 @@ - (UITextPosition *)positionFromPosition:(UITextPosition *)position offset:(NSInteger)offset { int p = static_cast(position).index; - return [QUITextPosition positionWithIndex:p + offset]; + const int posWithIndex = p + offset; + const int textLength = [self currentImeState:Qt::ImSurroundingText].toString().length(); + if (posWithIndex < 0 || posWithIndex > textLength) + return nil; + return [QUITextPosition positionWithIndex:posWithIndex]; } - (UITextPosition *)positionFromPosition:(UITextPosition *)position inDirection:(UITextLayoutDirection)direction offset:(NSInteger)offset -- cgit v1.2.3 From 0a78e5f117a1988b4cf41195b4ac57ea3010a041 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 9 Jan 2020 16:34:07 +0100 Subject: xcb: Fix nullptr vs. VK_NULL_HANDLE error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fallout from a recent 0 - nullptr fixup in 5.15. Change-Id: I17adf742d4f65dc6a468fbe72d0f02d3efa276d7 Reviewed-by: Mårten Nordheim --- src/plugins/platforms/xcb/qxcbvulkaninstance.cpp | 2 +- src/plugins/platforms/xcb/qxcbvulkanwindow.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp b/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp index 7c15882768..bb82bcec39 100644 --- a/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp +++ b/src/plugins/platforms/xcb/qxcbvulkaninstance.cpp @@ -93,7 +93,7 @@ bool QXcbVulkanInstance::supportsPresent(VkPhysicalDevice physicalDevice, VkSurfaceKHR QXcbVulkanInstance::createSurface(QXcbWindow *window) { - VkSurfaceKHR surface = nullptr; + VkSurfaceKHR surface = VK_NULL_HANDLE; if (!m_createSurface) { m_createSurface = reinterpret_cast( diff --git a/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp b/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp index 17d7d9791e..a05ecab51d 100644 --- a/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE QXcbVulkanWindow::QXcbVulkanWindow(QWindow *window) : QXcbWindow(window), - m_surface(nullptr) + m_surface(VK_NULL_HANDLE) { } -- cgit v1.2.3 From 9a112bebe56f5975bdb11549c8d66773cf60419f Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Thu, 19 Dec 2019 17:24:24 +0500 Subject: QWindowsVistaStyle: Fix build with no dockwidget & commandlinkbutton features Change-Id: I0f7465cbe80e305680df37b2bf5e2f50874e6fe3 Reviewed-by: Friedemann Kleint --- src/plugins/styles/windowsvista/qwindowsvistastyle.cpp | 9 ++++++++- src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp index 345267c8fc..e8d74180cd 100644 --- a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp @@ -1365,6 +1365,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QWindowsStyle::drawControl(element, ©Opt, painter, widget); } break; +#if QT_CONFIG(dockwidget) case CE_DockWidgetTitle: if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast(option)) { const QDockWidget *dockWidget = qobject_cast(widget); @@ -1431,6 +1432,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption } } break; +#endif // QT_CONFIG(dockwidget) #if QT_CONFIG(itemviews) case CE_ItemViewItem: { @@ -2311,11 +2313,13 @@ void QWindowsVistaStyle::polish(QWidget *widget) #endif // QT_CONFIG(lineedit) if (qobject_cast(widget)) widget->setAttribute(Qt::WA_Hover); +#if QT_CONFIG(commandlinkbutton) else if (qobject_cast(widget)) { QFont buttonFont = widget->font(); buttonFont.setFamily(QLatin1String("Segoe UI")); widget->setFont(buttonFont); } +#endif // QT_CONFIG(commandlinkbutton) else if (widget->inherits("QTipLabel")){ //note that since tooltips are not reused //we do not have to care about unpolishing @@ -2392,12 +2396,15 @@ void QWindowsVistaStyle::unpolish(QWidget *widget) #endif // QT_CONFIG(inputdialog) else if (QTreeView *tree = qobject_cast (widget)) { tree->viewport()->setAttribute(Qt::WA_Hover, false); - } else if (qobject_cast(widget)) { + } +#if QT_CONFIG(commandlinkbutton) + else if (qobject_cast(widget)) { QFont font = QApplication::font("QCommandLinkButton"); QFont widgetFont = widget->font(); widgetFont.setFamily(font.family()); //Only family set by polish widget->setFont(widgetFont); } +#endif // QT_CONFIG(commandlinkbutton) } diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h b/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h index 8fef9f9927..c1d764a60e 100644 --- a/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h +++ b/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h @@ -106,7 +106,9 @@ #include #endif #include +#if QT_CONFIG(commandlinkbutton) #include +#endif QT_BEGIN_NAMESPACE -- cgit v1.2.3 From c4a9429be7e0e927289abbe7a34c061df0c07628 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 19 Dec 2019 10:36:15 +0100 Subject: Fix developer build with clang-cl failing due exception spec Clang does seem to understand __declspec(nothrow) as used by the COM macros like STDMETHOD. Suppress the warning, fixing errors like: qwindowsfontenginedirectwrite.cpp(105,24): error: 'AddBeziers' is missing exception specification '__attribute__((nothrow))' [-Werror,-Wmicrosoft-exception-spec] Task-number: QTBUG-63512 Change-Id: If582cb0c12c62a7d12c4ae702747aac1f735db3c Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowscombase.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowscombase.h b/src/plugins/platforms/windows/qwindowscombase.h index 45cba9c68b..bb4b295395 100644 --- a/src/plugins/platforms/windows/qwindowscombase.h +++ b/src/plugins/platforms/windows/qwindowscombase.h @@ -107,6 +107,9 @@ private: ULONG m_ref; }; +// Clang does not consider __declspec(nothrow) as nothrow +QT_WARNING_DISABLE_CLANG("-Wmicrosoft-exception-spec") + QT_END_NAMESPACE #endif // QWINDOWSCOMBASE_H -- cgit v1.2.3 From 3d1e257770e8c79c7cd9a08f9caf1bd8395cb10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 31 Oct 2019 09:33:40 +0100 Subject: Wasm: Support event loop wakeup from secondary threads Minimal fix for the missing wakeup issue, in leu of a new event loop implementation. So far, emscripten_async_run_in_main_runtime_thread_ looks to be our option for scheduling calls on the main thread. This function is available on emsdk 1.38.22 and higher. Requires making from QEventDispatcherUNIX::wakeUp() non-final. The future event dispatcher implementation will not inherit QEventDispatcherUNIX, so this is a temporary change. Fixes: QTBUG-75793 Task-number: QTBUG-76007 Change-Id: Ie6f6ee6f7674206fc0673a4fe866ac614432ab65 Reviewed-by: Lorn Potter --- .../platforms/wasm/qwasmeventdispatcher.cpp | 23 ++++++++++++++++++++++ src/plugins/platforms/wasm/qwasmeventdispatcher.h | 2 ++ 2 files changed, 25 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp index 41355d72ae..d89cd78b28 100644 --- a/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp +++ b/src/plugins/platforms/wasm/qwasmeventdispatcher.cpp @@ -33,6 +33,14 @@ #include +#if (__EMSCRIPTEN_major__ > 1 || __EMSCRIPTEN_minor__ > 38 || __EMSCRIPTEN_minor__ == 38 && __EMSCRIPTEN_tiny__ >= 22) +# define EMSCRIPTEN_HAS_ASYNC_RUN_IN_MAIN_RUNTIME_THREAD +#endif + +#ifdef EMSCRIPTEN_HAS_ASYNC_RUN_IN_MAIN_RUNTIME_THREAD +#include +#endif + class QWasmEventDispatcherPrivate : public QEventDispatcherUNIXPrivate { @@ -179,3 +187,18 @@ void QWasmEventDispatcher::doMaintainTimers() emscripten_async_call(callback, this, toWaitDuration); m_currentTargetTime = newTargetTime; } + +void QWasmEventDispatcher::wakeUp() +{ +#ifdef EMSCRIPTEN_HAS_ASYNC_RUN_IN_MAIN_RUNTIME_THREAD + if (!emscripten_is_main_runtime_thread()) + emscripten_async_run_in_main_runtime_thread_(EM_FUNC_SIG_VI, (void*)(&QWasmEventDispatcher::mainThreadWakeUp), this); +#endif + QEventDispatcherUNIX::wakeUp(); +} + +void QWasmEventDispatcher::mainThreadWakeUp(void *eventDispatcher) +{ + emscripten_resume_main_loop(); // Service possible requestUpdate Calls + static_cast(eventDispatcher)->processEvents(QEventLoop::AllEvents); +} diff --git a/src/plugins/platforms/wasm/qwasmeventdispatcher.h b/src/plugins/platforms/wasm/qwasmeventdispatcher.h index 5300b3de73..f72d92ce07 100644 --- a/src/plugins/platforms/wasm/qwasmeventdispatcher.h +++ b/src/plugins/platforms/wasm/qwasmeventdispatcher.h @@ -51,6 +51,8 @@ public: protected: bool processEvents(QEventLoop::ProcessEventsFlags flags) override; void doMaintainTimers(); + void wakeUp() override; + static void mainThreadWakeUp(void *eventDispatcher); private: bool m_hasMainLoop = false; -- cgit v1.2.3 From 18e06c37e10943f4b4f6d57b7044b9bce3a23202 Mon Sep 17 00:00:00 2001 From: Alexandra Cherdantseva Date: Mon, 30 Dec 2019 14:40:03 +0300 Subject: wasm: do not get canvas as property of js global object You cannot be sure that property with specified key in a global object is really a canvas. Should use `document.getElementById`. Change-Id: Ife55adaad5517aed64122b0c9bff32489cf19a2f Reviewed-by: Lorn Potter --- src/plugins/platforms/wasm/qwasmclipboard.cpp | 4 +++- src/plugins/platforms/wasm/qwasmcursor.cpp | 8 ++++++-- src/plugins/platforms/wasm/qwasmeventtranslator.cpp | 12 +++++++----- src/plugins/platforms/wasm/qwasmopenglcontext.cpp | 2 +- src/plugins/platforms/wasm/qwasmscreen.cpp | 9 ++++++--- 5 files changed, 23 insertions(+), 12 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/wasm/qwasmclipboard.cpp b/src/plugins/platforms/wasm/qwasmclipboard.cpp index d4a1e4dd50..fb46f1534f 100644 --- a/src/plugins/platforms/wasm/qwasmclipboard.cpp +++ b/src/plugins/platforms/wasm/qwasmclipboard.cpp @@ -198,7 +198,9 @@ void QWasmClipboard::installEventHandlers(const QString &canvasId) return; // Fallback path for browsers which do not support direct clipboard access - val canvas = val::global(canvasId.toUtf8().constData()); + val document = val::global("document"); + val canvas = document.call("getElementById", val(canvasId.toUtf8().constData())); + canvas.call("addEventListener", std::string("cut"), val::module_property("qtClipboardCutTo")); canvas.call("addEventListener", std::string("copy"), diff --git a/src/plugins/platforms/wasm/qwasmcursor.cpp b/src/plugins/platforms/wasm/qwasmcursor.cpp index 28ec3b58dd..c04fa6441a 100644 --- a/src/plugins/platforms/wasm/qwasmcursor.cpp +++ b/src/plugins/platforms/wasm/qwasmcursor.cpp @@ -36,6 +36,8 @@ #include #include +using namespace emscripten; + void QWasmCursor::changeCursor(QCursor *windowCursor, QWindow *window) { if (!windowCursor || !window) @@ -54,8 +56,10 @@ void QWasmCursor::changeCursor(QCursor *windowCursor, QWindow *window) htmlCursorName = "auto"; // Set cursor on the canvas - QString canvasId = QWasmScreen::get(screen)->canvasId(); - emscripten::val canvasStyle = emscripten::val::global(canvasId.toUtf8().constData())["style"]; + QByteArray canvasId = QWasmScreen::get(screen)->canvasId().toUtf8(); + val document = val::global("document"); + val canvas = document.call("getElementById", val(canvasId.constData())); + val canvasStyle = canvas["style"]; canvasStyle.set("cursor", emscripten::val(htmlCursorName.constData())); } diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index ad94ba9c77..8b7d00082f 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -47,9 +47,10 @@ #include -QT_BEGIN_NAMESPACE using namespace emscripten; +QT_BEGIN_NAMESPACE + typedef struct emkb2qt { const char *em; unsigned int qt; @@ -353,10 +354,11 @@ void QWasmEventTranslator::initEventHandlers() g_useNaturalScrolling = false; // make this !default on macOS if (emscripten::val::global("window")["safari"].isUndefined()) { - - emscripten::val::global(canvasId).call("addEventListener", - std::string("wheel"), - val::module_property("qtMouseWheelEvent")); + val document = val::global("document"); + val canvas = document.call("getElementById", val(canvasId)); + canvas.call("addEventListener", + std::string("wheel"), + val::module_property("qtMouseWheelEvent")); } } diff --git a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp index 0532b7e726..501ab99116 100644 --- a/src/plugins/platforms/wasm/qwasmopenglcontext.cpp +++ b/src/plugins/platforms/wasm/qwasmopenglcontext.cpp @@ -106,7 +106,7 @@ EMSCRIPTEN_WEBGL_CONTEXT_HANDLE QWasmOpenGLContext::createEmscriptenContext(cons attributes.depth = useDepthStencil; attributes.stencil = useDepthStencil; - EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(canvasId.toLocal8Bit().constData(), &attributes); + EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(canvasId.toUtf8().constData(), &attributes); return context; } diff --git a/src/plugins/platforms/wasm/qwasmscreen.cpp b/src/plugins/platforms/wasm/qwasmscreen.cpp index 37f1ea832a..fe44fdb096 100644 --- a/src/plugins/platforms/wasm/qwasmscreen.cpp +++ b/src/plugins/platforms/wasm/qwasmscreen.cpp @@ -44,6 +44,7 @@ #include #include +using namespace emscripten; QT_BEGIN_NAMESPACE @@ -182,13 +183,15 @@ void QWasmScreen::updateQScreenAndCanvasRenderSize() QSizeF cssSize(css_width, css_height); QSizeF canvasSize = cssSize * devicePixelRatio(); - emscripten::val canvas = emscripten::val::global(canvasId.constData()); + val document = val::global("document"); + val canvas = document.call("getElementById", val(canvasId.constData())); + canvas.set("width", canvasSize.width()); canvas.set("height", canvasSize.height()); QPoint offset; - offset.setX(emscripten::val::global(canvasId.constData())["offsetTop"].as()); - offset.setY(emscripten::val::global(canvasId.constData())["offsetLeft"].as()); + offset.setX(canvas["offsetTop"].as()); + offset.setY(canvas["offsetLeft"].as()); emscripten::val rect = canvas.call("getBoundingClientRect"); QPoint position(rect["left"].as() - offset.x(), rect["top"].as() - offset.y()); -- cgit v1.2.3 From 0a93db4d82c051164923a10e4382b12de9049b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 8 Jan 2020 17:48:58 +0100 Subject: Unify application palette handling between QGuiApplication and QApplication The logic is now mostly handled in QGuiApplication, with QApplication only dealing with the widget-specific palettes and interaction between the style and the palette. The application now picks up changes to the platform theme and will re-resolve the current application palette appropriately. This also works even if an explicit application palette has been set, in which case any missing roles are filled in by the theme. The palette can now also be reset back to the default application palette that's fully based on the theme, by passing in the default constructed palette (or any palette that doesn't have any roles set). This is also correctly reflected in the Qt::AA_SetPalette attribute. Conceptually this means QGuiApplication and QApplication follow the same behavior as QWidget, where the palette falls back to a base or inherited palette for roles that are not set, in this case the theme. Behavior-wise this means that the default application palette of the application does not have any roles set, but clients should not have relied on this, nor does QWidget rely on that internally. It also means that setting a palette on the application and then getting it back again will not produce the same palette as set, since the palette was resolved against the theme in the meantime. This is the same behavior as for QWidget, and although it's a behavior change it's one towards a more sane behavior, so we accept it. [ChangeLog] Application palettes are now resolved against the platform's theme palette, the same way widget palettes are resolved against their parents, and the application palette. This means the application palette reflected through QGuiApplication::palette() may not be exactly the same palette as set via QGuiApplication::setPalette(). Change-Id: I76b99fcd27285e564899548349aa2a5713e5965d Reviewed-by: Vitaly Fanaskov Reviewed-by: Friedemann Kleint --- src/plugins/styles/mac/qmacstyle_mac.mm | 2 +- src/plugins/styles/windowsvista/qwindowsxpstyle.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 5aa7befb84..37b658dd76 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -2585,7 +2585,7 @@ QPalette QMacStyle::standardPalette() const auto platformTheme = QGuiApplicationPrivate::platformTheme(); auto styleNames = platformTheme->themeHint(QPlatformTheme::StyleNames); if (styleNames.toStringList().contains("macintosh")) - return *platformTheme->palette(); + return QPalette(); // Inherit everything from theme else return QStyle::standardPalette(); } diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp index bf80138b32..5d2e8efd68 100644 --- a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp @@ -3774,8 +3774,7 @@ int QWindowsXPStyle::styleHint(StyleHint hint, const QStyleOption *option, const /*! \reimp */ QPalette QWindowsXPStyle::standardPalette() const { - return QWindowsXPStylePrivate::useXP() && QApplicationPrivate::sys_pal - ? *QApplicationPrivate::sys_pal : QWindowsStyle::standardPalette(); + return QWindowsXPStylePrivate::useXP() ? QPalette() : QWindowsStyle::standardPalette(); } /*! -- cgit v1.2.3 From 2f366a63b20a943ae3099605c2cdb34009ca5602 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 13 Jan 2020 15:58:14 +0100 Subject: Windows QPA: Fix message box and other system sounds Re-add the code hooking into QWindowsUiaAccessibility::notifyAccessibilityUpdate() which was removed by 0cf6297c15be45d852be98c862bd0211e6de1aa2. Fixes: QTBUG-81342 Change-Id: Ie97d7cca5b774196d53b675c92d84f4ce208f987 Reviewed-by: Oliver Wolff --- .../uiautomation/qwindowsuiaaccessibility.cpp | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp index c7c0deab3f..32a57473ad 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiaaccessibility.cpp @@ -52,6 +52,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE using namespace QWindowsUiAutomation; @@ -85,12 +87,63 @@ bool QWindowsUiaAccessibility::handleWmGetObject(HWND hwnd, WPARAM wParam, LPARA return false; } +// Retrieve sound name by checking the icon property of a message box +// should it be the event object. +static QString alertSound(const QObject *object) +{ + if (object->inherits("QMessageBox")) { + enum MessageBoxIcon { // Keep in sync with QMessageBox::Icon + Information = 1, + Warning = 2, + Critical = 3 + }; + switch (object->property("icon").toInt()) { + case Information: + return QStringLiteral("SystemAsterisk"); + case Warning: + return QStringLiteral("SystemExclamation"); + case Critical: + return QStringLiteral("SystemHand"); + } + } + return QStringLiteral("SystemAsterisk"); +} + +static QString soundFileName(const QString &soundName) +{ + const QString key = QStringLiteral("AppEvents\\Schemes\\Apps\\.Default\\") + + soundName + QStringLiteral("\\.Current"); + return QWinRegistryKey(HKEY_CURRENT_USER, key).stringValue(L""); +} + +static void playSystemSound(const QString &soundName) +{ + if (!soundName.isEmpty() && !soundFileName(soundName).isEmpty()) { + PlaySound(reinterpret_cast(soundName.utf16()), nullptr, + SND_ALIAS | SND_ASYNC | SND_NODEFAULT | SND_NOWAIT); + } +} + // Handles accessibility update notifications. void QWindowsUiaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) { if (!event) return; + switch (event->type()) { + case QAccessible::PopupMenuStart: + playSystemSound(QStringLiteral("MenuPopup")); + break; + case QAccessible::MenuCommand: + playSystemSound(QStringLiteral("MenuCommand")); + break; + case QAccessible::Alert: + playSystemSound(alertSound(event->object())); + break; + default: + break; + } + QAccessibleInterface *accessible = event->accessibleInterface(); if (!isActive() || !accessible || !accessible->isValid()) return; -- cgit v1.2.3 From 01d24eea09e1312e9fa7eee98e98ce22ed504aba Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 Jan 2020 09:26:46 +0100 Subject: Windows QPA: Fix co-existence of several Qt versions in an application Change qtbase/ef54abae43db79792b40dfdca30ac0fa1b582354 added a new dummy message window for power notification. This causes the static class name conflict check to assume there is no conflict since it does not exist in previous Qt versions. Change it to perform the for each class name. Fixes: QTBUG-81347 Change-Id: I290806d021ac7de130a41e996d03b8fb4eb2c437 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowscontext.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index a2dd25f8cc..d31352b854 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -604,15 +604,12 @@ QString QWindowsContext::registerWindowClass(QString cname, // each one has to have window class names with a unique name // The first instance gets the unmodified name; if the class // has already been registered by another instance of Qt then - // add a UUID. - static int classExists = -1; - + // add a UUID. The check needs to be performed for each name + // in case new message windows are added (QTBUG-81347). const auto appInstance = static_cast(GetModuleHandle(nullptr)); - if (classExists == -1) { - WNDCLASS wcinfo; - classExists = GetClassInfo(appInstance, reinterpret_cast(cname.utf16()), &wcinfo); - classExists = classExists && wcinfo.lpfnWndProc != proc; - } + WNDCLASS wcinfo; + const bool classExists = GetClassInfo(appInstance, reinterpret_cast(cname.utf16()), &wcinfo) == TRUE + && wcinfo.lpfnWndProc != proc; if (classExists) cname += QUuid::createUuid().toString(); -- cgit v1.2.3 From 8298118c527ae427ea2e8718122e1a65f4bb8bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 7 Jan 2020 16:18:10 +0100 Subject: macOS: Move palette setup into platform theme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The theme was the only client, so there's no point in keeping it separate from its only call site. Change-Id: I4783c5db6975ad2daaede704ab5855c57f190344 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/cocoa.pro | 2 - src/plugins/platforms/cocoa/qcocoasystemsettings.h | 54 ----- .../platforms/cocoa/qcocoasystemsettings.mm | 245 --------------------- src/plugins/platforms/cocoa/qcocoatheme.mm | 196 ++++++++++++++++- 4 files changed, 195 insertions(+), 302 deletions(-) delete mode 100644 src/plugins/platforms/cocoa/qcocoasystemsettings.h delete mode 100644 src/plugins/platforms/cocoa/qcocoasystemsettings.mm (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index 4cf9e64447..6645b6c90a 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -25,7 +25,6 @@ SOURCES += main.mm \ qcocoaclipboard.mm \ qcocoadrag.mm \ qmacclipboard.mm \ - qcocoasystemsettings.mm \ qcocoainputcontext.mm \ qcocoaservices.mm \ qcocoasystemtrayicon.mm \ @@ -59,7 +58,6 @@ HEADERS += qcocoaintegration.h \ qcocoaclipboard.h \ qcocoadrag.h \ qmacclipboard.h \ - qcocoasystemsettings.h \ qcocoainputcontext.h \ qcocoaservices.h \ qcocoasystemtrayicon.h \ diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.h b/src/plugins/platforms/cocoa/qcocoasystemsettings.h deleted file mode 100644 index cf5688bbed..0000000000 --- a/src/plugins/platforms/cocoa/qcocoasystemsettings.h +++ /dev/null @@ -1,54 +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 QCOCOASYSTEMSETTINGS_H -#define QCOCOASYSTEMSETTINGS_H - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -QPalette * qt_mac_createSystemPalette(); -QHash qt_mac_createRolePalettes(); - -QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm deleted file mode 100644 index cb25bd7d81..0000000000 --- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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 "qcocoasystemsettings.h" - -#include "qcocoahelpers.h" - -#include -#include -#include - -#if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_14) -@interface NSColor (MojaveForwardDeclarations) -@property (class, strong, readonly) NSColor *selectedContentBackgroundColor NS_AVAILABLE_MAC(10_14); -@property (class, strong, readonly) NSColor *unemphasizedSelectedTextBackgroundColor NS_AVAILABLE_MAC(10_14); -@property (class, strong, readonly) NSColor *unemphasizedSelectedTextColor NS_AVAILABLE_MAC(10_14); -@property (class, strong, readonly) NSColor *unemphasizedSelectedContentBackgroundColor NS_AVAILABLE_MAC(10_14); -@property (class, strong, readonly) NSArray *alternatingContentBackgroundColors NS_AVAILABLE_MAC(10_14); -// Missing from non-Mojave SDKs, even if introduced in 10.10 -@property (class, strong, readonly) NSColor *linkColor NS_AVAILABLE_MAC(10_10); -@end -#endif - -QT_BEGIN_NAMESPACE - -QPalette * qt_mac_createSystemPalette() -{ - QColor qc; - - // Standard palette initialization (copied from Qt 4 styles) - QBrush backgroundBrush = qt_mac_toQBrush([NSColor windowBackgroundColor]); - QColor background = backgroundBrush.color(); - QColor light(background.lighter(110)); - QColor dark(background.darker(160)); - QColor mid(background.darker(140)); - QPalette *palette = new QPalette(Qt::black, background, light, dark, mid, Qt::black, Qt::white); - - palette->setBrush(QPalette::Window, backgroundBrush); - - palette->setBrush(QPalette::Disabled, QPalette::WindowText, dark); - palette->setBrush(QPalette::Disabled, QPalette::Text, dark); - palette->setBrush(QPalette::Disabled, QPalette::ButtonText, dark); - palette->setBrush(QPalette::Disabled, QPalette::Base, backgroundBrush); - QBrush textBackgroundBrush = qt_mac_toQBrush([NSColor textBackgroundColor]); - palette->setBrush(QPalette::Active, QPalette::Base, textBackgroundBrush); - palette->setBrush(QPalette::Inactive, QPalette::Base, textBackgroundBrush); - palette->setColor(QPalette::Disabled, QPalette::Dark, QColor(191, 191, 191)); - palette->setColor(QPalette::Active, QPalette::Dark, QColor(191, 191, 191)); - palette->setColor(QPalette::Inactive, QPalette::Dark, QColor(191, 191, 191)); - - // System palette initialization: - QBrush br = qt_mac_toQBrush([NSColor selectedControlColor]); - palette->setBrush(QPalette::Active, QPalette::Highlight, br); - if (__builtin_available(macOS 10.14, *)) { - const auto inactiveHighlight = qt_mac_toQBrush([NSColor unemphasizedSelectedContentBackgroundColor]); - palette->setBrush(QPalette::Inactive, QPalette::Highlight, inactiveHighlight); - palette->setBrush(QPalette::Disabled, QPalette::Highlight, inactiveHighlight); - } else { - palette->setBrush(QPalette::Inactive, QPalette::Highlight, br); - palette->setBrush(QPalette::Disabled, QPalette::Highlight, br); - } - - palette->setBrush(QPalette::Shadow, qt_mac_toQColor([NSColor shadowColor])); - - qc = qt_mac_toQColor([NSColor controlTextColor]); - palette->setColor(QPalette::Active, QPalette::Text, qc); - palette->setColor(QPalette::Active, QPalette::WindowText, qc); - palette->setColor(QPalette::Active, QPalette::HighlightedText, qc); - palette->setColor(QPalette::Inactive, QPalette::Text, qc); - palette->setColor(QPalette::Inactive, QPalette::WindowText, qc); - palette->setColor(QPalette::Inactive, QPalette::HighlightedText, qc); - - qc = qt_mac_toQColor([NSColor disabledControlTextColor]); - palette->setColor(QPalette::Disabled, QPalette::Text, qc); - palette->setColor(QPalette::Disabled, QPalette::WindowText, qc); - palette->setColor(QPalette::Disabled, QPalette::HighlightedText, qc); - - palette->setBrush(QPalette::ToolTipBase, qt_mac_toQBrush([NSColor controlColor])); - - palette->setColor(QPalette::Normal, QPalette::Link, qt_mac_toQColor([NSColor linkColor])); - - return palette; -} - -struct QMacPaletteMap { - inline QMacPaletteMap(QPlatformTheme::Palette p, NSColor *a, NSColor *i) : - active(a), inactive(i), paletteRole(p) { } - - NSColor *active; - NSColor *inactive; - QPlatformTheme::Palette paletteRole; -}; - -#define MAC_PALETTE_ENTRY(pal, active, inactive) \ - QMacPaletteMap(pal, [NSColor active], [NSColor inactive]) -static QMacPaletteMap mac_widget_colors[] = { - MAC_PALETTE_ENTRY(QPlatformTheme::ToolButtonPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::ButtonPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::HeaderPalette, headerTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::ComboBoxPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::ItemViewPalette, textColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::MessageBoxLabelPalette, textColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::TabBarPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::LabelPalette, textColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::GroupBoxPalette, textColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::MenuPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::MenuBarPalette, controlTextColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::TextEditPalette, textColor, disabledControlTextColor), - MAC_PALETTE_ENTRY(QPlatformTheme::TextLineEditPalette, textColor, disabledControlTextColor) -}; -#undef MAC_PALETTE_ENTRY - -static const int mac_widget_colors_count = sizeof(mac_widget_colors) / sizeof(mac_widget_colors[0]); - -QHash qt_mac_createRolePalettes() -{ - QHash palettes; - QColor qc; - for (int i = 0; i < mac_widget_colors_count; i++) { - QPalette &pal = *qt_mac_createSystemPalette(); - if (mac_widget_colors[i].active) { - qc = qt_mac_toQColor(mac_widget_colors[i].active); - pal.setColor(QPalette::Active, QPalette::Text, qc); - pal.setColor(QPalette::Inactive, QPalette::Text, qc); - pal.setColor(QPalette::Active, QPalette::WindowText, qc); - pal.setColor(QPalette::Inactive, QPalette::WindowText, qc); - pal.setColor(QPalette::Active, QPalette::HighlightedText, qc); - pal.setColor(QPalette::Inactive, QPalette::HighlightedText, qc); - pal.setColor(QPalette::Active, QPalette::ButtonText, qc); - pal.setColor(QPalette::Inactive, QPalette::ButtonText, qc); - qc = qt_mac_toQColor(mac_widget_colors[i].inactive); - pal.setColor(QPalette::Disabled, QPalette::Text, qc); - pal.setColor(QPalette::Disabled, QPalette::WindowText, qc); - pal.setColor(QPalette::Disabled, QPalette::HighlightedText, qc); - pal.setColor(QPalette::Disabled, QPalette::ButtonText, qc); - } - if (mac_widget_colors[i].paletteRole == QPlatformTheme::MenuPalette - || mac_widget_colors[i].paletteRole == QPlatformTheme::MenuBarPalette) { - NSColor *selectedMenuItemColor = nil; - if (__builtin_available(macOS 10.14, *)) { - // Cheap approximation for NSVisualEffectView (see deprecation note for selectedMenuItemTextColor) - selectedMenuItemColor = [[NSColor selectedContentBackgroundColor] highlightWithLevel:0.4]; - } else { - // selectedMenuItemColor would presumably be the correct color to use as the background - // for selected menu items. But that color is always blue, and doesn't follow the - // appearance color in system preferences. So we therefore deliberatly choose to use - // keyboardFocusIndicatorColor instead, which appears to have the same color value. - selectedMenuItemColor = [NSColor keyboardFocusIndicatorColor]; - } - pal.setBrush(QPalette::Highlight, qt_mac_toQColor(selectedMenuItemColor)); - qc = qt_mac_toQColor([NSColor labelColor]); - pal.setBrush(QPalette::ButtonText, qc); - pal.setBrush(QPalette::Text, qc); - qc = qt_mac_toQColor([NSColor selectedMenuItemTextColor]); - pal.setBrush(QPalette::HighlightedText, qc); - qc = qt_mac_toQColor([NSColor disabledControlTextColor]); - pal.setBrush(QPalette::Disabled, QPalette::Text, qc); - } else if ((mac_widget_colors[i].paletteRole == QPlatformTheme::ButtonPalette) - || (mac_widget_colors[i].paletteRole == QPlatformTheme::HeaderPalette) - || (mac_widget_colors[i].paletteRole == QPlatformTheme::TabBarPalette)) { - pal.setColor(QPalette::Disabled, QPalette::ButtonText, - pal.color(QPalette::Disabled, QPalette::Text)); - pal.setColor(QPalette::Inactive, QPalette::ButtonText, - pal.color(QPalette::Inactive, QPalette::Text)); - pal.setColor(QPalette::Active, QPalette::ButtonText, - pal.color(QPalette::Active, QPalette::Text)); - } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::ItemViewPalette) { - NSArray *baseColors = nil; - NSColor *activeHighlightColor = nil; - if (__builtin_available(macOS 10.14, *)) { - baseColors = [NSColor alternatingContentBackgroundColors]; - activeHighlightColor = [NSColor selectedContentBackgroundColor]; - pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, - qt_mac_toQBrush([NSColor unemphasizedSelectedTextColor])); - } else { - baseColors = [NSColor controlAlternatingRowBackgroundColors]; - activeHighlightColor = [NSColor alternateSelectedControlColor]; - pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, - pal.brush(QPalette::Active, QPalette::Text)); - } - pal.setBrush(QPalette::Base, qt_mac_toQBrush(baseColors[0])); - pal.setBrush(QPalette::AlternateBase, qt_mac_toQBrush(baseColors[1])); - pal.setBrush(QPalette::Active, QPalette::Highlight, - qt_mac_toQBrush(activeHighlightColor)); - pal.setBrush(QPalette::Active, QPalette::HighlightedText, - qt_mac_toQBrush([NSColor alternateSelectedControlTextColor])); - pal.setBrush(QPalette::Inactive, QPalette::Text, - pal.brush(QPalette::Active, QPalette::Text)); - } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::TextEditPalette) { - pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor])); - pal.setBrush(QPalette::Inactive, QPalette::Text, - pal.brush(QPalette::Active, QPalette::Text)); - pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, - pal.brush(QPalette::Active, QPalette::Text)); - } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::TextLineEditPalette - || mac_widget_colors[i].paletteRole == QPlatformTheme::ComboBoxPalette) { - pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor])); - pal.setBrush(QPalette::Disabled, QPalette::Base, - pal.brush(QPalette::Active, QPalette::Base)); - } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::LabelPalette) { - qc = qt_mac_toQColor([NSColor labelColor]); - pal.setBrush(QPalette::Inactive, QPalette::ToolTipText, qc); - } - palettes.insert(mac_widget_colors[i].paletteRole, &pal); - } - return palettes; -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 387df65721..a76ba300e9 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -45,7 +45,6 @@ #include #include -#include "qcocoasystemsettings.h" #include "qcocoasystemtrayicon.h" #include "qcocoamenuitem.h" #include "qcocoamenu.h" @@ -80,8 +79,203 @@ #include +#if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_14) +@interface NSColor (MojaveForwardDeclarations) +@property (class, strong, readonly) NSColor *selectedContentBackgroundColor NS_AVAILABLE_MAC(10_14); +@property (class, strong, readonly) NSColor *unemphasizedSelectedTextBackgroundColor NS_AVAILABLE_MAC(10_14); +@property (class, strong, readonly) NSColor *unemphasizedSelectedTextColor NS_AVAILABLE_MAC(10_14); +@property (class, strong, readonly) NSColor *unemphasizedSelectedContentBackgroundColor NS_AVAILABLE_MAC(10_14); +@property (class, strong, readonly) NSArray *alternatingContentBackgroundColors NS_AVAILABLE_MAC(10_14); +// Missing from non-Mojave SDKs, even if introduced in 10.10 +@property (class, strong, readonly) NSColor *linkColor NS_AVAILABLE_MAC(10_10); +@end +#endif + QT_BEGIN_NAMESPACE +static QPalette *qt_mac_createSystemPalette() +{ + QColor qc; + + // Standard palette initialization (copied from Qt 4 styles) + QBrush backgroundBrush = qt_mac_toQBrush([NSColor windowBackgroundColor]); + QColor background = backgroundBrush.color(); + QColor light(background.lighter(110)); + QColor dark(background.darker(160)); + QColor mid(background.darker(140)); + QPalette *palette = new QPalette(Qt::black, background, light, dark, mid, Qt::black, Qt::white); + + palette->setBrush(QPalette::Window, backgroundBrush); + + palette->setBrush(QPalette::Disabled, QPalette::WindowText, dark); + palette->setBrush(QPalette::Disabled, QPalette::Text, dark); + palette->setBrush(QPalette::Disabled, QPalette::ButtonText, dark); + palette->setBrush(QPalette::Disabled, QPalette::Base, backgroundBrush); + QBrush textBackgroundBrush = qt_mac_toQBrush([NSColor textBackgroundColor]); + palette->setBrush(QPalette::Active, QPalette::Base, textBackgroundBrush); + palette->setBrush(QPalette::Inactive, QPalette::Base, textBackgroundBrush); + palette->setColor(QPalette::Disabled, QPalette::Dark, QColor(191, 191, 191)); + palette->setColor(QPalette::Active, QPalette::Dark, QColor(191, 191, 191)); + palette->setColor(QPalette::Inactive, QPalette::Dark, QColor(191, 191, 191)); + + // System palette initialization: + QBrush br = qt_mac_toQBrush([NSColor selectedControlColor]); + palette->setBrush(QPalette::Active, QPalette::Highlight, br); + if (__builtin_available(macOS 10.14, *)) { + const auto inactiveHighlight = qt_mac_toQBrush([NSColor unemphasizedSelectedContentBackgroundColor]); + palette->setBrush(QPalette::Inactive, QPalette::Highlight, inactiveHighlight); + palette->setBrush(QPalette::Disabled, QPalette::Highlight, inactiveHighlight); + } else { + palette->setBrush(QPalette::Inactive, QPalette::Highlight, br); + palette->setBrush(QPalette::Disabled, QPalette::Highlight, br); + } + + palette->setBrush(QPalette::Shadow, qt_mac_toQColor([NSColor shadowColor])); + + qc = qt_mac_toQColor([NSColor controlTextColor]); + palette->setColor(QPalette::Active, QPalette::Text, qc); + palette->setColor(QPalette::Active, QPalette::WindowText, qc); + palette->setColor(QPalette::Active, QPalette::HighlightedText, qc); + palette->setColor(QPalette::Inactive, QPalette::Text, qc); + palette->setColor(QPalette::Inactive, QPalette::WindowText, qc); + palette->setColor(QPalette::Inactive, QPalette::HighlightedText, qc); + + qc = qt_mac_toQColor([NSColor disabledControlTextColor]); + palette->setColor(QPalette::Disabled, QPalette::Text, qc); + palette->setColor(QPalette::Disabled, QPalette::WindowText, qc); + palette->setColor(QPalette::Disabled, QPalette::HighlightedText, qc); + + palette->setBrush(QPalette::ToolTipBase, qt_mac_toQBrush([NSColor controlColor])); + + palette->setColor(QPalette::Normal, QPalette::Link, qt_mac_toQColor([NSColor linkColor])); + + return palette; +} + +struct QMacPaletteMap { + inline QMacPaletteMap(QPlatformTheme::Palette p, NSColor *a, NSColor *i) : + active(a), inactive(i), paletteRole(p) { } + + NSColor *active; + NSColor *inactive; + QPlatformTheme::Palette paletteRole; +}; + +#define MAC_PALETTE_ENTRY(pal, active, inactive) \ + QMacPaletteMap(pal, [NSColor active], [NSColor inactive]) +static QMacPaletteMap mac_widget_colors[] = { + MAC_PALETTE_ENTRY(QPlatformTheme::ToolButtonPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::ButtonPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::HeaderPalette, headerTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::ComboBoxPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::ItemViewPalette, textColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::MessageBoxLabelPalette, textColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::TabBarPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::LabelPalette, textColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::GroupBoxPalette, textColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::MenuPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::MenuBarPalette, controlTextColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::TextEditPalette, textColor, disabledControlTextColor), + MAC_PALETTE_ENTRY(QPlatformTheme::TextLineEditPalette, textColor, disabledControlTextColor) +}; +#undef MAC_PALETTE_ENTRY + +static const int mac_widget_colors_count = sizeof(mac_widget_colors) / sizeof(mac_widget_colors[0]); + +static QHash qt_mac_createRolePalettes() +{ + QHash palettes; + QColor qc; + for (int i = 0; i < mac_widget_colors_count; i++) { + QPalette &pal = *qt_mac_createSystemPalette(); + if (mac_widget_colors[i].active) { + qc = qt_mac_toQColor(mac_widget_colors[i].active); + pal.setColor(QPalette::Active, QPalette::Text, qc); + pal.setColor(QPalette::Inactive, QPalette::Text, qc); + pal.setColor(QPalette::Active, QPalette::WindowText, qc); + pal.setColor(QPalette::Inactive, QPalette::WindowText, qc); + pal.setColor(QPalette::Active, QPalette::HighlightedText, qc); + pal.setColor(QPalette::Inactive, QPalette::HighlightedText, qc); + pal.setColor(QPalette::Active, QPalette::ButtonText, qc); + pal.setColor(QPalette::Inactive, QPalette::ButtonText, qc); + qc = qt_mac_toQColor(mac_widget_colors[i].inactive); + pal.setColor(QPalette::Disabled, QPalette::Text, qc); + pal.setColor(QPalette::Disabled, QPalette::WindowText, qc); + pal.setColor(QPalette::Disabled, QPalette::HighlightedText, qc); + pal.setColor(QPalette::Disabled, QPalette::ButtonText, qc); + } + if (mac_widget_colors[i].paletteRole == QPlatformTheme::MenuPalette + || mac_widget_colors[i].paletteRole == QPlatformTheme::MenuBarPalette) { + NSColor *selectedMenuItemColor = nil; + if (__builtin_available(macOS 10.14, *)) { + // Cheap approximation for NSVisualEffectView (see deprecation note for selectedMenuItemTextColor) + selectedMenuItemColor = [[NSColor selectedContentBackgroundColor] highlightWithLevel:0.4]; + } else { + // selectedMenuItemColor would presumably be the correct color to use as the background + // for selected menu items. But that color is always blue, and doesn't follow the + // appearance color in system preferences. So we therefore deliberatly choose to use + // keyboardFocusIndicatorColor instead, which appears to have the same color value. + selectedMenuItemColor = [NSColor keyboardFocusIndicatorColor]; + } + pal.setBrush(QPalette::Highlight, qt_mac_toQColor(selectedMenuItemColor)); + qc = qt_mac_toQColor([NSColor labelColor]); + pal.setBrush(QPalette::ButtonText, qc); + pal.setBrush(QPalette::Text, qc); + qc = qt_mac_toQColor([NSColor selectedMenuItemTextColor]); + pal.setBrush(QPalette::HighlightedText, qc); + qc = qt_mac_toQColor([NSColor disabledControlTextColor]); + pal.setBrush(QPalette::Disabled, QPalette::Text, qc); + } else if ((mac_widget_colors[i].paletteRole == QPlatformTheme::ButtonPalette) + || (mac_widget_colors[i].paletteRole == QPlatformTheme::HeaderPalette) + || (mac_widget_colors[i].paletteRole == QPlatformTheme::TabBarPalette)) { + pal.setColor(QPalette::Disabled, QPalette::ButtonText, + pal.color(QPalette::Disabled, QPalette::Text)); + pal.setColor(QPalette::Inactive, QPalette::ButtonText, + pal.color(QPalette::Inactive, QPalette::Text)); + pal.setColor(QPalette::Active, QPalette::ButtonText, + pal.color(QPalette::Active, QPalette::Text)); + } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::ItemViewPalette) { + NSArray *baseColors = nil; + NSColor *activeHighlightColor = nil; + if (__builtin_available(macOS 10.14, *)) { + baseColors = [NSColor alternatingContentBackgroundColors]; + activeHighlightColor = [NSColor selectedContentBackgroundColor]; + pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, + qt_mac_toQBrush([NSColor unemphasizedSelectedTextColor])); + } else { + baseColors = [NSColor controlAlternatingRowBackgroundColors]; + activeHighlightColor = [NSColor alternateSelectedControlColor]; + pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, + pal.brush(QPalette::Active, QPalette::Text)); + } + pal.setBrush(QPalette::Base, qt_mac_toQBrush(baseColors[0])); + pal.setBrush(QPalette::AlternateBase, qt_mac_toQBrush(baseColors[1])); + pal.setBrush(QPalette::Active, QPalette::Highlight, + qt_mac_toQBrush(activeHighlightColor)); + pal.setBrush(QPalette::Active, QPalette::HighlightedText, + qt_mac_toQBrush([NSColor alternateSelectedControlTextColor])); + pal.setBrush(QPalette::Inactive, QPalette::Text, + pal.brush(QPalette::Active, QPalette::Text)); + } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::TextEditPalette) { + pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor])); + pal.setBrush(QPalette::Inactive, QPalette::Text, + pal.brush(QPalette::Active, QPalette::Text)); + pal.setBrush(QPalette::Inactive, QPalette::HighlightedText, + pal.brush(QPalette::Active, QPalette::Text)); + } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::TextLineEditPalette + || mac_widget_colors[i].paletteRole == QPlatformTheme::ComboBoxPalette) { + pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor])); + pal.setBrush(QPalette::Disabled, QPalette::Base, + pal.brush(QPalette::Active, QPalette::Base)); + } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::LabelPalette) { + qc = qt_mac_toQColor([NSColor labelColor]); + pal.setBrush(QPalette::Inactive, QPalette::ToolTipText, qc); + } + palettes.insert(mac_widget_colors[i].paletteRole, &pal); + } + return palettes; +} + const char *QCocoaTheme::name = "cocoa"; QCocoaTheme::QCocoaTheme() -- cgit v1.2.3