From 2ddc0fcd9bfde1a72846af43967cfd1796156078 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 7 May 2014 09:24:04 +0200 Subject: winrt: DNS lookup: don't have duplicate entries Change-Id: I60ee29bd692f8e385080d4532a0e3230942a2cd3 Reviewed-by: Andrew Knight --- src/network/kernel/qdnslookup_winrt.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/kernel/qdnslookup_winrt.cpp b/src/network/kernel/qdnslookup_winrt.cpp index 08f3167a29..e2a5ba2f37 100644 --- a/src/network/kernel/qdnslookup_winrt.cpp +++ b/src/network/kernel/qdnslookup_winrt.cpp @@ -120,6 +120,8 @@ void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestN unsigned int size; endpointPairs->get_Size(&size); + // endpoint pairs might contain duplicates so we temporarily store addresses in a QSet + QSet addresses; for (unsigned int i = 0; i < size; ++i) { IEndpointPair *endpointpair; endpointPairs->GetAt(i, &endpointpair); @@ -139,9 +141,12 @@ void QDnsLookupRunnable::query(const int requestType, const QByteArray &requestN remoteHost->Release(); UINT32 length; PCWSTR rawString = name.GetRawBuffer(&length); + addresses.insert(QHostAddress(QString::fromWCharArray(rawString, length))); + } + foreach (const QHostAddress &address, addresses) { QDnsHostAddressRecord record; record.d->name = aceHostname; - record.d->value = QHostAddress(QString::fromWCharArray(rawString, length)); + record.d->value = address; reply->hostAddressRecords.append(record); } } -- cgit v1.2.3 From bcbf38b7019c6a3bb71fe57ca7610e6f05478422 Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Thu, 26 Jun 2014 15:25:13 +0200 Subject: Doc: Various \note fixes in Qt namespace documentation. -changed \note and \warning to "Note:" and "Warning:" -\note and \warning split the table. -other minor \note changes Task-number: QTBUG-36972 Change-Id: I88042550cd01101e7225cd3b5f4e0115ea102ea9 Reviewed-by: Liang Qi Reviewed-by: Martin Smith --- src/corelib/global/qnamespace.qdoc | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 8ade3f86d6..4227dd358e 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the documentation of the Qt Toolkit. @@ -294,7 +294,7 @@ This enum provides shorter names for the keyboard modifier keys supported by Qt. - \b{Note:} On Mac OS X, the \c CTRL value corresponds to + \note On Mac OS X, the \c CTRL value corresponds to the Command keys on the Macintosh keyboard, and the \c META value corresponds to the Control keys. @@ -974,7 +974,7 @@ \value WA_NoSystemBackground Indicates that the widget has no background, i.e. when the widget receives paint events, the background is not - automatically repainted. \note Unlike WA_OpaquePaintEvent, newly exposed + automatically repainted. \b Note: Unlike WA_OpaquePaintEvent, newly exposed areas are \b never filled with the background (e.g., after showing a window for the first time the user can see "through" it until the application processes the paint events). This flag is set or cleared by the @@ -986,7 +986,7 @@ before generating paint events. The use of WA_OpaquePaintEvent provides a small optimization by helping to reduce flicker on systems that do not support double buffering and avoiding computational cycles necessary to - erase the background prior to painting. \note Unlike + erase the background prior to painting. \b Note: Unlike WA_NoSystemBackground, WA_OpaquePaintEvent makes an effort to avoid transparent window backgrounds. This flag is set or cleared by the widget's author. @@ -999,7 +999,7 @@ \value WA_PaintOnScreen Indicates that the widget wants to draw directly onto the screen. Widgets with this attribute set do not participate in composition management, i.e. they cannot be semi-transparent or shine - through semi-transparent overlapping widgets. \note This flag is only + through semi-transparent overlapping widgets. \b Note: This flag is only supported on X11 and it disables double buffering. On Qt for Embedded Linux, the flag only works when set on a top-level widget and it relies on support from the active screen driver. This flag is set or cleared by the @@ -1070,7 +1070,7 @@ \value WA_UpdatesDisabled Indicates that updates are blocked (including the system background). This flag is set or cleared by the Qt kernel. - \warning This flag must \e never be set or cleared by the widget's author. + \b Warning: This flag must \e never be set or cleared by the widget's author. \value WA_WindowModified Indicates that the window is marked as modified. On some platforms this flag will do nothing, on others (including Mac OS X @@ -1112,50 +1112,50 @@ \value WA_X11NetWmWindowTypeToolBar Adds _NET_WM_WINDOW_TYPE_TOOLBAR to the window's _NET_WM_WINDOW_TYPE X11 window property. See http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automatically sets this + has no effect on non-X11 platforms. \b Note: Qt automatically sets this attribute for QToolBar. \value WA_X11NetWmWindowTypeMenu Adds _NET_WM_WINDOW_TYPE_MENU to the window's _NET_WM_WINDOW_TYPE X11 window property. See http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automatically sets this + has no effect on non-X11 platforms. \b Note: Qt automatically sets this attribute for QMenu when torn-off. \value WA_X11NetWmWindowTypeUtility Adds _NET_WM_WINDOW_TYPE_UTILITY to the window's _NET_WM_WINDOW_TYPE X11 window property. See http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automatically sets this + has no effect on non-X11 platforms. \b Note: Qt automatically sets this attribute for the Qt::Tool window type. \value WA_X11NetWmWindowTypeSplash Adds _NET_WM_WINDOW_TYPE_SPLASH to the window's _NET_WM_WINDOW_TYPE X11 window property. See http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automatically sets this + has no effect on non-X11 platforms. \b Note: Qt automatically sets this attribute for the Qt::SplashScreen window type. \value WA_X11NetWmWindowTypeDialog Adds _NET_WM_WINDOW_TYPE_DIALOG to the window's _NET_WM_WINDOW_TYPE X11 window property. See http://standards.freedesktop.org/wm-spec/ for more details. This - attribute has no effect on non-X11 platforms. \note Qt automatically sets + attribute has no effect on non-X11 platforms. \b Note: Qt automatically sets this attribute for the Qt::Dialog and Qt::Sheet window types. \value WA_X11NetWmWindowTypeDropDownMenu Adds _NET_WM_WINDOW_TYPE_DROPDOWN_MENU to the window's _NET_WM_WINDOW_TYPE X11 window property. See http://standards.freedesktop.org/wm-spec/ for more details. This - attribute has no effect on non-X11 platforms. \note Qt + attribute has no effect on non-X11 platforms. \b Note: Qt automatically sets this attribute for QMenus added to a QMenuBar. \value WA_X11NetWmWindowTypePopupMenu Adds _NET_WM_WINDOW_TYPE_POPUP_MENU to the window's _NET_WM_WINDOW_TYPE X11 window property. See http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automatically sets this + has no effect on non-X11 platforms. \b Note: Qt automatically sets this attribute for QMenu. \value WA_X11NetWmWindowTypeToolTip Adds _NET_WM_WINDOW_TYPE_TOOLTIP to the window's _NET_WM_WINDOW_TYPE X11 window property. See http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automatically sets this + has no effect on non-X11 platforms. \b Note: Qt automatically sets this attribute for the Qt::ToolTip window type. \value WA_X11NetWmWindowTypeNotification Adds @@ -1166,13 +1166,13 @@ \value WA_X11NetWmWindowTypeCombo Adds _NET_WM_WINDOW_TYPE_COMBO to the window's _NET_WM_WINDOW_TYPE X11 window property. See http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automatically sets this + has no effect on non-X11 platforms. \b Note: Qt automatically sets this attribute for the QComboBox pop-up. \value WA_X11NetWmWindowTypeDND Adds _NET_WM_WINDOW_TYPE_DND to the window's _NET_WM_WINDOW_TYPE X11 window property. See http://standards.freedesktop.org/wm-spec/ for more details. This attribute - has no effect on non-X11 platforms. \note Qt automatically sets this + has no effect on non-X11 platforms. \b Note: Qt automatically sets this attribute on the feedback widget used during a drag. \value WA_MacFrameworkScaled Enables resolution independence aware mode @@ -1243,7 +1243,7 @@ \value Key_Enter Typically located on the keypad. \value Key_Insert \value Key_Delete - \value Key_Pause The Pause/Break key (\note Not anything to do with pausing media) + \value Key_Pause The Pause/Break key (\b Note: Not related to pausing media) \value Key_Print \value Key_SysReq \value Key_Clear @@ -1514,7 +1514,7 @@ \value Key_MediaPrevious \value Key_MediaNext \value Key_MediaRecord - \value Key_MediaPause A key setting the state of the media player to pause (\note not the pause/break key) + \value Key_MediaPause A key setting the state of the media player to pause (\b Note: not the pause/break key) \value Key_MediaTogglePlayPause A key to toggle the play/pause state in the media player (rather than setting an absolute state) \value Key_HomePage \value Key_Favorites @@ -2856,7 +2856,7 @@ The keypad is used to implement a virtual cursor, unless the device has an analog mouse type of input device (e.g. touchpad) - \note: in 4.6, cursor navigation is only implemented for Symbian OS. + \note In 4.6, cursor navigation is only implemented for Symbian OS. On other platforms, it behaves as NavigationModeNone. \sa QApplication::setNavigationMode() \sa QApplication::navigationMode() -- cgit v1.2.3 From 256f810be3af225bac1ed464a13bcd314a00f303 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 24 Jun 2014 11:28:11 -0700 Subject: Fix annoying warning from ICC 14 on Windows It says that defining a macro that does defined() is not portable. The solution implemented for MSVC 2008 and earlier does work, however, and is portable to all compilers (the parentheses around the macro are unnecessary). Incidentally, this makes d98004cd2f33e8147cff9f3cb203fdef5e6dd00e actually work: Q_CC_MSVC wasn't defined at that point in the file, so that change had never taken effect. warning #3199: "defined" is always false in a macro expansion in Microsoft mode Task-number: QTBUG-39597 Change-Id: Iaa2895e7f63d97c439090043435a2b8d2f185c3a Reviewed-by: Oswald Buddenhagen --- src/corelib/global/qglobal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index f610cfab8c..255eb6c00b 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Copyright (C) 2012 Intel Corporation. +** Copyright (C) 2014 Intel Corporation. ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtCore module of the Qt Toolkit. @@ -59,7 +59,7 @@ #include #include #endif -#if defined(Q_CC_MSVC) && _MSC_VER <= 1500 /* VS2008 */ +#ifdef _MSC_VER # define QT_SUPPORTS(FEATURE) (!defined QT_NO_##FEATURE) #else # define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE)) -- cgit v1.2.3 From 0272ce641778ddaba6ac550b6bbfd4e5e5adaad1 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 24 Jun 2014 16:06:04 +0200 Subject: Accessibility Windows: Do not assert on invalid indexInParent We try to but don't always guarantee a valid hierarchy, having applications crash because of this is not a good idea. The assert currently triggers when showing message boxes. Fix for the message box case is in progress but this may happen in other situations. Change-Id: I6f82b23c8abfcb7f91ecde0584f0e01bd8216ca1 Reviewed-by: Gabriel de Dietrich Reviewed-by: Caroline Chao --- src/plugins/platforms/windows/accessible/iaccessible2.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp index d56925d0c4..032f33163a 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp +++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp @@ -502,13 +502,11 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_indexInParent(long *indexIn if (!indexInParent) return E_INVALIDARG; QAccessibleInterface *par = accessible->parent(); - if (!par) { - *indexInParent = -1; + *indexInParent = par ? par->indexOfChild(accessible) : -1; + if (*indexInParent < 0) { + qCWarning(lcQpaAccessibility) << "index in parent invalid:" << accessible << "parent:" << par; return S_FALSE; } - int indexOfChild = par->indexOfChild(accessible); - Q_ASSERT(indexOfChild >= 0); - *indexInParent = indexOfChild; return S_OK; } -- cgit v1.2.3 From 9ee27005ee3cfa295c681a5ac04ac1c282b396ca Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 8 Jun 2014 14:10:56 +0200 Subject: qDebug: fix data race in qt_message_print The setting of (static) messageHandler to qDefaultMessageHandler if null was happening in multiple threads simultaneously, so it needs synchronization. Used an atomic pointer in case qInstallMessageHandler is called from a thread, but more importantly, initialized the static vars right away. Improve auto test to ensure that qInstallMessageHandler(0) still sets the default message handler. Change-Id: I70335af38c1d28a1cdba1df8a79c6006f227422e Reviewed-by: Thiago Macieira --- src/corelib/global/qlogging.cpp | 42 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index ff4372a049..ca0fb1bb23 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1148,8 +1148,13 @@ typedef void (*QtMsgHandler)(QtMsgType, const char *); Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler); #endif -static QtMsgHandler msgHandler = 0; // pointer to debug handler (without context) -static QtMessageHandler messageHandler = 0; // pointer to debug handler (with context) +static void qDefaultMsgHandler(QtMsgType type, const char *buf); +static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &buf); + +// pointer to QtMsgHandler debug handler (without context) +static QBasicAtomicPointer msgHandler = Q_BASIC_ATOMIC_INITIALIZER(qDefaultMsgHandler); +// pointer to QtMessageHandler debug handler (with context) +static QBasicAtomicPointer messageHandler = Q_BASIC_ATOMIC_INITIALIZER(qDefaultMessageHandler); #if defined(QT_USE_JOURNALD) && !defined(QT_BOOTSTRAPPED) static void systemd_default_message_handler(QtMsgType type, @@ -1315,20 +1320,15 @@ static void qt_message_print(QtMsgType msgType, const QMessageLogContext &contex } #endif - if (!msgHandler) - msgHandler = qDefaultMsgHandler; - if (!messageHandler) - messageHandler = qDefaultMessageHandler; - // prevent recursion in case the message handler generates messages // itself, e.g. by using Qt API if (grabMessageHandler()) { // prefer new message handler over the old one - if (msgHandler == qDefaultMsgHandler - || messageHandler != qDefaultMessageHandler) { - (*messageHandler)(msgType, context, message); + if (msgHandler.load() == qDefaultMsgHandler + || messageHandler.load() != qDefaultMessageHandler) { + (*messageHandler.load())(msgType, context, message); } else { - (*msgHandler)(msgType, message.toLocal8Bit().constData()); + (*msgHandler.load())(msgType, message.toLocal8Bit().constData()); } ungrabMessageHandler(); } else { @@ -1530,22 +1530,18 @@ void qErrnoWarning(int code, const char *msg, ...) QtMessageHandler qInstallMessageHandler(QtMessageHandler h) { - if (!messageHandler) - messageHandler = qDefaultMessageHandler; - QtMessageHandler old = messageHandler; - messageHandler = h; - return old; + if (!h) + h = qDefaultMessageHandler; + //set 'h' and return old message handler + return messageHandler.fetchAndStoreRelaxed(h); } QtMsgHandler qInstallMsgHandler(QtMsgHandler h) { - //if handler is 0, set it to the - //default message handler - if (!msgHandler) - msgHandler = qDefaultMsgHandler; - QtMsgHandler old = msgHandler; - msgHandler = h; - return old; + if (!h) + h = qDefaultMsgHandler; + //set 'h' and return old message handler + return msgHandler.fetchAndStoreRelaxed(h); } void qSetMessagePattern(const QString &pattern) -- cgit v1.2.3 From 9e5765fba0c2986d4fb4f7103f2f9c72f4c0d20d Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 1 Jul 2014 20:57:42 +0200 Subject: QOpenGLTexture: fix the feature test for Buffer Textures 1a4ff6f122f575aca21f6a0b9d9c14cac4a5ea66 modified the features test by checking extensions as well as the GL version. The problem was that the GL version was wrong in the first place -- buffer textures are natively supported since OpenGL 3.0, not 4.3. 4.3 introduced support for buffer texture ranges, i.e. ARB_texture_buffer_range; however it's pointless to take the highest requirement, especially considering that so far QOpenGLTexture doesn't wrap glTexBuffer(Range) in any way. In the future, if QOpenGLTexture will also wrap glTexBuffer, then we will also be able to introduce a different feature flag for testing buffer texture ranges. Change-Id: I6becbd49ac26d44ce01d088cbb7831b5cc127bdb Reviewed-by: Sean Harmer Reviewed-by: Paul Lemire --- src/gui/opengl/qopengltexture.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index 6e2e72a3b4..e0e1c72a6c 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -2446,9 +2446,8 @@ bool QOpenGLTexture::hasFeature(Feature feature) break; case TextureBuffer: - supported = f.version() >= qMakePair(4, 3) - || (ctx->hasExtension(QByteArrayLiteral("GL_ARB_texture_buffer_object")) - && ctx->hasExtension(QByteArrayLiteral("GL_ARB_texture_buffer_range"))); + supported = f.version() >= qMakePair(3, 0) + || ctx->hasExtension(QByteArrayLiteral("GL_ARB_texture_buffer_object")); break; case StencilTexturing: -- cgit v1.2.3 From 1529a3df951c0a65be2f9c1f3994bcfaa5cb95fe Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 30 Jun 2014 10:31:01 +0200 Subject: Empty icons and Cocoa menu items. Clear menu item's image if QImage is empty (isNull). Task-number: QTBUG-39557 Change-Id: I8145b67342b0361da2bb945070603cc182202b71 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoamenuitem.mm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 32692edde4..4b9a0146a9 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -329,12 +329,13 @@ NSMenuItem *QCocoaMenuItem::sync() [m_native setKeyEquivalentModifierMask:NSCommandKeyMask]; } + NSImage *img = nil; if (!m_icon.isNull()) { - NSImage *img = qt_mac_create_nsimage(m_icon); + img = qt_mac_create_nsimage(m_icon); [img setSize:NSMakeSize(16, 16)]; - [m_native setImage: img]; - [img release]; } + [m_native setImage:img]; + [img release]; [m_native setState:m_checked ? NSOnState : NSOffState]; return m_native; -- cgit v1.2.3 From 23961aa54cfc688b66b206c6d04122c0d36fc98f Mon Sep 17 00:00:00 2001 From: Andreas Holzammer Date: Tue, 1 Jul 2014 12:59:15 +0200 Subject: WINCE: Fix grabWindow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BitBlt does not support CAPTUREBLT under Windows Embedded compact. It was before defined to the value it would have for a desktop Windows, but as it looks if the bit gets set for Windows Embedded Compact he does not do the right thing anymore. So lets define it to 0 so that we dont do any harm. Change-Id: I447ebcd90eb9ae7c64f931aa8859b83794f201a0 Reviewed-by: Friedemann Kleint Reviewed-by: Björn Breitmeyer --- src/plugins/platforms/windows/qplatformfunctions_wince.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qplatformfunctions_wince.h b/src/plugins/platforms/windows/qplatformfunctions_wince.h index 921e64d64c..47b03b29cc 100644 --- a/src/plugins/platforms/windows/qplatformfunctions_wince.h +++ b/src/plugins/platforms/windows/qplatformfunctions_wince.h @@ -86,8 +86,10 @@ #define HWND_MESSAGE 0 #endif +// Real Value would be 0x40000000, but if we pass this to Windows Embedded Compact +// he blits it wrongly, so lets not do any harm and define it to 0 #ifndef CAPTUREBLT -#define CAPTUREBLT (DWORD)0x40000000 +#define CAPTUREBLT (DWORD)0x0 #endif #define SW_SHOWMINIMIZED SW_MINIMIZE -- cgit v1.2.3 From 5250e4f15743bcdc67e77e5ab3b41d64723e62dd Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Sat, 28 Jun 2014 11:26:26 +0900 Subject: xcb: make sure to update window title when it is changed Task-number: QTBUG-33775 Change-Id: Ibe346c4304532d031bfa1c9b4d73cd02d1e5a64f Reviewed-by: Laszlo Agocs Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbwindow.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 74d8b7c2c8..586068d8d9 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1342,6 +1342,7 @@ void QXcbWindow::setWindowTitle(const QString &title) 8, ba.length(), ba.constData())); + xcb_flush(xcb_connection()); } void QXcbWindow::setWindowIcon(const QIcon &icon) -- cgit v1.2.3 From 375b52f20f12e9180d2b4e2dce9f53facbdb4a21 Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Thu, 12 Jun 2014 15:28:44 +0200 Subject: QNX: Override QPlatformScreen::topLevelAt Implemented QQnxScreen::topLevelAt method, as base implementation returned wrong results. This fixes "tst_qwidget widgetAt" for instance. Removed related method, that is not used at all. Change-Id: I25c4f474cb0d661e5e5cdcdd0ab13d670fd4dc37 Reviewed-by: Fabian Bumberger Reviewed-by: Rafael Roquetto --- src/plugins/platforms/qnx/qqnxscreen.cpp | 25 ++++++++++++------------- src/plugins/platforms/qnx/qqnxscreen.h | 4 ++-- 2 files changed, 14 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp index 9ba0f5cd2e..add45ecbe5 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.cpp +++ b/src/plugins/platforms/qnx/qqnxscreen.cpp @@ -286,6 +286,18 @@ Qt::ScreenOrientation QQnxScreen::orientation() const return orient; } +QWindow *QQnxScreen::topLevelAt(const QPoint &point) const +{ + QListIterator it(m_childWindows); + it.toBack(); + while (it.hasPrevious()) { + QWindow *win = it.previous()->window(); + if (win->geometry().contains(point)) + return win; + } + return 0; +} + /*! Check if the supplied angles are perpendicular to each other. */ @@ -767,17 +779,4 @@ void QQnxScreen::setRootWindow(QQnxWindow *window) m_rootWindow = window; } -QWindow * QQnxScreen::topMostChildWindow() const -{ - if (!m_childWindows.isEmpty()) { - - // We're picking up the last window of the list here - // because this list is ordered by stacking order. - // Last window is effectively the one on top. - return m_childWindows.last()->window(); - } - - return 0; -} - QT_END_NAMESPACE diff --git a/src/plugins/platforms/qnx/qqnxscreen.h b/src/plugins/platforms/qnx/qqnxscreen.h index a0b760135f..6b2281f7b9 100644 --- a/src/plugins/platforms/qnx/qqnxscreen.h +++ b/src/plugins/platforms/qnx/qqnxscreen.h @@ -73,6 +73,8 @@ public: Qt::ScreenOrientation nativeOrientation() const; Qt::ScreenOrientation orientation() const; + QWindow *topLevelAt(const QPoint &point) const; + bool isPrimaryScreen() const { return m_primaryScreen; } int rotation() const { return m_currentRotation; } @@ -124,8 +126,6 @@ private: void addMultimediaWindow(const QByteArray &id, screen_window_t window); void removeOverlayOrUnderlayWindow(screen_window_t window); - QWindow *topMostChildWindow() const; - screen_context_t m_screenContext; screen_display_t m_display; QQnxWindow *m_rootWindow; -- cgit v1.2.3 From 90053954b8a3b2b048ab86e759e26c4c643bcb72 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 1 Jul 2014 14:42:50 +0200 Subject: OS X: when opening a URL via QFileOpenEvent, pass as QUrl Opening a file from Finder and opening a URL from the browser are two different operations, and the URL might not be a local file. Task-number: QTBUG-39972 Change-Id: I467dfef7efe8eb88c922410db16137e135bc8133 Reviewed-by: Jake Petroules Reviewed-by: Thiago Macieira --- src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm index f89439734f..92358ecc74 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm @@ -411,7 +411,7 @@ static void cleanupCocoaApplicationDelegate() { Q_UNUSED(replyEvent); NSString *urlString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; - QWindowSystemInterface::handleFileOpenEvent(QCFString::toQString(urlString)); + QWindowSystemInterface::handleFileOpenEvent(QUrl(QCFString::toQString(urlString))); } - (void)appleEventQuit:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent -- cgit v1.2.3 From 769af6689337285927a2637b184149f688332542 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 30 Jun 2014 16:29:32 +0200 Subject: QMacStyle: Fix focus frame rendering in Yosemite MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using the HITheme API would result in the frame's right edge to be missing. Instead, we use the recommended technique to draw the focus ring around a custom NSCell. (See https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ControlCell/Articles/ManipulateCellControl.html) Change-Id: I12d4834d353b5cbd5893bf070b14ad0d8bb75634 Reviewed-by: Morten Johan Sørvig --- src/widgets/styles/qmacstyle_mac.mm | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 0084bf68dc..d647acdacc 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -4044,11 +4044,20 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } break; case CE_FocusFrame: { - int xOff = proxy()->pixelMetric(PM_FocusFrameHMargin, opt, w) + 1; - int yOff = proxy()->pixelMetric(PM_FocusFrameVMargin, opt, w) + 1; - HIRect hirect = CGRectMake(xOff+opt->rect.x(), yOff+opt->rect.y(), opt->rect.width() - 2 * xOff, - opt->rect.height() - 2 * yOff); - HIThemeDrawFocusRect(&hirect, true, QMacCGContext(p), kHIThemeOrientationNormal); + int xOff = proxy()->pixelMetric(PM_FocusFrameHMargin, opt, w); + int yOff = proxy()->pixelMetric(PM_FocusFrameVMargin, opt, w); + NSRect rect = NSMakeRect(xOff+opt->rect.x(), yOff+opt->rect.y(), opt->rect.width() - 2 * xOff, + opt->rect.height() - 2 * yOff); + CGContextSaveGState(cg); + [NSGraphicsContext setCurrentContext:[NSGraphicsContext + graphicsContextWithGraphicsPort:(CGContextRef)cg flipped:NO]]; + [NSGraphicsContext saveGraphicsState]; + NSSetFocusRingStyle(NSFocusRingOnly); + NSBezierPath *focusFramePath = [NSBezierPath bezierPathWithRect:rect]; + [focusFramePath setClip]; // Clear clip path to avoid artifacts when rendering the cursor at zero pos + [focusFramePath fill]; + [NSGraphicsContext restoreGraphicsState]; + CGContextRestoreGState(cg); break; } case CE_MenuItem: case CE_MenuEmptyArea: -- cgit v1.2.3 From 62f1aa7ca758f20a325d3d74702b5cd1b07e97f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 24 Jun 2014 12:56:59 +0200 Subject: Cocoa: Separate framestrut and normal button state Frame strut button state can get out of sync due to missing calls to handleFrameStrutMouseEvent, typically when a mouse down is sent but the mouse up isn't. There is no reason this should interfere with normal button state: Add m_frameStrutButtons for tracking the frame strut button state. Change-Id: Ia21700af94fe000c73088b7657237372f3a04bf8 Task-number: QTBUG-39810 Reviewed-by: Eike Ziller Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnsview.h | 1 + src/plugins/platforms/cocoa/qnsview.mm | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 37a0c1feb1..5387f2a825 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -65,6 +65,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QNSViewMouseMoveHelper); QWindow *m_window; QCocoaWindow *m_platformWindow; Qt::MouseButtons m_buttons; + Qt::MouseButtons m_frameStrutButtons; QString m_composingText; bool m_sendKeyEvent; QStringList *currentCustomDragTypes; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 4a744245f0..b9e4826d72 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -140,6 +140,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; m_shouldInvalidateWindowShadow = false; m_window = 0; m_buttons = Qt::NoButton; + m_frameStrutButtons = Qt::NoButton; m_sendKeyEvent = false; m_subscribesForGlobalFrameNotifications = false; m_glContext = 0; @@ -653,6 +654,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; - (void)resetMouseButtons { m_buttons = Qt::NoButton; + m_frameStrutButtons = Qt::NoButton; } - (void)handleMouseEvent:(NSEvent *)theEvent @@ -685,22 +687,22 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; NSEventType ty = [theEvent type]; switch (ty) { case NSLeftMouseDown: - m_buttons |= Qt::LeftButton; + m_frameStrutButtons |= Qt::LeftButton; break; case NSLeftMouseUp: - m_buttons &= ~Qt::LeftButton; + m_frameStrutButtons &= ~Qt::LeftButton; break; case NSRightMouseDown: - m_buttons |= Qt::RightButton; + m_frameStrutButtons |= Qt::RightButton; break; case NSRightMouseUp: - m_buttons &= ~Qt::RightButton; + m_frameStrutButtons &= ~Qt::RightButton; break; case NSOtherMouseDown: - m_buttons |= cocoaButton2QtButton([theEvent buttonNumber]); + m_frameStrutButtons |= cocoaButton2QtButton([theEvent buttonNumber]); break; case NSOtherMouseUp: - m_buttons &= ~cocoaButton2QtButton([theEvent buttonNumber]); + m_frameStrutButtons &= ~cocoaButton2QtButton([theEvent buttonNumber]); default: break; } @@ -718,7 +720,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; QPoint qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y)); ulong timestamp = [theEvent timestamp] * 1000; - QWindowSystemInterface::handleFrameStrutMouseEvent(m_window, timestamp, qtWindowPoint, qtScreenPoint, m_buttons); + QWindowSystemInterface::handleFrameStrutMouseEvent(m_window, timestamp, qtWindowPoint, qtScreenPoint, m_frameStrutButtons); } - (void)mouseDown:(NSEvent *)theEvent -- cgit v1.2.3 From 4f155b0535c69b895d044bbbbf9535a21dd57994 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Sun, 1 Jun 2014 14:35:04 +0200 Subject: Cocoa: Fix Qt-in-namespace build. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wrap cocoa classes in namespace macros. Task-number: QTBUG-39382 Change-Id: Id840e666105afca21760fcb529b5765e0a534120 Reviewed-by: Morten Johan Sørvig --- src/gui/accessible/qaccessiblecache_mac.mm | 6 +++--- src/gui/accessible/qaccessiblecache_p.h | 8 ++++---- .../platforms/cocoa/qcocoaaccessibilityelement.h | 11 +++++++---- src/plugins/platforms/cocoa/qcocoawindow.h | 19 +++++++++++++------ src/plugins/platforms/cocoa/qnswindowdelegate.h | 4 +++- src/widgets/styles/qmacstyle_mac.mm | 3 ++- 6 files changed, 32 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/gui/accessible/qaccessiblecache_mac.mm b/src/gui/accessible/qaccessiblecache_mac.mm index 861423af7d..6ed461d371 100644 --- a/src/gui/accessible/qaccessiblecache_mac.mm +++ b/src/gui/accessible/qaccessiblecache_mac.mm @@ -45,19 +45,19 @@ QT_BEGIN_NAMESPACE -void QAccessibleCache::insertElement(QAccessible::Id axid, QCocoaAccessibleElement *element) const +void QAccessibleCache::insertElement(QAccessible::Id axid, QT_MANGLE_NAMESPACE(QCocoaAccessibleElement) *element) const { cocoaElements[axid] = element; } void QAccessibleCache::removeCocoaElement(QAccessible::Id axid) { - QCocoaAccessibleElement *element = elementForId(axid); + QT_MANGLE_NAMESPACE(QCocoaAccessibleElement) *element = elementForId(axid); [element invalidate]; cocoaElements.remove(axid); } -QCocoaAccessibleElement *QAccessibleCache::elementForId(QAccessible::Id axid) const +QT_MANGLE_NAMESPACE(QCocoaAccessibleElement) *QAccessibleCache::elementForId(QAccessible::Id axid) const { return cocoaElements.value(axid); } diff --git a/src/gui/accessible/qaccessiblecache_p.h b/src/gui/accessible/qaccessiblecache_p.h index 30b023cfbd..933c6f7313 100644 --- a/src/gui/accessible/qaccessiblecache_p.h +++ b/src/gui/accessible/qaccessiblecache_p.h @@ -59,7 +59,7 @@ #include "qaccessible.h" -Q_FORWARD_DECLARE_OBJC_CLASS(QCocoaAccessibleElement); +Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QCocoaAccessibleElement)); QT_BEGIN_NAMESPACE @@ -74,8 +74,8 @@ public: void deleteInterface(QAccessible::Id id, QObject *obj = 0); #ifdef Q_OS_OSX - QCocoaAccessibleElement *elementForId(QAccessible::Id axid) const; - void insertElement(QAccessible::Id axid, QCocoaAccessibleElement *element) const; + QT_MANGLE_NAMESPACE(QCocoaAccessibleElement) *elementForId(QAccessible::Id axid) const; + void insertElement(QAccessible::Id axid, QT_MANGLE_NAMESPACE(QCocoaAccessibleElement) *element) const; #endif private Q_SLOTS: @@ -89,7 +89,7 @@ private: #ifdef Q_OS_OSX void removeCocoaElement(QAccessible::Id axid); - mutable QHash cocoaElements; + mutable QHash cocoaElements; #endif friend class QAccessible; diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h index babaab5ae2..9760f492ea 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h @@ -43,22 +43,25 @@ #include +#include "qt_mac_p.h" + #import #import #import -@class QCocoaAccessibleElement; +@class QT_MANGLE_NAMESPACE(QCocoaAccessibleElement); -@interface QCocoaAccessibleElement : NSObject { +@interface QT_MANGLE_NAMESPACE(QCocoaAccessibleElement) : NSObject { NSString *role; QAccessible::Id axid; } - (id)initWithId:(QAccessible::Id)anId; -+ (QCocoaAccessibleElement *)elementWithId:(QAccessible::Id)anId; ++ (QT_MANGLE_NAMESPACE(QCocoaAccessibleElement) *)elementWithId:(QAccessible::Id)anId; @end -#endif +QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaAccessibleElement); +#endif diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index bb5c0c1974..33647a8cbd 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -49,14 +49,15 @@ #include "qcocoaglcontext.h" #include "qnsview.h" +#include "qt_mac_p.h" QT_FORWARD_DECLARE_CLASS(QCocoaWindow) -@class QNSWindowHelper; +@class QT_MANGLE_NAMESPACE(QNSWindowHelper); @protocol QNSWindowProtocol -@property (nonatomic, readonly) QNSWindowHelper *helper; +@property (nonatomic, readonly) QT_MANGLE_NAMESPACE(QNSWindowHelper) *helper; - (void)superSendEvent:(NSEvent *)theEvent; - (void)closeAndRelease; @@ -65,7 +66,7 @@ QT_FORWARD_DECLARE_CLASS(QCocoaWindow) typedef NSWindow QCocoaNSWindow; -@interface QNSWindowHelper : NSObject +@interface QT_MANGLE_NAMESPACE(QNSWindowHelper) : NSObject { QCocoaNSWindow *_window; QCocoaWindow *_platformWindow; @@ -84,7 +85,9 @@ typedef NSWindow QCocoaNSWindow; @end -@interface QNSWindow : NSWindow +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSWindowHelper); + +@interface QT_MANGLE_NAMESPACE(QNSWindow) : NSWindow { QNSWindowHelper *_helper; } @@ -97,7 +100,9 @@ typedef NSWindow QCocoaNSWindow; @end -@interface QNSPanel : NSPanel +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSWindow); + +@interface QT_MANGLE_NAMESPACE(QNSPanel) : NSPanel { QNSWindowHelper *_helper; } @@ -110,7 +115,9 @@ typedef NSWindow QCocoaNSWindow; @end -@class QNSWindowDelegate; +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSPanel); + +@class QT_MANGLE_NAMESPACE(QNSWindowDelegate); QT_BEGIN_NAMESPACE // QCocoaWindow diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h index 5717551cc3..083466861b 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.h +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h @@ -46,7 +46,7 @@ #include "qcocoawindow.h" -@interface QNSWindowDelegate : NSObject +@interface QT_MANGLE_NAMESPACE(QNSWindowDelegate) : NSObject { QCocoaWindow *m_cocoaWindow; } @@ -62,4 +62,6 @@ @end +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSWindowDelegate); + #endif // QNSWINDOWDELEGATE_H diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index d647acdacc..b3c0463bca 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -100,13 +100,14 @@ QT_USE_NAMESPACE -@interface NotificationReceiver : NSObject { +@interface QT_MANGLE_NAMESPACE(NotificationReceiver) : NSObject { QMacStylePrivate *mPrivate; } - (id)initWithPrivate:(QMacStylePrivate *)priv; - (void)scrollBarStyleDidChange:(NSNotification *)notification; @end +QT_NAMESPACE_ALIAS_OBJC_CLASS(NotificationReceiver); @implementation NotificationReceiver - (id)initWithPrivate:(QMacStylePrivate *)priv -- cgit v1.2.3 From 3c982a6384f5c5782463fd841cce6f59d2cda754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 24 Apr 2014 09:36:29 +0200 Subject: Cocoa: Handle Qt::WindowDoesNotAcceptFocus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make windows with the Qt::WindowDoesNotAcceptFocus flag refuse to become the key window. This is in addition to the existing refusal to become the first responder in QNSView. Refactor the common test into a new function: bool shouldRefuseKeyWindowAndFirstResponder() Task-number: QTBUG-32385 Change-Id: I31021b5d8895a17c48f94f3691e6590c90b68627 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.h | 1 + src/plugins/platforms/cocoa/qcocoawindow.mm | 17 +++++++++++++++++ src/plugins/platforms/cocoa/qnsview.mm | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 33647a8cbd..7e7848467c 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -230,6 +230,7 @@ public: void obscureWindow(); void updateExposedGeometry(); QWindow *childWindowAt(QPoint windowPoint); + bool shouldRefuseKeyWindowAndFirstResponder(); protected: void recreateWindow(const QPlatformWindow *parentWindow); QCocoaNSWindow *createNSWindow(); diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index c8ca494b33..39ca1ff636 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -237,6 +237,9 @@ static bool isMouseEvent(NSEvent *ev) if (!pw || pw->m_isNSWindowChild) return NO; + if (pw->shouldRefuseKeyWindowAndFirstResponder()) + return NO; + // The default implementation returns NO for title-bar less windows, // override and return yes here to make sure popup windows such as // the combobox popup can become the key window. @@ -314,6 +317,9 @@ static bool isMouseEvent(NSEvent *ev) if (!pw) return NO; + if (pw->shouldRefuseKeyWindowAndFirstResponder()) + return NO; + // Only tool or dialog windows should become key: Qt::WindowType type = pw->window()->type(); if (type == Qt::Tool || type == Qt::Dialog) @@ -1776,6 +1782,17 @@ QWindow *QCocoaWindow::childWindowAt(QPoint windowPoint) return targetWindow; } +bool QCocoaWindow::shouldRefuseKeyWindowAndFirstResponder() +{ + // This function speaks up if there's any reason + // to refuse key window or first responder state. + + if (window()->flags() & Qt::WindowDoesNotAcceptFocus) + return true; + + return false; +} + QMargins QCocoaWindow::frameMargins() const { NSRect frameW = [m_nsWindow frame]; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index b9e4826d72..a18ee7ff71 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -596,7 +596,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; - (BOOL)acceptsFirstResponder { - if (m_window->flags() & Qt::WindowDoesNotAcceptFocus) + if (m_platformWindow->shouldRefuseKeyWindowAndFirstResponder()) return NO; if (m_window->flags() & Qt::WindowTransparentForInput) return NO; -- cgit v1.2.3 From cd07830e3b27da7e96a0a83f91ba08c168b45e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 24 Apr 2014 09:46:15 +0200 Subject: Cocoa: Handle Qt::WA_ShowWithoutActivating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Forward the flag to QWindow by setting the _q_showWithoutActivating property on the window in QWidgetPrivate::create_sys(). Implement by refusing to become the key window or first responder during QCocoaWindow::setVisible(). Task-number: QTBUG-19194 Change-Id: I8446927ec510d7226a5a7b51b7be49d2f9bfd098 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.h | 1 + src/plugins/platforms/cocoa/qcocoawindow.mm | 11 +++++++++++ src/widgets/kernel/qwidget_qpa.cpp | 4 ++++ 3 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 7e7848467c..7a21f7a8d3 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -271,6 +271,7 @@ public: // for QNSView bool m_windowUnderMouse; bool m_inConstructor; + bool m_inSetVisible; QCocoaGLContext *m_glContext; QCocoaMenuBar *m_menubar; NSCursor *m_windowCursor; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 39ca1ff636..4d0458a4aa 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -372,6 +372,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) , m_windowModality(Qt::NonModal) , m_windowUnderMouse(false) , m_inConstructor(true) + , m_inSetVisible(false) , m_glContext(0) , m_menubar(0) , m_windowCursor(0) @@ -618,6 +619,8 @@ void QCocoaWindow::setVisible(bool visible) if (m_isNSWindowChild && m_hiddenByClipping) return; + m_inSetVisible = true; + QCocoaAutoReleasePool pool; QCocoaWindow *parentCocoaWindow = 0; if (window()->transientParent()) @@ -755,6 +758,8 @@ void QCocoaWindow::setVisible(bool visible) [parentCocoaWindow->m_nsWindow setStyleMask:[parentCocoaWindow->m_nsWindow styleMask] | NSResizableWindowMask]; } } + + m_inSetVisible = false; } NSInteger QCocoaWindow::windowLevel(Qt::WindowFlags flags) @@ -1790,6 +1795,12 @@ bool QCocoaWindow::shouldRefuseKeyWindowAndFirstResponder() if (window()->flags() & Qt::WindowDoesNotAcceptFocus) return true; + if (m_inSetVisible) { + QVariant showWithoutActivating = window()->property("_q_showWithoutActivating"); + if (showWithoutActivating.isValid() && showWithoutActivating.toBool()) + return true; + } + return false; } diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 17ed4ca477..70d274796b 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -115,6 +115,10 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO win->setProperty(propertyName, q->property(propertyName)); } +#ifdef Q_OS_OSX + if (q->testAttribute(Qt::WA_ShowWithoutActivating)) + win->setProperty("_q_showWithoutActivating", QVariant(true)); +#endif win->setFlags(data.window_flags); fixPosIncludesFrame(); if (q->testAttribute(Qt::WA_Moved) -- cgit v1.2.3 From 19d289ab1b5bde3e136765e5432b5c7d004df3a4 Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Tue, 20 May 2014 09:57:39 +0200 Subject: Listen to touch events on the master device instead of slave. Listening to touch events on the master prevents pointer emulation events from being generated, alleviating the need to grab. Grabbing on the slave device is buggy, and breaks pointer emulation on all current servers that support XInput 2.2 due to a bug in the server, and will also grab unwanted touch events. For reference, see https://bugs.freedesktop.org/show_bug.cgi?id=78345 Reverts 2c65b78b400ec27e6e559829b9a970dca2df6669. The idea of enabling each touchscreen separately was introduced in 4dbf574b7acb7ae8f852219700afa95f8d568f0e; that aspect is also reverted. Change-Id: I30d36397aa4ff2fb7a8ad2bbb94c2a13abd472b4 Task-number: QTBUG-38625 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 49 +++++++----------------- 1 file changed, 13 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index a574dcae6c..cf809b37e5 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -251,14 +251,13 @@ void QXcbConnection::xi2Select(xcb_window_t window) XIEventMask mask; mask.mask_len = sizeof(bitMask); mask.mask = xiBitMask; - // Enable each touchscreen - foreach (XInput2DeviceData *dev, m_touchDevices) { - mask.deviceid = dev->xiDeviceInfo->deviceid; + if (!m_touchDevices.isEmpty()) { + mask.deviceid = XIAllMasterDevices; Status result = XISelectEvents(xDisplay, window, &mask, 1); - // If we have XInput >= 2.2 and successfully enable a touchscreen, then - // it will provide touch only. In most other cases, there will be - // emulated mouse events from the driver. If not, then Qt must do its - // own mouse emulation to enable interaction with mouse-oriented QWidgets. + // If we select for touch events on the master pointer, XInput2 + // will not synthesize mouse events. This means Qt must do it, + // which is also preferable, since Qt can control better when + // to do so. if (m_xi2Minor >= 2 && result == Success) has_touch_without_mouse_emulation = true; } @@ -272,10 +271,10 @@ void QXcbConnection::xi2Select(xcb_window_t window) // similar handlers useless and we have no intention to infect // all the pure xcb code with Xlib-based XI2. if (!m_tabletData.isEmpty()) { - unsigned int tabletBitMask = bitMask; + unsigned int tabletBitMask; unsigned char *xiTabletBitMask = reinterpret_cast(&tabletBitMask); QVector xiEventMask(m_tabletData.count()); - tabletBitMask |= XI_ButtonPressMask; + tabletBitMask = XI_ButtonPressMask; tabletBitMask |= XI_ButtonReleaseMask; tabletBitMask |= XI_MotionMask; tabletBitMask |= XI_PropertyEventMask; @@ -294,24 +293,18 @@ void QXcbConnection::xi2Select(xcb_window_t window) // Enable each scroll device if (!m_scrollingDevices.isEmpty()) { QVector xiEventMask(m_scrollingDevices.size()); - unsigned int scrollBitMask = 0; + unsigned int scrollBitMask; unsigned char *xiScrollBitMask = reinterpret_cast(&scrollBitMask); + scrollBitMask = XI_MotionMask; scrollBitMask |= XI_ButtonReleaseMask; - bitMask |= XI_MotionMask; - bitMask |= XI_ButtonReleaseMask; int i=0; Q_FOREACH (const ScrollingDevice& scrollingDevice, m_scrollingDevices) { if (tabletDevices.contains(scrollingDevice.deviceId)) continue; // All necessary events are already captured. xiEventMask[i].deviceid = scrollingDevice.deviceId; - if (m_touchDevices.contains(scrollingDevice.deviceId)) { - xiEventMask[i].mask_len = sizeof(bitMask); - xiEventMask[i].mask = xiBitMask; - } else { - xiEventMask[i].mask_len = sizeof(scrollBitMask); - xiEventMask[i].mask = xiScrollBitMask; - } + xiEventMask[i].mask_len = sizeof(scrollBitMask); + xiEventMask[i].mask = xiScrollBitMask; i++; } XISelectEvents(xDisplay, window, xiEventMask.data(), i); @@ -458,7 +451,7 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event) fixed1616ToReal(xiDeviceEvent->root_x), fixed1616ToReal(xiDeviceEvent->root_y) ); if (QXcbWindow *platformWindow = platformWindowFromId(xiDeviceEvent->event)) { - XInput2DeviceData *dev = deviceForId(xiEvent->deviceid); + XInput2DeviceData *dev = deviceForId(xiDeviceEvent->sourceid); Q_ASSERT(dev); const bool firstTouch = m_touchPoints.isEmpty(); if (xiEvent->evtype == XI_TouchBegin) { @@ -563,22 +556,6 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event) qDebug() << " touchpoint " << touchPoint.id << " state " << touchPoint.state << " pos norm " << touchPoint.normalPosition << " area " << touchPoint.area << " pressure " << touchPoint.pressure; QWindowSystemInterface::handleTouchEvent(platformWindow->window(), xiEvent->time, dev->qtTouchDevice, m_touchPoints.values()); - if (has_touch_without_mouse_emulation) { - // We need to grab the touch event to prevent mouse emulation. - if (xiEvent->evtype == XI_TouchBegin) { - XIEventMask xieventmask; - unsigned int bitMask = 0; - unsigned char *xiBitMask = reinterpret_cast(&bitMask); - xieventmask.deviceid = xiEvent->deviceid; - xieventmask.mask = xiBitMask; - xieventmask.mask_len = sizeof(bitMask); - bitMask |= XI_TouchBeginMask; - bitMask |= XI_TouchUpdateMask; - bitMask |= XI_TouchEndMask; - XIGrabDevice(static_cast(m_xlib_display), xiEvent->deviceid, platformWindow->winId(), xiEvent->time, None, GrabModeAsync, GrabModeAsync, true, &xieventmask); - } else if (xiEvent->evtype == XI_TouchEnd) - XIUngrabDevice(static_cast(m_xlib_display), xiEvent->deviceid, xiEvent->time); - } if (touchPoint.state == Qt::TouchPointReleased) // If a touchpoint was released, we can forget it, because the ID won't be reused. m_touchPoints.remove(touchPoint.id); -- cgit v1.2.3