From ac1517bacb54f9cb48dffb8142ce63fe842dfe1e Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 9 Jun 2008 18:24:12 +0200 Subject: [PATCH] [client] Add support for hide/unhide Signed-off-by: Julien Danjou --- client.c | 30 +++++++++++++++++++++++++++--- focus.c | 2 +- layout.c | 4 ++-- structs.h | 6 ++++-- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/client.c b/client.c index 3c9431520..923298ad1 100644 --- a/client.c +++ b/client.c @@ -126,7 +126,7 @@ client_isvisible_anyscreen(client_t *c) workspace_t *ws; int screen; - if(c) + if(c && !c->ishidden) { ws = workspace_client_get(c); for(screen = 0; screen < globalconf.screens_info->nscreen; screen++) @@ -146,7 +146,7 @@ client_isvisible_anyscreen(client_t *c) bool client_isvisible(client_t *c, int screen) { - if(c) + if(c && !c->ishidden) return (workspace_client_get(c) == globalconf.screens[screen].workspace); return false; } @@ -850,7 +850,7 @@ luaA_client_visible_get(lua_State *L) lua_newtable(L); for(c = globalconf.clients; c; c = c->next) - if(!c->skip && client_isvisible(c, screen)) + if(!c->skip && !c->ishidden && client_isvisible(c, screen)) { luaA_client_userdata_new(c); lua_rawseti(L, -2, i++); @@ -1169,6 +1169,28 @@ luaA_client_unmanage(lua_State *L) return 0; } +/** Hide a client. + */ +static int +luaA_client_hide(lua_State *L) +{ + client_t **c = luaA_checkudata(L, 1, "client"); + (*c)->ishidden = true; + workspace_client_get(*c)->need_arrange = true; + return 0; +} + +/** Unhide a client. + */ +static int +luaA_client_unhide(lua_State *L) +{ + client_t **c = luaA_checkudata(L, 1, "client"); + (*c)->ishidden = false; + workspace_client_get(*c)->need_arrange = true; + return 0; +} + int luaA_client_userdata_new(client_t *c) { @@ -1209,6 +1231,8 @@ const struct luaL_reg awesome_client_meta[] = { "mouse_resize", luaA_client_mouse_resize }, { "mouse_move", luaA_client_mouse_move }, { "unmanage", luaA_client_unmanage }, + { "hide", luaA_client_hide }, + { "unhide", luaA_client_unhide }, { "__eq", luaA_client_eq }, { "__tostring", luaA_client_tostring }, { NULL, NULL } diff --git a/focus.c b/focus.c index e1df6a491..e2152f52c 100644 --- a/focus.c +++ b/focus.c @@ -67,7 +67,7 @@ focus_get_latest_client_for_workspace(workspace_t *ws, int nindex) int i = 0; for(node = globalconf.focus; node; node = node->next) - if(node->client && !node->client->skip) + if(node->client && !node->client->skip && !node->client->ishidden) if(workspace_client_get(node->client) == ws) if(i-- == nindex) return node->client; diff --git a/layout.c b/layout.c index ed6c3112f..f271a429e 100644 --- a/layout.c +++ b/layout.c @@ -49,13 +49,13 @@ arrange(workspace_t *ws) workspace_t *cws; for(c = globalconf.clients; c; c = c->next) - if((cws = workspace_client_get(c)) == ws) + if((cws = workspace_client_get(c)) == ws && !c->ishidden) { screen_client_moveto(c, screen); client_unban(c); } /* we don't touch other screens windows */ - else if(workspace_screen_get(cws) == -1) + else if(c->ishidden || workspace_screen_get(cws) == -1) client_ban(c); qp_c = xcb_query_pointer_unchecked(globalconf.connection, diff --git a/structs.h b/structs.h index fd947f6ea..c723532f9 100644 --- a/structs.h +++ b/structs.h @@ -274,10 +274,10 @@ struct client_t bool skip; /** true if the client is moving */ bool ismoving; + /** True if the client is hidden */ + bool ishidden; /** true if the client must be skipped from task bar client list */ bool skiptb; - /** Next and previous clients */ - client_t *prev, *next; /** Window of the client */ xcb_window_t win; /** Client physical screen */ @@ -288,6 +288,8 @@ struct client_t char *icon_path; /** Titlebar */ titlebar_t *titlebar; + /** Next and previous clients */ + client_t *prev, *next; }; struct client_node_t