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/plugins') 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 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/plugins') 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/plugins') 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/plugins') 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/plugins') 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/plugins') 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 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/plugins') 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 --- .../platforms/cocoa/qcocoaaccessibilityelement.h | 11 +++++++---- src/plugins/platforms/cocoa/qcocoawindow.h | 19 +++++++++++++------ src/plugins/platforms/cocoa/qnswindowdelegate.h | 4 +++- 3 files changed, 23 insertions(+), 11 deletions(-) (limited to 'src/plugins') 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 -- 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/plugins') 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 +++++++++++ 2 files changed, 12 insertions(+) (limited to 'src/plugins') 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; } -- 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/plugins') 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