]> git.sur5r.net Git - i3/i3/blobdiff - src/handlers.c
Ignore X11 errors caused by ReparentWindow / ChangeProperty on already destroyed...
[i3/i3] / src / handlers.c
index 583b0c5a46443ab45c0be6be14c94a7f64eb0ebc..0b64d14160b710d6fb03a17c608c2fa6af1ed509 100644 (file)
@@ -21,6 +21,14 @@ int randr_base = -1;
    changing workspaces */
 static SLIST_HEAD(ignore_head, Ignore_Event) ignore_events;
 
+/*
+ * Adds the given sequence to the list of events which are ignored.
+ * If this ignore should only affect a specific response_type, pass
+ * response_type, otherwise, pass -1.
+ *
+ * Every ignored sequence number gets garbage collected after 5 seconds.
+ *
+ */
 void add_ignore_event(const int sequence, const int response_type) {
     struct Ignore_Event *event = smalloc(sizeof(struct Ignore_Event));
 
@@ -35,7 +43,7 @@ void add_ignore_event(const int sequence, const int response_type) {
  * Checks if the given sequence is ignored and returns true if so.
  *
  */
-static bool event_is_ignored(const int sequence, const int response_type) {
+bool event_is_ignored(const int sequence, const int response_type) {
     struct Ignore_Event *event;
     time_t now = time(NULL);
     for (event = SLIST_FIRST(&ignore_events); event != SLIST_END(&ignore_events);) {
@@ -51,7 +59,7 @@ static bool event_is_ignored(const int sequence, const int response_type) {
         if (event->sequence != sequence)
             continue;
 
-        if (event->response_type != 0 &&
+        if (event->response_type != -1 &&
             event->response_type != response_type)
             continue;
 
@@ -286,7 +294,7 @@ static int handle_map_request(xcb_map_request_event_t *event) {
     cookie = xcb_get_window_attributes_unchecked(conn, event->window);
 
     DLOG("window = 0x%08x, serial is %d.\n", event->window, event->sequence);
-    add_ignore_event(event->sequence, 0);
+    add_ignore_event(event->sequence, -1);
 
     manage_window(event->window, cookie, false);
     x_push_changes(croot);
@@ -586,7 +594,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 +608,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;