From ee7a41370fb25c15caba3e15cdcd6939ee8b0034 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 28 Feb 2016 16:24:30 +0100 Subject: [PATCH] Lazily apply changes to border_width and border_color Fixes: https://github.com/awesomeWM/awesome/issues/592 Signed-off-by: Uli Schlachter --- event.h | 2 ++ objects/client.c | 7 +++++++ objects/drawin.c | 3 +++ objects/window.c | 21 +++++++++++++++------ objects/window.h | 3 +++ 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/event.h b/event.h index 61c60884..f47add4b 100644 --- a/event.h +++ b/event.h @@ -36,6 +36,7 @@ void drawin_refresh(void); /* objects/client.c */ void client_focus_refresh(void); +void client_border_refresh(void); static inline int awesome_refresh(void) @@ -44,6 +45,7 @@ awesome_refresh(void) banning_refresh(); stack_refresh(); drawin_refresh(); + client_border_refresh(); client_focus_refresh(); return xcb_flush(globalconf.connection); } diff --git a/objects/client.c b/objects/client.c index 5a61869a..f43d336f 100644 --- a/objects/client.c +++ b/objects/client.c @@ -453,6 +453,13 @@ client_focus_refresh(void) win, globalconf.timestamp); } +void +client_border_refresh(void) +{ + foreach(c, globalconf.clients) + window_border_refresh((window_t *) *c); +} + static void border_width_callback(client_t *c, uint16_t old_width, uint16_t new_width) { diff --git a/objects/drawin.c b/objects/drawin.c index 96d46c9e..f4712144 100644 --- a/objects/drawin.c +++ b/objects/drawin.c @@ -165,7 +165,10 @@ void drawin_refresh(void) { foreach(item, globalconf.drawins) + { drawin_apply_moveresize(*item); + window_border_refresh((window_t *) *item); + } } /** Move and/or resize a drawin diff --git a/objects/window.c b/objects/window.c index 5f9802ab..5f229225 100644 --- a/objects/window.c +++ b/objects/window.c @@ -148,6 +148,19 @@ luaA_window_get_opacity(lua_State *L, window_t *window) return 1; } +void +window_border_refresh(window_t *window) +{ + if(!window->border_need_update) + return; + window->border_need_update = false; + xwindow_set_border_color(window_get(window), &window->border_color); + if(window->window) + xcb_configure_window(globalconf.connection, window_get(window), + XCB_CONFIG_WINDOW_BORDER_WIDTH, + (uint32_t[]) { window->border_width }); +} + /** Set the window border color. * \param L The Lua VM state. * \param window The window object. @@ -162,7 +175,7 @@ luaA_window_set_border_color(lua_State *L, window_t *window) if(color_name && color_init_reply(color_init_unchecked(&window->border_color, color_name, len))) { - xwindow_set_border_color(window_get(window), &window->border_color); + window->border_need_update = true; luaA_object_emit_signal(L, -3, "property::border_color", 0); } @@ -183,11 +196,7 @@ window_set_border_width(lua_State *L, int idx, int width) if(width == window->border_width || width < 0) return; - if(window->window) - xcb_configure_window(globalconf.connection, window_get(window), - XCB_CONFIG_WINDOW_BORDER_WIDTH, - (uint32_t[]) { width }); - + window->border_need_update = true; window->border_width = width; if(window->border_width_callback) diff --git a/objects/window.h b/objects/window.h index 7c20eee7..3afcbb35 100644 --- a/objects/window.h +++ b/objects/window.h @@ -62,6 +62,8 @@ typedef enum strut_t strut; \ /** Button bindings */ \ button_array_t buttons; \ + /** Do we have pending border changes? */ \ + bool border_need_update; \ /** Border color */ \ color_t border_color; \ /** Border width */ \ @@ -83,6 +85,7 @@ void window_class_setup(lua_State *); void window_set_opacity(lua_State *, int, double); void window_set_border_width(lua_State *, int, int); +void window_border_refresh(window_t *); int luaA_window_get_type(lua_State *, window_t *); int luaA_window_set_type(lua_State *, window_t *); uint32_t window_translate_type(window_type_t);