From cdd888d6cf0482963b37150a77576ff819236814 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 2 Oct 2009 16:33:39 +0200 Subject: [PATCH] xwindow: add xwindow_set_border_color helper function Signed-off-by: Julien Danjou --- objects/client.c | 3 +-- objects/wibox.c | 4 +--- xwindow.c | 15 +++++++++++++-- xwindow.h | 1 + 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/objects/client.c b/objects/client.c index af64d60f9..33f9ba2dd 100644 --- a/objects/client.c +++ b/objects/client.c @@ -1630,8 +1630,7 @@ luaA_client_set_border_color(lua_State *L, client_t *c) if((buf = luaL_checklstring(L, -1, &len)) && xcolor_init_reply(xcolor_init_unchecked(&c->border_color, buf, len))) { - xcb_change_window_attributes(globalconf.connection, c->window, - XCB_CW_BORDER_PIXEL, &c->border_color.pixel); + xwindow_set_border_color(c->window, &c->border_color); luaA_object_emit_signal(L, -3, "property::border_color", 0); } return 0; diff --git a/objects/wibox.c b/objects/wibox.c index 2be50182b..28a3e6bec 100644 --- a/objects/wibox.c +++ b/objects/wibox.c @@ -356,9 +356,7 @@ static void wibox_set_border_color(lua_State *L, int udx, const xcolor_t *color) { wibox_t *w = luaA_checkudata(L, udx, &wibox_class); - if (w->window != XCB_NONE) - xcb_change_window_attributes(globalconf.connection, w->window, - XCB_CW_BORDER_PIXEL, &color->pixel); + xwindow_set_border_color(w->window, &w->border_color); w->border_color = *color; luaA_object_emit_signal(L, udx, "property::border_color", 0); } diff --git a/xwindow.c b/xwindow.c index 35394687f..2b12eb7e0 100644 --- a/xwindow.c +++ b/xwindow.c @@ -225,8 +225,8 @@ xwindow_takefocus(xcb_window_t win) XCB_EVENT_MASK_NO_EVENT, (char *) &ev); } -/** Set wibox cursor. - * \param w The wibox. +/** Set window cursor. + * \param w The window. * \param c The cursor. */ void @@ -236,4 +236,15 @@ xwindow_set_cursor(xcb_window_t w, xcb_cursor_t c) (const uint32_t[]) { c }); } +/** Set a window border color. + * \param w The window. + * \param color The color. + */ +void +xwindow_set_border_color(xcb_window_t w, xcolor_t *color) +{ + if(w) + xcb_change_window_attributes(globalconf.connection, w, XCB_CW_BORDER_PIXEL, &color->pixel); +} + // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/xwindow.h b/xwindow.h index eab2f972e..475465ad8 100644 --- a/xwindow.h +++ b/xwindow.h @@ -36,6 +36,7 @@ void xwindow_set_opacity(xcb_window_t, double); void xwindow_grabkeys(xcb_window_t, key_array_t *); void xwindow_takefocus(xcb_window_t); void xwindow_set_cursor(xcb_window_t, xcb_cursor_t); +void xwindow_set_border_color(xcb_window_t, xcolor_t *); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80