]> git.sur5r.net Git - i3/i3/commitdiff
handle client messages (fullscreen window state)
authorMichael Stapelberg <michael@stapelberg.de>
Sat, 17 Apr 2010 11:54:45 +0000 (13:54 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Sat, 17 Apr 2010 11:54:45 +0000 (13:54 +0200)
include/handlers.h
src/handlers.c
src/nc.c

index f5ea0591a874ccf35cd19706082af442d44ed52c..270822b834d49455e420fab88e3e710d2c623cec 100644 (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,
                         xcb_expose_event_t *event);
-#if 0
 /**
  * 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,
                           xcb_client_message_event_t *event);
 
+#if 0
 /**
  * Handles _NET_WM_WINDOW_TYPE changes
  *
index 510148d0cdde5f1c09f28548667855684894a2e9..6b71316994074184b9efadfbc48bba38d3f7658f 100644 (file)
@@ -642,36 +642,40 @@ int handle_expose_event(void *data, xcb_connection_t *conn, xcb_expose_event_t *
 #endif
 }
 
-#if 0
 /*
  * Handle client messages (EWMH)
  *
  */
 int handle_client_message(void *data, xcb_connection_t *conn, xcb_client_message_event_t *event) {
-        if (event->type == atoms[_NET_WM_STATE]) {
-                if (event->format != 32 || event->data.data32[1] != atoms[_NET_WM_STATE_FULLSCREEN])
-                        return 0;
-
-                Client *client = table_get(&by_child, event->window);
-                if (client == NULL)
-                        return 0;
-
-                /* Check if the fullscreen state should be toggled */
-                if ((client->fullscreen &&
-                     (event->data.data32[0] == _NET_WM_STATE_REMOVE ||
-                      event->data.data32[0] == _NET_WM_STATE_TOGGLE)) ||
-                    (!client->fullscreen &&
-                     (event->data.data32[0] == _NET_WM_STATE_ADD ||
-                      event->data.data32[0] == _NET_WM_STATE_TOGGLE)))
-                        client_toggle_fullscreen(conn, client);
-        } else {
-                ELOG("unhandled clientmessage\n");
-                return 0;
-        }
+    LOG("ClientMessage for window 0x%08x\n", event->window);
+    if (event->type == atoms[_NET_WM_STATE]) {
+        if (event->format != 32 || event->data.data32[1] != atoms[_NET_WM_STATE_FULLSCREEN])
+            return 0;
+
+        Con *con = con_by_window_id(event->window);
+        if (con == NULL)
+            return 0;
+
+        /* Check if the fullscreen state should be toggled */
+        if ((con->fullscreen_mode != CF_NONE &&
+             (event->data.data32[0] == _NET_WM_STATE_REMOVE ||
+              event->data.data32[0] == _NET_WM_STATE_TOGGLE)) ||
+            (con->fullscreen_mode == CF_NONE &&
+             (event->data.data32[0] == _NET_WM_STATE_ADD ||
+              event->data.data32[0] == _NET_WM_STATE_TOGGLE)))
+                con_toggle_fullscreen(con);
+
+        tree_render();
+        x_push_changes(croot);
+    } else {
+        ELOG("unhandled clientmessage\n");
+        return 0;
+    }
 
-        return 1;
+    return 1;
 }
 
+#if 0
 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) {
         /* TODO: Implement this one. To do this, implement a little test program which sleep(1)s
index 92dba08d2c7d79c716df6e6d5b1243a01f459e22..869a6f866188314281c72aff5c05711302dcaa10 100644 (file)
--- a/src/nc.c
+++ b/src/nc.c
@@ -279,6 +279,9 @@ int main(int argc, char *argv[]) {
     /* Enter window = user moved his mouse over the window */
     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 */
     #define GET_ATOM(name) \