From 3ab739553cb90e7d022ec3b4452b4471f0a6c3f4 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 28 May 2008 14:33:45 +0200 Subject: [PATCH] [client] Add and honor the noborder attribute Signed-off-by: Julien Danjou --- client.c | 30 ++++++++++++++++++++++-------- client.h | 1 + ewmh.c | 11 +++++++---- structs.h | 2 ++ 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/client.c b/client.c index b4949d45..3c6ae0a0 100644 --- a/client.c +++ b/client.c @@ -871,21 +871,35 @@ luaA_client_focus_get(lua_State *L __attribute__ ((unused))) return 1; } +/** Set client border width. + * \c The client. + * \ width The border width. + */ +void +client_setborder(client_t *c, uint32_t width) +{ + if(c->noborder && width > 0) + return; + + c->border = width; + xcb_configure_window(globalconf.connection, c->win, + XCB_CONFIG_WINDOW_BORDER_WIDTH, &width); + globalconf.screens[c->screen].need_arrange = true; +} + +/** Set the client border width and color. + * \param The border width in pixel. + * \param The border color. + */ static int luaA_client_border_set(lua_State *L) { client_t **c = luaL_checkudata(L, 1, "client"); - int width = luaA_getopt_number(L, 2, "width", -1); + uint32_t width = luaA_getopt_number(L, 2, "width", 0); const char *colorstr = luaA_getopt_string(L, 2, "color", NULL); xcolor_t color; - if(width >= 0) - { - (*c)->border = width; - globalconf.screens[(*c)->screen].need_arrange = true; - xcb_configure_window(globalconf.connection, (*c)->win, - XCB_CONFIG_WINDOW_BORDER_WIDTH, (uint32_t *) &width); - } + client_setborder(*c, width); if(colorstr && draw_color_new(globalconf.connection, (*c)->phys_screen, colorstr, &color)) diff --git a/client.h b/client.h index 360573af..083a78e7 100644 --- a/client.h +++ b/client.h @@ -42,6 +42,7 @@ void client_saveprops(client_t *); void client_kill(client_t *); void client_setfloating(client_t *, bool, layer_t); char * client_markup_parse(client_t *, const char *, ssize_t); +void client_setborder(client_t *, uint32_t); int luaA_client_userdata_new(client_t *); diff --git a/ewmh.c b/ewmh.c index d5257ab8..5cd08533 100644 --- a/ewmh.c +++ b/ewmh.c @@ -286,8 +286,9 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set) c->titlebar.position = c->titlebar_oldposition; xcb_map_window(globalconf.connection, c->titlebar_sw->window); } - c->border = c->oldborder; + c->noborder = false; c->ismax = false; + client_setborder(c, c->oldborder); client_setfloating(c, c->wasfloating, c->oldlayer); } else if(set == _NET_WM_STATE_ADD) @@ -302,9 +303,10 @@ ewmh_process_state_atom(client_t *c, xcb_atom_t state, int set) xcb_unmap_window(globalconf.connection, c->titlebar_sw->window); c->titlebar.position = Off; } - c->oldborder = c->border; - c->border = 0; c->ismax = true; + c->oldborder = c->border; + client_setborder(c, 0); + c->noborder = true; client_setfloating(c, true, LAYER_FULLSCREEN); } widget_invalidate_cache(c->screen, WIDGET_CACHE_CLIENTS); @@ -348,7 +350,6 @@ ewmh_process_window_type_atom(client_t *c, xcb_atom_t state) else if(state == net_wm_window_type_dock || state == net_wm_window_type_splash) { - c->border = 0; c->skip = true; c->isfixed = true; if(c->titlebar.position) @@ -356,6 +357,8 @@ ewmh_process_window_type_atom(client_t *c, xcb_atom_t state) xcb_unmap_window(globalconf.connection, c->titlebar_sw->window); c->titlebar.position = Off; } + client_setborder(c, 0); + c->noborder = true; client_setfloating(c, true, LAYER_ABOVE); } else if (state == net_wm_window_type_dialog) diff --git a/structs.h b/structs.h index d0a01d49..2f2be809 100644 --- a/structs.h +++ b/structs.h @@ -246,6 +246,8 @@ struct client_t int basew, baseh, incw, inch, maxw, maxh, minw, minh; int minax, maxax, minay, maxay; int border, oldborder; + /** True if the client does not want any border */ + bool noborder; /** Has urgency hint */ bool isurgent; /** Store previous floating state before maximizing */