ewmh: correctly set _NET_ACTIVE_WINDOW

This commit is contained in:
Michael Stapelberg 2009-12-25 15:19:39 +01:00
parent 0641e6a1a3
commit e7e9e8e49d
7 changed files with 31 additions and 3 deletions

View File

@ -20,4 +20,13 @@
*/ */
void ewmh_update_current_desktop(); 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 #endif

View File

@ -21,7 +21,7 @@
#ifndef _I3_H #ifndef _I3_H
#define _I3_H #define _I3_H
#define NUM_ATOMS 19 #define NUM_ATOMS 20
extern xcb_connection_t *global_conn; extern xcb_connection_t *global_conn;
extern xcb_key_symbols_t *keysyms; extern xcb_key_symbols_t *keysyms;

View File

@ -62,7 +62,8 @@ enum { _NET_SUPPORTED = 0,
UTF8_STRING, UTF8_STRING,
WM_STATE, WM_STATE,
WM_CLIENT_LEADER, WM_CLIENT_LEADER,
_NET_CURRENT_DESKTOP _NET_CURRENT_DESKTOP,
_NET_ACTIVE_WINDOW
}; };
extern unsigned int xcb_numlock_mask; extern unsigned int xcb_numlock_mask;

View File

@ -30,3 +30,15 @@ void ewmh_update_current_desktop() {
atoms[_NET_CURRENT_DESKTOP], CARDINAL, 32, 1, atoms[_NET_CURRENT_DESKTOP], CARDINAL, 32, 1,
&current_desktop); &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);
}

View File

@ -249,6 +249,7 @@ int main(int argc, char *argv[], char *env[]) {
REQUEST_ATOM(WM_STATE); REQUEST_ATOM(WM_STATE);
REQUEST_ATOM(WM_CLIENT_LEADER); REQUEST_ATOM(WM_CLIENT_LEADER);
REQUEST_ATOM(_NET_CURRENT_DESKTOP); REQUEST_ATOM(_NET_CURRENT_DESKTOP);
REQUEST_ATOM(_NET_ACTIVE_WINDOW);
/* TODO: this has to be more beautiful somewhen */ /* TODO: this has to be more beautiful somewhen */
int major, minor, error; int major, minor, error;
@ -412,6 +413,7 @@ int main(int argc, char *argv[], char *env[]) {
GET_ATOM(WM_STATE); GET_ATOM(WM_STATE);
GET_ATOM(WM_CLIENT_LEADER); GET_ATOM(WM_CLIENT_LEADER);
GET_ATOM(_NET_CURRENT_DESKTOP); 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); 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 */ /* TODO: In order to comply with EWMH, we have to watch _NET_WM_STRUT_PARTIAL */

View File

@ -31,6 +31,7 @@
#include "client.h" #include "client.h"
#include "workspace.h" #include "workspace.h"
#include "log.h" #include "log.h"
#include "ewmh.h"
/* /*
* Go through all existing windows (if the window manager is restarted) and manage them * Go through all existing windows (if the window manager is restarted) and manage them
@ -450,8 +451,10 @@ map:
if (map_frame) if (map_frame)
render_container(conn, new->container); 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); xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, new->child, XCB_CURRENT_TIME);
ewmh_update_active_window(new->child);
}
} }
} }

View File

@ -247,6 +247,7 @@ void set_focus(xcb_connection_t *conn, Client *client, bool set_anyways) {
CLIENT_LOG(client); CLIENT_LOG(client);
/* Set focus to the entered window, and flush xcb buffer immediately */ /* 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); 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); //xcb_warp_pointer(conn, XCB_NONE, client->child, 0, 0, 0, 0, 10, 10);
if (client->container != NULL) { if (client->container != NULL) {