From c350bb45d0e9040b1f6f14e9f928c32a8bc256ae Mon Sep 17 00:00:00 2001 From: OldMan Date: Thu, 25 Mar 2010 19:53:00 +0100 Subject: [PATCH] Conf: Buttons as indicators of client mode (Feature #33) --- src/config.c | 9 +++++++++ src/frame.c | 24 +++++++++++++++++------- src/structs.h | 1 + wmfsrc.in | 2 ++ 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/config.c b/src/config.c index 7f0046b..2072c23 100644 --- a/src/config.c +++ b/src/config.c @@ -264,6 +264,15 @@ conf_client_section(char *src) cfg_set_sauv(tmp2); + tmp3 = get_opt(tmp2, "none", "flags").str; + conf.titlebar.button[i].flags = 0; + if(strstr(tmp3, "free")) + conf.titlebar.button[i].flags |= FreeFlag; + if(strstr(tmp3, "max")) + conf.titlebar.button[i].flags |= MaxFlag; + if(strstr(tmp3, "tile")) + conf.titlebar.button[i].flags |= TileFlag; + /* Multi mouse section */ if((conf.titlebar.button[i].nmouse = get_size_sec(tmp2, "mouse"))) { diff --git a/src/frame.c b/src/frame.c index 66787d1..8982bf7 100644 --- a/src/frame.c +++ b/src/frame.c @@ -220,16 +220,26 @@ frame_update(Client *c) { XSetWindowBackground(dpy, c->button[i], c->colors.frame); XClearWindow(dpy, c->button[i]); - XSetWindowBorder(dpy, c->button[i], getcolor(c->colors.fg)); - /* Button's lines */ - if(conf.titlebar.button[i].nlines) + if((!conf.titlebar.button[i].flags) + || ((conf.titlebar.button[i].flags & FreeFlag) && (c->flags & FreeFlag)) + || ((conf.titlebar.button[i].flags & MaxFlag) && (c->flags & MaxFlag)) + || ((conf.titlebar.button[i].flags & TileFlag) && (c->flags & TileFlag))) { - XSetForeground(dpy, gc, getcolor(c->colors.fg)); - XDrawSegments(dpy, c->button[i], gc, - conf.titlebar.button[i].linecoord, - conf.titlebar.button[i].nlines); + + XSetWindowBorder(dpy, c->button[i], getcolor(c->colors.fg)); + + /* Button's lines */ + if(conf.titlebar.button[i].nlines) + { + XSetForeground(dpy, gc, getcolor(c->colors.fg)); + XDrawSegments(dpy, c->button[i], gc, + conf.titlebar.button[i].linecoord, + conf.titlebar.button[i].nlines); + } } + else + XSetWindowBorder(dpy, c->button[i], c->colors.frame); } } diff --git a/src/structs.h b/src/structs.h index 50cddd7..4ee9ff9 100644 --- a/src/structs.h +++ b/src/structs.h @@ -303,6 +303,7 @@ typedef struct XSegment *linecoord; int nlines; int nmouse; + uint flags; } Button; /* Alias struct */ diff --git a/wmfsrc.in b/wmfsrc.in index 23f90fc..8f520ca 100644 --- a/wmfsrc.in +++ b/wmfsrc.in @@ -111,6 +111,8 @@ [mouse] button = "3" func = "mouse_resize" [/mouse] [button] + # Available "free", "max", "tile" flags of button. + flags = "free,max,tile" [mouse] button = "1" func = "client_kill" [/mouse] [mouse] button = "3" func = "menu" cmd = "clientmenu" [/mouse]