xwindow: add xwindow_set_border_color helper function

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-10-02 16:33:39 +02:00
parent d3c277b8ab
commit cdd888d6cf
4 changed files with 16 additions and 7 deletions

View File

@ -1630,8 +1630,7 @@ luaA_client_set_border_color(lua_State *L, client_t *c)
if((buf = luaL_checklstring(L, -1, &len)) if((buf = luaL_checklstring(L, -1, &len))
&& xcolor_init_reply(xcolor_init_unchecked(&c->border_color, buf, len))) && xcolor_init_reply(xcolor_init_unchecked(&c->border_color, buf, len)))
{ {
xcb_change_window_attributes(globalconf.connection, c->window, xwindow_set_border_color(c->window, &c->border_color);
XCB_CW_BORDER_PIXEL, &c->border_color.pixel);
luaA_object_emit_signal(L, -3, "property::border_color", 0); luaA_object_emit_signal(L, -3, "property::border_color", 0);
} }
return 0; return 0;

View File

@ -356,9 +356,7 @@ static void
wibox_set_border_color(lua_State *L, int udx, const xcolor_t *color) wibox_set_border_color(lua_State *L, int udx, const xcolor_t *color)
{ {
wibox_t *w = luaA_checkudata(L, udx, &wibox_class); wibox_t *w = luaA_checkudata(L, udx, &wibox_class);
if (w->window != XCB_NONE) xwindow_set_border_color(w->window, &w->border_color);
xcb_change_window_attributes(globalconf.connection, w->window,
XCB_CW_BORDER_PIXEL, &color->pixel);
w->border_color = *color; w->border_color = *color;
luaA_object_emit_signal(L, udx, "property::border_color", 0); luaA_object_emit_signal(L, udx, "property::border_color", 0);
} }

View File

@ -225,8 +225,8 @@ xwindow_takefocus(xcb_window_t win)
XCB_EVENT_MASK_NO_EVENT, (char *) &ev); XCB_EVENT_MASK_NO_EVENT, (char *) &ev);
} }
/** Set wibox cursor. /** Set window cursor.
* \param w The wibox. * \param w The window.
* \param c The cursor. * \param c The cursor.
*/ */
void void
@ -236,4 +236,15 @@ xwindow_set_cursor(xcb_window_t w, xcb_cursor_t c)
(const uint32_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 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -36,6 +36,7 @@ void xwindow_set_opacity(xcb_window_t, double);
void xwindow_grabkeys(xcb_window_t, key_array_t *); void xwindow_grabkeys(xcb_window_t, key_array_t *);
void xwindow_takefocus(xcb_window_t); void xwindow_takefocus(xcb_window_t);
void xwindow_set_cursor(xcb_window_t, xcb_cursor_t); void xwindow_set_cursor(xcb_window_t, xcb_cursor_t);
void xwindow_set_border_color(xcb_window_t, xcolor_t *);
#endif #endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80