Merge lp:~lukas-kde/qtubuntu/kbdLayout into lp:qtubuntu

Proposed by Lukáš Tinkl on 2016-01-28
Status: Merged
Approved by: Michael Terry on 2016-02-03
Approved revision: 309
Merged at revision: 312
Proposed branch: lp:~lukas-kde/qtubuntu/kbdLayout
Merge into: lp:qtubuntu
Prerequisite: lp:~osomon/qtubuntu/qkeyevent-native-virtual-key
Diff against target: 128 lines (+54/-23)
2 files modified
src/ubuntumirclient/input.cpp (+53/-22)
src/ubuntumirclient/ubuntumirclient.pro (+1/-1)
To merge this branch: bzr merge lp:~lukas-kde/qtubuntu/kbdLayout
Reviewer Review Type Date Requested Status
Michael Terry 2016-01-28 Approve on 2016-02-03
PS Jenkins bot continuous-integration Approve on 2016-02-01
Unity8 CI Bot continuous-integration Approve on 2016-02-01
Review via email: mp+284310@code.launchpad.net

Commit Message

Support for switching kbd layouts

Description of the Change

Support for switching kbd layouts

Fixup UTF-8 text and add support for dead keys

To post a comment you must log in.
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:308
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-1-ci/8/
Executed test runs:

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-1-ci/8/rebuild

review: Needs Fixing (continuous-integration)
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Michael Terry (mterry) wrote :

You need to link with xkbcommon, like you did in qtmir.

review: Needs Fixing
Lukáš Tinkl (lukas-kde) wrote :

> You need to link with xkbcommon, like you did in qtmir.

Did you really need it? It compiled and linked just fine without

Michael Terry (mterry) wrote :

As mentioned on IRC (not sure if you saw it), yes it's needed here. Note how jenkins fails to build without it.

lp:~lukas-kde/qtubuntu/kbdLayout updated on 2016-02-01
309. By Lukáš Tinkl on 2016-02-01

explicitely link against xkbcommon

Lukáš Tinkl (lukas-kde) wrote :

> As mentioned on IRC (not sure if you saw it), yes it's needed here. Note how
> jenkins fails to build without it.

Done

Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:309
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-1-ci/9/
Executed test runs:

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-1-ci/9/rebuild

review: Approve (continuous-integration)
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:309
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-1-ci/10/
Executed test runs:

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-1-ci/10/rebuild

review: Approve (continuous-integration)
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Michael Terry (mterry) wrote :

LGTM!

review: Approve
lp:~lukas-kde/qtubuntu/kbdLayout updated on 2016-03-11
310. By Lukáš Tinkl on 2016-02-25

merge trunk

311. By Lukáš Tinkl on 2016-03-11

add support for right_alt modifier

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ubuntumirclient/input.cpp'
2--- src/ubuntumirclient/input.cpp 2016-02-02 11:07:38 +0000
3+++ src/ubuntumirclient/input.cpp 2016-03-11 13:29:40 +0000
4@@ -30,6 +30,7 @@
5 #include <private/qguiapplication_p.h>
6 #include <qpa/qplatforminputcontext.h>
7 #include <qpa/qwindowsysteminterface.h>
8+#include <QTextCodec>
9
10 #include <xkbcommon/xkbcommon.h>
11 #include <xkbcommon/xkbcommon-keysyms.h>
12@@ -108,6 +109,27 @@
13 XKB_KEY_MultipleCandidate, Qt::Key_MultipleCandidate,
14 XKB_KEY_PreviousCandidate, Qt::Key_PreviousCandidate,
15
16+ // dead keys
17+ XKB_KEY_dead_grave, Qt::Key_Dead_Grave,
18+ XKB_KEY_dead_acute, Qt::Key_Dead_Acute,
19+ XKB_KEY_dead_circumflex, Qt::Key_Dead_Circumflex,
20+ XKB_KEY_dead_tilde, Qt::Key_Dead_Tilde,
21+ XKB_KEY_dead_macron, Qt::Key_Dead_Macron,
22+ XKB_KEY_dead_breve, Qt::Key_Dead_Breve,
23+ XKB_KEY_dead_abovedot, Qt::Key_Dead_Abovedot,
24+ XKB_KEY_dead_diaeresis, Qt::Key_Dead_Diaeresis,
25+ XKB_KEY_dead_abovering, Qt::Key_Dead_Abovering,
26+ XKB_KEY_dead_doubleacute, Qt::Key_Dead_Doubleacute,
27+ XKB_KEY_dead_caron, Qt::Key_Dead_Caron,
28+ XKB_KEY_dead_cedilla, Qt::Key_Dead_Cedilla,
29+ XKB_KEY_dead_ogonek, Qt::Key_Dead_Ogonek,
30+ XKB_KEY_dead_iota, Qt::Key_Dead_Iota,
31+ XKB_KEY_dead_voiced_sound, Qt::Key_Dead_Voiced_Sound,
32+ XKB_KEY_dead_semivoiced_sound, Qt::Key_Dead_Semivoiced_Sound,
33+ XKB_KEY_dead_belowdot, Qt::Key_Dead_Belowdot,
34+ XKB_KEY_dead_hook, Qt::Key_Dead_Hook,
35+ XKB_KEY_dead_horn, Qt::Key_Dead_Horn,
36+
37 XKB_KEY_Mode_switch, Qt::Key_Mode_switch,
38 XKB_KEY_script_switch, Qt::Key_Mode_switch,
39 XKB_KEY_XF86AudioRaiseVolume, Qt::Key_VolumeUp,
40@@ -352,27 +374,26 @@
41 mTouchDevice, touchPoints);
42 }
43
44-static uint32_t translateKeysym(uint32_t sym, char *string, size_t size)
45-{
46- Q_UNUSED(size);
47- string[0] = '\0';
48+static uint32_t translateKeysym(uint32_t sym, const QString &text) {
49+ int code = 0;
50
51- if (sym >= XKB_KEY_F1 && sym <= XKB_KEY_F35)
52+ QTextCodec *systemCodec = QTextCodec::codecForLocale();
53+ if (sym < 128 || (sym < 256 && systemCodec->mibEnum() == 4)) {
54+ // upper-case key, if known
55+ code = isprint((int)sym) ? toupper((int)sym) : 0;
56+ } else if (sym >= XKB_KEY_F1 && sym <= XKB_KEY_F35) {
57 return Qt::Key_F1 + (int(sym) - XKB_KEY_F1);
58-
59- if (sym == XKB_KEY_Return || sym == XKB_KEY_KP_Enter) {
60- string[0] = '\r';
61- string[1] = '\0';
62- }
63-
64- for (int i = 0; KeyTable[i]; i += 2) {
65- if (sym == KeyTable[i])
66- return KeyTable[i + 1];
67- }
68-
69- string[0] = sym;
70- string[1] = '\0';
71- return toupper(sym);
72+ } else if (text.length() == 1 && text.unicode()->unicode() > 0x1f
73+ && text.unicode()->unicode() != 0x7f
74+ && !(sym >= XKB_KEY_dead_grave && sym <= XKB_KEY_dead_currency)) {
75+ code = text.unicode()->toUpper().unicode();
76+ } else {
77+ for (int i = 0; KeyTable[i]; i += 2)
78+ if (sym == KeyTable[i])
79+ code = KeyTable[i + 1];
80+ }
81+
82+ return code;
83 }
84
85 namespace
86@@ -392,6 +413,9 @@
87 if (modifiers & mir_input_event_modifier_meta) {
88 q_modifiers |= Qt::MetaModifier;
89 }
90+ if (modifiers & mir_input_event_modifier_alt_right) {
91+ q_modifiers |= Qt::GroupSwitchModifier;
92+ }
93 return q_modifiers;
94 }
95 }
96@@ -415,9 +439,16 @@
97 if (action == mir_keyboard_action_down)
98 mLastFocusedWindow = window;
99
100- char s[2];
101- int sym = translateKeysym(xk_sym, s, sizeof(s));
102- QString text = QString::fromLatin1(s);
103+ QString text;
104+ QVarLengthArray<char, 32> chars(32);
105+ {
106+ int result = xkb_keysym_to_utf8(xk_sym, chars.data(), chars.size());
107+
108+ if (result > 0) {
109+ text = QString::fromUtf8(chars.constData());
110+ }
111+ }
112+ int sym = translateKeysym(xk_sym, text);
113
114 bool is_auto_rep = action == mir_keyboard_action_repeat;
115
116
117=== modified file 'src/ubuntumirclient/ubuntumirclient.pro'
118--- src/ubuntumirclient/ubuntumirclient.pro 2016-01-04 17:18:51 +0000
119+++ src/ubuntumirclient/ubuntumirclient.pro 2016-03-11 13:29:40 +0000
120@@ -12,7 +12,7 @@
121 QMAKE_LFLAGS += -std=c++11 -Wl,-no-undefined
122
123 CONFIG += link_pkgconfig
124-PKGCONFIG += egl mirclient ubuntu-platform-api
125+PKGCONFIG += egl mirclient ubuntu-platform-api xkbcommon
126
127 SOURCES = \
128 backingstore.cpp \

Subscribers

People subscribed via source and target branches