78 #undef IsPrivateKeypadKey |
78 #undef IsPrivateKeypadKey |
79 #define IsPrivateKeypadKey(keysym) \ |
79 #define IsPrivateKeypadKey(keysym) \ |
80 (((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF)) |
80 (((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF)) |
81 #endif |
81 #endif |
82 |
82 |
83 static void getLocaleAndDirection(QLocale *locale, |
83 void q_getLocaleAndDirection(QLocale *locale, |
84 Qt::LayoutDirection *direction, |
84 Qt::LayoutDirection *direction, |
85 const QByteArray &layoutName, |
85 const QByteArray &layoutName, |
86 const QByteArray &variantName) |
86 const QByteArray &variantName) |
87 { |
87 { |
88 int i = 0; |
88 int i = 0; |
246 |
246 |
247 |
247 |
248 |
248 |
249 |
249 |
250 QKeyMapperPrivate::QKeyMapperPrivate() |
250 QKeyMapperPrivate::QKeyMapperPrivate() |
251 : keyboardInputDirection(Qt::LeftToRight), useXKB(false) |
251 : keyboardInputDirection(Qt::LeftToRight), xkb_currentGroup(0) |
252 { |
252 { |
253 memset(&coreDesc, 0, sizeof(coreDesc)); |
253 memset(&coreDesc, 0, sizeof(coreDesc)); |
254 |
254 |
255 #ifndef QT_NO_XKB |
255 #ifndef QT_NO_XKB |
256 int opcode = -1; |
256 if (X11->use_xkb) { |
257 int xkbEventBase = -1; |
257 // get the current group |
258 int xkbErrorBase = -1; |
258 XkbStateRec xkbState; |
259 int xkblibMajor = XkbMajorVersion; |
259 if (XkbGetState(X11->display, XkbUseCoreKbd, &xkbState) == Success) |
260 int xkblibMinor = XkbMinorVersion; |
260 xkb_currentGroup = xkbState.group; |
261 if (XkbQueryExtension(X11->display, &opcode, &xkbEventBase, &xkbErrorBase, &xkblibMajor, &xkblibMinor)) |
261 } |
262 useXKB = true; |
|
263 #endif |
|
264 |
|
265 #if 0 |
|
266 qDebug() << "useXKB =" << useXKB; |
|
267 #endif |
262 #endif |
268 } |
263 } |
269 |
264 |
270 QKeyMapperPrivate::~QKeyMapperPrivate() |
265 QKeyMapperPrivate::~QKeyMapperPrivate() |
271 { |
266 { |
513 do { |
508 do { |
514 names[i++] = p; |
509 names[i++] = p; |
515 p += qstrlen(p) + 1; |
510 p += qstrlen(p) + 1; |
516 } while (p < end); |
511 } while (p < end); |
517 |
512 |
518 layoutName = QByteArray::fromRawData(names[2], qstrlen(names[2])); |
513 // the layout names and variants are saved in the _XKB_RULES_NAMES property as a comma separated list |
519 variantName = QByteArray::fromRawData(names[3], qstrlen(names[3])); |
514 QList<QByteArray> layoutNames = QByteArray::fromRawData(names[2], qstrlen(names[2])).split(','); |
|
515 if (uint(xkb_currentGroup) < uint(layoutNames.count())) |
|
516 layoutName = layoutNames.at(xkb_currentGroup); |
|
517 QList<QByteArray> variantNames = QByteArray::fromRawData(names[3], qstrlen(names[3])).split(','); |
|
518 if (uint(xkb_currentGroup) < uint(variantNames.count())) |
|
519 variantName = variantNames.at(xkb_currentGroup); |
520 } |
520 } |
521 |
521 |
522 // ### ??? |
522 // ### ??? |
523 // if (keyboardLayoutName.isEmpty()) |
523 // if (keyboardLayoutName.isEmpty()) |
524 // qWarning("Qt: unable to determine keyboard layout, please talk to qt-bugs@trolltech.com"); ? |
524 // qWarning("Qt: unable to determine keyboard layout, please talk to qt-bugs@trolltech.com"); ? |
525 |
525 |
526 getLocaleAndDirection(&keyboardInputLocale, |
526 q_getLocaleAndDirection(&keyboardInputLocale, |
527 &keyboardInputDirection, |
527 &keyboardInputDirection, |
528 layoutName, |
528 layoutName, |
529 variantName); |
529 variantName); |
530 |
530 |
531 #if 0 |
531 #if 0 |
532 qDebug() << "keyboard input locale =" |
532 qDebug() << "keyboard input locale =" |
533 << keyboardInputLocale.name() |
533 << keyboardInputLocale.name() |
534 << "direction =" |
534 << "direction =" |
535 << keyboardInputDirection; |
535 << keyboardInputDirection; |
536 #endif |
536 #endif |
537 |
|
538 if (data) |
537 if (data) |
539 XFree(data); |
538 XFree(data); |
540 } else |
539 } else |
541 #endif // QT_NO_XKB |
540 #endif // QT_NO_XKB |
542 { |
541 { |
572 qt_hyper_mask = 0; |
571 qt_hyper_mask = 0; |
573 qt_mode_switch_mask = 0; |
572 qt_mode_switch_mask = 0; |
574 |
573 |
575 // look at the modifier mapping, and get the correct masks for alt, meta, super, hyper, and mode_switch |
574 // look at the modifier mapping, and get the correct masks for alt, meta, super, hyper, and mode_switch |
576 #ifndef QT_NO_XKB |
575 #ifndef QT_NO_XKB |
577 if (useXKB) { |
576 if (X11->use_xkb) { |
578 XkbDescPtr xkbDesc = XkbGetMap(X11->display, XkbAllClientInfoMask, XkbUseCoreKbd); |
577 XkbDescPtr xkbDesc = XkbGetMap(X11->display, XkbAllClientInfoMask, XkbUseCoreKbd); |
579 for (int i = xkbDesc->min_key_code; i < xkbDesc->max_key_code; ++i) { |
578 for (int i = xkbDesc->min_key_code; i < xkbDesc->max_key_code; ++i) { |
580 const uint mask = xkbDesc->map->modmap ? xkbDesc->map->modmap[i] : 0; |
579 const uint mask = xkbDesc->map->modmap ? xkbDesc->map->modmap[i] : 0; |
581 if (mask == 0) { |
580 if (mask == 0) { |
582 // key is not bound to a modifier |
581 // key is not bound to a modifier |
1184 XF86XK_Launch9, Qt::Key_LaunchB, |
1183 XF86XK_Launch9, Qt::Key_LaunchB, |
1185 XF86XK_LaunchA, Qt::Key_LaunchC, |
1184 XF86XK_LaunchA, Qt::Key_LaunchC, |
1186 XF86XK_LaunchB, Qt::Key_LaunchD, |
1185 XF86XK_LaunchB, Qt::Key_LaunchD, |
1187 XF86XK_LaunchC, Qt::Key_LaunchE, |
1186 XF86XK_LaunchC, Qt::Key_LaunchE, |
1188 XF86XK_LaunchD, Qt::Key_LaunchF, |
1187 XF86XK_LaunchD, Qt::Key_LaunchF, |
|
1188 XF86XK_LaunchE, Qt::Key_LaunchG, |
|
1189 XF86XK_LaunchF, Qt::Key_LaunchH, |
1189 |
1190 |
1190 // Qtopia keys |
1191 // Qtopia keys |
1191 QTOPIAXK_Select, Qt::Key_Select, |
1192 QTOPIAXK_Select, Qt::Key_Select, |
1192 QTOPIAXK_Yes, Qt::Key_Yes, |
1193 QTOPIAXK_Yes, Qt::Key_Yes, |
1193 QTOPIAXK_No, Qt::Key_No, |
1194 QTOPIAXK_No, Qt::Key_No, |