diff --git a/ewmh.c b/ewmh.c index c186100d1..f06ebbde0 100644 --- a/ewmh.c +++ b/ewmh.c @@ -28,6 +28,7 @@ #include "screen.h" #include "client.h" #include "widget.h" +#include "titlebar.h" extern AwesomeConf globalconf; @@ -254,7 +255,7 @@ ewmh_process_state_atom(Client *c, Atom state, int set) /* restore geometry */ geometry = c->m_geometry; /* restore borders and titlebar */ - c->titlebar.position = c->titlebar.dposition; + titlebar_position_set(&c->titlebar, c->titlebar.dposition); c->border = c->oldborder; c->ismax = False; client_setfloating(c, c->wasfloating); @@ -266,7 +267,7 @@ ewmh_process_state_atom(Client *c, Atom state, int set) c->m_geometry = c->geometry; c->wasfloating = c->isfloating; /* disable titlebar and borders */ - c->titlebar.position = Off; + titlebar_position_set(&c->titlebar, Off); c->oldborder = c->border; c->border = 0; c->ismax = True; @@ -291,7 +292,7 @@ ewmh_process_window_type_atom(Client *c, Atom state) c->border = 0; c->skip = True; c->isfixed = True; - c->titlebar.position = Off; + titlebar_position_set(&c->titlebar, Off); client_setfloating(c, True); } else if (state == net_wm_window_type_dialog) diff --git a/titlebar.c b/titlebar.c index 1be0e4a61..2ba474e62 100644 --- a/titlebar.c +++ b/titlebar.c @@ -440,6 +440,18 @@ titlebar_update_geometry(Client *c, area_t geometry) titlebar_draw(c); } +void +titlebar_position_set(Titlebar *t, Position p) +{ + if(!t->sw) + return; + + if((t->position = p)) + XMapWindow(globalconf.display, t->sw->window); + else + XUnmapWindow(globalconf.display, t->sw->window); +} + /** Toggle the visibility of the focused window's titlebar. * \param screen screen number (unused) * \param arg unused argument @@ -454,15 +466,9 @@ uicb_client_toggletitlebar(int screen __attribute__ ((unused)), char *arg __attr return; if(!c->titlebar.position) - { - if((c->titlebar.position = c->titlebar.dposition)) - XMapWindow(globalconf.display, c->titlebar.sw->window); - } + titlebar_position_set(&c->titlebar, c->titlebar.dposition); else - { - c->titlebar.position = Off; - XUnmapWindow(globalconf.display, c->titlebar.sw->window); - } + titlebar_position_set(&c->titlebar, Off); if(c->isfloating || layout_get_current(screen)->arrange == layout_floating) titlebar_update_geometry_floating(c); diff --git a/titlebar.h b/titlebar.h index 4577831c6..af4aaedce 100644 --- a/titlebar.h +++ b/titlebar.h @@ -30,6 +30,7 @@ void titlebar_update_geometry_floating(Client *); void titlebar_update_geometry(Client *, area_t); area_t titlebar_geometry_add(Titlebar *, area_t); area_t titlebar_geometry_remove(Titlebar *, area_t); +void titlebar_position_set(Titlebar *, Position); Uicb uicb_client_toggletitlebar;