Skip to content

Commit

Permalink
xwindow: add xwindow_set_border_color helper function
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Danjou <julien@danjou.info>
  • Loading branch information
jd committed May 28, 2010
1 parent d3c277b commit cdd888d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
3 changes: 1 addition & 2 deletions objects/client.c
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions objects/wibox.c
Expand Up @@ -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);
}
Expand Down
15 changes: 13 additions & 2 deletions xwindow.c
Expand Up @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions xwindow.h
Expand Up @@ -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

0 comments on commit cdd888d

Please sign in to comment.