Handle changes to _NET_WM_WINDOW_TYPE after the window has been managed.

This commit is contained in:
Ingo Bürk 2015-04-19 00:29:31 +02:00
parent 550c0ec318
commit 1f472b454c
3 changed files with 34 additions and 9 deletions

View File

@ -56,6 +56,12 @@ void window_update_strut_partial(i3Window *win, xcb_get_property_reply_t *prop);
*/ */
void window_update_role(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt); void window_update_role(i3Window *win, xcb_get_property_reply_t *prop, bool before_mgmt);
/**
* Updates the _NET_WM_WINDOW_TYPE property.
*
*/
void window_update_type(i3Window *window, xcb_get_property_reply_t *reply);
/** /**
* Updates the WM_HINTS (we only care about the input focus handling part). * Updates the WM_HINTS (we only care about the input focus handling part).
* *

View File

@ -892,15 +892,15 @@ static void handle_client_message(xcb_client_message_event_t *event) {
} }
} }
#if 0 bool handle_window_type(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window,
int handle_window_type(void *data, xcb_connection_t *conn, uint8_t state, xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *reply) {
xcb_atom_t atom, xcb_get_property_reply_t *property) { Con *con;
/* TODO: Implement this one. To do this, implement a little test program which sleep(1)s if ((con = con_by_window_id(window)) == NULL || con->window == NULL)
before changing this property. */ return false;
ELOG("_NET_WM_WINDOW_TYPE changed, this is not yet implemented.\n");
return 0; window_update_type(con->window, reply);
return true;
} }
#endif
/* /*
* Handles the size hints set by a window, but currently only the part necessary for displaying * Handles the size hints set by a window, but currently only the part necessary for displaying
@ -1264,7 +1264,8 @@ static struct property_handler_t property_handlers[] = {
{0, UINT_MAX, handle_transient_for}, {0, UINT_MAX, handle_transient_for},
{0, 128, handle_windowrole_change}, {0, 128, handle_windowrole_change},
{0, 128, handle_class_change}, {0, 128, handle_class_change},
{0, UINT_MAX, handle_strut_partial_change}}; {0, UINT_MAX, handle_strut_partial_change},
{0, UINT_MAX, handle_window_type}};
#define NUM_HANDLERS (sizeof(property_handlers) / sizeof(struct property_handler_t)) #define NUM_HANDLERS (sizeof(property_handlers) / sizeof(struct property_handler_t))
/* /*
@ -1284,6 +1285,7 @@ void property_handlers_init(void) {
property_handlers[6].atom = A_WM_WINDOW_ROLE; property_handlers[6].atom = A_WM_WINDOW_ROLE;
property_handlers[7].atom = XCB_ATOM_WM_CLASS; property_handlers[7].atom = XCB_ATOM_WM_CLASS;
property_handlers[8].atom = A__NET_WM_STRUT_PARTIAL; property_handlers[8].atom = A__NET_WM_STRUT_PARTIAL;
property_handlers[9].atom = A__NET_WM_WINDOW_TYPE;
} }
static void property_notify(uint8_t state, xcb_window_t window, xcb_atom_t atom) { static void property_notify(uint8_t state, xcb_window_t window, xcb_atom_t atom) {

View File

@ -232,6 +232,23 @@ void window_update_role(i3Window *win, xcb_get_property_reply_t *prop, bool befo
free(prop); free(prop);
} }
/*
* Updates the _NET_WM_WINDOW_TYPE property.
*
*/
void window_update_type(i3Window *window, xcb_get_property_reply_t *reply) {
xcb_atom_t new_type = xcb_get_preferred_window_type(reply);
if (new_type == XCB_NONE) {
DLOG("cannot read _NET_WM_WINDOW_TYPE from window.\n");
return;
}
window->window_type = new_type;
LOG("_NET_WM_WINDOW_TYPE changed to %i", window->window_type);
run_assignments(window);
}
/* /*
* Updates the WM_HINTS (we only care about the input focus handling part). * Updates the WM_HINTS (we only care about the input focus handling part).
* *