From c7fd4b39c61a97977fb18779a73f2c7799332e38 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 3 Mar 2015 09:46:16 +0100 Subject: [PATCH 1/2] Fix keyboard layout change detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …by listening to XKB_NEW_KEYBOARD events and re-allocating the keysym map on both XKB_NEW_KEYBOARD and XKB_MAP_NOTIFY. fixes #1302 --- src/handlers.c | 11 ++++++++++- src/main.c | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/handlers.c b/src/handlers.c index 3569710b..b0a27df5 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -1257,12 +1257,21 @@ void handle_event(int type, xcb_generic_event_t *event) { DLOG("xkb event, need to handle it.\n"); xcb_xkb_state_notify_event_t *state = (xcb_xkb_state_notify_event_t *)event; - if (state->xkbType == XCB_XKB_MAP_NOTIFY) { + if (state->xkbType == XCB_XKB_NEW_KEYBOARD_NOTIFY) { + DLOG("xkb new keyboard notify, sequence %d, time %d\n", state->sequence, state->time); + xcb_key_symbols_free(keysyms); + keysyms = xcb_key_symbols_alloc(conn); + ungrab_all_keys(conn); + translate_keysyms(); + grab_all_keys(conn, false); + } else if (state->xkbType == XCB_XKB_MAP_NOTIFY) { if (event_is_ignored(event->sequence, type)) { DLOG("Ignoring map notify event for sequence %d.\n", state->sequence); } else { DLOG("xkb map notify, sequence %d, time %d\n", state->sequence, state->time); add_ignore_event(event->sequence, type); + xcb_key_symbols_free(keysyms); + keysyms = xcb_key_symbols_alloc(conn); ungrab_all_keys(conn); translate_keysyms(); grab_all_keys(conn, false); diff --git a/src/main.c b/src/main.c index b696e031..473be1e5 100644 --- a/src/main.c +++ b/src/main.c @@ -536,9 +536,9 @@ int main(int argc, char *argv[]) { xcb_xkb_use_extension(conn, XCB_XKB_MAJOR_VERSION, XCB_XKB_MINOR_VERSION); xcb_xkb_select_events(conn, XCB_XKB_ID_USE_CORE_KBD, - XCB_XKB_EVENT_TYPE_STATE_NOTIFY | XCB_XKB_EVENT_TYPE_MAP_NOTIFY, + XCB_XKB_EVENT_TYPE_STATE_NOTIFY | XCB_XKB_EVENT_TYPE_MAP_NOTIFY | XCB_XKB_EVENT_TYPE_NEW_KEYBOARD_NOTIFY, 0, - XCB_XKB_EVENT_TYPE_STATE_NOTIFY | XCB_XKB_EVENT_TYPE_MAP_NOTIFY, + XCB_XKB_EVENT_TYPE_STATE_NOTIFY | XCB_XKB_EVENT_TYPE_MAP_NOTIFY | XCB_XKB_EVENT_TYPE_NEW_KEYBOARD_NOTIFY, 0xff, 0xff, NULL); From d551618cf03695b765b4f6d7f30df8e01847b79f Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 7 Mar 2015 11:46:43 +0100 Subject: [PATCH 2/2] Revert "Handle WM_CHANGE_STATE requests for iconic state" This reverts commit 136b3e345bfde637d3270eafaa2d8aa3555cc3d5. fixes #1516 --- include/atoms.xmacro | 1 - src/handlers.c | 15 ---------- testcases/t/231-wm-change-state.t | 49 ------------------------------- 3 files changed, 65 deletions(-) delete mode 100644 testcases/t/231-wm-change-state.t diff --git a/include/atoms.xmacro b/include/atoms.xmacro index 1f28c014..59dab6ed 100644 --- a/include/atoms.xmacro +++ b/include/atoms.xmacro @@ -39,4 +39,3 @@ xmacro(I3_PID) xmacro(_NET_REQUEST_FRAME_EXTENTS) xmacro(_NET_FRAME_EXTENTS) xmacro(_MOTIF_WM_HINTS) -xmacro(WM_CHANGE_STATE) diff --git a/src/handlers.c b/src/handlers.c index b0a27df5..529a4b58 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -804,21 +804,6 @@ static void handle_client_message(xcb_client_message_event_t *event) { XCB_ATOM_CARDINAL, 32, 4, &r); xcb_flush(conn); - } else if (event->type == A_WM_CHANGE_STATE) { - /* http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.4 */ - Con *con = con_by_window_id(event->window); - - if (con && event->data.data32[0] == 3) { - /* this request is so we can play some animiation showing the - * window physically moving to the tray before we close it (I - * think) */ - DLOG("Client has requested iconic state. Closing this con. (con = %p)\n", con); - tree_close(con, DONT_KILL_WINDOW, false, false); - tree_render(); - } else { - DLOG("Not handling WM_CHANGE_STATE request. (window = %d, state = %d)\n", event->window, event->data.data32[0]); - } - } else if (event->type == A__NET_CURRENT_DESKTOP) { /* This request is used by pagers and bars to change the current * desktop likely as a result of some user action. We interpret this as diff --git a/testcases/t/231-wm-change-state.t b/testcases/t/231-wm-change-state.t deleted file mode 100644 index 92992b45..00000000 --- a/testcases/t/231-wm-change-state.t +++ /dev/null @@ -1,49 +0,0 @@ -#!perl -# vim:ts=4:sw=4:expandtab -# -# Please read the following documents before working on tests: -# • http://build.i3wm.org/docs/testsuite.html -# (or docs/testsuite) -# -# • http://build.i3wm.org/docs/lib-i3test.html -# (alternatively: perldoc ./testcases/lib/i3test.pm) -# -# • http://build.i3wm.org/docs/ipc.html -# (or docs/ipc) -# -# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf -# (unless you are already familiar with Perl) -# -# Correctly handle WM_CHANGE_STATE requests for the iconic state -# See http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.4 -# Ticket: #1279 -# Bug still in: 4.8-7-gf4a8253 -use i3test; - -sub send_iconic_state_request { - my ($win) = @_; - - my $msg = pack "CCSLLLLLL", - X11::XCB::CLIENT_MESSAGE, # response_type - 32, # format - 0, # sequence - $win->id, # window - $x->atom(name => 'WM_CHANGE_STATE')->id, # message type - 3, # data32[0] - 0, # data32[1] - 0, # data32[2] - 0, # data32[3] - 0; # data32[4] - - $x->send_event(0, $x->get_root_window(), X11::XCB::EVENT_MASK_SUBSTRUCTURE_REDIRECT, $msg); -} - -my $ws = fresh_workspace; -my $win = open_window; - -send_iconic_state_request($win); -sync_with_i3; - -is(@{get_ws($ws)->{nodes}}, 0, 'When a window requests the iconic state, the container should be closed'); - -done_testing;