From d8f65bb1d8b9291fe4e902d32c7a762899a62ba6 Mon Sep 17 00:00:00 2001 From: seanpringle Date: Thu, 27 Dec 2012 11:04:17 +1000 Subject: [PATCH] allow building without title bars --- client.c | 9 +++++---- config.h | 6 +++++- event.c | 1 + setup.c | 19 +++++++++++-------- spot.c | 28 ++++++++++++++++------------ 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/client.c b/client.c index 87e1414..6d0756b 100644 --- a/client.c +++ b/client.c @@ -71,9 +71,10 @@ client* window_build_client(Window win) ? 1:0; // detect our own title bars - for_monitors(i, m) for_spots(j) - if (m->bars[j] && m->bars[j]->window == c->window) - { c->ours = 1; c->manage = 0; break; } + if (TITLE) + for_monitors(i, m) for_spots(j) + if (m->bars[j] && m->bars[j]->window == c->window) + { c->ours = 1; c->manage = 0; break; } if (c->manage) { @@ -272,7 +273,7 @@ void client_raise_family(client *c) client_stack_family(c, &raise); - if (!c->full) + if (!c->full && TITLE) { // raise spot's title bar in case some other fullscreen or max v/h window has obscured monitor *m = &monitors[c->monitor]; diff --git a/config.h b/config.h index abc41f4..cf16826 100644 --- a/config.h +++ b/config.h @@ -6,8 +6,12 @@ #define BORDER_URGENT "Red" #define GAP 2 -// Title bar xft font +// Title bar xft font. +// Setting this to NULL will disable title bars +//#define TITLE NULL #define TITLE "sans:size=8" + +// Title bar style #define TITLE_BLUR "Black" #define TITLE_FOCUS "White" #define TITLE_ELLIPSIS 32 diff --git a/event.c b/event.c index 7e27861..178fffd 100644 --- a/event.c +++ b/event.c @@ -144,6 +144,7 @@ void button_press(XEvent *ev) if (c && c->manage) client_activate(c); else + if (TITLE) for_monitors(i, m) for_spots(j) if (m->bars[j]->window == e->subwindow) spot_focus_top_window(j, i, None); diff --git a/setup.c b/setup.c index ab8789f..63703f2 100644 --- a/setup.c +++ b/setup.c @@ -185,16 +185,19 @@ void setup() XGrabButton(display, Button3, AnyModifier, root, True, ButtonPressMask, GrabModeSync, GrabModeSync, None, None); // create title bars - STACK_FREE(&windows); - for_monitors(i, m) for_spots(j) + if (TITLE) { - m->bars[j] = textbox_create(root, TB_AUTOHEIGHT|TB_LEFT, m->spots[j].x, m->spots[j].y, m->spots[j].w, 0, - TITLE, TITLE_BLUR, BORDER_BLUR, NULL, NULL); - XSelectInput(display, m->bars[j]->window, ExposureMask); + STACK_FREE(&windows); + for_monitors(i, m) for_spots(j) + { + m->bars[j] = textbox_create(root, TB_AUTOHEIGHT|TB_LEFT, m->spots[j].x, m->spots[j].y, m->spots[j].w, 0, + TITLE, TITLE_BLUR, BORDER_BLUR, NULL, NULL); + XSelectInput(display, m->bars[j]->window, ExposureMask); - m->spots[j].y += m->bars[j]->h; - m->spots[j].h -= m->bars[j]->h; - spot_update_bar(j, i); + m->spots[j].y += m->bars[j]->h; + m->spots[j].h -= m->bars[j]->h; + spot_update_bar(j, i); + } } // setup existing managable windows diff --git a/spot.c b/spot.c index 5aa79ed..ce3892e 100644 --- a/spot.c +++ b/spot.c @@ -51,25 +51,29 @@ void spot_update_bar(int spot, int mon) } if (tmp) XFree(tmp); } - if (c && !c->full && *title && m->bars[spot]) + if (TITLE) { - int focus = c->window == current || (spot == current_spot && mon == current_mon); - char *color = focus && c->window == current ? TITLE_FOCUS : TITLE_BLUR; - char *border = focus && c->window == current ? BORDER_FOCUS: BORDER_BLUR; - textbox_font(m->bars[spot], TITLE, color, border); - textbox_text(m->bars[spot], title); - textbox_draw(m->bars[spot]); - textbox_show(m->bars[spot]); + if (c && !c->full && *title && m->bars[spot]) + { + int focus = c->window == current || (spot == current_spot && mon == current_mon); + char *color = focus && c->window == current ? TITLE_FOCUS : TITLE_BLUR; + char *border = focus && c->window == current ? BORDER_FOCUS: BORDER_BLUR; + textbox_font(m->bars[spot], TITLE, color, border); + textbox_text(m->bars[spot], title); + textbox_draw(m->bars[spot]); + textbox_show(m->bars[spot]); + } + else + if (m->bars[spot]) + textbox_hide(m->bars[spot]); } - else - if (m->bars[spot]) - textbox_hide(m->bars[spot]); } void update_bars() { int i, j; monitor *m; - for_monitors(i, m) for_spots(j) spot_update_bar(j, i); + if (TITLE) for_monitors(i, m) for_spots(j) + spot_update_bar(j, i); } Window spot_focus_top_window(int spot, int mon, Window except)