From 8b217359e98cf25b3476eef1c16832e7acbf1634 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 14 Mar 2008 17:33:10 +0100 Subject: [PATCH] Rename Auto to Maybe in Fuzzy; add Auto as Position; add support for titlebar as rule --- client.c | 94 ++++++++++++++++++++++++--------------------- common/configopts.c | 1 + config.c | 1 + event.c | 2 +- rules.c | 2 +- screen.c | 2 +- statusbar.c | 2 +- structs.h | 3 +- 8 files changed, 58 insertions(+), 49 deletions(-) diff --git a/client.c b/client.c index 62ecc468..e377300b 100644 --- a/client.c +++ b/client.c @@ -347,8 +347,57 @@ client_manage(Window w, XWindowAttributes *wa, int screen) /* propagates border_width, if size doesn't change */ window_configure(c->win, c->geometry, c->border); + /* update window title */ + client_updatetitle(c); + + /* update hints */ + flags = client_updatesizehints(c); + client_updatewmhints(c); + + /* Try to load props if any */ + retloadprops = client_loadprops(c, screen); + + /* Then check clients hints */ + ewmh_check_client_hints(c); + + /* default titlebar position */ c->titlebar.position = globalconf.screens[screen].titlebar_default_position; + /* Then apply rules if no props */ + if(!retloadprops) + { + /* Get the client's rule */ + if((rule = rule_matching_client(c))) + { + if(rule->screen != RULE_NOSCREEN) + move_client_to_screen(c, rule->screen, True); + else + move_client_to_screen(c, screen, True); + tag_client_with_rule(c, rule); + + switch(rule->isfloating) + { + case Maybe: + break; + case Yes: + client_setfloating(c, True); + break; + case No: + client_setfloating(c, False); + break; + } + + if(rule->opacity >= 0.0f) + window_settrans(c->win, rule->opacity); + + if(rule->titlebar != Auto) + c->titlebar.position = rule->titlebar; + } + else + move_client_to_screen(c, screen, True); + } + + switch(c->titlebar.position) { case Top: @@ -366,49 +415,6 @@ client_manage(Window w, XWindowAttributes *wa, int screen) default: break; } - /* update window title */ - client_updatetitle(c); - - /* update hints */ - flags = client_updatesizehints(c); - client_updatewmhints(c); - - /* Try to load props if any */ - retloadprops = client_loadprops(c, screen); - - /* Then check clients hints */ - ewmh_check_client_hints(c); - - /* Then apply rules if no props */ - if(!retloadprops) - { - /* Get the client's rule */ - if((rule = rule_matching_client(c))) - { - if(rule->screen != RULE_NOSCREEN) - move_client_to_screen(c, rule->screen, True); - else - move_client_to_screen(c, screen, True); - tag_client_with_rule(c, rule); - - switch(rule->isfloating) - { - case Auto: - break; - case Yes: - client_setfloating(c, True); - break; - case No: - client_setfloating(c, False); - break; - } - - if(rule->opacity >= 0.0f) - window_settrans(c->win, rule->opacity); - } - else - move_client_to_screen(c, screen, True); - } /* check for transient and set tags like its parent, * XGetTransientForHint returns 1 on success @@ -446,7 +452,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen) case No: client_list_append(&globalconf.clients, c); break; - case Auto: + case Maybe: rule = NULL; break; } diff --git a/common/configopts.c b/common/configopts.c index 5d68afe1..539ac8f6 100644 --- a/common/configopts.c +++ b/common/configopts.c @@ -280,6 +280,7 @@ cfg_opt_t rule_opts[] = CFG_STR((char *) "icon", NULL, CFGF_NONE), CFG_STR((char *) "float", (char *) "auto", CFGF_NONE), CFG_STR((char *) "master", (char *) "auto", CFGF_NONE), + CFG_STR((char *) "titlebar", (char *) "auto", CFGF_NONE), CFG_INT((char *) "screen", RULE_NOSCREEN, CFGF_NONE), CFG_FLOAT((char *) "opacity", -1.0f, CFGF_NONE), CFG_AWESOME_END() diff --git a/config.c b/config.c index 42f4a53a..3326b1c7 100644 --- a/config.c +++ b/config.c @@ -526,6 +526,7 @@ config_parse(const char *confpatharg) rule->isfloating = rules_get_fuzzy_from_str(cfg_getstr(cfgsectmp, "float")); rule->screen = cfg_getint(cfgsectmp, "screen"); rule->ismaster = rules_get_fuzzy_from_str(cfg_getstr(cfgsectmp, "master")); + rule->titlebar = position_get_from_str(cfg_getstr(cfgsectmp, "titlebar")); rule->opacity = cfg_getfloat(cfgsectmp, "opacity"); if(rule->screen >= globalconf.screens_info->nscreen) rule->screen = 0; diff --git a/event.c b/event.c index 2cbf8830..748ab309 100644 --- a/event.c +++ b/event.c @@ -117,7 +117,7 @@ event_handle_buttonpress(XEvent *e) return; } break; - case Off: + default: break; } /* return if no widget match */ diff --git a/rules.c b/rules.c index 4ff05ded..2ab3c47d 100644 --- a/rules.c +++ b/rules.c @@ -115,7 +115,7 @@ rules_get_fuzzy_from_str(const char *str) else if(!a_strcmp(str, "false") || !a_strcmp(str, "no")) return No; - return Auto; + return Maybe; } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/screen.c b/screen.c index 1bbd4f68..840555b6 100644 --- a/screen.c +++ b/screen.c @@ -61,7 +61,7 @@ screen_get_area(int screen, Statusbar *statusbar, Padding *padding) case Right: area.width -= sb->height; break; - case Off: + default: break; } diff --git a/statusbar.c b/statusbar.c index fabb411e..fc50db16 100644 --- a/statusbar.c +++ b/statusbar.c @@ -62,7 +62,7 @@ statusbar_update_position(Statusbar *statusbar) case Right: simplewindow_move(statusbar->sw, area.x + area.width, area.y); break; - case Off: + default: XUnmapWindow(globalconf.display, statusbar->sw->window); break; } diff --git a/structs.h b/structs.h index d41bed80..89f58bf5 100644 --- a/structs.h +++ b/structs.h @@ -33,7 +33,7 @@ typedef enum { No = False, Yes = True, - Auto + Maybe } Fuzzy; /** Cursors */ @@ -49,6 +49,7 @@ struct Rule int screen; Fuzzy isfloating; Fuzzy ismaster; + Position titlebar; double opacity; regex_t *prop_r; regex_t *tags_r;