Merge lp:~timo-jyrinki/kubuntu-packaging/qtbase-fix-keymap-update-handling2 into lp:~kubuntu-packagers/kubuntu-packaging/qtbase-opensource-src

Proposed by Timo Jyrinki
Status: Merged
Merged at revision: 167
Proposed branch: lp:~timo-jyrinki/kubuntu-packaging/qtbase-fix-keymap-update-handling2
Merge into: lp:~kubuntu-packagers/kubuntu-packaging/qtbase-opensource-src
Diff against target: 709 lines (+678/-0)
4 files modified
debian/changelog (+11/-0)
debian/control (+1/-0)
debian/patches/Add_better_support_for_keymap_update_handling.patch (+665/-0)
debian/patches/series (+1/-0)
To merge this branch: bzr merge lp:~timo-jyrinki/kubuntu-packaging/qtbase-fix-keymap-update-handling2
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Timo Jyrinki Approve
Dmitry Shachnev Approve
Review via email: mp+216815@code.launchpad.net

Commit message

[ Dmitry Shachnev ]
* Backport upstream patch to fix issues with keymap update handling
  (Add_better_support_for_keymap_update_handling.patch, copied from
  Debian and rebased).
* Build-depend on libxkbcommon-x11-dev, as the new patch includes
  <xkbcommon/xkbcommon-x11.h>.

Description of the change

For U-series when it opens, via a landing silo

To post a comment you must log in.
Revision history for this message
Dmitry Shachnev (mitya57) wrote :

> For U-series when it opens, via a landing silo

We will be able to land this not when U opens, but …

> Build-depend on libxkbcommon-x11-dev

… when that package becomes available in Ubuntu (via a Debian merge).

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

There was a last minute 0.4.1 upload to trusty:
http://packages.ubuntu.com/search?keywords=libxkbcommon-x11-dev

So it's ok already now.

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Indeed, I missed that. Looks good to me then.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2014-04-23 05:06:52 +0000
+++ debian/changelog 2014-04-24 09:08:03 +0000
@@ -1,3 +1,14 @@
1qtbase-opensource-src (5.2.1+dfsg-1ubuntu15) UNRELEASED; urgency=medium
2
3 [ Dmitry Shachnev ]
4 * Backport upstream patch to fix issues with keymap update handling
5 (Add_better_support_for_keymap_update_handling.patch, copied from
6 Debian and rebased).
7 * Build-depend on libxkbcommon-x11-dev, as the new patch includes
8 <xkbcommon/xkbcommon-x11.h>.
9
10 -- Timo Jyrinki <timo-jyrinki@ubuntu.com> Wed, 23 Apr 2014 05:09:08 +0000
11
1qtbase-opensource-src (5.2.1+dfsg-1ubuntu14) trusty; urgency=medium12qtbase-opensource-src (5.2.1+dfsg-1ubuntu14) trusty; urgency=medium
213
3 * libqt5gui5.symbols, libqt5opengl5.symbols: making the gl/gles symbols14 * libqt5gui5.symbols, libqt5opengl5.symbols: making the gl/gles symbols
415
=== modified file 'debian/control'
--- debian/control 2014-03-18 12:08:16 +0000
+++ debian/control 2014-04-24 09:08:03 +0000
@@ -55,6 +55,7 @@
55 libxcb1-dev,55 libxcb1-dev,
56 libxi-dev,56 libxi-dev,
57 libxkbcommon-dev,57 libxkbcommon-dev,
58 libxkbcommon-x11-dev,
58 libxrender-dev,59 libxrender-dev,
59 pkg-kde-tools (>= 0.14.2),60 pkg-kde-tools (>= 0.14.2),
60 unixodbc-dev,61 unixodbc-dev,
6162
=== added file 'debian/patches/Add_better_support_for_keymap_update_handling.patch'
--- debian/patches/Add_better_support_for_keymap_update_handling.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/Add_better_support_for_keymap_update_handling.patch 2014-04-24 09:08:03 +0000
@@ -0,0 +1,665 @@
1From 18e162e8640d96f2d7f2a85ef35d00350360903d Mon Sep 17 00:00:00 2001
2From: Gatis Paeglis <gatis.paeglis@digia.com>
3Date: Thu, 27 Feb 2014 18:05:14 +0100
4Subject: [PATCH] Add better support for keymap update handling
5
6Use the new X11 support API xkb_x11_* released in libxkbcommon version 0.4.0.
7
8From the commit message where this API was introduced:
9
10"These are function to create an xkb_keymap directly from XKB requests
11to the X server. This opens up the possibility for X clients to use
12xcb + xcb-xkb + xkbcommon as a proper replacement for Xlib + xkbfile for
13keyboard support.
14
15Why not just use the RMLVO that the server puts in the _XKB_RULES_NAMES
16property? This does not account for custom keymaps, on-the-fly keymap
17modifications, remote clients, etc., so is not a proper solution in
18practice. Also, some servers don't even set it. Now, the client just
19needs to recreate the keymap in response to a change in the server's
20keymap (as Xlib clients do with XRefreshKeyboardMapping() and friends)."
21
22This patch moves XKEYBOARD presence decision from compile time to runtime
23for a proper remote X client support.
24
25Task-number: QTBUG-31527
26Task-number: QTBUG-32760
27Change-Id: I4d402668cda2126ef180b27022154f96b1874b1d
28---
29 src/plugins/platforms/xcb/qxcbconnection.cpp | 61 ++++----
30 src/plugins/platforms/xcb/qxcbconnection.h | 2 +-
31 src/plugins/platforms/xcb/qxcbkeyboard.cpp | 220 +++++++++++----------------
32 src/plugins/platforms/xcb/qxcbkeyboard.h | 35 ++---
33 src/plugins/platforms/xcb/xcb-plugin.pro | 8 +-
34 5 files changed, 136 insertions(+), 190 deletions(-)
35
36--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
37+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
38@@ -782,6 +782,7 @@
39 xcb_timestamp_t time;
40 uint8_t deviceID;
41 } any;
42+ xcb_xkb_new_keyboard_notify_event_t new_keyboard_notify;
43 xcb_xkb_map_notify_event_t map_notify;
44 xcb_xkb_state_notify_event_t state_notify;
45 } _xkb_event;
46@@ -812,15 +813,11 @@
47 case XCB_EXPOSE:
48 HANDLE_PLATFORM_WINDOW_EVENT(xcb_expose_event_t, window, handleExposeEvent);
49 case XCB_BUTTON_PRESS:
50-#ifdef QT_NO_XKB
51 m_keyboard->updateXKBStateFromCore(((xcb_button_press_event_t *)event)->state);
52-#endif
53 handleButtonPress(event);
54 HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_press_event_t, event, handleButtonPressEvent);
55 case XCB_BUTTON_RELEASE:
56-#ifdef QT_NO_XKB
57 m_keyboard->updateXKBStateFromCore(((xcb_button_release_event_t *)event)->state);
58-#endif
59 handleButtonRelease(event);
60 HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_release_event_t, event, handleButtonReleaseEvent);
61 case XCB_MOTION_NOTIFY:
62@@ -828,9 +825,7 @@
63 xcb_motion_notify_event_t *mev = (xcb_motion_notify_event_t *)event;
64 qDebug("xcb: moved mouse to %4d, %4d; button state %X", mev->event_x, mev->event_y, static_cast<unsigned int>(m_buttons));
65 }
66-#ifdef QT_NO_XKB
67 m_keyboard->updateXKBStateFromCore(((xcb_motion_notify_event_t *)event)->state);
68-#endif
69 HANDLE_PLATFORM_WINDOW_EVENT(xcb_motion_notify_event_t, event, handleMotionNotifyEvent);
70 case XCB_CONFIGURE_NOTIFY:
71 HANDLE_PLATFORM_WINDOW_EVENT(xcb_configure_notify_event_t, event, handleConfigureNotifyEvent);
72@@ -846,29 +841,21 @@
73 case XCB_ENTER_NOTIFY:
74 HANDLE_PLATFORM_WINDOW_EVENT(xcb_enter_notify_event_t, event, handleEnterNotifyEvent);
75 case XCB_LEAVE_NOTIFY:
76-#ifdef QT_NO_XKB
77 m_keyboard->updateXKBStateFromCore(((xcb_leave_notify_event_t *)event)->state);
78-#endif
79 HANDLE_PLATFORM_WINDOW_EVENT(xcb_leave_notify_event_t, event, handleLeaveNotifyEvent);
80 case XCB_FOCUS_IN:
81 HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_in_event_t, event, handleFocusInEvent);
82 case XCB_FOCUS_OUT:
83 HANDLE_PLATFORM_WINDOW_EVENT(xcb_focus_out_event_t, event, handleFocusOutEvent);
84 case XCB_KEY_PRESS:
85-#ifdef QT_NO_XKB
86 m_keyboard->updateXKBStateFromCore(((xcb_key_press_event_t *)event)->state);
87-#endif
88 HANDLE_KEYBOARD_EVENT(xcb_key_press_event_t, handleKeyPressEvent);
89 case XCB_KEY_RELEASE:
90-#ifdef QT_NO_XKB
91 m_keyboard->updateXKBStateFromCore(((xcb_key_release_event_t *)event)->state);
92-#endif
93 HANDLE_KEYBOARD_EVENT(xcb_key_release_event_t, handleKeyReleaseEvent);
94-#ifdef QT_NO_XKB
95 case XCB_MAPPING_NOTIFY:
96 m_keyboard->handleMappingNotifyEvent((xcb_mapping_notify_event_t *)event);
97 break;
98-#endif
99 case XCB_SELECTION_REQUEST:
100 {
101 xcb_selection_request_event_t *sr = (xcb_selection_request_event_t *)event;
102@@ -936,6 +923,8 @@
103 _xkb_event *xkb_event = reinterpret_cast<_xkb_event *>(event);
104 if (xkb_event->any.deviceID == m_keyboard->coreDeviceId()) {
105 switch (xkb_event->any.xkbType) {
106+ // XkbNewKkdNotify and XkbMapNotify together capture all sorts of keymap
107+ // updates (e.g. xmodmap, xkbcomp, setxkbmap), with minimal redundent recompilations.
108 case XCB_XKB_STATE_NOTIFY:
109 m_keyboard->updateXKBState(&xkb_event->state_notify);
110 handled = true;
111@@ -944,6 +933,12 @@
112 m_keyboard->handleMappingNotifyEvent(&xkb_event->map_notify);
113 handled = true;
114 break;
115+ case XCB_XKB_NEW_KEYBOARD_NOTIFY: {
116+ xcb_xkb_new_keyboard_notify_event_t *ev = &xkb_event->new_keyboard_notify;
117+ if (ev->changed & XCB_XKB_NKN_DETAIL_KEYCODES)
118+ m_keyboard->updateKeymap();
119+ break;
120+ }
121 default:
122 break;
123 }
124@@ -1667,6 +1662,7 @@
125 #ifndef QT_NO_XKB
126 const xcb_query_extension_reply_t *reply = xcb_get_extension_data(m_connection, &xcb_xkb_id);
127 if (!reply || !reply->present) {
128+ qWarning() << "Qt: XKEYBOARD extension not present on the X server.";
129 xkb_first_event = 0;
130 return;
131 }
132@@ -1676,14 +1672,14 @@
133 xcb_xkb_use_extension_cookie_t xkb_query_cookie;
134 xcb_xkb_use_extension_reply_t *xkb_query;
135
136- xkb_query_cookie = xcb_xkb_use_extension(c, XCB_XKB_MAJOR_VERSION, XCB_XKB_MINOR_VERSION);
137+ xkb_query_cookie = xcb_xkb_use_extension(c, XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION);
138 xkb_query = xcb_xkb_use_extension_reply(c, xkb_query_cookie, 0);
139
140 if (!xkb_query) {
141 qWarning("Qt: Failed to initialize XKB extension");
142 return;
143 } else if (!xkb_query->supported) {
144- qWarning("Qt: Unsupported XKB version (want %d %d, has %d %d)",
145+ qWarning("Qt: Unsupported XKB version (We want %d %d, but X server has %d %d)",
146 XCB_XKB_MAJOR_VERSION, XCB_XKB_MINOR_VERSION,
147 xkb_query->serverMajor, xkb_query->serverMinor);
148 free(xkb_query);
149@@ -1693,25 +1689,28 @@
150 has_xkb = true;
151 free(xkb_query);
152
153- uint affectMap, map;
154- affectMap = map = XCB_XKB_MAP_PART_KEY_TYPES |
155- XCB_XKB_MAP_PART_KEY_SYMS |
156- XCB_XKB_MAP_PART_MODIFIER_MAP |
157- XCB_XKB_MAP_PART_EXPLICIT_COMPONENTS |
158- XCB_XKB_MAP_PART_KEY_ACTIONS |
159- XCB_XKB_MAP_PART_KEY_BEHAVIORS |
160- XCB_XKB_MAP_PART_VIRTUAL_MODS |
161- XCB_XKB_MAP_PART_VIRTUAL_MOD_MAP;
162+ const uint16_t required_map_parts = (XCB_XKB_MAP_PART_KEY_TYPES |
163+ XCB_XKB_MAP_PART_KEY_SYMS |
164+ XCB_XKB_MAP_PART_MODIFIER_MAP |
165+ XCB_XKB_MAP_PART_EXPLICIT_COMPONENTS |
166+ XCB_XKB_MAP_PART_KEY_ACTIONS |
167+ XCB_XKB_MAP_PART_KEY_BEHAVIORS |
168+ XCB_XKB_MAP_PART_VIRTUAL_MODS |
169+ XCB_XKB_MAP_PART_VIRTUAL_MOD_MAP);
170+
171+ const uint16_t required_events = (XCB_XKB_EVENT_TYPE_NEW_KEYBOARD_NOTIFY |
172+ XCB_XKB_EVENT_TYPE_MAP_NOTIFY |
173+ XCB_XKB_EVENT_TYPE_STATE_NOTIFY);
174
175- // Xkb events are reported to all interested clients without regard
176+ // XKB events are reported to all interested clients without regard
177 // to the current keyboard input focus or grab state
178 xcb_void_cookie_t select = xcb_xkb_select_events_checked(c,
179 XCB_XKB_ID_USE_CORE_KBD,
180- XCB_XKB_EVENT_TYPE_STATE_NOTIFY | XCB_XKB_EVENT_TYPE_MAP_NOTIFY,
181+ required_events,
182 0,
183- XCB_XKB_EVENT_TYPE_STATE_NOTIFY | XCB_XKB_EVENT_TYPE_MAP_NOTIFY,
184- affectMap,
185- map,
186+ required_events,
187+ required_map_parts,
188+ required_map_parts,
189 0);
190
191 xcb_generic_error_t *error = xcb_request_check(c, select);
192--- a/src/plugins/platforms/xcb/qxcbconnection.h
193+++ b/src/plugins/platforms/xcb/qxcbconnection.h
194@@ -54,7 +54,7 @@
195 #include <qpa/qwindowsysteminterface.h>
196
197 // This is needed to make Qt compile together with XKB. xkb.h is using a variable
198-// which is called 'explicit', this is a reserved keyword in c++ */
199+// which is called 'explicit', this is a reserved keyword in c++
200 #ifndef QT_NO_XKB
201 #define explicit dont_use_cxx_explicit
202 #include <xcb/xkb.h>
203--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
204+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
205@@ -662,6 +662,7 @@
206 void QXcbKeyboard::updateKeymap()
207 {
208 m_config = true;
209+ // set xkb context object
210 if (!xkb_context) {
211 xkb_context = xkb_context_new((xkb_context_flags)0);
212 if (!xkb_context) {
213@@ -670,67 +671,50 @@
214 return;
215 }
216 }
217- readXKBConfig();
218- // Compile a keymap from RMLVO (rules, models, layouts, variants and options) names
219- if (xkb_keymap)
220- xkb_keymap_unref(xkb_keymap);
221+ // update xkb keymap object
222+ xkb_keymap_unref(xkb_keymap);
223+ xkb_keymap = 0;
224
225- xkb_keymap = xkb_keymap_new_from_names(xkb_context, &xkb_names, (xkb_keymap_compile_flags)0);
226+ struct xkb_state *new_state = 0;
227+#ifndef QT_NO_XKB
228+ if (connection()->hasXKB()) {
229+ xkb_keymap = xkb_x11_keymap_new_from_device(xkb_context, xcb_connection(), core_device_id, (xkb_keymap_compile_flags)0);
230+ if (xkb_keymap) {
231+ // Create a new keyboard state object for a keymap
232+ new_state = xkb_x11_state_new_from_device(xkb_keymap, xcb_connection(), core_device_id);
233+ }
234+ }
235+#endif
236+ if (!xkb_keymap) {
237+ // Compile a keymap from RMLVO (rules, models, layouts, variants and options) names
238+ readXKBConfig();
239+ xkb_keymap = xkb_keymap_new_from_names(xkb_context, &xkb_names, (xkb_keymap_compile_flags)0);
240+ if (xkb_keymap)
241+ new_state = xkb_state_new(xkb_keymap);
242+ }
243
244 if (!xkb_keymap) {
245 qWarning("Qt: Failed to compile a keymap");
246 m_config = false;
247- return;
248 }
249- // Create a new keyboard state object for a keymap
250- struct xkb_state *new_state = xkb_state_new(xkb_keymap);
251 if (!new_state) {
252- qWarning("Qt: Failed to create a new keyboard state");
253+ qWarning("Qt: Failed to create xkb state");
254 m_config = false;
255- return;
256 }
257+ if (!m_config)
258+ return;
259
260- if (xkb_state) {
261- xkb_state_unref(xkb_state);
262- xkb_state = new_state;
263- } else {
264- xkb_state = new_state;
265-#ifndef QT_NO_XKB
266- // get initial state from the X server (and keep it up-to-date at all times)
267- xcb_xkb_get_state_cookie_t state;
268- xcb_xkb_get_state_reply_t *init_state;
269-
270- xcb_connection_t *c = xcb_connection();
271- state = xcb_xkb_get_state(c, XCB_XKB_ID_USE_CORE_KBD);
272- init_state = xcb_xkb_get_state_reply(c, state, 0);
273- if (!init_state) {
274- qWarning("Qt: couldn't retrieve an initial keyboard state");
275- return;
276- }
277- /* The xkb keyboard state is comprised of the state of all keyboard modifiers,
278- the keyboard group, and the state of the pointer buttons */
279- xkb_state_update_mask(xkb_state,
280- init_state->baseMods,
281- init_state->latchedMods,
282- init_state->lockedMods,
283- init_state->baseGroup,
284- init_state->latchedGroup,
285- init_state->lockedGroup);
286- free(init_state);
287-#else
288+ // update xkb state object
289+ xkb_state_unref(xkb_state);
290+ xkb_state = new_state;
291+ if (!connection()->hasXKB())
292 updateXKBMods();
293-#endif
294- }
295 }
296
297 #ifndef QT_NO_XKB
298 void QXcbKeyboard::updateXKBState(xcb_xkb_state_notify_event_t *state)
299 {
300- if (!m_config)
301- return;
302-
303- if (connection()->hasXKB()) {
304-
305+ if (m_config && connection()->hasXKB()) {
306 const xkb_state_component newState
307 = xkb_state_update_mask(xkb_state,
308 state->baseMods,
309@@ -745,35 +729,34 @@
310 }
311 }
312 }
313+#endif
314
315-#else
316 void QXcbKeyboard::updateXKBStateFromCore(quint16 state)
317 {
318- if (!m_config)
319- return;
320+ if (m_config && !connection()->hasXKB()) {
321+ const quint32 modsDepressed = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_DEPRESSED);
322+ const quint32 modsLatched = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LATCHED);
323+ const quint32 modsLocked = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LOCKED);
324+ const quint32 xkbMask = xkbModMask(state);
325+
326+ const quint32 latched = modsLatched & xkbMask;
327+ const quint32 locked = modsLocked & xkbMask;
328+ quint32 depressed = modsDepressed & xkbMask;
329+ // set modifiers in depressed if they don't appear in any of the final masks
330+ depressed |= ~(depressed | latched | locked) & xkbMask;
331
332- const quint32 modsDepressed = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_DEPRESSED);
333- const quint32 modsLatched = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LATCHED);
334- const quint32 modsLocked = xkb_state_serialize_mods(xkb_state, XKB_STATE_MODS_LOCKED);
335- const quint32 xkbMask = xkbModMask(state);
336-
337- const quint32 latched = modsLatched & xkbMask;
338- const quint32 locked = modsLocked & xkbMask;
339- quint32 depressed = modsDepressed & xkbMask;
340- // set modifiers in depressed if they don't appear in any of the final masks
341- depressed |= ~(depressed | latched | locked) & xkbMask;
342-
343- const xkb_state_component newState
344- = xkb_state_update_mask(xkb_state,
345- depressed,
346- latched,
347- locked,
348- 0,
349- 0,
350- (state >> 13) & 3); // bits 13 and 14 report the state keyboard group
351+ const xkb_state_component newState
352+ = xkb_state_update_mask(xkb_state,
353+ depressed,
354+ latched,
355+ locked,
356+ 0,
357+ 0,
358+ (state >> 13) & 3); // bits 13 and 14 report the state keyboard group
359
360- if ((newState & XKB_STATE_LAYOUT_EFFECTIVE) == XKB_STATE_LAYOUT_EFFECTIVE) {
361- //qWarning("TODO: Support KeyboardLayoutChange on QPA (QTBUG-27681)");
362+ if ((newState & XKB_STATE_LAYOUT_EFFECTIVE) == XKB_STATE_LAYOUT_EFFECTIVE) {
363+ //qWarning("TODO: Support KeyboardLayoutChange on QPA (QTBUG-27681)");
364+ }
365 }
366 }
367
368@@ -803,16 +786,15 @@
369
370 void QXcbKeyboard::updateXKBMods()
371 {
372- xkb_mods.shift = xkb_map_mod_get_index(xkb_keymap, XKB_MOD_NAME_SHIFT);
373- xkb_mods.lock = xkb_map_mod_get_index(xkb_keymap, XKB_MOD_NAME_CAPS);
374- xkb_mods.control = xkb_map_mod_get_index(xkb_keymap, XKB_MOD_NAME_CTRL);
375- xkb_mods.mod1 = xkb_map_mod_get_index(xkb_keymap, "Mod1");
376- xkb_mods.mod2 = xkb_map_mod_get_index(xkb_keymap, "Mod2");
377- xkb_mods.mod3 = xkb_map_mod_get_index(xkb_keymap, "Mod3");
378- xkb_mods.mod4 = xkb_map_mod_get_index(xkb_keymap, "Mod4");
379- xkb_mods.mod5 = xkb_map_mod_get_index(xkb_keymap, "Mod5");
380+ xkb_mods.shift = xkb_keymap_mod_get_index(xkb_keymap, XKB_MOD_NAME_SHIFT);
381+ xkb_mods.lock = xkb_keymap_mod_get_index(xkb_keymap, XKB_MOD_NAME_CAPS);
382+ xkb_mods.control = xkb_keymap_mod_get_index(xkb_keymap, XKB_MOD_NAME_CTRL);
383+ xkb_mods.mod1 = xkb_keymap_mod_get_index(xkb_keymap, "Mod1");
384+ xkb_mods.mod2 = xkb_keymap_mod_get_index(xkb_keymap, "Mod2");
385+ xkb_mods.mod3 = xkb_keymap_mod_get_index(xkb_keymap, "Mod3");
386+ xkb_mods.mod4 = xkb_keymap_mod_get_index(xkb_keymap, "Mod4");
387+ xkb_mods.mod5 = xkb_keymap_mod_get_index(xkb_keymap, "Mod5");
388 }
389-#endif
390
391 QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
392 {
393@@ -897,10 +879,8 @@
394 result += (qtKey + mods);
395 }
396 }
397- if (kb_state)
398- xkb_state_unref(kb_state);
399- if (fallback_keymap)
400- xkb_keymap_unref(fallback_keymap);
401+ xkb_state_unref(kb_state);
402+ xkb_keymap_unref(fallback_keymap);
403
404 return result;
405 }
406@@ -967,58 +947,41 @@
407 , xkb_context(0)
408 , xkb_keymap(0)
409 , xkb_state(0)
410-#ifndef QT_NO_XKB
411 , core_device_id(0)
412-#endif
413 {
414 memset(&xkb_names, 0, sizeof(xkb_names));
415- updateKeymap();
416 #ifndef QT_NO_XKB
417 if (connection->hasXKB()) {
418-
419 updateVModMapping();
420 updateVModToRModMapping();
421-
422- // get the core keyboard id
423- xcb_xkb_get_device_info_cookie_t device_id_cookie;
424- xcb_xkb_get_device_info_reply_t *device_id;
425-
426- device_id_cookie = xcb_xkb_get_device_info(xcb_connection(),
427- XCB_XKB_ID_USE_CORE_KBD,
428- 0, 0, 0, 0, 0, 0);
429-
430- device_id = xcb_xkb_get_device_info_reply(xcb_connection(), device_id_cookie, 0);
431- if (!device_id) {
432+ core_device_id = xkb_x11_get_core_keyboard_device_id(xcb_connection());
433+ if (core_device_id == -1) {
434 qWarning("Qt: couldn't get core keyboard device info");
435 return;
436 }
437-
438- core_device_id = device_id->deviceID;
439- free(device_id);
440+ } else {
441+#endif
442+ m_key_symbols = xcb_key_symbols_alloc(xcb_connection());
443+ updateModifiers();
444+#ifndef QT_NO_XKB
445 }
446-#else
447- m_key_symbols = xcb_key_symbols_alloc(xcb_connection());
448- updateModifiers();
449 #endif
450+ updateKeymap();
451 }
452
453 QXcbKeyboard::~QXcbKeyboard()
454 {
455- if (xkb_state)
456- xkb_state_unref(xkb_state);
457- if (xkb_keymap)
458- xkb_keymap_unref(xkb_keymap);
459- if (xkb_context)
460- xkb_context_unref(xkb_context);
461-#ifdef QT_NO_XKB
462- xcb_key_symbols_free(m_key_symbols);
463-#endif
464+ xkb_state_unref(xkb_state);
465+ xkb_keymap_unref(xkb_keymap);
466+ xkb_context_unref(xkb_context);
467+ if (!connection()->hasXKB())
468+ xcb_key_symbols_free(m_key_symbols);
469 clearXKBConfig();
470 }
471
472-#ifndef QT_NO_XKB
473 void QXcbKeyboard::updateVModMapping()
474 {
475+#ifndef QT_NO_XKB
476 xcb_xkb_get_names_cookie_t names_cookie;
477 xcb_xkb_get_names_reply_t *name_reply;
478 xcb_xkb_get_names_value_list_t names_list;
479@@ -1082,10 +1045,12 @@
480 }
481
482 free(name_reply);
483+#endif
484 }
485
486 void QXcbKeyboard::updateVModToRModMapping()
487 {
488+#ifndef QT_NO_XKB
489 xcb_xkb_get_map_cookie_t map_cookie;
490 xcb_xkb_get_map_reply_t *map_reply;
491 xcb_xkb_get_map_map_t map;
492@@ -1148,8 +1113,9 @@
493
494 free(map_reply);
495 resolveMaskConflicts();
496+#endif
497 }
498-#else
499+
500 void QXcbKeyboard::updateModifiers()
501 {
502 // The core protocol does not provide a convenient way to determine the mapping
503@@ -1213,7 +1179,6 @@
504 free(modMapReply);
505 resolveMaskConflicts();
506 }
507-#endif
508
509 void QXcbKeyboard::resolveMaskConflicts()
510 {
511@@ -1296,17 +1261,9 @@
512
513 if (!m_config)
514 return;
515- // It is crucial the order of xkb_state_key_get_one_sym &
516- // xkb_state_update_key operations is not reversed!
517+
518+ // It is crucial the order of xkb_state_key_get_one_sym & xkb_state_update_key operations is not reversed!
519 xcb_keysym_t sym = xkb_state_key_get_one_sym(xkb_state, code);
520-#ifdef QT_NO_XKB
521- enum xkb_key_direction direction;
522- if (type == QEvent::KeyPress)
523- direction = XKB_KEY_DOWN;
524- else
525- direction = XKB_KEY_UP;
526- xkb_state_update_key(xkb_state, code, direction);
527-#endif
528
529 QPlatformInputContext *inputContext = QGuiApplicationPrivate::platformIntegration()->inputContext();
530 QMetaMethod method;
531@@ -1442,17 +1399,14 @@
532 void QXcbKeyboard::handleMappingNotifyEvent(const void *event)
533 {
534 updateKeymap();
535-#ifdef QT_NO_XKB
536- void *ev = const_cast<void *>(event);
537- xcb_refresh_keyboard_mapping(m_key_symbols, static_cast<xcb_mapping_notify_event_t *>(ev));
538- updateModifiers();
539-#else
540- Q_UNUSED(event)
541 if (connection()->hasXKB()) {
542 updateVModMapping();
543 updateVModToRModMapping();
544+ } else {
545+ void *ev = const_cast<void *>(event);
546+ xcb_refresh_keyboard_mapping(m_key_symbols, static_cast<xcb_mapping_notify_event_t *>(ev));
547+ updateModifiers();
548 }
549-#endif
550 }
551
552 QT_END_NAMESPACE
553--- a/src/plugins/platforms/xcb/qxcbkeyboard.h
554+++ b/src/plugins/platforms/xcb/qxcbkeyboard.h
555@@ -44,11 +44,15 @@
556
557 #include "qxcbobject.h"
558
559-#ifdef QT_NO_XKB
560 #include <xcb/xcb_keysyms.h>
561-#endif
562
563 #include <xkbcommon/xkbcommon.h>
564+#ifndef QT_NO_XKB
565+// note: extern won't be needed from libxkbcommon 0.4.1 and above
566+extern "C" {
567+#include <xkbcommon/xkbcommon-x11.h>
568+}
569+#endif
570
571 #include <QEvent>
572
573@@ -65,41 +69,37 @@
574
575 void handleKeyPressEvent(QXcbWindowEventListener *eventListener, const xcb_key_press_event_t *event);
576 void handleKeyReleaseEvent(QXcbWindowEventListener *eventListener, const xcb_key_release_event_t *event);
577-
578 void handleMappingNotifyEvent(const void *event);
579
580 Qt::KeyboardModifiers translateModifiers(int s) const;
581-
582 void updateKeymap();
583 QList<int> possibleKeys(const QKeyEvent *e) const;
584
585-#ifdef QT_NO_XKB
586- void updateXKBStateFromCore(quint16 state);
587+ // when XKEYBOARD not present on the X server
588 void updateXKBMods();
589 quint32 xkbModMask(quint16 state);
590-#else
591- int coreDeviceId() { return core_device_id; }
592+ void updateXKBStateFromCore(quint16 state);
593+ // when XKEYBOARD is present on the X server
594+ int coreDeviceId() const { return core_device_id; }
595+#ifndef QT_NO_XKB
596 void updateXKBState(xcb_xkb_state_notify_event_t *state);
597 #endif
598
599 protected:
600 void handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time);
601- void resolveMaskConflicts();
602
603+ void resolveMaskConflicts();
604 QString keysymToUnicode(xcb_keysym_t sym) const;
605-
606 int keysymToQtKey(xcb_keysym_t keysym) const;
607 int keysymToQtKey(xcb_keysym_t keysym, Qt::KeyboardModifiers &modifiers, QString text) const;
608
609 void readXKBConfig();
610 void clearXKBConfig();
611-
612-#ifdef QT_NO_XKB
613+ // when XKEYBOARD not present on the X server
614 void updateModifiers();
615-#else
616+ // when XKEYBOARD is present on the X server
617 void updateVModMapping();
618 void updateVModToRModMapping();
619-#endif
620
621 private:
622 bool m_config;
623@@ -120,9 +120,8 @@
624
625 _mod_masks rmod_masks;
626
627-#ifdef QT_NO_XKB
628+ // when XKEYBOARD not present on the X server
629 xcb_key_symbols_t *m_key_symbols;
630-
631 struct _xkb_mods {
632 xkb_mod_index_t shift;
633 xkb_mod_index_t lock;
634@@ -133,12 +132,10 @@
635 xkb_mod_index_t mod4;
636 xkb_mod_index_t mod5;
637 };
638-
639 _xkb_mods xkb_mods;
640-#else
641+ // when XKEYBOARD is present on the X server
642 _mod_masks vmod_masks;
643 int core_device_id;
644-#endif
645 };
646
647 QT_END_NAMESPACE
648--- a/src/plugins/platforms/xcb/xcb-plugin.pro
649+++ b/src/plugins/platforms/xcb/xcb-plugin.pro
650@@ -121,13 +121,9 @@
651 INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/sysinclude
652 LIBS += -lxcb -L$$OUT_PWD/xcb-static -lxcb-static
653 } else {
654- LIBS += -lxcb -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr
655+ LIBS += -lxcb -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr -lxcb-keysyms
656 !contains(DEFINES, QT_NO_SHAPE):LIBS += -lxcb-shape
657- contains(DEFINES, QT_NO_XKB) {
658- LIBS += -lxcb-keysyms
659- } else {
660- LIBS += -lxcb-xkb
661- }
662+ !contains(DEFINES, QT_NO_XKB):LIBS += -lxcb-xkb -lxkbcommon-x11
663 }
664
665 # libxkbcommon
0666
=== modified file 'debian/patches/series'
--- debian/patches/series 2014-04-01 12:42:46 +0000
+++ debian/patches/series 2014-04-24 09:08:03 +0000
@@ -29,3 +29,4 @@
29Minor-optimization-for-QTextEngine-shapeText.patch29Minor-optimization-for-QTextEngine-shapeText.patch
30HarfBuzz-NG-Hide-characters-that-should-normally-be-.patch30HarfBuzz-NG-Hide-characters-that-should-normally-be-.patch
31When-looking-up-the-window-hierarchy-stop-at-foreign.patch31When-looking-up-the-window-hierarchy-stop-at-foreign.patch
32Add_better_support_for_keymap_update_handling.patch

Subscribers

People subscribed via source and target branches