Changeset 846 for trunk/src/gui/kernel/qkeymapper_mac.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/kernel/qkeymapper_mac.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 324 324 }; 325 325 326 static qt_mac_enum_mapper qt_mac_private_unicode[] = { 327 { 0xF700, QT_MAC_MAP_ENUM(Qt::Key_Up) }, //NSUpArrowFunctionKey 328 { 0xF701, QT_MAC_MAP_ENUM(Qt::Key_Down) }, //NSDownArrowFunctionKey 329 { 0xF702, QT_MAC_MAP_ENUM(Qt::Key_Left) }, //NSLeftArrowFunctionKey 330 { 0xF703, QT_MAC_MAP_ENUM(Qt::Key_Right) }, //NSRightArrowFunctionKey 331 { 0xF727, QT_MAC_MAP_ENUM(Qt::Key_Insert) }, //NSInsertFunctionKey 332 { 0xF728, QT_MAC_MAP_ENUM(Qt::Key_Delete) }, //NSDeleteFunctionKey 333 { 0xF729, QT_MAC_MAP_ENUM(Qt::Key_Home) }, //NSHomeFunctionKey 334 { 0xF72B, QT_MAC_MAP_ENUM(Qt::Key_End) }, //NSEndFunctionKey 335 { 0xF72C, QT_MAC_MAP_ENUM(Qt::Key_PageUp) }, //NSPageUpFunctionKey 336 { 0xF72D, QT_MAC_MAP_ENUM(Qt::Key_PageDown) }, //NSPageDownFunctionKey 337 { 0xF72F, QT_MAC_MAP_ENUM(Qt::Key_ScrollLock) }, //NSScrollLockFunctionKey 338 { 0xF730, QT_MAC_MAP_ENUM(Qt::Key_Pause) }, //NSPauseFunctionKey 339 { 0xF731, QT_MAC_MAP_ENUM(Qt::Key_SysReq) }, //NSSysReqFunctionKey 340 { 0xF735, QT_MAC_MAP_ENUM(Qt::Key_Menu) }, //NSMenuFunctionKey 341 { 0xF738, QT_MAC_MAP_ENUM(Qt::Key_Print) }, //NSPrintFunctionKey 342 { 0xF73A, QT_MAC_MAP_ENUM(Qt::Key_Clear) }, //NSClearDisplayFunctionKey 343 { 0xF73D, QT_MAC_MAP_ENUM(Qt::Key_Insert) }, //NSInsertCharFunctionKey 344 { 0xF73E, QT_MAC_MAP_ENUM(Qt::Key_Delete) }, //NSDeleteCharFunctionKey 345 { 0xF741, QT_MAC_MAP_ENUM(Qt::Key_Select) }, //NSSelectFunctionKey 346 { 0xF742, QT_MAC_MAP_ENUM(Qt::Key_Execute) }, //NSExecuteFunctionKey 347 { 0xF746, QT_MAC_MAP_ENUM(Qt::Key_Help) }, //NSHelpFunctionKey 348 { 0xF747, QT_MAC_MAP_ENUM(Qt::Key_Mode_switch) }, //NSModeSwitchFunctionKey 349 { 0, QT_MAC_MAP_ENUM(0) } 350 }; 351 326 352 static int qt_mac_get_key(int modif, const QChar &key, int virtualKey) 327 353 { … … 378 404 return qt_mac_keyvkey_symbols[i].qt_code; 379 405 } 406 } 407 408 // check if they belong to key codes in private unicode range 409 if (key >= 0xf700 && key <= 0xf747) { 410 if (key >= 0xf704 && key <= 0xf726) { 411 return Qt::Key_F1 + (key.unicode() - 0xf704) ; 412 } 413 for (int i = 0; qt_mac_private_unicode[i].qt_code; i++) { 414 if (qt_mac_private_unicode[i].mac_code == key) { 415 return qt_mac_private_unicode[i].qt_code; 416 } 417 } 418 380 419 } 381 420 … … 634 673 if (iso639Code) { 635 674 keyboardInputLocale = QLocale(QCFString::toQString(iso639Code)); 636 QString monday = keyboardInputLocale.dayName(1); 637 bool rtl = false; 638 for (int i = 0; i < monday.length(); ++i) { 639 switch (monday.at(i).direction()) { 640 default: 641 break; 642 case QChar::DirR: 643 case QChar::DirAL: 644 case QChar::DirRLE: 645 case QChar::DirRLO: 646 rtl = true; 647 break; 648 } 649 if (rtl) 650 break; 651 } 652 keyboardInputDirection = rtl ? Qt::RightToLeft : Qt::LeftToRight; 675 keyboardInputDirection = keyboardInputLocale.textDirection(); 653 676 } else { 654 677 keyboardInputLocale = QLocale::c(); … … 718 741 } 719 742 720 if (qApp->inputContext() && qApp->inputContext()->isComposing()) { 743 QInputContext *currentContext = qApp->inputContext(); 744 if (currentContext && currentContext->isComposing()) { 721 745 if (ekind == kEventRawKeyDown) { 722 QMacInputContext *context = qobject_cast<QMacInputContext*>( qApp->inputContext());746 QMacInputContext *context = qobject_cast<QMacInputContext*>(currentContext); 723 747 if (context) 724 748 context->setLastKeydownEvent(event); … … 726 750 return false; 727 751 } 752 // Once we process the key down , we don't need to send the saved event again from 753 // kEventTextInputUnicodeForKeyEvent, so clear it. 754 if (currentContext && ekind == kEventRawKeyDown) { 755 QMacInputContext *context = qobject_cast<QMacInputContext*>(currentContext); 756 if (context) 757 context->setLastKeydownEvent(0); 758 } 759 728 760 //get modifiers 729 761 Qt::KeyboardModifiers modifiers; … … 734 766 return handled_event; 735 767 QString text(ourChar); 736 /* This is actually wrong - but unfortunat ly it is the best that can be768 /* This is actually wrong - but unfortunately it is the best that can be 737 769 done for now because of the Control/Meta mapping problems */ 738 770 if (modifiers & (Qt::ControlModifier | Qt::MetaModifier) … … 835 867 GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, 0, 836 868 sizeof(macModifiers), 0, &macModifiers); 869 #ifdef QT_MAC_USE_COCOA 870 // The unicode characters in the range 0xF700-0xF747 are reserved 871 // by Mac OS X for transient use as keyboard function keys. We 872 // wont send 'text' for such key events. This is done to match 873 // behavior on other platforms. 874 unsigned int *unicodeKey = (unsigned int*)info; 875 if (*unicodeKey >= 0xf700 && *unicodeKey <= 0xf747) 876 text = QString(); 877 bool isAccepted; 878 #endif 837 879 handled_event = QKeyMapper::sendKeyEvent(widget, grab, 838 880 (ekind == kEventRawKeyUp) ? QEvent::KeyRelease : QEvent::KeyPress, … … 840 882 macScanCode, macVirtualKey, macModifiers 841 883 #ifdef QT_MAC_USE_COCOA 842 , static_cast<bool *>(info)884 ,&isAccepted 843 885 #endif 844 886 ); 887 #ifdef QT_MAC_USE_COCOA 888 *unicodeKey = (unsigned int)isAccepted; 889 #endif 845 890 } 846 891 return handled_event; … … 848 893 849 894 void 850 QKeyMapperPrivate::updateKeyMap(EventHandlerCallRef, EventRef event, void *) 895 QKeyMapperPrivate::updateKeyMap(EventHandlerCallRef, EventRef event, void * 896 #if defined(QT_MAC_USE_COCOA) 897 unicodeKey // unicode character from NSEvent (modifiers applied) 898 #endif 899 ) 851 900 { 852 901 UInt32 macVirtualKey = 0; … … 876 925 keyLayout[macVirtualKey]->qtKey[i] = qtkey; 877 926 } 927 #ifndef Q_WS_MAC32 928 else { 929 const QChar unicode(*((UniChar *)unicodeKey)); 930 int qtkey = qt_mac_get_key(keyModifier, unicode, macVirtualKey); 931 if (qtkey == Qt::Key_unknown) 932 qtkey = unicode.unicode(); 933 keyLayout[macVirtualKey]->qtKey[i] = qtkey; 934 } 935 #endif 878 936 #ifdef Q_WS_MAC32 879 937 } else {
Note:
See TracChangeset
for help on using the changeset viewer.