]> git.sur5r.net Git - i3/i3/blobdiff - src/handlers.c
expose event handler: use x_deco_recurse
[i3/i3] / src / handlers.c
index f1e1c4b02704c6d3a828a47c88b858f70def6913..8e9bbb0448cddb7c598dd7232b8599f02adef02d 100644 (file)
@@ -106,7 +106,6 @@ static int handle_key_press(xcb_key_press_event_t *event) {
     }
 
     parse_cmd(bind->command);
-    tree_render();
     return 1;
 }
 
@@ -440,9 +439,10 @@ static int handle_screen_change(xcb_generic_event_t *e) {
  *
  */
 static int handle_unmap_notify_event(xcb_unmap_notify_event_t *event) {
+    // XXX: this is commented out because in src/x.c we disable EnterNotify events
     /* we need to ignore EnterNotify events which will be generated because a
      * different window is visible now */
-    add_ignore_event(event->sequence, XCB_ENTER_NOTIFY);
+    //add_ignore_event(event->sequence, XCB_ENTER_NOTIFY);
 
     DLOG("UnmapNotify for 0x%08x (received from 0x%08x), serial %d\n", event->window, event->event, event->sequence);
     Con *con = con_by_window_id(event->window);
@@ -541,7 +541,7 @@ static int handle_windowname_change(void *data, xcb_connection_t *conn, uint8_t
     if ((con = con_by_window_id(window)) == NULL || con->window == NULL)
         return 1;
 
-    window_update_name(con->window, prop);
+    window_update_name(con->window, prop, false);
 
     x_push_changes(croot);
 
@@ -559,7 +559,7 @@ static int handle_windowname_change_legacy(void *data, xcb_connection_t *conn, u
     if ((con = con_by_window_id(window)) == NULL || con->window == NULL)
         return 1;
 
-    window_update_name_legacy(con->window, prop);
+    window_update_name_legacy(con->window, prop, false);
 
     x_push_changes(croot);
 
@@ -576,7 +576,7 @@ static int handle_windowclass_change(void *data, xcb_connection_t *conn, uint8_t
     if ((con = con_by_window_id(window)) == NULL || con->window == NULL)
         return 1;
 
-    window_update_class(con->window, prop);
+    window_update_class(con->window, prop, false);
 
     return 0;
 }
@@ -586,7 +586,7 @@ static int handle_windowclass_change(void *data, xcb_connection_t *conn, uint8_t
  *
  */
 static int handle_expose_event(xcb_expose_event_t *event) {
-    Con *parent, *con;
+    Con *parent;
 
     /* event->count is the number of minimum remaining expose events for this
      * window, so we skip all events but the last one */
@@ -600,22 +600,8 @@ static int handle_expose_event(xcb_expose_event_t *event) {
         return 1;
     }
 
-    if (parent->window)
-        x_draw_decoration(parent);
-
-    TAILQ_FOREACH(con, &(parent->nodes_head), nodes) {
-        DLOG("expose for con %p / %s\n", con, con->name);
-        if (con->window)
-            x_draw_decoration(con);
-    }
-
-    /* We also need to render the decorations of other Cons nearby the Con
-     * itself to not get overlapping decorations */
-    TAILQ_FOREACH(con, &(parent->parent->nodes_head), nodes) {
-        DLOG("expose for con %p / %s\n", con, con->name);
-        if (con->window)
-            x_draw_decoration(con);
-    }
+    /* re-render the parent (recursively, if it’s a split con) */
+    x_deco_recurse(parent);
     xcb_flush(conn);
 
     return 1;
@@ -649,7 +635,7 @@ static int handle_client_message(xcb_client_message_event_t *event) {
              (event->data.data32[0] == _NET_WM_STATE_ADD ||
               event->data.data32[0] == _NET_WM_STATE_TOGGLE))) {
             DLOG("toggling fullscreen\n");
-            con_toggle_fullscreen(con);
+            con_toggle_fullscreen(con, CF_OUTPUT);
         }
 
         tree_render();
@@ -739,6 +725,7 @@ static int handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t state
         con->base_height = base_height;
         DLOG("client's base_height changed to %d\n", base_height);
         DLOG("client's base_width changed to %d\n", base_width);
+        changed = true;
     }
 
     /* If no aspect ratio was set or if it was invalid, we ignore the hints */
@@ -764,15 +751,24 @@ static int handle_normal_hints(void *data, xcb_connection_t *conn, uint8_t state
 
     /* Check if we need to set proportional_* variables using the correct ratio */
     if ((width / height) < min_aspect) {
-        con->proportional_width = width;
-        con->proportional_height = width / min_aspect;
+        if (con->proportional_width != width ||
+            con->proportional_height != (width / min_aspect)) {
+            con->proportional_width = width;
+            con->proportional_height = width / min_aspect;
+            changed = true;
+        }
     } else if ((width / height) > max_aspect) {
-        con->proportional_width = width;
-        con->proportional_height = width / max_aspect;
+        if (con->proportional_width != width ||
+            con->proportional_height != (width / max_aspect)) {
+            con->proportional_width = width;
+            con->proportional_height = width / max_aspect;
+            changed = true;
+        }
     } else goto render_and_return;
 
 render_and_return:
-    tree_render();
+    if (changed)
+        tree_render();
     return 1;
 }