From 07b92c27926cd020071e4934bf4a25dee74362fe Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 23 Feb 2009 03:44:10 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20assign=20->container=20for=20do?= =?UTF-8?q?ck-windows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands.c | 2 ++ src/handlers.c | 16 +++++++++++----- src/layout.c | 11 ++++------- src/mainx.c | 10 ++++++---- src/util.c | 10 ++++++++++ 5 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/commands.c b/src/commands.c index 8dca6a74..7266a327 100644 --- a/src/commands.c +++ b/src/commands.c @@ -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)); diff --git a/src/handlers.c b/src/handlers.c index b4c5f94e..ea050be4 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -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); diff --git a/src/layout.c b/src/layout.c index 42b08541..0848a617 100644 --- a/src/layout.c +++ b/src/layout.c @@ -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 | diff --git a/src/mainx.c b/src/mainx.c index ca714ead..baaaa290 100644 --- a/src/mainx.c +++ b/src/mainx.c @@ -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); } diff --git a/src/util.c b/src/util.c index f7e71d15..63e98ff9 100644 --- a/src/util.c +++ b/src/util.c @@ -16,6 +16,7 @@ #include #include #include +#include #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);