Lazily apply changes to border_width and border_color

Fixes: https://github.com/awesomeWM/awesome/issues/592
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2016-02-28 16:24:30 +01:00
parent f9d15691b8
commit ee7a41370f
5 changed files with 30 additions and 6 deletions

View File

@ -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);
}

View File

@ -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)
{

View File

@ -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

View File

@ -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)

View File

@ -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);