diff --git a/CMakeLists.txt b/CMakeLists.txt index ed1bd7dd2..74c8e79ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,6 @@ set(AWE_DOC_FILES set(AWE_SRCS ${SOURCE_DIR}/awesome.c ${SOURCE_DIR}/client.c - ${SOURCE_DIR}/cnode.c ${SOURCE_DIR}/dbus.c ${SOURCE_DIR}/root.c ${SOURCE_DIR}/event.c diff --git a/client.c b/client.c index 0ad341c4f..94b4c5361 100644 --- a/client.c +++ b/client.c @@ -22,7 +22,6 @@ #include #include -#include "cnode.h" #include "tag.h" #include "ewmh.h" #include "screen.h" @@ -311,10 +310,9 @@ client_stack_above(client_t *c, xcb_window_t previous) previous = c->win; /* stack transient window on top of their parents */ - for(client_node_t *node = *client_node_list_last(&globalconf.stack); - node; node = node->prev) - if(node->client->transient_for == c) - previous = client_stack_above(node->client, previous); + foreach(node, globalconf.stack) + if((*node)->transient_for == c) + previous = client_stack_above(*node, previous); return previous; } @@ -375,7 +373,6 @@ static void client_real_stack(void) { uint32_t config_win_vals[2]; - client_node_t *node, *last = *client_node_list_last(&globalconf.stack); layer_t layer; config_win_vals[0] = XCB_NONE; @@ -383,9 +380,9 @@ client_real_stack(void) /* stack desktop windows */ for(layer = LAYER_DESKTOP; layer < LAYER_BELOW; layer++) - for(node = last; node; node = node->prev) - if(client_layer_translator(node->client) == layer) - config_win_vals[0] = client_stack_above(node->client, + foreach(node, globalconf.stack) + if(client_layer_translator(*node) == layer) + config_win_vals[0] = client_stack_above(*node, config_win_vals[0]); /* first stack not ontop wibox window */ @@ -405,9 +402,9 @@ client_real_stack(void) /* then stack clients */ for(layer = LAYER_BELOW; layer < LAYER_COUNT; layer++) - for(node = last; node; node = node->prev) - if(client_layer_translator(node->client) == layer) - config_win_vals[0] = client_stack_above(node->client, + foreach(node, globalconf.stack) + if(client_layer_translator(*node) == layer) + config_win_vals[0] = client_stack_above(*node, config_win_vals[0]); /* then stack ontop wibox window */ @@ -1237,7 +1234,7 @@ client_unmanage(client_t *c) client_array_remove(&globalconf.clients, elem); break; } - stack_client_delete(c); + stack_client_remove(c); for(int i = 0; i < tags->len; i++) untag_client(c, tags->tab[i]); diff --git a/client.h b/client.h index d319e5b7b..51ccb6564 100644 --- a/client.h +++ b/client.h @@ -216,11 +216,11 @@ client_raise(client_t *c) tc = c; for(int i = 0; i < counter; i++) tc = tc->transient_for; - stack_client_push(tc); + stack_client_append(tc); } /* Push c on top of the stack. */ - stack_client_push(c); + stack_client_append(c); client_stack(); } @@ -230,11 +230,11 @@ client_raise(client_t *c) static inline void client_lower(client_t *c) { - stack_client_append(c); + stack_client_push(c); /* Traverse all transient layers. */ for(client_t *tc = c->transient_for; tc; tc = tc->transient_for) - stack_client_append(tc); + stack_client_push(tc); client_stack(); } diff --git a/cnode.c b/cnode.c deleted file mode 100644 index 9df80c1f1..000000000 --- a/cnode.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * cnode.c - client node lists management - * - * Copyright © 2008 Julien Danjou - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#include "cnode.h" - -/** Get the client's node focus. - * \param list The client list. - * \param c The client. - * \return The client node focus. - */ -client_node_t * -client_node_client_getby(client_node_t *list, client_t *c) -{ - client_node_t *node; - - for(node = list; node; node = node->next) - if(node->client == c) - return node; - - return NULL; -} - -/** Create a client node for focus. - * \param list The client list. - * \param c The client. - * \return The client focus node. - */ -client_node_t * -client_node_client_add(client_node_t **list, client_t *c) -{ - client_node_t *node; - - /* if we don't find this node, create a new one */ - if(!(node = client_node_client_getby(*list, c))) - { - node = p_new(client_node_t, 1); - node->client = c; - } - else /* if we've got a node, detach it */ - client_node_list_detach(list, node); - - return node; -} - -// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/cnode.h b/cnode.h deleted file mode 100644 index 044d3bc7d..000000000 --- a/cnode.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * cnode.h - client node lists management header - * - * Copyright © 2008 Julien Danjou - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#ifndef AWESOME_CNODE_H -#define AWESOME_CNODE_H - -#include "client.h" -#include "common/list.h" - -struct client_node -{ - /** The client */ - client_t *client; - /** Next and previous client_nodes */ - client_node_t *prev, *next; -}; - -client_node_t * client_node_client_getby(client_node_t *, client_t *); -client_node_t * client_node_client_add(client_node_t **, client_t *); - -DO_SLIST(client_node_t, client_node, p_delete) - -#endif -// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/ewmh.c b/ewmh.c index 797ef32ee..2ac8bd7ef 100644 --- a/ewmh.c +++ b/ewmh.c @@ -30,7 +30,6 @@ #include "screen.h" #include "client.h" #include "widget.h" -#include "cnode.h" #include "wibox.h" #include "common/atoms.h" #include "common/buffer.h" @@ -166,18 +165,12 @@ ewmh_update_net_client_list(int phys_screen) void ewmh_update_net_client_list_stacking(int phys_screen) { - xcb_window_t *wins; - client_node_t *c; int n = 0; + xcb_window_t *wins = p_alloca(xcb_window_t, globalconf.stack.len); - for(c = globalconf.stack; c; c = c->next) - n++; - - wins = p_alloca(xcb_window_t, n); - - for(n = 0, c = *client_node_list_last(&globalconf.stack); c; c = c->prev, n++) - if(c->client->phys_screen == phys_screen) - wins[n] = c->client->win; + foreach(client, globalconf.stack) + if((*client)->phys_screen == phys_screen) + wins[n++] = (*client)->win; xcb_change_property(globalconf.connection, XCB_PROP_MODE_REPLACE, xutil_screen_get(globalconf.connection, phys_screen)->root, diff --git a/stack.c b/stack.c index 0110ba371..cb58ec33e 100644 --- a/stack.c +++ b/stack.c @@ -1,7 +1,7 @@ /* * stack.c - client stack management * - * Copyright © 2008 Julien Danjou + * Copyright © 2008-2009 Julien Danjou * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,8 +19,21 @@ * */ -#include "cnode.h" #include "ewmh.h" +#include "stack.h" +#include "client.h" + +void +stack_client_remove(client_t *c) +{ + foreach(client, globalconf.stack) + if(*client == c) + { + client_array_remove(&globalconf.stack, client); + break; + } + ewmh_update_net_client_list_stacking(c->phys_screen); +} /** Push the client at the beginning of the client stack. * \param c The client to push. @@ -28,8 +41,8 @@ void stack_client_push(client_t *c) { - client_node_t *node = client_node_client_add(&globalconf.stack, c); - client_node_list_push(&globalconf.stack, node); + stack_client_remove(c); + client_array_push(&globalconf.stack, c); ewmh_update_net_client_list_stacking(c->phys_screen); } @@ -39,25 +52,9 @@ stack_client_push(client_t *c) void stack_client_append(client_t *c) { - client_node_t *node = client_node_client_add(&globalconf.stack, c); - client_node_list_append(&globalconf.stack, node); + stack_client_remove(c); + client_array_append(&globalconf.stack, c); ewmh_update_net_client_list_stacking(c->phys_screen); } -/** Remove a client from stack history. - * \param c The client. - */ -void -stack_client_delete(client_t *c) -{ - client_node_t *node = client_node_client_getby(globalconf.stack, c); - - if(node) - { - client_node_list_detach(&globalconf.stack, node); - p_delete(&node); - ewmh_update_net_client_list_stacking(c->phys_screen); - } -} - // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/stack.h b/stack.h index 4aff8fa1a..39037659b 100644 --- a/stack.h +++ b/stack.h @@ -1,7 +1,7 @@ /* * stack.h - client stack management header * - * Copyright © 2007-2008 Julien Danjou + * Copyright © 2007-2009 Julien Danjou * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,9 +24,9 @@ #include "structs.h" +void stack_client_remove(client_t *); void stack_client_push(client_t *); void stack_client_append(client_t *); -void stack_client_delete(client_t *); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/structs.h b/structs.h index f9fd918ed..aca37c6dd 100644 --- a/structs.h +++ b/structs.h @@ -81,7 +81,7 @@ struct awesome_t /** Path to config file */ char *conffile; /** Stack client history */ - client_node_t *stack; + client_array_t stack; /** Command line passed to awesome */ char *argv; /** Lua VM state */