From 8c0ef140b3a7202c03f223b692b31206aaf9d8b8 Mon Sep 17 00:00:00 2001 From: Liang Jian Date: Tue, 3 Mar 2015 17:16:16 +0800 Subject: Avoid deadlock with two consecutive suspended notification According to our Android app test, sometimes we will receive two consecutive app suspended notifications. In the second app suspended notification QWindowSystemInterface::flushWindowSystemEvents() will deadlock due to the fact that the event dispatcher has been stopped in the first app suspended notification. This patch will simply return if we found the event dispatcher has been stopped in the beginning of app suspended notification. Change-Id: I15fa4a6a118510b866ff16061862f4bb8360cc9b Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/androidjnimain.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 1c157c79c3..00ef8f670a 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -593,6 +593,13 @@ static void updateApplicationState(JNIEnv */*env*/, jobject /*thiz*/, jint state return; if (state <= Qt::ApplicationInactive) { + // NOTE: sometimes we will receive two consecutive suspended notifications, + // In the second suspended notification, QWindowSystemInterface::flushWindowSystemEvents() + // will deadlock since the dispatcher has been stopped in the first suspended notification. + // To avoid the deadlock we simply return if we found the event dispatcher has been stopped. + if (QAndroidEventDispatcherStopper::instance()->stopped()) + return; + // Don't send timers and sockets events anymore if we are going to hide all windows QAndroidEventDispatcherStopper::instance()->goingToStop(true); QCoreApplication::processEvents(); -- cgit v1.2.3 From 3c282ad1770e50078348b24bd52772f352800782 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Tue, 3 Mar 2015 12:19:44 +0100 Subject: Remove C++11 usage from NetworkManager bearer plugin Change-Id: Icac28ac11222a62636fdbe2cbdf289b7e24f9f20 Reviewed-by: Allan Sandfeld Jensen --- src/plugins/bearer/networkmanager/qnetworkmanagerservice.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h index f945532603..2f001bda23 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h @@ -497,7 +497,6 @@ public: QObject *parent = 0) : QDBusAbstractInterface(service, path, interface.toLatin1().data(), connection, parent) {} - ~PropertiesDBusInterface() = default; }; QT_END_NAMESPACE -- cgit v1.2.3 From 4ca43c71eb4f1b2cb969a219e3f1d3b12af02309 Mon Sep 17 00:00:00 2001 From: Mike Kuta Date: Fri, 6 Feb 2015 11:34:28 -0500 Subject: Improved Windows printer support and fixed crashes due to NULL devMode With certain printer drivers, the PRINTER_INFO_2 can return NULL for the pDevMode member in the call to GetPrinter() as mentioned on MSDN: https://msdn.microsoft.com/en-us/library/windows/desktop/dd144911 In many places, Qt first checks that devMode isn't NULL before dereferencing it. In other places it does not (such as when it actually attempts to print in QWin32PrintEngine::begin()). Checking every dereference aside, most printer functionality is removed without access to the DEVMODE structure. This fix uses DocumentProperties() to get the DEVMODE information when the first method fails. [ChangeLog][QtPrintSupport][QPrinter][Windows] Improved Windows printer support and fixed crashes due to NULL devMode Task-number: QTBUG-44349 Task-number: QTBUG-43877 Task-number: QTBUG-2251 Change-Id: Iafa337055d967c70f2096dcde4cc9c8ca8a0d252 Reviewed-by: Andy Shaw --- .../printsupport/windows/qwindowsprintdevice.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp b/src/plugins/printsupport/windows/qwindowsprintdevice.cpp index c349655b1e..31c47f9660 100644 --- a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp +++ b/src/plugins/printsupport/windows/qwindowsprintdevice.cpp @@ -248,8 +248,20 @@ QMarginsF QWindowsPrintDevice::printableMargins(const QPageSize &pageSize, if (GetPrinter(m_hPrinter, 2, buffer.data(), needed, &needed)) { PPRINTER_INFO_2 info = reinterpret_cast(buffer.data()); DEVMODE *devMode = info->pDevMode; - if (!devMode) - return margins; + bool separateDevMode = false; + if (!devMode) { + // GetPrinter() didn't include the DEVMODE. Get it a different way. + LONG result = DocumentProperties(NULL, m_hPrinter, (LPWSTR)m_id.utf16(), + NULL, NULL, 0); + devMode = (DEVMODE *)malloc(result); + separateDevMode = true; + result = DocumentProperties(NULL, m_hPrinter, (LPWSTR)m_id.utf16(), + devMode, NULL, DM_OUT_BUFFER); + if (result != IDOK) { + free(devMode); + return margins; + } + } HDC pDC = CreateDC(NULL, (LPWSTR)m_id.utf16(), NULL, devMode); if (pageSize.id() == QPageSize::Custom || pageSize.windowsId() <= 0 || pageSize.windowsId() > DMPAPER_LAST) { @@ -275,6 +287,8 @@ QMarginsF QWindowsPrintDevice::printableMargins(const QPageSize &pageSize, const qreal rightMargin = physicalWidth - leftMargin - printableWidth; const qreal bottomMargin = physicalHeight - topMargin - printableHeight; margins = QMarginsF(leftMargin, topMargin, rightMargin, bottomMargin); + if (separateDevMode) + free(devMode); DeleteDC(pDC); } return margins; -- cgit v1.2.3 From a9a41961c6ef3627a8dd2bf69664c13d9cb20568 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 6 Mar 2015 11:08:04 +0100 Subject: Win QPA: Pass in the top level setting instead of relying on isTopLevel() When updateDropSite() is called then most of the time calling window()->isTopLevel() is enough. But in a case like while the window is being reparented it cannot be trusted. So we pass it as a variable so that it is possible to give it the correct information when it is being called. Task-number: QTBUG-39739 Change-Id: I77a7ceeaf78e89b1f65a10d60df86088b35e0fe5 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowswindow.cpp | 10 +++++----- src/plugins/platforms/windows/qwindowswindow.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 0216b40e3e..54d1908e8b 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -933,7 +933,7 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data) setFlag(OpenGL_ES2); } #endif // QT_NO_OPENGL - updateDropSite(); + updateDropSite(window()->isTopLevel()); #ifndef Q_OS_WINCE if ((QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch) @@ -1020,10 +1020,10 @@ void QWindowsWindow::destroyWindow() } } -void QWindowsWindow::updateDropSite() +void QWindowsWindow::updateDropSite(bool topLevel) { bool enabled = false; - if (window()->isTopLevel()) { + if (topLevel) { switch (window()->type()) { case Qt::Window: case Qt::Dialog: @@ -1306,7 +1306,7 @@ void QWindowsWindow::setParent_sys(const QPlatformWindow *parent) if (wasTopLevel != isTopLevel) { setDropSiteEnabled(false); setWindowFlags_sys(window()->flags(), unsigned(isTopLevel ? WindowCreationData::ForceTopLevel : WindowCreationData::ForceChild)); - updateDropSite(); + updateDropSite(isTopLevel); } } } @@ -1561,7 +1561,7 @@ void QWindowsWindow::setWindowFlags(Qt::WindowFlags flags) m_data.flags = flags; if (m_data.hwnd) { m_data = setWindowFlags_sys(flags); - updateDropSite(); + updateDropSite(window()->isTopLevel()); } } // When switching to a frameless window, geometry diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 6d6d473ccd..0b42e77ecd 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -274,7 +274,7 @@ private: void destroyWindow(); inline bool isDropSiteEnabled() const { return m_dropTarget != 0; } void setDropSiteEnabled(bool enabled); - void updateDropSite(); + void updateDropSite(bool topLevel); void handleGeometryChange(); void handleWindowStateChange(Qt::WindowState state); inline void destroyIcon(); -- cgit v1.2.3 From 5bf9528b9164bd888e991552b66d6237e84a7ee2 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Tue, 17 Feb 2015 17:19:42 +0100 Subject: Revert "OS X: main window doesn't become key." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit da0c74550f0e8a21239896d6aead6e05f85eb695. The patch da0c74 unfortunately does not work well with QCocoaMenuBar's logic: it can happen that our selectNextKeyWindow chooses a Popup or another window with some 'unusual' flag as a key, but QCocoaMenuBar::updateMenuBarImmediately will return immediately, assuming that popup does not have a menu and there are no menu items to enable. Task-number: QTBUG-44369 Change-Id: I83cd2f6a62acd3a6ceb4d9dbf53ca42af67476d8 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 6656212457..2adea0f493 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -82,31 +82,6 @@ static bool isMouseEvent(NSEvent *ev) } } -static void selectNextKeyWindow(NSWindow *currentKeyWindow) -{ - if (!currentKeyWindow) - return; - - const QCocoaAutoReleasePool pool; - - if ([[NSApplication sharedApplication] keyWindow] != currentKeyWindow) - return;//currentKeyWindow is not a key window actually. - - NSArray *const windows = [[NSApplication sharedApplication] windows]; - bool startLookup = false; - for (NSWindow *candidate in [windows reverseObjectEnumerator]) { - if (!startLookup) { - if (candidate == currentKeyWindow) - startLookup = true; - } else { - if ([candidate isVisible] && [candidate canBecomeKeyWindow]) { - [candidate makeKeyWindow]; - break; - } - } - } -} - @implementation QNSWindowHelper @synthesize window = _window; @@ -599,9 +574,6 @@ void QCocoaWindow::hide(bool becauseOfAncestor) foreach (QCocoaWindow *childWindow, m_childWindows) childWindow->hide(true); - if (window()->transientParent() && m_nsWindow == [[NSApplication sharedApplication] keyWindow]) - selectNextKeyWindow(m_nsWindow); // Otherwise, Cocoa can do it wrong. - [m_nsWindow orderOut:nil]; } -- cgit v1.2.3 From 156be545785d959aa07bd2afd99ddfd6098ab85d Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 2 Mar 2015 12:55:37 +0100 Subject: Avoid deadlock when suspending app at startup QWindowSystemInterface::flushWindowSystemEvents() is a synchronous call. This will cause a deadlock if the GUI thread is waiting for an OpenGL surface at the same time. Add deadlock protection to this case as well. Task-number: QTBUG-44721 Change-Id: Id26370f6e07011dbcd861617bf96f59e85837db6 Reviewed-by: Christian Stromme --- src/plugins/platforms/android/androidjnimain.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 00ef8f670a..721c3f6f54 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -42,6 +42,7 @@ #include "androidjniinput.h" #include "androidjniclipboard.h" #include "androidjnimenu.h" +#include "androiddeadlockprotector.h" #include "qandroidplatformdialoghelpers.h" #include "qandroidplatformintegration.h" #include "qandroidassetsfileenginehandler.h" @@ -604,7 +605,11 @@ static void updateApplicationState(JNIEnv */*env*/, jobject /*thiz*/, jint state QAndroidEventDispatcherStopper::instance()->goingToStop(true); QCoreApplication::processEvents(); QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationState(state)); - QWindowSystemInterface::flushWindowSystemEvents(); + { + AndroidDeadlockProtector protector; + if (protector.acquire()) + QWindowSystemInterface::flushWindowSystemEvents(); + } if (state == Qt::ApplicationSuspended) QAndroidEventDispatcherStopper::instance()->stopAll(); } else { -- cgit v1.2.3 From 22f3d359350fd65e4bbe2e9420fcc4460e8a590a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 10 Mar 2015 22:37:39 +0100 Subject: Cocoa: Fix systray SVG icons. Regression caused by f3699510. Task-number: QTBUG-44686 Change-Id: I546422a67d4da29fac196025b09bddcb45c1b641 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm index e449fd37d6..8a35705429 100755 --- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm @@ -234,6 +234,10 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon) } } + // Handle SVG icons, which do not return anything for availableSizes(). + if (!selectedSize.isValid()) + selectedSize = icon.actualSize(QSize(maxPixmapHeight, maxPixmapHeight), mode); + QPixmap pixmap = icon.pixmap(selectedSize, mode); // Draw a low-resolution icon if there is not enough pixels for a retina -- cgit v1.2.3 From ba440f35e1dc38a7cdec72176b921c7a6f4a4727 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 12 Mar 2015 09:18:16 +0100 Subject: Cocoa integration - invalid backing store on geometry update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In case we skip flushing window events (while we're in setGeometry), backing store has to be invalidated, otherwise drawRect will use scaled CGImage. Change-Id: I26ff7083d7c702b4ff107eff235b2067eda540c2 Task-number: QTBUG-44313 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qnsview.mm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 5d3befa25b..197259c7d7 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -366,6 +366,8 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; // calles, which Qt and Qt applications do not excpect. if (!m_platformWindow->m_inSetGeometry) QWindowSystemInterface::flushWindowSystemEvents(); + else + m_backingStore = QImage(); } } -- cgit v1.2.3 From adc3ef97d7b1e93ab2b2081134855f8cccd0f166 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 12 Mar 2015 11:38:07 +0100 Subject: Cocoa: Send mouse release as a right button when clicking right button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-43612 Change-Id: Id6c764be13527e6b15255b509b4d43b8fe1b54d8 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qnsview.mm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 197259c7d7..6d75ce59f3 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -927,6 +927,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; if (m_window->flags() & Qt::WindowTransparentForInput) return [super rightMouseDown:theEvent]; m_buttons |= Qt::RightButton; + m_sendUpAsRightButton = true; [self handleMouseEvent:theEvent]; } @@ -944,6 +945,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; if (m_window->flags() & Qt::WindowTransparentForInput) return [super rightMouseUp:theEvent]; m_buttons &= ~Qt::RightButton; + m_sendUpAsRightButton = false; [self handleMouseEvent:theEvent]; } -- cgit v1.2.3 From 51ec7ebfe5f45d1c0a03d992e97053cac66e25fe Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Wed, 11 Mar 2015 13:34:01 +0100 Subject: Fixes crash in bmp and ico image decoding Fuzzing test revealed that for certain malformed bmp and ico files, the handler would segfault. Change-Id: I19d45145f31e7f808f7f6a1a1610270ea4159cbe Reviewed-by: Lars Knoll --- src/plugins/imageformats/ico/qicohandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index 00de0c80ad..ec1654ec58 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -567,7 +567,7 @@ QImage ICOReader::iconAt(int index) QImage::Format format = QImage::Format_ARGB32; if (icoAttrib.nbits == 24) format = QImage::Format_RGB32; - else if (icoAttrib.ncolors == 2) + else if (icoAttrib.ncolors == 2 && icoAttrib.depth == 1) format = QImage::Format_Mono; else if (icoAttrib.ncolors > 0) format = QImage::Format_Indexed8; -- cgit v1.2.3 From aa645caec178767e57da25f2a4566e1212c12b35 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 10 Mar 2015 22:47:52 +0100 Subject: Windows: Get the normal virtual key when not composing When there is no composing currently being done then we need to get the real virtual key rather than the one it was sent as with ImmGetVirtualKey. This ensures that any shortcut associated with the key will be fired right away. Change-Id: Id526b7030ca21eaacbd6c74774392b0707cf762a Reviewed-by: Lars Knoll --- src/plugins/platforms/windows/qwindowsinputcontext.h | 1 + src/plugins/platforms/windows/qwindowskeymapper.cpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.h b/src/plugins/platforms/windows/qwindowsinputcontext.h index 86243952ec..898a0e6909 100644 --- a/src/plugins/platforms/windows/qwindowsinputcontext.h +++ b/src/plugins/platforms/windows/qwindowsinputcontext.h @@ -73,6 +73,7 @@ public: bool startComposition(HWND hwnd); bool composition(HWND hwnd, LPARAM lParam); bool endComposition(HWND hwnd); + inline bool isComposing() const { return m_compositionContext.isComposing; } int reconvertString(RECONVERTSTRING *reconv); diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 4b1d1112d5..aa418a0100 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -36,6 +36,7 @@ #include "qwindowswindow.h" #include "qwindowsguieventdispatcher.h" #include "qwindowsscaling.h" +#include "qwindowsinputcontext.h" #include #include @@ -847,7 +848,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms const int msgType = msg.message; const quint32 scancode = (msg.lParam >> 16) & scancodeBitmask; - const quint32 vk_key = msg.wParam; + quint32 vk_key = msg.wParam; quint32 nModifiers = 0; QWindow *receiver = m_keyGrabber ? m_keyGrabber : window; @@ -1041,6 +1042,8 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms // results, if we map this virtual key-code directly (for eg '?' US layouts). So try // to find the correct key using the current message parameters & keyboard state. if (uch.isNull() && msgType == WM_IME_KEYDOWN) { + if (!QWindowsInputContext::instance()->isComposing()) + vk_key = ImmGetVirtualKey((HWND)window->winId()); BYTE keyState[256]; wchar_t newKey[3] = {0}; GetKeyboardState(keyState); -- cgit v1.2.3 From d0d107ffc88c5a4be34355e8bd32fe3d9826445a Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 13 Mar 2015 10:05:21 +0100 Subject: Android: Also populate database with otf fonts On Android 5, the Chinese fallback fonts are .otf format, and these were ignored when we populated the font database. Note that this also requires an upgrade of FreeType, otherwise the Simplified Chinese font will not load. [ChangeLog][Android] Fixed rendering Chinese text on Android 5. Change-Id: I972d0fbc0b16458650a7b82ea82a0ddd5bdfa641 Task-number: QTBUG-44648 Reviewed-by: Liang Qi --- src/plugins/platforms/android/qandroidplatformfontdatabase.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp b/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp index 2dcc0399c0..47bf4754f1 100644 --- a/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp +++ b/src/plugins/platforms/android/qandroidplatformfontdatabase.cpp @@ -51,10 +51,10 @@ void QAndroidPlatformFontDatabase::populateFontDatabase() qPrintable(fontpath)); } - QDir dir(fontpath, QLatin1String("*.ttf")); - for (int i = 0; i < int(dir.count()); ++i) { - const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i])); - + QDir dir(fontpath); + QList entries = dir.entryInfoList(QStringList() << QStringLiteral("*.ttf") << QStringLiteral("*.otf"), QDir::Files); + for (int i = 0; i < int(entries.count()); ++i) { + const QByteArray file = QFile::encodeName(entries.at(i).absoluteFilePath()); QSupportedWritingSystems supportedWritingSystems; QStringList families = addTTFile(QByteArray(), file, &supportedWritingSystems); -- cgit v1.2.3 From 5d34bf9033531264cfaa87c0259d331a2f07443b Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 13 Mar 2015 11:41:49 +0100 Subject: Avoid deadlock on suspend/resume On some devices, there is a possibility of getting a state change while we are locking the event loop for suspend. This is probably related to change 8c0ef140b3a7202c, but we should in any case use the existing deadlock protection mutex mechanism, just to make sure that there are not other cases which could trigger the same deadlock. Task-number: QTBUG-44339 Change-Id: I3e0b5fa2ddf4ef86e6b29cb1d67c4cccedd8242e Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/android/qandroideventdispatcher.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/qandroideventdispatcher.cpp b/src/plugins/platforms/android/qandroideventdispatcher.cpp index 2ba1399c6a..2348467722 100644 --- a/src/plugins/platforms/android/qandroideventdispatcher.cpp +++ b/src/plugins/platforms/android/qandroideventdispatcher.cpp @@ -33,6 +33,7 @@ #include "qandroideventdispatcher.h" #include "androidjnimain.h" +#include "androiddeadlockprotector.h" QAndroidEventDispatcher::QAndroidEventDispatcher(QObject *parent) : QUnixEventDispatcherQPA(parent) @@ -78,11 +79,13 @@ void QAndroidEventDispatcher::goingToStop(bool stop) int QAndroidEventDispatcher::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, timespec *timeout) { - if (m_stopRequest.testAndSetAcquire(StopRequest, Stopping)) { - m_semaphore.acquire(); - wakeUp(); + { + AndroidDeadlockProtector protector; + if (protector.acquire() && m_stopRequest.testAndSetAcquire(StopRequest, Stopping)) { + m_semaphore.acquire(); + wakeUp(); + } } - return QUnixEventDispatcherQPA::select(nfds, readfds, writefds, exceptfds, timeout); } -- cgit v1.2.3 From f64b87a5df8870be138dbf3febad950e1fc4ed8c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 18 Mar 2015 10:03:36 +0100 Subject: Fallback to malloc for insanely large windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If shmget() does not work (probably because the backingstore size is bigger than SHMMAX), don't create a QImage with the previous buffer and the new size. That does not end well when we try to draw to the image later. Instead, fall back to the malloc path, like we do when the system doesn't support shared memory. [ChangeLog][X11] Don't crash when resizing windows to bigger than 3840x2160 Task-number: QTBUG-45071 Change-Id: I009de7c2179ffde28e252593067756877cad1b1c Reviewed-by: Laszlo Agocs Reviewed-by: Jørgen Lind --- src/plugins/platforms/xcb/qxcbbackingstore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index f4382c7b50..42a868d997 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -122,7 +122,7 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI xcb_generic_error_t *error = NULL; if (shm_present) error = xcb_request_check(xcb_connection(), xcb_shm_attach_checked(xcb_connection(), m_shm_info.shmseg, m_shm_info.shmid, false)); - if (!shm_present || error) { + if (!shm_present || error || id == -1) { free(error); shmdt(m_shm_info.shmaddr); -- cgit v1.2.3 From ee7fea33383726f0bb72e8082a357820e3ee3675 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 24 Feb 2015 17:02:02 +0100 Subject: OSX Fix disapearing tray icon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It would happen together with an error: QPainter::begin: Paint device returned engine == 0 and would be caused by the size provided to QIcon::pixmap being empty, itself caused by the availableSizes list being empty for the Selected mode. This bug was most often hidden by the fact that the Selected icon mode was not triggered properly since we usually only set menuVisible after calling updateIcon, and most of the time when it did, we would overwrite it right after with a Normal mode icon. Fix the issue by disabling the broken feature completely since the default Selected icon is grayed out while tray icons are now usually black (or white when selected). To support the dark menu bar mode on 10.10 we'll need to use NSImage's setTemplate anyway and that knowing in advance if we can invert the colors ourselves would also better solve the menuVisible usecase. Task-number: QTBUG-42910 Change-Id: If9ec9659af28ecceb841bfc2f11721e6029fe891 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm index 8a35705429..d366a3c66e 100755 --- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm @@ -102,7 +102,6 @@ QT_USE_NAMESPACE QCocoaSystemTrayIcon *systray; NSStatusItem *item; QCocoaMenu *menu; - bool menuVisible; QIcon icon; QT_MANGLE_NAMESPACE(QNSImageView) *imageCell; } @@ -202,8 +201,6 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon) m_sys->item->icon = icon; - const bool menuVisible = m_sys->item->menu && m_sys->item->menuVisible; - // The reccomended maximum title bar icon height is 18 points // (device independent pixels). The menu height on past and // current OS X versions is 22 points. Provide some future-proofing @@ -218,9 +215,8 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon) // devicePixelRatio for the "best" screen on the system. qreal devicePixelRatio = qApp->devicePixelRatio(); const int maxPixmapHeight = maxImageHeight * devicePixelRatio; - const QIcon::Mode mode = menuVisible ? QIcon::Selected : QIcon::Normal; QSize selectedSize; - Q_FOREACH (const QSize& size, sortByHeight(icon.availableSizes(mode))) { + Q_FOREACH (const QSize& size, sortByHeight(icon.availableSizes())) { // Select a pixmap based on the height. We want the largest pixmap // with a height smaller or equal to maxPixmapHeight. The pixmap // may rectangular; assume it has a reasonable size. If there is @@ -236,9 +232,9 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon) // Handle SVG icons, which do not return anything for availableSizes(). if (!selectedSize.isValid()) - selectedSize = icon.actualSize(QSize(maxPixmapHeight, maxPixmapHeight), mode); + selectedSize = icon.actualSize(QSize(maxPixmapHeight, maxPixmapHeight)); - QPixmap pixmap = icon.pixmap(selectedSize, mode); + QPixmap pixmap = icon.pixmap(selectedSize); // Draw a low-resolution icon if there is not enough pixels for a retina // icon. This prevents showing a small icon on retina displays. @@ -385,9 +381,6 @@ QT_END_NAMESPACE Q_UNUSED(notification); down = NO; - parent->systray->updateIcon(parent->icon); - parent->menuVisible = false; - [self setNeedsDisplay:YES]; } @@ -397,8 +390,6 @@ QT_END_NAMESPACE int clickCount = [mouseEvent clickCount]; [self setNeedsDisplay:YES]; - parent->systray->updateIcon(parent->icon); - if (clickCount == 2) { [self menuTrackingDone:nil]; [parent doubleClickSelector:self]; @@ -454,7 +445,6 @@ QT_END_NAMESPACE if (self) { item = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain]; menu = 0; - menuVisible = false; systray = sys; imageCell = [[QNSImageView alloc] initWithParent:self]; [item setView: imageCell]; @@ -498,7 +488,6 @@ QT_END_NAMESPACE selector:@selector(menuTrackingDone:) name:NSMenuDidEndTrackingNotification object:m]; - menuVisible = true; [item popUpStatusItemMenu: m]; } } -- cgit v1.2.3 From 8c242fd65d7f38aaf2ffa62993d70df7d317ec44 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Wed, 24 Sep 2014 08:48:49 +1000 Subject: Fix a crash in connman bearer backend on d'tor when using QStringLiteral Task-number: QTBUG-41507 Change-Id: I7711eb34bf9ca738fb25031acff3371a6126ae23 Reviewed-by: Christopher Adams --- .../bearer/connman/qconnmanservice_linux.cpp | 66 +++++++++++----------- .../bearer/linux_common/qofonoservice_linux.cpp | 28 ++++----- 2 files changed, 47 insertions(+), 47 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp index 65c4ac307a..b690b97ddd 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp +++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp @@ -67,8 +67,8 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMap &map) } QConnmanManagerInterface::QConnmanManagerInterface( QObject *parent) - : QDBusAbstractInterface(QStringLiteral(CONNMAN_SERVICE), - QStringLiteral(CONNMAN_MANAGER_PATH), + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), CONNMAN_MANAGER_INTERFACE, QDBusConnection::systemBus(), parent) { @@ -82,23 +82,23 @@ QConnmanManagerInterface::QConnmanManagerInterface( QObject *parent) QObject::connect(watcher,SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(propertiesReply(QDBusPendingCallWatcher*))); - QDBusConnection::systemBus().connect(QStringLiteral(CONNMAN_SERVICE), - QStringLiteral(CONNMAN_MANAGER_PATH), - QStringLiteral(CONNMAN_SERVICE_INTERFACE), - QStringLiteral("PropertyChanged"), + QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + QLatin1String(CONNMAN_SERVICE_INTERFACE), + QLatin1String("PropertyChanged"), this,SLOT(changedProperty(QString,QDBusVariant))); - QDBusConnection::systemBus().connect(QStringLiteral(CONNMAN_SERVICE), - QStringLiteral(CONNMAN_MANAGER_PATH), - QStringLiteral(CONNMAN_SERVICE_INTERFACE), - QStringLiteral("TechnologyAdded"), + QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + QLatin1String(CONNMAN_SERVICE_INTERFACE), + QLatin1String("TechnologyAdded"), this,SLOT(technologyAdded(QDBusObjectPath,QVariantMap))); - QDBusConnection::systemBus().connect(QStringLiteral(CONNMAN_SERVICE), - QStringLiteral(CONNMAN_MANAGER_PATH), - QStringLiteral(CONNMAN_SERVICE_INTERFACE), - QStringLiteral("TechnologyRemoved"), + QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + QLatin1String(CONNMAN_SERVICE_INTERFACE), + QLatin1String("TechnologyRemoved"), this,SLOT(technologyRemoved(QDBusObjectPath))); QList argumentList2; @@ -152,10 +152,10 @@ void QConnmanManagerInterface::connectNotify(const QMetaMethod &signal) { static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QConnmanManagerInterface::propertyChanged); if (signal == propertyChangedSignal) { - if (!connection().connect(QStringLiteral(CONNMAN_SERVICE), - QStringLiteral(CONNMAN_MANAGER_PATH), - QStringLiteral(CONNMAN_MANAGER_INTERFACE), - QStringLiteral("PropertyChanged"), + if (!connection().connect(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + QLatin1String(CONNMAN_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), this,SIGNAL(propertyChanged(QString,QDBusVariant)))) { qWarning() << "PropertyChanged not connected"; } @@ -163,10 +163,10 @@ void QConnmanManagerInterface::connectNotify(const QMetaMethod &signal) static const QMetaMethod servicesChangedSignal = QMetaMethod::fromSignal(&QConnmanManagerInterface::servicesChanged); if (signal == servicesChangedSignal) { - if (!connection().connect(QStringLiteral(CONNMAN_SERVICE), - QStringLiteral(CONNMAN_MANAGER_PATH), - QStringLiteral(CONNMAN_MANAGER_INTERFACE), - QStringLiteral("ServicesChanged"), + if (!connection().connect(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + QLatin1String(CONNMAN_MANAGER_INTERFACE), + QLatin1String("ServicesChanged"), this,SLOT(onServicesChanged(ConnmanMapList, QList)))) { qWarning() << "servicesChanged not connected"; } @@ -275,7 +275,7 @@ void QConnmanManagerInterface::technologyRemoved(const QDBusObjectPath &path) } QConnmanServiceInterface::QConnmanServiceInterface(const QString &dbusPathName,QObject *parent) - : QDBusAbstractInterface(QStringLiteral(CONNMAN_SERVICE), + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), dbusPathName, CONNMAN_SERVICE_INTERFACE, QDBusConnection::systemBus(), parent) @@ -288,10 +288,10 @@ QConnmanServiceInterface::QConnmanServiceInterface(const QString &dbusPathName,Q QObject::connect(watcher,SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(propertiesReply(QDBusPendingCallWatcher*))); - QDBusConnection::systemBus().connect(QStringLiteral(CONNMAN_SERVICE), + QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE), path(), - QStringLiteral(CONNMAN_SERVICE_INTERFACE), - QStringLiteral("PropertyChanged"), + QLatin1String(CONNMAN_SERVICE_INTERFACE), + QLatin1String("PropertyChanged"), this,SLOT(changedProperty(QString,QDBusVariant))); } @@ -327,10 +327,10 @@ void QConnmanServiceInterface::connectNotify(const QMetaMethod &signal) { static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QConnmanServiceInterface::propertyChanged); if (signal == propertyChangedSignal) { - QDBusConnection::systemBus().connect(QStringLiteral(CONNMAN_SERVICE), + QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE), path(), - QStringLiteral(CONNMAN_SERVICE_INTERFACE), - QStringLiteral("PropertyChanged"), + QLatin1String(CONNMAN_SERVICE_INTERFACE), + QLatin1String("PropertyChanged"), this,SIGNAL(propertyChanged(QString,QDBusVariant))); } } @@ -440,7 +440,7 @@ QStringList QConnmanServiceInterface::services() ////////////////////////// QConnmanTechnologyInterface::QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent) - : QDBusAbstractInterface(QStringLiteral(CONNMAN_SERVICE), + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), dbusPathName, CONNMAN_TECHNOLOGY_INTERFACE, QDBusConnection::systemBus(), parent) @@ -455,10 +455,10 @@ void QConnmanTechnologyInterface::connectNotify(const QMetaMethod &signal) { static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QConnmanTechnologyInterface::propertyChanged); if (signal == propertyChangedSignal) { - QDBusConnection::systemBus().connect(QStringLiteral(CONNMAN_SERVICE), + QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE), path(), - QStringLiteral(CONNMAN_TECHNOLOGY_INTERFACE), - QStringLiteral("PropertyChanged"), + QLatin1String(CONNMAN_TECHNOLOGY_INTERFACE), + QLatin1String("PropertyChanged"), this,SIGNAL(propertyChanged(QString,QDBusVariant))); } } diff --git a/src/plugins/bearer/linux_common/qofonoservice_linux.cpp b/src/plugins/bearer/linux_common/qofonoservice_linux.cpp index abbfd445a5..a08c0a7057 100644 --- a/src/plugins/bearer/linux_common/qofonoservice_linux.cpp +++ b/src/plugins/bearer/linux_common/qofonoservice_linux.cpp @@ -67,23 +67,23 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, ObjectPathPropert QT_BEGIN_NAMESPACE QOfonoManagerInterface::QOfonoManagerInterface( QObject *parent) - : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE), - QStringLiteral(OFONO_MANAGER_PATH), + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + QLatin1String(OFONO_MANAGER_PATH), OFONO_MANAGER_INTERFACE, QDBusConnection::systemBus(), parent) { qDBusRegisterMetaType(); qDBusRegisterMetaType(); - QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE), - QStringLiteral(OFONO_MANAGER_PATH), - QStringLiteral(OFONO_MANAGER_INTERFACE), - QStringLiteral("ModemAdded"), + QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), + QLatin1String(OFONO_MANAGER_PATH), + QLatin1String(OFONO_MANAGER_INTERFACE), + QLatin1String("ModemAdded"), this,SLOT(modemAdded(QDBusObjectPath, QVariantMap))); - QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE), - QStringLiteral(OFONO_MANAGER_PATH), - QStringLiteral(OFONO_MANAGER_INTERFACE), - QStringLiteral("ModemRemoved"), + QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), + QLatin1String(OFONO_MANAGER_PATH), + QLatin1String(OFONO_MANAGER_INTERFACE), + QLatin1String("ModemRemoved"), this,SLOT(modemRemoved(QDBusObjectPath))); } @@ -137,15 +137,15 @@ void QOfonoManagerInterface::modemRemoved(const QDBusObjectPath &path) QOfonoModemInterface::QOfonoModemInterface(const QString &dbusPathName, QObject *parent) - : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE), + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), dbusPathName, OFONO_MODEM_INTERFACE, QDBusConnection::systemBus(), parent) { - QDBusConnection::systemBus().connect(QStringLiteral(OFONO_SERVICE), + QDBusConnection::systemBus().connect(QLatin1String(OFONO_SERVICE), path(), OFONO_MODEM_INTERFACE, - QStringLiteral("PropertyChanged"), + QLatin1String("PropertyChanged"), this,SLOT(propertyChanged(QString,QDBusVariant))); } @@ -199,7 +199,7 @@ QVariant QOfonoModemInterface::getProperty(const QString &property) QOfonoNetworkRegistrationInterface::QOfonoNetworkRegistrationInterface(const QString &dbusPathName, QObject *parent) - : QDBusAbstractInterface(QStringLiteral(OFONO_SERVICE), + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), dbusPathName, OFONO_NETWORK_REGISTRATION_INTERFACE, QDBusConnection::systemBus(), parent) -- cgit v1.2.3 From eea5a6ea15651a4bc2d0d1b1f45a2542a26083d0 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 24 Nov 2014 12:05:43 +0100 Subject: Android MessageDialog: order buttons according to OS X button layout At least the dismissive action should be on the left, but we can take the OS X rules as reasonable in cases where a lot of buttons are in use. Task-number: QTBUG-42808 Change-Id: If45f991a068d47009e02d39fbb3886ff4b31c8e1 Reviewed-by: BogDan Vatra --- .../android/qandroidplatformdialoghelpers.cpp | 25 +++++++++++++++++----- .../android/qandroidplatformdialoghelpers.h | 3 +++ 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp b/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp index 2ea4c90324..bcd88547d2 100644 --- a/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp +++ b/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp @@ -97,11 +97,15 @@ bool QAndroidPlatformMessageDialogHelper::show(Qt::WindowFlags windowFlags if (!str.isEmpty()) m_javaMessageDialog.callMethod("setDetailedText", "(Ljava/lang/String;)V", QJNIObjectPrivate::fromString(str).object()); - for (int i = QPlatformDialogHelper::FirstButton; i < QPlatformDialogHelper::LastButton; i<<=1) { - if ( opt->standardButtons() & i ) { - const QString text = QGuiApplicationPrivate::platformTheme()->standardButtonText(i); - m_javaMessageDialog.callMethod("addButton", "(ILjava/lang/String;)V", i, QJNIObjectPrivate::fromString(text).object()); - } + // http://developer.android.com/design/building-blocks/dialogs.html + // dismissive action on the left, affirmative on the right + // There don't seem to be more fine-grained rules, but the OS X layout + // at least conforms to this one rule and makes the rest deterministic. + const int * currentLayout = buttonLayout(Qt::Horizontal, MacLayout); + while (*currentLayout != QPlatformDialogHelper::EOL) { + int role = (*currentLayout & ~QPlatformDialogHelper::Reverse); + addButtons(opt, static_cast(role)); + ++currentLayout; } m_javaMessageDialog.callMethod("show", "(J)V", jlong(static_cast(this))); @@ -109,6 +113,17 @@ bool QAndroidPlatformMessageDialogHelper::show(Qt::WindowFlags windowFlags return true; } +void QAndroidPlatformMessageDialogHelper::addButtons(QSharedPointer opt, ButtonRole role) +{ + for (int i = QPlatformDialogHelper::FirstButton; i < QPlatformDialogHelper::LastButton; i<<=1) { + StandardButton b = static_cast(i); + if (buttonRole(b) == role && (opt->standardButtons() & i)) { + const QString text = QGuiApplicationPrivate::platformTheme()->standardButtonText(b); + m_javaMessageDialog.callMethod("addButton", "(ILjava/lang/String;)V", i, QJNIObjectPrivate::fromString(text).object()); + } + } +} + void QAndroidPlatformMessageDialogHelper::hide() { m_javaMessageDialog.callMethod("hide", "()V"); diff --git a/src/plugins/platforms/android/qandroidplatformdialoghelpers.h b/src/plugins/platforms/android/qandroidplatformdialoghelpers.h index c1ec95a68c..7a7ad46723 100644 --- a/src/plugins/platforms/android/qandroidplatformdialoghelpers.h +++ b/src/plugins/platforms/android/qandroidplatformdialoghelpers.h @@ -56,6 +56,9 @@ public: public slots: void dialogResult(int buttonID); +private: + void addButtons(QSharedPointer opt, ButtonRole role); + private: int m_buttonId; QEventLoop m_loop; -- cgit v1.2.3 From f451d4800595caf00b6aa61408006cd100a6d416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Wed, 25 Mar 2015 13:37:31 +0000 Subject: Windows: Add support for horizontal scroll on some touchpads. While most (all?) touchpads send WM_MOUSEWHEEL for vertical scroll the story is quite different for horizontal scroll. Some of them send WM_HSCROLL instead of WM_MOUSEHWHEEL. Some of them even send left/right key event but those are lost cases. Task-number: QTBUG-45120 Change-Id: I3bf86e25a6f4f3ba03ac7e89a23f4b7bc432f2de Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qtwindowsglobal.h | 6 +- src/plugins/platforms/windows/qwindowscontext.cpp | 6 ++ .../platforms/windows/qwindowsmousehandler.cpp | 73 +++++++++++++++++----- .../platforms/windows/qwindowsmousehandler.h | 2 + 4 files changed, 69 insertions(+), 18 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qtwindowsglobal.h b/src/plugins/platforms/windows/qtwindowsglobal.h index 083d82ed8c..74fa561e10 100644 --- a/src/plugins/platforms/windows/qtwindowsglobal.h +++ b/src/plugins/platforms/windows/qtwindowsglobal.h @@ -57,7 +57,8 @@ enum TouchEventFlag = 0x400000, ClipboardEventFlag = 0x800000, ApplicationEventFlag = 0x1000000, - ThemingEventFlag = 0x2000000 + ThemingEventFlag = 0x2000000, + GenericEventFlag = 0x4000000, // Misc }; enum WindowsEventType // Simplify event types @@ -108,6 +109,7 @@ enum WindowsEventType // Simplify event types CompositionSettingsChanged = ThemingEventFlag + 2, DisplayChangedEvent = 437, SettingChangedEvent = DisplayChangedEvent + 1, + ScrollEvent = GenericEventFlag + 1, ContextMenu = 123, GestureEvent = 124, UnknownEvent = 542 @@ -145,6 +147,8 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI return QtWindows::CursorEvent; case WM_MOUSELEAVE: return QtWindows::MouseEvent; + case WM_HSCROLL: + return QtWindows::ScrollEvent; case WM_MOUSEWHEEL: case WM_MOUSEHWHEEL: return QtWindows::MouseWheelEvent; diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 72bfeec143..bcd3922773 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -1031,6 +1031,12 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, QWindowsWindow::baseWindowOf(platformWindow->window())->applyCursor(); return true; } +#endif + case QtWindows::ScrollEvent: +#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER) + return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateScrollEvent(platformWindow->window(), hwnd, msg, result); +#else + return d->m_mouseHandler.translateScrollEvent(platformWindow->window(), hwnd, msg, result); #endif case QtWindows::MouseWheelEvent: case QtWindows::MouseEvent: diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 0fa34041d6..0ce8c09fc4 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -375,6 +376,31 @@ static bool isValidWheelReceiver(QWindow *candidate) return false; } +static void redirectWheelEvent(QWindow *window, const QPoint &globalPos, int delta, + Qt::Orientation orientation, Qt::KeyboardModifiers mods) +{ + // Redirect wheel event to one of the following, in order of preference: + // 1) The window under mouse + // 2) The window receiving the event + // If a window is blocked by modality, it can't get the event. + + QWindow *receiver = QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE); + bool handleEvent = true; + if (!isValidWheelReceiver(receiver)) { + receiver = window; + if (!isValidWheelReceiver(receiver)) + handleEvent = false; + } + + if (handleEvent) { + const QPoint posDip = QWindowsGeometryHint::mapFromGlobal(receiver, globalPos) / QWindowsScaling::factor(); + QWindowSystemInterface::handleWheelEvent(receiver, + posDip, globalPos / QWindowsScaling::factor(), + delta / QWindowsScaling::factor(), + orientation, mods); + } +} + bool QWindowsMouseHandler::translateMouseWheelEvent(QWindow *window, HWND, MSG msg, LRESULT *) { @@ -397,27 +423,40 @@ bool QWindowsMouseHandler::translateMouseWheelEvent(QWindow *window, HWND, if (msg.message == WM_MOUSEHWHEEL) delta = -delta; - // Redirect wheel event to one of the following, in order of preference: - // 1) The window under mouse - // 2) The window receiving the event - // If a window is blocked by modality, it can't get the event. const QPoint globalPos(GET_X_LPARAM(msg.lParam), GET_Y_LPARAM(msg.lParam)); - QWindow *receiver = QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE); - bool handleEvent = true; - if (!isValidWheelReceiver(receiver)) { - receiver = window; - if (!isValidWheelReceiver(receiver)) - handleEvent = false; - } + redirectWheelEvent(window, globalPos, delta, orientation, mods); - if (handleEvent) { - const QPoint posDip = QWindowsGeometryHint::mapFromGlobal(receiver, globalPos) / QWindowsScaling::factor(); - QWindowSystemInterface::handleWheelEvent(receiver, - posDip, globalPos / QWindowsScaling::factor(), - delta / QWindowsScaling::factor(), - orientation, mods); + return true; +} + +bool QWindowsMouseHandler::translateScrollEvent(QWindow *window, HWND, + MSG msg, LRESULT *) +{ + // This is a workaround against some touchpads that send WM_HSCROLL instead of WM_MOUSEHWHEEL. + // We could also handle vertical scroll here but there's no reason to, there's no bug for vertical + // (broken vertical scroll would have been noticed long time ago), so lets keep the change small + // and minimize the chance for regressions. + + int delta = 0; + switch (LOWORD(msg.wParam)) { + case SB_LINELEFT: + delta = 120; + break; + case SB_LINERIGHT: + delta = -120; + break; + case SB_PAGELEFT: + delta = 240; + break; + case SB_PAGERIGHT: + delta = -240; + break; + default: + return false; } + redirectWheelEvent(window, QCursor::pos(), delta, Qt::Horizontal, Qt::NoModifier); + return true; } diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.h b/src/plugins/platforms/windows/qwindowsmousehandler.h index 60fe26b2b9..76d45897f0 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.h +++ b/src/plugins/platforms/windows/qwindowsmousehandler.h @@ -59,6 +59,8 @@ public: bool translateTouchEvent(QWindow *widget, HWND hwnd, QtWindows::WindowsEventType t, MSG msg, LRESULT *result); + bool translateScrollEvent(QWindow *window, HWND hwnd, + MSG msg, LRESULT *result); static inline Qt::MouseButtons keyStateToMouseButtons(int); static inline Qt::KeyboardModifiers keyStateToModifiers(int); -- cgit v1.2.3 From 9f1f8aaa92cdd0a1a655bb7dc4fae200c805489d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 6 Feb 2015 07:34:43 +0100 Subject: Handle SelectionWindowDestroy in QXcbClipboard This change is related to 6a7ee92b3958e3a3ebc16be15f8bd34217ec7bd2 which added handling for SelectionClientClose. Further testing showed that with e.g. Qt 4 applications the SelectionClientClose is not emitted, but the selection window seems to be destroyed before the client is destroyed. Fur a destroyed selection window the same applies: the clipboard content is no longer valid and we should emit the changed signal. Change-Id: Id3778a28b9f5601bf2c6e0106981316e0efa6e7c Reviewed-by: Gatis Paeglis Reviewed-by: Uli Schlachter --- src/plugins/platforms/xcb/qxcbclipboard.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp index f56a29d985..4b6caa9620 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.cpp +++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp @@ -742,7 +742,8 @@ void QXcbClipboard::handleXFixesSelectionRequest(xcb_xfixes_selection_notify_eve m_xClipboard[mode]->reset(); } emitChanged(mode); - } else if (event->subtype == XCB_XFIXES_SELECTION_EVENT_SELECTION_CLIENT_CLOSE) + } else if (event->subtype == XCB_XFIXES_SELECTION_EVENT_SELECTION_CLIENT_CLOSE || + event->subtype == XCB_XFIXES_SELECTION_EVENT_SELECTION_WINDOW_DESTROY) emitChanged(mode); } -- cgit v1.2.3 From c0e4f24336cb0f0c21ad6c79e3da898d974ac1ad Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 5 Mar 2015 16:18:02 +0300 Subject: xcb: Determine the window gravity just before the window is shown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It may change after the window has been created. Change-Id: Ib81a7ad7353b1909cc42684fc70d6b7d2556106f Reviewed-by: Uli Schlachter Reviewed-by: Jørgen Lind --- src/plugins/platforms/xcb/qxcbwindow.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 233514a181..c0076a9977 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -308,11 +308,6 @@ void QXcbWindow::create() return; } - // Determine gravity from initial position. Do not change - // later as it will cause the window to move uncontrollably. - m_gravity = positionIncludesFrame(window()) ? - XCB_GRAVITY_NORTH_WEST : XCB_GRAVITY_STATIC; - const quint32 mask = XCB_CW_BACK_PIXMAP | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK; const quint32 values[] = { // XCB_CW_BACK_PIXMAP @@ -732,6 +727,9 @@ void QXcbWindow::show() xcb_set_wm_hints(xcb_connection(), m_window, &hints); + m_gravity = positionIncludesFrame(window()) ? + XCB_GRAVITY_NORTH_WEST : XCB_GRAVITY_STATIC; + // update WM_NORMAL_HINTS propagateSizeHints(); -- cgit v1.2.3