i3 - improved tiling WM


Send last event timestamp with WM_TAKE_FOCUS msg

Patch status: merged

Patch by Tony Crisci

Long description:

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.

To apply this patch, use:
curl http://cr.i3wm.org/patch/498/raw.patch | git am

b/include/xcb.h

26
@@ -94,7 +94,7 @@ void fake_absolute_configure_notify(Con *con);
27
  * Sends the WM_TAKE_FOCUS ClientMessage to the given window
28
  *
29
  */
30
-void send_take_focus(xcb_window_t window);
31
+void send_take_focus(xcb_window_t window, xcb_timestamp_t timestamp);
32
 
33
 /**
34
  * Raises the given window (typically client->frame) above all other windows

b/src/x.c

39
@@ -992,7 +992,7 @@ void x_push_changes(Con *con) {
40
                 focused->window->needs_take_focus) {
41
                 DLOG("Updating focus by sending WM_TAKE_FOCUS to window 0x%08x (focused: %p / %s)\n",
42
                      to_focus, focused, focused->name);
43
-                send_take_focus(to_focus);
44
+                send_take_focus(to_focus, last_timestamp);
45
                 set_focus = !focused->window->doesnt_accept_focus;
46
                 DLOG("set_focus = %d\n", set_focus);
47
 

b/src/xcb.c

52
@@ -110,7 +110,7 @@ void fake_absolute_configure_notify(Con *con) {
53
  * Sends the WM_TAKE_FOCUS ClientMessage to the given window
54
  *
55
  */
56
-void send_take_focus(xcb_window_t window) {
57
+void send_take_focus(xcb_window_t window, xcb_timestamp_t timestamp) {
58
     /* Every X11 event is 32 bytes long. Therefore, XCB will copy 32 bytes.
59
      * In order to properly initialize these bytes, we allocate 32 bytes even
60
      * though we only need less for an xcb_configure_notify_event_t */
61
@@ -122,7 +122,7 @@ void send_take_focus(xcb_window_t window) {
62
     ev->type = A_WM_PROTOCOLS;
63
     ev->format = 32;
64
     ev->data.data32[0] = A_WM_TAKE_FOCUS;
65
-    ev->data.data32[1] = XCB_CURRENT_TIME;
66
+    ev->data.data32[1] = timestamp;
67
 
68
     DLOG("Sending WM_TAKE_FOCUS to the client\n");
69
     xcb_send_event(conn, false, window, XCB_EVENT_MASK_NO_EVENT, (char*)ev);