summaryrefslogtreecommitdiffstats
path: root/src/gui/inputmethod
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@nokia.com>2010-03-18 21:13:30 (GMT)
committerPierre Rossi <pierre.rossi@nokia.com>2010-03-31 14:33:21 (GMT)
commit33a2afa8cccc38302539573f8d3559976bf4cc91 (patch)
tree47fad6f37be0650d5f68b5f9a100052c92ffee77 /src/gui/inputmethod
parenta0df2ac07c75882618b40657e1485dda3204880e (diff)
downloadQt-33a2afa8cccc38302539573f8d3559976bf4cc91.zip
Qt-33a2afa8cccc38302539573f8d3559976bf4cc91.tar.gz
Qt-33a2afa8cccc38302539573f8d3559976bf4cc91.tar.bz2
Remove the "Insert unicode control character" menu entry on X11.
It's still displayed when it seems to make sense with respect to the active keyboard layouts. It can also be enabled from qtconfig. Task-number: QTBUG-9186 Reviewed-by: Denis
Diffstat (limited to 'src/gui/inputmethod')
-rw-r--r--src/gui/inputmethod/qximinputcontext_x11.cpp54
1 files changed, 53 insertions, 1 deletions
diff --git a/src/gui/inputmethod/qximinputcontext_x11.cpp b/src/gui/inputmethod/qximinputcontext_x11.cpp
index 68ade38..d048b36 100644
--- a/src/gui/inputmethod/qximinputcontext_x11.cpp
+++ b/src/gui/inputmethod/qximinputcontext_x11.cpp
@@ -344,7 +344,13 @@ static XFontSet getFontSet(const QFont &f)
return (fontsetCache[i] == (XFontSet)-1) ? 0 : fontsetCache[i];
}
-
+extern bool qt_use_rtl_extensions; // from qapplication_x11.cpp
+#ifndef QT_NO_XKB
+extern void q_getLocaleAndDirection(QLocale *locale,
+ Qt::LayoutDirection *direction,
+ const QByteArray &layoutName,
+ const QByteArray &variantName);
+#endif
QXIMInputContext::QXIMInputContext()
{
@@ -375,6 +381,52 @@ QXIMInputContext::QXIMInputContext()
else
QXIMInputContext::create_xim();
#endif // USE_X11R6_XIM
+
+#ifndef QT_NO_XKB
+ if (X11->use_xkb) {
+ QByteArray layoutName;
+ QByteArray variantName;
+
+ Atom type = XNone;
+ int format = 0;
+ ulong nitems = 0;
+ ulong bytesAfter = 0;
+ uchar *data = 0;
+ if (XGetWindowProperty(X11->display, RootWindow(X11->display, 0), ATOM(_XKB_RULES_NAMES), 0, 1024,
+ false, XA_STRING, &type, &format, &nitems, &bytesAfter, &data) == Success
+ && type == XA_STRING && format == 8 && nitems > 2) {
+
+ char *names[5] = { 0, 0, 0, 0, 0 };
+ char *p = reinterpret_cast<char *>(data), *end = p + nitems;
+ int i = 0;
+ do {
+ names[i++] = p;
+ p += qstrlen(p) + 1;
+ } while (p < end);
+
+ QList<QByteArray> layoutNames = QByteArray::fromRawData(names[2], qstrlen(names[2])).split(',');
+ QList<QByteArray> variantNames = QByteArray::fromRawData(names[3], qstrlen(names[3])).split(',');
+ for (int i = 0; i < qMin(layoutNames.count(), variantNames.count()); ++i ) {
+ QLocale keyboardInputLocale;
+ Qt::LayoutDirection keyboardInputDirection;
+ QByteArray variantName = variantNames.at(i);
+ const int dashPos = variantName.indexOf("-");
+ if (dashPos >= 0)
+ variantName.truncate(dashPos);
+ q_getLocaleAndDirection(&keyboardInputLocale,
+ &keyboardInputDirection,
+ layoutNames.at(i),
+ variantName);
+ if (keyboardInputDirection == Qt::RightToLeft)
+ qt_use_rtl_extensions = true;
+ }
+ }
+
+ if (data)
+ XFree(data);
+ }
+#endif // QT_NO_XKB
+
}