diff options
author | Martin Smith <msmith@trolltech.com> | 2010-03-16 12:28:16 (GMT) |
---|---|---|
committer | Martin Smith <msmith@trolltech.com> | 2010-03-16 12:28:16 (GMT) |
commit | 4574b41dfb56652e806afd1dd64cc8b300284570 (patch) | |
tree | 396b8464a4831d7a5df3cb8211e46381a9d5a6f2 /src | |
parent | 62a7fd7752d203610eaa50f682069dfe09afa895 (diff) | |
parent | b2e9757b6481be20485d4a36f2d74ea919ff8833 (diff) | |
download | Qt-4574b41dfb56652e806afd1dd64cc8b300284570.zip Qt-4574b41dfb56652e806afd1dd64cc8b300284570.tar.gz Qt-4574b41dfb56652e806afd1dd64cc8b300284570.tar.bz2 |
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qkeymapper_mac.cpp | 54 | ||||
-rw-r--r-- | src/gui/kernel/qt_cocoa_helpers_mac.mm | 4 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_mac.mm | 21 |
3 files changed, 68 insertions, 11 deletions
diff --git a/src/gui/kernel/qkeymapper_mac.cpp b/src/gui/kernel/qkeymapper_mac.cpp index a31480d..f259654 100644 --- a/src/gui/kernel/qkeymapper_mac.cpp +++ b/src/gui/kernel/qkeymapper_mac.cpp @@ -323,6 +323,32 @@ static qt_mac_enum_mapper qt_mac_keyvkey_symbols[] = { //real scan codes { 0, QT_MAC_MAP_ENUM(0) } }; +static qt_mac_enum_mapper qt_mac_private_unicode[] = { + { 0xF700, QT_MAC_MAP_ENUM(Qt::Key_Up) }, //NSUpArrowFunctionKey + { 0xF701, QT_MAC_MAP_ENUM(Qt::Key_Down) }, //NSDownArrowFunctionKey + { 0xF702, QT_MAC_MAP_ENUM(Qt::Key_Left) }, //NSLeftArrowFunctionKey + { 0xF703, QT_MAC_MAP_ENUM(Qt::Key_Right) }, //NSRightArrowFunctionKey + { 0xF727, QT_MAC_MAP_ENUM(Qt::Key_Insert) }, //NSInsertFunctionKey + { 0xF728, QT_MAC_MAP_ENUM(Qt::Key_Delete) }, //NSDeleteFunctionKey + { 0xF729, QT_MAC_MAP_ENUM(Qt::Key_Home) }, //NSHomeFunctionKey + { 0xF72B, QT_MAC_MAP_ENUM(Qt::Key_End) }, //NSEndFunctionKey + { 0xF72C, QT_MAC_MAP_ENUM(Qt::Key_PageUp) }, //NSPageUpFunctionKey + { 0xF72D, QT_MAC_MAP_ENUM(Qt::Key_PageDown) }, //NSPageDownFunctionKey + { 0xF72F, QT_MAC_MAP_ENUM(Qt::Key_ScrollLock) }, //NSScrollLockFunctionKey + { 0xF730, QT_MAC_MAP_ENUM(Qt::Key_Pause) }, //NSPauseFunctionKey + { 0xF731, QT_MAC_MAP_ENUM(Qt::Key_SysReq) }, //NSSysReqFunctionKey + { 0xF735, QT_MAC_MAP_ENUM(Qt::Key_Menu) }, //NSMenuFunctionKey + { 0xF738, QT_MAC_MAP_ENUM(Qt::Key_Print) }, //NSPrintFunctionKey + { 0xF73A, QT_MAC_MAP_ENUM(Qt::Key_Clear) }, //NSClearDisplayFunctionKey + { 0xF73D, QT_MAC_MAP_ENUM(Qt::Key_Insert) }, //NSInsertCharFunctionKey + { 0xF73E, QT_MAC_MAP_ENUM(Qt::Key_Delete) }, //NSDeleteCharFunctionKey + { 0xF741, QT_MAC_MAP_ENUM(Qt::Key_Select) }, //NSSelectFunctionKey + { 0xF742, QT_MAC_MAP_ENUM(Qt::Key_Execute) }, //NSExecuteFunctionKey + { 0xF746, QT_MAC_MAP_ENUM(Qt::Key_Help) }, //NSHelpFunctionKey + { 0xF747, QT_MAC_MAP_ENUM(Qt::Key_Mode_switch) }, //NSModeSwitchFunctionKey + { 0, QT_MAC_MAP_ENUM(0) } +}; + static int qt_mac_get_key(int modif, const QChar &key, int virtualKey) { #ifdef DEBUG_KEY_BINDINGS @@ -379,6 +405,19 @@ static int qt_mac_get_key(int modif, const QChar &key, int virtualKey) } } + // check if they belong to key codes in private unicode range + if (key >= 0xf700 && key <= 0xf747) { + if (key >= 0xf704 && key <= 0xf726) { + return Qt::Key_F1 + (key.unicode() - 0xf704) ; + } + for (int i = 0; qt_mac_private_unicode[i].qt_code; i++) { + if (qt_mac_private_unicode[i].mac_code == key) { + return qt_mac_private_unicode[i].qt_code; + } + } + + } + //oh well #ifdef DEBUG_KEY_BINDINGS qDebug("Unknown case.. %s:%d %d[%d] %d", __FILE__, __LINE__, key.unicode(), key.toLatin1(), virtualKey); @@ -847,7 +886,11 @@ bool QKeyMapperPrivate::translateKeyEvent(QWidget *widget, EventHandlerCallRef e } void -QKeyMapperPrivate::updateKeyMap(EventHandlerCallRef, EventRef event, void *) +QKeyMapperPrivate::updateKeyMap(EventHandlerCallRef, EventRef event, void * +#if defined(QT_MAC_USE_COCOA) + unicodeKey // unicode character from NSEvent (modifiers applied) +#endif + ) { UInt32 macVirtualKey = 0; GetEventParameter(event, kEventParamKeyCode, typeUInt32, 0, sizeof(macVirtualKey), 0, &macVirtualKey); @@ -875,6 +918,15 @@ QKeyMapperPrivate::updateKeyMap(EventHandlerCallRef, EventRef event, void *) qtkey = unicode.unicode(); keyLayout[macVirtualKey]->qtKey[i] = qtkey; } +#ifndef Q_WS_MAC32 + else { + const QChar unicode(*((UniChar *)unicodeKey)); + int qtkey = qt_mac_get_key(keyModifier, unicode, macVirtualKey); + if (qtkey == Qt::Key_unknown) + qtkey = unicode.unicode(); + keyLayout[macVirtualKey]->qtKey[i] = qtkey; + } +#endif #ifdef Q_WS_MAC32 } else { const UInt32 keyModifier = (qt_mac_get_mac_modifiers(ModsTbl[i])); diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index 3fbd978..24fe5f7 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -684,7 +684,9 @@ bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEve EventRef key_event = static_cast<EventRef>(const_cast<void *>([event eventRef])); Q_ASSERT(key_event); if ([event type] == NSKeyDown) { - qt_keymapper_private()->updateKeyMap(0, key_event, 0); + NSString *characters = [event characters]; + unichar value = [characters characterAtIndex:0]; + qt_keymapper_private()->updateKeyMap(0, key_event, (void *)&value); } // Redirect keys to alien widgets. diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index a19c57b..b3a6aec 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -3332,21 +3332,24 @@ void QWidgetPrivate::update_sys(const QRegion &rgn) HIViewSetNeedsDisplay(qt_mac_nativeview_for(q), true); // do a complete repaint on overflow. } #else - // Cocoa doesn't do regions, it seems more efficient to just update the bounding rect instead of a potential number of message passes for each rect. - const QRect & boundingRect = rgn.boundingRect(); - // Alien support: get the first native ancestor widget (will be q itself in the non-alien case), // map the coordinates from q space to NSView space and invalidate the rect. QWidget *nativeParent = q->internalWinId() ? q : q->nativeParentWidget(); if (nativeParent == 0) return; - const QRect nativeBoundingRect = QRect( - QPoint(q->mapTo(nativeParent, boundingRect.topLeft())), - QSize(boundingRect.size())); - [qt_mac_nativeview_for(nativeParent) setNeedsDisplayInRect:NSMakeRect(nativeBoundingRect.x(), - nativeBoundingRect.y(), nativeBoundingRect.width(), - nativeBoundingRect.height())]; + QVector<QRect> rects = rgn.rects(); + for (int i = 0; i < rects.count(); ++i) { + const QRect &rect = rects.at(i); + + const QRect nativeBoundingRect = QRect( + QPoint(q->mapTo(nativeParent, rect.topLeft())), + QSize(rect.size())); + + [qt_mac_nativeview_for(nativeParent) setNeedsDisplayInRect:NSMakeRect(nativeBoundingRect.x(), + nativeBoundingRect.y(), nativeBoundingRect.width(), + nativeBoundingRect.height())]; + } #endif } |