From: Michael Stapelberg Date: Fri, 25 Dec 2009 14:19:39 +0000 (+0100) Subject: ewmh: correctly set _NET_ACTIVE_WINDOW X-Git-Tag: 3.e~6^2~184 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e7e9e8e49d3df01c3f534a17e810242b9621058c;p=i3%2Fi3 ewmh: correctly set _NET_ACTIVE_WINDOW --- diff --git a/include/ewmh.h b/include/ewmh.h index a54a79c3..9ed85275 100644 --- a/include/ewmh.h +++ b/include/ewmh.h @@ -20,4 +20,13 @@ */ 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 diff --git a/include/i3.h b/include/i3.h index ddcbc3b7..abd503f4 100644 --- a/include/i3.h +++ b/include/i3.h @@ -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; diff --git a/include/xcb.h b/include/xcb.h index aa9a4ec5..883824dc 100644 --- a/include/xcb.h +++ b/include/xcb.h @@ -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; diff --git a/src/ewmh.c b/src/ewmh.c index b222e289..2e6e121b 100644 --- a/src/ewmh.c +++ b/src/ewmh.c @@ -30,3 +30,15 @@ void ewmh_update_current_desktop() { atoms[_NET_CURRENT_DESKTOP], CARDINAL, 32, 1, ¤t_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); +} diff --git a/src/mainx.c b/src/mainx.c index 9298fb3d..2a5f0037 100644 --- a/src/mainx.c +++ b/src/mainx.c @@ -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 */ diff --git a/src/manage.c b/src/manage.c index 40a6f64a..b80c94e0 100644 --- a/src/manage.c +++ b/src/manage.c @@ -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); + } } } diff --git a/src/util.c b/src/util.c index 8a202299..bc54caa5 100644 --- a/src/util.c +++ b/src/util.c @@ -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) {