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/inputmethod/qximinputcontext_x11.cpp

    r651 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)
     
    345345}
    346346
    347 
     347extern bool qt_use_rtl_extensions; // from qapplication_x11.cpp
     348#ifndef QT_NO_XKB
     349extern QLocale q_getKeyboardLocale(const QByteArray &layoutName, const QByteArray &variantName);
     350#endif
    348351
    349352QXIMInputContext::QXIMInputContext()
     
    376379        QXIMInputContext::create_xim();
    377380#endif // USE_X11R6_XIM
     381
     382#ifndef QT_NO_XKB
     383    if (X11->use_xkb) {
     384        QByteArray layoutName;
     385        QByteArray variantName;
     386
     387        Atom type = XNone;
     388        int format = 0;
     389        ulong nitems = 0;
     390        ulong bytesAfter = 0;
     391        uchar *data = 0;
     392        if (XGetWindowProperty(X11->display, RootWindow(X11->display, 0), ATOM(_XKB_RULES_NAMES), 0, 1024,
     393                               false, XA_STRING, &type, &format, &nitems, &bytesAfter, &data) == Success
     394            && type == XA_STRING && format == 8 && nitems > 2) {
     395
     396            char *names[5] = { 0, 0, 0, 0, 0 };
     397            char *p = reinterpret_cast<char *>(data), *end = p + nitems;
     398            int i = 0;
     399            do {
     400                names[i++] = p;
     401                p += qstrlen(p) + 1;
     402            } while (p < end);
     403
     404            QList<QByteArray> layoutNames = QByteArray::fromRawData(names[2], qstrlen(names[2])).split(',');
     405            QList<QByteArray> variantNames = QByteArray::fromRawData(names[3], qstrlen(names[3])).split(',');
     406            for (int i = 0; i < qMin(layoutNames.count(), variantNames.count()); ++i  ) {
     407                QByteArray variantName = variantNames.at(i);
     408                const int dashPos = variantName.indexOf("-");
     409                if (dashPos >= 0)
     410                    variantName.truncate(dashPos);
     411                QLocale keyboardInputLocale = q_getKeyboardLocale(layoutNames.at(i), variantName);
     412                if (keyboardInputLocale.textDirection() == Qt::RightToLeft)
     413                    qt_use_rtl_extensions = true;
     414            }
     415        }
     416
     417        if (data)
     418            XFree(data);
     419    }
     420#endif // QT_NO_XKB
     421
    378422}
    379423
Note: See TracChangeset for help on using the changeset viewer.