summaryrefslogtreecommitdiffstats
path: root/src/gui
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
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')
-rw-r--r--src/gui/inputmethod/qximinputcontext_x11.cpp54
-rw-r--r--src/gui/kernel/qkeymapper_x11.cpp5
-rw-r--r--src/gui/text/qtextcontrol.cpp4
-rw-r--r--src/gui/widgets/qlineedit.cpp4
4 files changed, 59 insertions, 8 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
+
}
diff --git a/src/gui/kernel/qkeymapper_x11.cpp b/src/gui/kernel/qkeymapper_x11.cpp
index 428ac3e..807959c 100644
--- a/src/gui/kernel/qkeymapper_x11.cpp
+++ b/src/gui/kernel/qkeymapper_x11.cpp
@@ -80,7 +80,7 @@ QT_BEGIN_NAMESPACE
(((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF))
#endif
-static void getLocaleAndDirection(QLocale *locale,
+void q_getLocaleAndDirection(QLocale *locale,
Qt::LayoutDirection *direction,
const QByteArray &layoutName,
const QByteArray &variantName)
@@ -523,7 +523,7 @@ void QKeyMapperPrivate::clearMappings()
// if (keyboardLayoutName.isEmpty())
// qWarning("Qt: unable to determine keyboard layout, please talk to qt-bugs@trolltech.com"); ?
- getLocaleAndDirection(&keyboardInputLocale,
+ q_getLocaleAndDirection(&keyboardInputLocale,
&keyboardInputDirection,
layoutName,
variantName);
@@ -534,7 +534,6 @@ void QKeyMapperPrivate::clearMappings()
<< "direction ="
<< keyboardInputDirection;
#endif
-
if (data)
XFree(data);
} else
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp
index 6864fe1..671dfc0 100644
--- a/src/gui/text/qtextcontrol.cpp
+++ b/src/gui/text/qtextcontrol.cpp
@@ -91,7 +91,7 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_CONTEXTMENU
-#if defined(Q_WS_WIN)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11)
extern bool qt_use_rtl_extensions;
#endif
#endif
@@ -2080,7 +2080,7 @@ QMenu *QTextControl::createStandardContextMenu(const QPointF &pos, QWidget *pare
}
#endif
-#if defined(Q_WS_WIN)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11)
if ((d->interactionFlags & Qt::TextEditable) && qt_use_rtl_extensions) {
#else
if (d->interactionFlags & Qt::TextEditable) {
diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp
index 817547c..0b8dca9 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -2046,7 +2046,7 @@ void QLineEdit::contextMenuEvent(QContextMenuEvent *event)
}
}
-#if defined(Q_WS_WIN)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11)
extern bool qt_use_rtl_extensions;
#endif
@@ -2118,7 +2118,7 @@ QMenu *QLineEdit::createStandardContextMenu()
}
#endif
-#if defined(Q_WS_WIN)
+#if defined(Q_WS_WIN) || defined(Q_WS_X11)
if (!d->control->isReadOnly() && qt_use_rtl_extensions) {
#else
if (!d->control->isReadOnly()) {