From d63e7d8ec0c9337999a3d90b594eb3e955145de9 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 24 Jun 2010 10:34:56 +0200 Subject: QKeyEvent::text() inconsistency between Linux and Mac For a key event triggered by the cursor keys, QKeyEvent::text() returns char with value 0x14 or similar. This patch (Cocoa only)will remove text from all key events for the unicode range 0xF700-0xF747. This is part of the corporate unicode range used by apple for keyboard function keys. [http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/CORPCHAR.TXT] Task-number: QTBUG-11225 Reviewed-by: Bradley T. Hughes --- src/gui/kernel/qkeymapper_mac.cpp | 15 ++++++++++++++- src/gui/kernel/qt_cocoa_helpers_mac.mm | 7 ++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qkeymapper_mac.cpp b/src/gui/kernel/qkeymapper_mac.cpp index 873b8f9..3dc6afc 100644 --- a/src/gui/kernel/qkeymapper_mac.cpp +++ b/src/gui/kernel/qkeymapper_mac.cpp @@ -866,14 +866,27 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e UInt32 macModifiers = 0; GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, 0, sizeof(macModifiers), 0, &macModifiers); +#ifdef QT_MAC_USE_COCOA + // The unicode characters in the range 0xF700-0xF747 are reserved + // by Mac OS X for transient use as keyboard function keys. We + // wont send 'text' for such key events. This is done to match + // behavior on other platforms. + unsigned int *unicodeKey = (unsigned int*)info; + if (*unicodeKey >= 0xf700 && *unicodeKey <= 0xf747) + text = QString(); + bool isAccepted; +#endif handled_event = QKeyMapper::sendKeyEvent(widget, grab, (ekind == kEventRawKeyUp) ? QEvent::KeyRelease : QEvent::KeyPress, qtKey, modifiers, text, ekind == kEventRawKeyRepeat, 0, macScanCode, macVirtualKey, macModifiers #ifdef QT_MAC_USE_COCOA - ,static_cast(info) + ,&isAccepted #endif ); +#ifdef QT_MAC_USE_COCOA + *unicodeKey = (unsigned int)isAccepted; +#endif } return handled_event; } diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index 8cef03c..3fc27f4 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -682,10 +682,12 @@ bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEve NSEvent *event = static_cast(keyEvent); EventRef key_event = static_cast(const_cast([event eventRef])); Q_ASSERT(key_event); + unsigned int info = 0; if ([event type] == NSKeyDown) { NSString *characters = [event characters]; unichar value = [characters characterAtIndex:0]; qt_keymapper_private()->updateKeyMap(0, key_event, (void *)&value); + info = value; } // Redirect keys to alien widgets. @@ -701,9 +703,8 @@ bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEve if (mustUseCocoaKeyEvent()) return qt_dispatchKeyEventWithCocoa(keyEvent, widgetToGetEvent); - bool isAccepted; - bool consumed = qt_keymapper_private()->translateKeyEvent(widgetToGetEvent, 0, key_event, &isAccepted, true); - return consumed && isAccepted; + bool consumed = qt_keymapper_private()->translateKeyEvent(widgetToGetEvent, 0, key_event, &info, true); + return consumed && (info != 0); #endif } -- cgit v0.12 From 598ba59b9d2e4b28469088d4ef12407b0c27514a Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 24 Jun 2010 12:32:42 +0200 Subject: Child windows shown automatically when their parent is shown(Cocoa). While setting up the stacking order for child windows, their hidden state was never taken into consideration. Task-number: QTBUG-11239 Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qwidget_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 280712a..a9bb691 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -2804,7 +2804,7 @@ void QWidgetPrivate::setSubWindowStacking(bool set) QList widgets = q->findChildren(); for (int i=0; iisWindow() && child->testAttribute(Qt::WA_WState_Created)) { + if (child->isWindow() && child->testAttribute(Qt::WA_WState_Created) && child->isVisibleTo(q)) { if (set) [qt_mac_window_for(q) addChildWindow:qt_mac_window_for(child) ordered:NSWindowAbove]; else -- cgit v0.12 From d806b996beab76cbc43ffa11bc38721fa19c9c81 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 24 Jun 2010 15:02:02 +0200 Subject: No more enter & leave events after a popup menu is closed on Windows We use the TrackMouseEvent() to keep track of enter and leave messages. Upon receiving a WM_MOUSELEAVE, the effect of that function call is over, we need to call it again if we need more messages. This was not done when we close a popup because of mouse click outside. Task-number: QTBUG-11582 Reviewed-by: Bradley T. Hughes --- src/gui/kernel/qapplication_win.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 2a85fdc..ef719ca 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -3065,6 +3065,11 @@ bool QETWidget::translateMouseEvent(const MSG &msg) break; } } +#ifndef Q_OS_WINCE + static bool trackMouseEventLookup = false; + typedef BOOL (WINAPI *PtrTrackMouseEvent)(LPTRACKMOUSEEVENT); + static PtrTrackMouseEvent ptrTrackMouseEvent = 0; +#endif state = translateButtonState(msg.wParam, type, button); // button state const QPoint widgetPos = mapFromGlobal(QPoint(msg.pt.x, msg.pt.y)); QWidget *alienWidget = !internalWinId() ? this : childAt(widgetPos); @@ -3129,9 +3134,6 @@ bool QETWidget::translateMouseEvent(const MSG &msg) #ifndef Q_OS_WINCE if (curWin != 0) { - static bool trackMouseEventLookup = false; - typedef BOOL (WINAPI *PtrTrackMouseEvent)(LPTRACKMOUSEEVENT); - static PtrTrackMouseEvent ptrTrackMouseEvent = 0; if (!trackMouseEventLookup) { trackMouseEventLookup = true; ptrTrackMouseEvent = (PtrTrackMouseEvent)QLibrary::resolve(QLatin1String("comctl32"), "_TrackMouseEvent"); @@ -3245,6 +3247,21 @@ bool QETWidget::translateMouseEvent(const MSG &msg) qt_button_down = 0; } +#ifndef Q_OS_WINCE + if (type == QEvent::MouseButtonPress + && QApplication::activePopupWidget() != activePopupWidget + && ptrTrackMouseEvent + && curWin) { + // Since curWin is already the window we clicked on, + // we have to setup the mouse tracking here. + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(TRACKMOUSEEVENT); + tme.dwFlags = 0x00000002; // TME_LEAVE + tme.hwndTrack = curWin; // Track on window receiving msgs + tme.dwHoverTime = (DWORD)-1; // HOVER_DEFAULT + ptrTrackMouseEvent(&tme); + } +#endif if (type == QEvent::MouseButtonPress && QApplication::activePopupWidget() != activePopupWidget && replayPopupMouseEvent) { -- cgit v0.12 From 0531b97863f93c5a141bd9ef0b58bcf6282024e7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 24 Jun 2010 15:27:13 +0200 Subject: Manipulate buffer position via 'pPos' in peek() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: João Abecasis --- src/corelib/io/qiodevice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index ea60792..26e587d 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -1452,7 +1452,7 @@ qint64 QIODevicePrivate::peek(char *data, qint64 maxSize) return readBytes; buffer.ungetBlock(data, readBytes); - pos -= readBytes; + *pPos -= readBytes; return readBytes; } @@ -1467,7 +1467,7 @@ QByteArray QIODevicePrivate::peek(qint64 maxSize) return result; buffer.ungetBlock(result.constData(), result.size()); - pos -= result.size(); + *pPos -= result.size(); return result; } -- cgit v0.12