From b2e004b453ecd95278c662e1d6cb4fd1e700adfd Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 6 Feb 2008 08:49:31 +0100 Subject: [PATCH] add scratch window support --- awesomerc.1.txt | 4 ++++ awesomerc.in | 12 ++++++++++++ client.c | 40 ++++++++++++++++++++++++++++++++++++++++ client.h | 2 ++ config.c | 4 ---- structs.h | 6 ++++++ uicb.c | 4 ++++ widgets/taglist.c | 3 ++- widgets/tasklist.c | 10 +++++++++- 9 files changed, 79 insertions(+), 6 deletions(-) diff --git a/awesomerc.1.txt b/awesomerc.1.txt index d478a4f18..83009bd0d 100644 --- a/awesomerc.1.txt +++ b/awesomerc.1.txt @@ -87,6 +87,10 @@ Client Move client window with mouse. *client_resizemouse*:: Resize client window with mouse. +*client_setscratch*:: + Set or unset client as being the scratch window. +*client_togglescratch*:: + Toggle scratch window. Tag ~~~ diff --git a/awesomerc.in b/awesomerc.in index b5f1e78ef..fa490b413 100644 --- a/awesomerc.in +++ b/awesomerc.in @@ -316,6 +316,18 @@ keys command = "client_togglefloating" } key + { + modkey = {"Mod4"} + key = "s" + command = "client_togglescratch" + } + key + { + modkey = {"Mod4", "Control"} + key = "s" + command = "client_setscratch" + } + key { modkey = {"Mod4", "Shift"} key = "c" diff --git a/client.c b/client.c index 0e7fe9ca2..b2e81153f 100644 --- a/client.c +++ b/client.c @@ -704,6 +704,9 @@ client_isvisible(Client *c, int screen) if(!c || c->screen != screen) return False; + if(globalconf.scratch.client == c) + return globalconf.scratch.isvisible; + for(tag = globalconf.screens[screen].tags; tag; tag = tag->next) if(tag->selected && is_client_tagged(c, tag)) return True; @@ -1079,4 +1082,41 @@ uicb_client_togglefloating(int screen __attribute__ ((unused)), client_setfloating(globalconf.focus->client, !globalconf.focus->client->isfloating); } +/** Toggle scratch client attribute + * \param screen screen number + * \param arg unused argument + * \ingroup ui_callback + */ +void +uicb_client_setscratch(int screen, + char *arg __attribute__ ((unused))) +{ + if(!globalconf.focus->client) + return; + + if(globalconf.scratch.client == globalconf.focus->client) + globalconf.scratch.client = NULL; + else + globalconf.scratch.client = globalconf.focus->client; + + widget_invalidate_cache(screen, WIDGET_CACHE_CLIENTS | WIDGET_CACHE_TAGS); + globalconf.screens[screen].need_arrange = True; +} + +/** Toggle scratch client visibility + * \param screen screen number + * \param arg unused argument + * \ingroup ui_callback + */ +void +uicb_client_togglescratch(int screen __attribute__ ((unused)), + char *arg __attribute__ ((unused))) +{ + if(globalconf.scratch.client) + { + globalconf.scratch.isvisible = !globalconf.scratch.isvisible; + globalconf.screens[globalconf.scratch.client->screen].need_arrange = True; + widget_invalidate_cache(globalconf.scratch.client->screen, WIDGET_CACHE_CLIENTS); + } +} // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/client.h b/client.h index 28710dc7b..10d7ca1c2 100644 --- a/client.h +++ b/client.h @@ -52,6 +52,8 @@ Uicb uicb_client_zoom; Uicb uicb_client_focusnext; Uicb uicb_client_focusprev; Uicb uicb_client_togglefloating; +Uicb uicb_client_togglescratch; +Uicb uicb_client_setscratch; DO_SLIST(Client, client, p_delete); diff --git a/config.c b/config.c index c1f875aed..f59615739 100644 --- a/config.c +++ b/config.c @@ -19,10 +19,6 @@ * */ -/** - * @defgroup ui_callback User Interface Callbacks - */ - #include #include "config.h" diff --git a/structs.h b/structs.h index d81d561a3..8d0bd0f03 100644 --- a/structs.h +++ b/structs.h @@ -314,6 +314,12 @@ struct AwesomeConf Cursor cursor[CurLast]; /** Clients list */ Client *clients; + /** Scratch client */ + struct + { + Client *client; + Bool isvisible; + } scratch; /** Path to config file */ char *configpath; /** Selected clients history */ diff --git a/uicb.c b/uicb.c index a729d80dd..c8faf0677 100644 --- a/uicb.c +++ b/uicb.c @@ -19,6 +19,10 @@ * */ +/** + * @defgroup ui_callback User Interface Callbacks + */ + #include "awesome.h" #include "xutil.h" #include "tag.h" diff --git a/widgets/taglist.c b/widgets/taglist.c index 8cdf42b08..7f806275c 100644 --- a/widgets/taglist.c +++ b/widgets/taglist.c @@ -40,8 +40,9 @@ isoccupied(Tag *t) Client *c; for(c = globalconf.clients; c; c = c->next) - if(is_client_tagged(c, t) && !c->skip) + if(is_client_tagged(c, t) && !c->skip && c != globalconf.scratch.client) return True; + return False; } diff --git a/widgets/tasklist.c b/widgets/tasklist.c index aa74e3219..871bf4ab2 100644 --- a/widgets/tasklist.c +++ b/widgets/tasklist.c @@ -142,7 +142,15 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used) widget->font->height / 2, widget->font, c->name, d->fg, d->bg); - if(c->isfloating || c->ismax) + if(c == globalconf.scratch.client) + { + area.x = widget->area.x + icon_width + box_width * i; + area.y = widget->area.y; + area.width = (widget->font->height + 2) / 3; + area.height = (widget->font->height + 2) / 3; + draw_rectangle(ctx, area, c->isfloating, d->fg); + } + else if(c->isfloating || c->ismax) draw_circle(ctx, widget->area.x + icon_width + box_width * i, widget->area.y, (widget->font->height + 2) / 4,