Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/kernel/qkeymapper_x11.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6262#include <ctype.h>
    6363
    64 QT_BEGIN_NAMESPACE
    65 
    66 #ifndef QT_NO_XKB
    67 
    68 // bring in the auto-generated xkbLayoutData
    69 #include "qkeymapper_x11_p.cpp"
    70 
    7164#ifdef QT_LINUXBASE
    7265// LSB's IsKeypadKey define is wrong - see
     
    8174#endif
    8275
    83 static void getLocaleAndDirection(QLocale *locale,
    84                                   Qt::LayoutDirection *direction,
    85                                   const QByteArray &layoutName,
    86                                   const QByteArray &variantName)
     76QT_BEGIN_NAMESPACE
     77
     78#ifndef QT_NO_XKB
     79
     80// bring in the auto-generated xkbLayoutData
     81#include "qkeymapper_x11_p.cpp"
     82
     83QLocale q_getKeyboardLocale(const QByteArray &layoutName, const QByteArray &variantName)
    8784{
    8885    int i = 0;
    8986    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);
    9589        ++i;
    9690    }
    97     *locale = QLocale::c();
    98     *direction = Qt::LeftToRight;
     91    return QLocale::c();
    9992}
    10093#endif // QT_NO_XKB
    101 
    10294
    10395// from qapplication_x11.cpp
     
    249241
    250242QKeyMapperPrivate::QKeyMapperPrivate()
    251     : keyboardInputDirection(Qt::LeftToRight), useXKB(false)
     243    : keyboardInputDirection(Qt::LeftToRight), xkb_currentGroup(0)
    252244{
    253245    memset(&coreDesc, 0, sizeof(coreDesc));
    254246
    255247#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    }
    267254#endif
    268255}
     
    277264{
    278265#ifndef QT_NO_XKB
    279     if (useXKB)
     266    if (X11->use_xkb)
    280267        return possibleKeysXKB(event);
    281268#endif
     
    487474{
    488475#ifndef QT_NO_XKB
    489     if (useXKB) {
     476    if (X11->use_xkb) {
    490477        // try to determine the layout name and input direction by reading the _XKB_RULES_NAMES property off
    491478        // the root window
     
    516503            } while (p < end);
    517504
    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);
    520512        }
    521513
     
    524516        //     qWarning("Qt: unable to determine keyboard layout, please talk to qt-bugs@trolltech.com"); ?
    525517
    526         getLocaleAndDirection(&keyboardInputLocale,
    527                               &keyboardInputDirection,
    528                               layoutName,
    529                               variantName);
     518        keyboardInputLocale = q_getKeyboardLocale(layoutName, variantName);
     519        keyboardInputDirection = keyboardInputLocale.textDirection();
    530520
    531521#if 0
     
    535525                 << keyboardInputDirection;
    536526#endif
    537 
    538527        if (data)
    539528            XFree(data);
     
    575564    // look at the modifier mapping, and get the correct masks for alt, meta, super, hyper, and mode_switch
    576565#ifndef QT_NO_XKB
    577     if (useXKB) {
     566    if (X11->use_xkb) {
    578567        XkbDescPtr xkbDesc = XkbGetMap(X11->display, XkbAllClientInfoMask, XkbUseCoreKbd);
    579568        for (int i = xkbDesc->min_key_code; i < xkbDesc->max_key_code; ++i) {
     
    11871176    XF86XK_LaunchC,             Qt::Key_LaunchE,
    11881177    XF86XK_LaunchD,             Qt::Key_LaunchF,
     1178    XF86XK_LaunchE,             Qt::Key_LaunchG,
     1179    XF86XK_LaunchF,             Qt::Key_LaunchH,
    11891180
    11901181    // Qtopia keys
Note: See TracChangeset for help on using the changeset viewer.