From 7c79f9434103c93881ef8f91b41c4658bd0cb707 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 17 Mar 2008 08:56:17 +0100 Subject: [PATCH] Move titlebar initialization routine in titlebar.c --- client.c | 60 +++++++----------------------------------------------- titlebar.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ titlebar.h | 1 + 3 files changed, 63 insertions(+), 53 deletions(-) diff --git a/client.c b/client.c index 0579def54..1f85cd418 100644 --- a/client.c +++ b/client.c @@ -289,7 +289,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen) Tag *tag; Rule *rule; area_t screen_geom; - int phys_screen = get_phys_screen(screen), titlebar_height; + int phys_screen = get_phys_screen(screen); long flags; c = p_new(Client, 1); @@ -368,58 +368,6 @@ client_manage(Window w, XWindowAttributes *wa, int screen) move_client_to_screen(c, screen, True); } - if(rule && rule->titlebar.position != Auto) - c->titlebar = rule->titlebar; - - titlebar_height = 1.5 * MAX(globalconf.screens[c->screen].styles.normal.font->height, - MAX(globalconf.screens[c->screen].styles.focus.font->height, - globalconf.screens[c->screen].styles.urgent.font->height)); - - switch(c->titlebar.position) - { - case Top: - c->titlebar.sw = simplewindow_new(globalconf.display, - phys_screen, - c->geometry.x, - c->geometry.y - titlebar_height, - c->geometry.width + 2 * c->border, - titlebar_height, - 0); - break; - case Bottom: - c->titlebar.sw = simplewindow_new(globalconf.display, - phys_screen, - c->geometry.x, - c->geometry.y + c->geometry.height + 2 * c->border, - c->geometry.width + 2 * c->border, - titlebar_height, - 0); - break; - case Left: - c->titlebar.sw = simplewindow_new(globalconf.display, - phys_screen, - c->geometry.x - titlebar_height, - c->geometry.y, - titlebar_height, - c->geometry.width + 2 * c->border, - 0); - break; - case Right: - c->titlebar.sw = simplewindow_new(globalconf.display, - phys_screen, - c->geometry.x + c->geometry.width + 2 * c->border, - c->geometry.y, - titlebar_height, - c->geometry.width + 2 * c->border, - 0); - break; - case Off: - break; - default: - c->titlebar.position = Off; - break; - } - /* check for transient and set tags like its parent, * XGetTransientForHint returns 1 on success */ @@ -433,6 +381,12 @@ client_manage(Window w, XWindowAttributes *wa, int screen) if(!c->isfloating) client_setfloating(c, rettrans || c->isfixed); + /* titlebar init */ + if(rule && rule->titlebar.position != Auto) + c->titlebar = rule->titlebar; + + titlebar_init(c); + if(!(flags & (USPosition | PPosition))) { c->f_geometry = globalconf.screens[c->screen].floating_placement(c->f_geometry, diff --git a/titlebar.c b/titlebar.c index 6764a89e0..46e53168a 100644 --- a/titlebar.c +++ b/titlebar.c @@ -22,9 +22,64 @@ #include #include "titlebar.h" +#include "screen.h" extern AwesomeConf globalconf; +void +titlebar_init(Client *c) +{ + int titlebar_height = 1.5 * MAX(globalconf.screens[c->screen].styles.normal.font->height, + MAX(globalconf.screens[c->screen].styles.focus.font->height, + globalconf.screens[c->screen].styles.urgent.font->height)); + int phys_screen = get_phys_screen(c->screen); + + switch(c->titlebar.position) + { + case Top: + c->titlebar.sw = simplewindow_new(globalconf.display, + phys_screen, + c->geometry.x, + c->geometry.y - titlebar_height, + c->geometry.width + 2 * c->border, + titlebar_height, + 0); + break; + case Bottom: + c->titlebar.sw = simplewindow_new(globalconf.display, + phys_screen, + c->geometry.x, + c->geometry.y + c->geometry.height + 2 * c->border, + c->geometry.width + 2 * c->border, + titlebar_height, + 0); + break; + case Left: + c->titlebar.sw = simplewindow_new(globalconf.display, + phys_screen, + c->geometry.x - titlebar_height, + c->geometry.y, + titlebar_height, + c->geometry.width + 2 * c->border, + 0); + break; + case Right: + c->titlebar.sw = simplewindow_new(globalconf.display, + phys_screen, + c->geometry.x + c->geometry.width + 2 * c->border, + c->geometry.y, + titlebar_height, + c->geometry.width + 2 * c->border, + 0); + break; + case Off: + break; + default: + c->titlebar.position = Off; + break; + } +} + void titlebar_update(Client *c) { diff --git a/titlebar.h b/titlebar.h index be61c9343..5697e0ae5 100644 --- a/titlebar.h +++ b/titlebar.h @@ -24,6 +24,7 @@ #include "structs.h" +void titlebar_init(Client *); void titlebar_update(Client *); void titlebar_update_geometry_floating(Client *); area_t titlebar_update_geometry(Client *, area_t);