handle client messages (fullscreen window state)

This commit is contained in:
Michael Stapelberg 2010-04-17 13:54:45 +02:00
parent 1b4bd96ea9
commit c56867792a
3 changed files with 28 additions and 21 deletions

View File

@ -144,7 +144,6 @@ int handle_windowclass_change(void *data, xcb_connection_t *conn, uint8_t state,
*/ */
int handle_expose_event(void *data, xcb_connection_t *conn, int handle_expose_event(void *data, xcb_connection_t *conn,
xcb_expose_event_t *event); xcb_expose_event_t *event);
#if 0
/** /**
* Handle client messages (EWMH) * Handle client messages (EWMH)
* *
@ -152,6 +151,7 @@ int handle_expose_event(void *data, xcb_connection_t *conn,
int handle_client_message(void *data, xcb_connection_t *conn, int handle_client_message(void *data, xcb_connection_t *conn,
xcb_client_message_event_t *event); xcb_client_message_event_t *event);
#if 0
/** /**
* Handles _NET_WM_WINDOW_TYPE changes * Handles _NET_WM_WINDOW_TYPE changes
* *

View File

@ -642,28 +642,31 @@ int handle_expose_event(void *data, xcb_connection_t *conn, xcb_expose_event_t *
#endif #endif
} }
#if 0
/* /*
* Handle client messages (EWMH) * Handle client messages (EWMH)
* *
*/ */
int handle_client_message(void *data, xcb_connection_t *conn, xcb_client_message_event_t *event) { int handle_client_message(void *data, xcb_connection_t *conn, xcb_client_message_event_t *event) {
LOG("ClientMessage for window 0x%08x\n", event->window);
if (event->type == atoms[_NET_WM_STATE]) { if (event->type == atoms[_NET_WM_STATE]) {
if (event->format != 32 || event->data.data32[1] != atoms[_NET_WM_STATE_FULLSCREEN]) if (event->format != 32 || event->data.data32[1] != atoms[_NET_WM_STATE_FULLSCREEN])
return 0; return 0;
Client *client = table_get(&by_child, event->window); Con *con = con_by_window_id(event->window);
if (client == NULL) if (con == NULL)
return 0; return 0;
/* Check if the fullscreen state should be toggled */ /* Check if the fullscreen state should be toggled */
if ((client->fullscreen && if ((con->fullscreen_mode != CF_NONE &&
(event->data.data32[0] == _NET_WM_STATE_REMOVE || (event->data.data32[0] == _NET_WM_STATE_REMOVE ||
event->data.data32[0] == _NET_WM_STATE_TOGGLE)) || event->data.data32[0] == _NET_WM_STATE_TOGGLE)) ||
(!client->fullscreen && (con->fullscreen_mode == CF_NONE &&
(event->data.data32[0] == _NET_WM_STATE_ADD || (event->data.data32[0] == _NET_WM_STATE_ADD ||
event->data.data32[0] == _NET_WM_STATE_TOGGLE))) event->data.data32[0] == _NET_WM_STATE_TOGGLE)))
client_toggle_fullscreen(conn, client); con_toggle_fullscreen(con);
tree_render();
x_push_changes(croot);
} else { } else {
ELOG("unhandled clientmessage\n"); ELOG("unhandled clientmessage\n");
return 0; return 0;
@ -672,6 +675,7 @@ int handle_client_message(void *data, xcb_connection_t *conn, xcb_client_message
return 1; return 1;
} }
#if 0
int 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 *property) { xcb_atom_t atom, xcb_get_property_reply_t *property) {
/* TODO: Implement this one. To do this, implement a little test program which sleep(1)s /* TODO: Implement this one. To do this, implement a little test program which sleep(1)s

View File

@ -279,6 +279,9 @@ int main(int argc, char *argv[]) {
/* Enter window = user moved his mouse over the window */ /* Enter window = user moved his mouse over the window */
xcb_event_set_enter_notify_handler(&evenths, handle_enter_notify, NULL); xcb_event_set_enter_notify_handler(&evenths, handle_enter_notify, NULL);
/* Client message are sent to the root window. The only interesting client message
for us is _NET_WM_STATE, we honour _NET_WM_STATE_FULLSCREEN */
xcb_event_set_client_message_handler(&evenths, handle_client_message, NULL);
/* Setup NetWM atoms */ /* Setup NetWM atoms */
#define GET_ATOM(name) \ #define GET_ATOM(name) \