]> git.sur5r.net Git - i3/i3/commitdiff
Send last event timestamp with WM_TAKE_FOCUS msg
authorTony Crisci <tony@dubstepdish.com>
Sat, 29 Mar 2014 04:25:52 +0000 (00:25 -0400)
committerMichael Stapelberg <michael@stapelberg.de>
Mon, 31 Mar 2014 21:28:33 +0000 (23:28 +0200)
According to 4.1.7 of the iccm spec

http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.7

> Windows with the atom WM_TAKE_FOCUS in their WM_PROTOCOLS property may
> receive a ClientMessage event from the window manager (as described in
> section 4.2.8) with WM_TAKE_FOCUS in its data[0] field and a valid
> timestamp (i.e. not CurrentTime ) in its data[1] field.

Adds the timestamp parameter to send_take_focus to avoid the dangerous
use of a global variable.

include/xcb.h
src/x.c
src/xcb.c

index 848fe295251ec632f19e61629b645b9c85990a9a..4df7f6397765b261a6844a105996aa94ddb511f3 100644 (file)
@@ -94,7 +94,7 @@ void fake_absolute_configure_notify(Con *con);
  * Sends the WM_TAKE_FOCUS ClientMessage to the given window
  *
  */
-void send_take_focus(xcb_window_t window);
+void send_take_focus(xcb_window_t window, xcb_timestamp_t timestamp);
 
 /**
  * Raises the given window (typically client->frame) above all other windows
diff --git a/src/x.c b/src/x.c
index cd36a2834f03412a1b959b46a83125e6f26b7479..eca95da0b0f967315dee9fd375e4c3fc9867fbca 100644 (file)
--- a/src/x.c
+++ b/src/x.c
@@ -992,7 +992,7 @@ void x_push_changes(Con *con) {
                 focused->window->needs_take_focus) {
                 DLOG("Updating focus by sending WM_TAKE_FOCUS to window 0x%08x (focused: %p / %s)\n",
                      to_focus, focused, focused->name);
-                send_take_focus(to_focus);
+                send_take_focus(to_focus, last_timestamp);
                 set_focus = !focused->window->doesnt_accept_focus;
                 DLOG("set_focus = %d\n", set_focus);
 
index caa203f71208a331a622d73f23e8475d493c4d36..3039b030ce5b44eae5ea77cfbc3974a13c43a633 100644 (file)
--- a/src/xcb.c
+++ b/src/xcb.c
@@ -110,7 +110,7 @@ void fake_absolute_configure_notify(Con *con) {
  * Sends the WM_TAKE_FOCUS ClientMessage to the given window
  *
  */
-void send_take_focus(xcb_window_t window) {
+void send_take_focus(xcb_window_t window, xcb_timestamp_t timestamp) {
     /* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes.
      * In order to properly initialize these bytes, we allocate 32 bytes even
      * though we only need less for an xcb_configure_notify_event_t */
@@ -122,7 +122,7 @@ void send_take_focus(xcb_window_t window) {
     ev->type = A_WM_PROTOCOLS;
     ev->format = 32;
     ev->data.data32[0] = A_WM_TAKE_FOCUS;
-    ev->data.data32[1] = XCB_CURRENT_TIME;
+    ev->data.data32[1] = timestamp;
 
     DLOG("Sending WM_TAKE_FOCUS to the client\n");
     xcb_send_event(conn, false, window, XCB_EVENT_MASK_NO_EVENT, (char*)ev);