]> git.sur5r.net Git - i3/i3/commitdiff
Don’t assign ->container for dock-windows
authorMichael Stapelberg <michael+git@stapelberg.de>
Mon, 23 Feb 2009 02:44:10 +0000 (03:44 +0100)
committerMichael Stapelberg <michael+git@stapelberg.de>
Mon, 23 Feb 2009 02:44:10 +0000 (03:44 +0100)
src/commands.c
src/handlers.c
src/layout.c
src/mainx.c
src/util.c

index 8dca6a74972333dcf90b4418e9bb436f8e82fafe..7266a32735d0b087d0a2c54f003da7bca081858f 100644 (file)
@@ -89,6 +89,8 @@ static void focus_window(xcb_connection_t *connection, direction_t direction) {
  */
 static bool move_current_window_in_container(xcb_connection_t *connection, Client *client,
                 direction_t direction) {
+        assert(client->container != NULL);
+
         Client *other = (direction == D_UP ? CIRCLEQ_PREV(client, clients) :
                                                 CIRCLEQ_NEXT(client, clients));
 
index b4c5f94eab954882abf4db3e546ed8d9e8fa3b12..ea050be4404d9f3bb288b991e3b3c6134798bafc 100644 (file)
@@ -141,6 +141,11 @@ int handle_button_press(void *ignored, xcb_connection_t *conn, xcb_button_press_
                   *second = NULL;
         enum { O_HORIZONTAL, O_VERTICAL } orientation = O_VERTICAL;
 
+        if (con == NULL) {
+                printf("dock. done.\n");
+                return 1;
+        }
+
         printf("event->event_x = %d, client->rect.width = %d\n", event->event_x, client->rect.width);
 
         if (!border_click) {
@@ -310,15 +315,16 @@ int handle_unmap_notify_event(void *data, xcb_connection_t *c, xcb_unmap_notify_
         client = table_remove(byChild, e->window);
 
         printf("UnmapNotify for 0x%08x (received from 0x%08x): ", e->window, e->event);
-        if(client == NULL) {
+        if (client == NULL) {
                 printf("not a managed window. Ignoring.\n");
                 return 0;
         }
 
-
-        if (client->container->currently_focused == client)
-                client->container->currently_focused = NULL;
-        CIRCLEQ_REMOVE(&(client->container->clients), client, clients);
+        if (client->container != NULL) {
+                if (client->container->currently_focused == client)
+                        client->container->currently_focused = NULL;
+                CIRCLEQ_REMOVE(&(client->container->clients), client, clients);
+        }
 
         printf("child of 0x%08x.\n", client->frame);
         xcb_reparent_window(c, client->child, root, 0, 0);
index 42b08541358ba716af5e200e7f0495e5928ed551..0848a61792fff48d1a8b4dbdb086f9b12bb0ac79 100644 (file)
@@ -89,6 +89,10 @@ void decorate_window(xcb_connection_t *conn, Client *client) {
                  text_color,
                  border_color;
 
+        /* Clients without a container (docks) won’t get decorated */
+        if (client->container == NULL)
+                return;
+
         if (client->container->currently_focused == client) {
                 background_color = get_colorpixel(conn, client->frame, "#285577");
                 text_color = get_colorpixel(conn, client->frame, "#ffffff");
@@ -207,13 +211,6 @@ static void render_container(xcb_connection_t *connection, Container *container)
 
                 int current_client = 0;
                 CIRCLEQ_FOREACH(client, &(container->clients), clients) {
-                        /* TODO: currently, clients are assigned to the current container.
-                           Therefore, we need to skip them here. Does anything harmful happen
-                           if clients *do not* have a container. Is this the more desired
-                           situation? Let’s find out… */
-                        if (client->dock)
-                                continue;
-
                         /* Check if we changed client->x or client->y by updating it…
                          * Note the bitwise OR instead of logical OR to force evaluation of both statements */
                         if (client->force_reconfigure |
index ca714eaddf5ee2d609a7ae09734590fc56bb3866..baaaa2906121e00647ab42fc260acb6186a9bb48 100644 (file)
@@ -141,9 +141,6 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
         uint32_t mask = 0;
         uint32_t values[3];
 
-        /* Insert into the currently active container */
-        CIRCLEQ_INSERT_TAIL(&(CUR_CELL->clients), new, clients);
-
         /* Update the data structures */
         CUR_CELL->currently_focused = new;
         new->container = CUR_CELL;
@@ -222,7 +219,8 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
                                 new->dock = true;
                                 new->titlebar_position = TITLEBAR_OFF;
                                 new->force_reconfigure = true;
-                                SLIST_INSERT_HEAD(&(new->container->workspace->dock_clients), new, dock_clients);
+                                new->container = NULL;
+                                SLIST_INSERT_HEAD(&(c_ws->dock_clients), new, dock_clients);
                         }
         }
 
@@ -238,6 +236,10 @@ void reparent_window(xcb_connection_t *conn, xcb_window_t child,
                 printf("the client wants to be %d pixels height\n", new->desired_height);
         }
 
+        /* Insert into the currently active container, if it’s not a dock window */
+        if (!new->dock)
+                CIRCLEQ_INSERT_TAIL(&(CUR_CELL->clients), new, clients);
+
         render_layout(conn);
 }
 
index f7e71d1560ea7f6994a53f49dc7e881656504cce..63e98ff90fa027cf722e66e266145a3f0d194fad 100644 (file)
@@ -16,6 +16,7 @@
 #include <string.h>
 #include <sys/wait.h>
 #include <stdarg.h>
+#include <assert.h>
 
 #include "i3.h"
 #include "data.h"
@@ -113,6 +114,12 @@ void check_error(xcb_connection_t *connection, xcb_void_cookie_t cookie, char *e
  *
  */
 void set_focus(xcb_connection_t *conn, Client *client) {
+        /* The dock window cannot be focused */
+        /* TODO: does this play well with dzen2’s popup menus? or do we just need to set the input
+           focus but not update our internal structures? */
+        if (client->dock)
+                return;
+
         /* TODO: check if the focus needs to be changed at all */
         /* Store current_row/current_col */
         c_ws->current_row = current_row;
@@ -154,6 +161,9 @@ void warp_pointer_into(xcb_connection_t *connection, Client *client) {
  *
  */
 void toggle_fullscreen(xcb_connection_t *conn, Client *client) {
+        /* clients without a container (docks) cannot be focused */
+        assert(client->container != NULL);
+
         Workspace *workspace = client->container->workspace;
 
         workspace->fullscreen_client = (client->fullscreen ? NULL : client);