]> git.sur5r.net Git - i3/i3/commitdiff
ewmh: correctly set _NET_ACTIVE_WINDOW
authorMichael Stapelberg <michael@stapelberg.de>
Fri, 25 Dec 2009 14:19:39 +0000 (15:19 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 25 Dec 2009 14:19:39 +0000 (15:19 +0100)
include/ewmh.h
include/i3.h
include/xcb.h
src/ewmh.c
src/mainx.c
src/manage.c
src/util.c

index a54a79c30b88a24a88172c80f27beb047c2a7186..9ed8527502cd5373046bbbea632698e28bdea83d 100644 (file)
  */
 void ewmh_update_current_desktop();
 
+/**
+ * Updates _NET_ACTIVE_WINDOW with the currently focused window.
+ *
+ * EWMH: The window ID of the currently active window or None if no window has
+ * the focus.
+ *
+ */
+void ewmh_update_active_window(xcb_window_t window);
+
 #endif
index ddcbc3b7ac2e4fcc090cdbc6b621f50abf8e34b7..abd503f437585075803c837ca587c44df43e8986 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef _I3_H
 #define _I3_H
 
-#define NUM_ATOMS 19
+#define NUM_ATOMS 20
 
 extern xcb_connection_t *global_conn;
 extern xcb_key_symbols_t *keysyms;
index aa9a4ec51bcdb53004c9c925ee66fad79ce5edfa..883824dcc04fc672f20eb8dc722f22e93766ac7c 100644 (file)
@@ -62,7 +62,8 @@ enum { _NET_SUPPORTED = 0,
         UTF8_STRING,
         WM_STATE,
         WM_CLIENT_LEADER,
-        _NET_CURRENT_DESKTOP
+        _NET_CURRENT_DESKTOP,
+        _NET_ACTIVE_WINDOW
 };
 
 extern unsigned int xcb_numlock_mask;
index b222e289f2673399167c48023d692b72d676bbc4..2e6e121bcd840bca195d4af9ddd29aea0822cb9d 100644 (file)
@@ -30,3 +30,15 @@ void ewmh_update_current_desktop() {
                             atoms[_NET_CURRENT_DESKTOP], CARDINAL, 32, 1,
                             &current_desktop);
 }
+
+/*
+ * Updates _NET_ACTIVE_WINDOW with the currently focused window.
+ *
+ * EWMH: The window ID of the currently active window or None if no window has
+ * the focus.
+ *
+ */
+void ewmh_update_active_window(xcb_window_t window) {
+        xcb_change_property(global_conn, XCB_PROP_MODE_REPLACE, root,
+                            atoms[_NET_ACTIVE_WINDOW], WINDOW, 32, 1, &window);
+}
index 9298fb3d8999949cdf21f0518fbab84750b9b8cf..2a5f0037d2a13d22affaf0b5973bc5fa3f83fc10 100644 (file)
@@ -249,6 +249,7 @@ int main(int argc, char *argv[], char *env[]) {
         REQUEST_ATOM(WM_STATE);
         REQUEST_ATOM(WM_CLIENT_LEADER);
         REQUEST_ATOM(_NET_CURRENT_DESKTOP);
+        REQUEST_ATOM(_NET_ACTIVE_WINDOW);
 
         /* TODO: this has to be more beautiful somewhen */
         int major, minor, error;
@@ -412,6 +413,7 @@ int main(int argc, char *argv[], char *env[]) {
         GET_ATOM(WM_STATE);
         GET_ATOM(WM_CLIENT_LEADER);
         GET_ATOM(_NET_CURRENT_DESKTOP);
+        GET_ATOM(_NET_ACTIVE_WINDOW);
 
         xcb_property_set_handler(&prophs, atoms[_NET_WM_WINDOW_TYPE], UINT_MAX, handle_window_type, NULL);
         /* TODO: In order to comply with EWMH, we have to watch _NET_WM_STRUT_PARTIAL */
index 40a6f64a735670afd12baa58b0045532b7848cf1..b80c94e0ce930757b06904730138f300ddac3cb4 100644 (file)
@@ -31,6 +31,7 @@
 #include "client.h"
 #include "workspace.h"
 #include "log.h"
+#include "ewmh.h"
 
 /*
  * Go through all existing windows (if the window manager is restarted) and manage them
@@ -450,8 +451,10 @@ map:
                                 if (map_frame)
                                         render_container(conn, new->container);
                         }
-                        if (new->container == CUR_CELL || client_is_floating(new))
+                        if (new->container == CUR_CELL || client_is_floating(new)) {
                                 xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, new->child, XCB_CURRENT_TIME);
+                                ewmh_update_active_window(new->child);
+                        }
                 }
         }
 
index 8a202299451700921017564d7e333b4c728209be..bc54caa553614d11ef1c48388d8fb5dbb15b4986 100644 (file)
@@ -247,6 +247,7 @@ void set_focus(xcb_connection_t *conn, Client *client, bool set_anyways) {
         CLIENT_LOG(client);
         /* Set focus to the entered window, and flush xcb buffer immediately */
         xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, client->child, XCB_CURRENT_TIME);
+        ewmh_update_active_window(client->child);
         //xcb_warp_pointer(conn, XCB_NONE, client->child, 0, 0, 0, 0, 10, 10);
 
         if (client->container != NULL) {