Changeset 846 for trunk/src/gui/kernel/qkeymapper_x11.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_x11.cpp
r769 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) … … 62 62 #include <ctype.h> 63 63 64 QT_BEGIN_NAMESPACE65 66 #ifndef QT_NO_XKB67 68 // bring in the auto-generated xkbLayoutData69 #include "qkeymapper_x11_p.cpp"70 71 64 #ifdef QT_LINUXBASE 72 65 // LSB's IsKeypadKey define is wrong - see … … 81 74 #endif 82 75 83 static void getLocaleAndDirection(QLocale *locale, 84 Qt::LayoutDirection *direction, 85 const QByteArray &layoutName, 86 const QByteArray &variantName) 76 QT_BEGIN_NAMESPACE 77 78 #ifndef QT_NO_XKB 79 80 // bring in the auto-generated xkbLayoutData 81 #include "qkeymapper_x11_p.cpp" 82 83 QLocale q_getKeyboardLocale(const QByteArray &layoutName, const QByteArray &variantName) 87 84 { 88 85 int i = 0; 89 86 while (xkbLayoutData[i].layout != 0) { 90 if (layoutName == xkbLayoutData[i].layout && variantName == xkbLayoutData[i].variant) { 91 *locale = QLocale(xkbLayoutData[i].language, xkbLayoutData[i].country); 92 *direction = xkbLayoutData[i].direction; 93 return; 94 } 87 if (layoutName == xkbLayoutData[i].layout && variantName == xkbLayoutData[i].variant) 88 return QLocale(xkbLayoutData[i].language, xkbLayoutData[i].country); 95 89 ++i; 96 90 } 97 *locale = QLocale::c(); 98 *direction = Qt::LeftToRight; 91 return QLocale::c(); 99 92 } 100 93 #endif // QT_NO_XKB 101 102 94 103 95 // from qapplication_x11.cpp … … 249 241 250 242 QKeyMapperPrivate::QKeyMapperPrivate() 251 : keyboardInputDirection(Qt::LeftToRight), useXKB(false)243 : keyboardInputDirection(Qt::LeftToRight), xkb_currentGroup(0) 252 244 { 253 245 memset(&coreDesc, 0, sizeof(coreDesc)); 254 246 255 247 #ifndef QT_NO_XKB 256 int opcode = -1; 257 int xkbEventBase = -1; 258 int xkbErrorBase = -1; 259 int xkblibMajor = XkbMajorVersion; 260 int xkblibMinor = XkbMinorVersion; 261 if (XkbQueryExtension(X11->display, &opcode, &xkbEventBase, &xkbErrorBase, &xkblibMajor, &xkblibMinor)) 262 useXKB = true; 263 #endif 264 265 #if 0 266 qDebug() << "useXKB =" << useXKB; 248 if (X11->use_xkb) { 249 // get the current group 250 XkbStateRec xkbState; 251 if (XkbGetState(X11->display, XkbUseCoreKbd, &xkbState) == Success) 252 xkb_currentGroup = xkbState.group; 253 } 267 254 #endif 268 255 } … … 277 264 { 278 265 #ifndef QT_NO_XKB 279 if ( useXKB)266 if (X11->use_xkb) 280 267 return possibleKeysXKB(event); 281 268 #endif … … 487 474 { 488 475 #ifndef QT_NO_XKB 489 if ( useXKB) {476 if (X11->use_xkb) { 490 477 // try to determine the layout name and input direction by reading the _XKB_RULES_NAMES property off 491 478 // the root window … … 516 503 } while (p < end); 517 504 518 layoutName = QByteArray::fromRawData(names[2], qstrlen(names[2])); 519 variantName = QByteArray::fromRawData(names[3], qstrlen(names[3])); 505 // the layout names and variants are saved in the _XKB_RULES_NAMES property as a comma separated list 506 QList<QByteArray> layoutNames = QByteArray::fromRawData(names[2], qstrlen(names[2])).split(','); 507 if (uint(xkb_currentGroup) < uint(layoutNames.count())) 508 layoutName = layoutNames.at(xkb_currentGroup); 509 QList<QByteArray> variantNames = QByteArray::fromRawData(names[3], qstrlen(names[3])).split(','); 510 if (uint(xkb_currentGroup) < uint(variantNames.count())) 511 variantName = variantNames.at(xkb_currentGroup); 520 512 } 521 513 … … 524 516 // qWarning("Qt: unable to determine keyboard layout, please talk to qt-bugs@trolltech.com"); ? 525 517 526 getLocaleAndDirection(&keyboardInputLocale, 527 &keyboardInputDirection, 528 layoutName, 529 variantName); 518 keyboardInputLocale = q_getKeyboardLocale(layoutName, variantName); 519 keyboardInputDirection = keyboardInputLocale.textDirection(); 530 520 531 521 #if 0 … … 535 525 << keyboardInputDirection; 536 526 #endif 537 538 527 if (data) 539 528 XFree(data); … … 575 564 // look at the modifier mapping, and get the correct masks for alt, meta, super, hyper, and mode_switch 576 565 #ifndef QT_NO_XKB 577 if ( useXKB) {566 if (X11->use_xkb) { 578 567 XkbDescPtr xkbDesc = XkbGetMap(X11->display, XkbAllClientInfoMask, XkbUseCoreKbd); 579 568 for (int i = xkbDesc->min_key_code; i < xkbDesc->max_key_code; ++i) { … … 1187 1176 XF86XK_LaunchC, Qt::Key_LaunchE, 1188 1177 XF86XK_LaunchD, Qt::Key_LaunchF, 1178 XF86XK_LaunchE, Qt::Key_LaunchG, 1179 XF86XK_LaunchF, Qt::Key_LaunchH, 1189 1180 1190 1181 // Qtopia keys
Note:
See TracChangeset
for help on using the changeset viewer.