[statusbar] Add fake transparency
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
f1183cc6fa
commit
fda025a591
|
@ -272,8 +272,9 @@ xutil_get_class_hint(xcb_connection_t *conn, xcb_window_t win)
|
|||
|
||||
class_hint_r = xcb_get_property_reply(conn, class_hint_c, NULL);
|
||||
|
||||
if(!class_hint_r || class_hint_r->type != STRING ||
|
||||
class_hint_r->format != 8)
|
||||
if(!class_hint_r
|
||||
|| class_hint_r->type != STRING
|
||||
|| class_hint_r->format != 8)
|
||||
{
|
||||
p_delete(&class_hint_r);
|
||||
return NULL;
|
||||
|
|
52
statusbar.c
52
statusbar.c
|
@ -42,9 +42,23 @@ extern bool running;
|
|||
static void
|
||||
statusbar_draw(statusbar_t *statusbar)
|
||||
{
|
||||
xcb_window_t rootwin;
|
||||
xcb_pixmap_t rootpix;
|
||||
widget_node_t *w;
|
||||
int left = 0, right = 0;
|
||||
char *data;
|
||||
xcb_get_property_reply_t *prop_r;
|
||||
xcb_get_property_cookie_t prop_c;
|
||||
area_t rectangle = { 0, 0, 0, 0, NULL, NULL };
|
||||
xcb_atom_t rootpix_atom, pixmap_atom;
|
||||
xutil_intern_atom_request_t rootpix_atom_req, pixmap_atom_req;
|
||||
|
||||
/* Send requests needed for transparency */
|
||||
if(statusbar->transparency)
|
||||
{
|
||||
pixmap_atom_req = xutil_intern_atom(globalconf.connection, &globalconf.atoms, "PIXMAP");
|
||||
rootpix_atom_req = xutil_intern_atom(globalconf.connection, &globalconf.atoms, "_XROOTPMAP_ID");
|
||||
}
|
||||
|
||||
statusbar->need_update.value = false;
|
||||
|
||||
|
@ -53,6 +67,31 @@ statusbar_draw(statusbar_t *statusbar)
|
|||
|
||||
rectangle.width = statusbar->width;
|
||||
rectangle.height = statusbar->height;
|
||||
|
||||
if(statusbar->transparency)
|
||||
{
|
||||
rootwin = xcb_aux_get_screen(globalconf.connection, statusbar->phys_screen)->root;
|
||||
pixmap_atom = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, pixmap_atom_req);
|
||||
rootpix_atom = xutil_intern_atom_reply(globalconf.connection, &globalconf.atoms, rootpix_atom_req);
|
||||
prop_c = xcb_get_property_unchecked(globalconf.connection, false, rootwin, rootpix_atom,
|
||||
pixmap_atom, 0, 1);
|
||||
if((prop_r = xcb_get_property_reply(globalconf.connection, prop_c, NULL)))
|
||||
{
|
||||
if((data = xcb_get_property_value(prop_r)))
|
||||
{
|
||||
rootpix = *(xcb_pixmap_t *) data;
|
||||
printf("data %d\n", rootpix);
|
||||
xcb_copy_area(globalconf.connection, rootpix,
|
||||
statusbar->sw->drawable, statusbar->sw->gc,
|
||||
statusbar->sw->geometry.x, statusbar->sw->geometry.y,
|
||||
0, 0,
|
||||
statusbar->sw->geometry.width,
|
||||
statusbar->sw->geometry.height);
|
||||
}
|
||||
p_delete(&prop_r);
|
||||
}
|
||||
}
|
||||
else
|
||||
draw_rectangle(statusbar->ctx, rectangle, 1.0, true,
|
||||
statusbar->colors.bg);
|
||||
|
||||
|
@ -526,6 +565,18 @@ luaA_statusbar_new(lua_State *L)
|
|||
return luaA_settype(L, "statusbar");
|
||||
}
|
||||
|
||||
/** Set statusbar transparency.
|
||||
* \param A boolean value, true to enable, false to disable.
|
||||
*/
|
||||
static int
|
||||
luaA_statusbar_transparency_set(lua_State *L)
|
||||
{
|
||||
statusbar_t **sb = luaL_checkudata(L, 1, "statusbar");
|
||||
(*sb)->transparency = luaA_checkboolean(L, 2);
|
||||
statusbar_needupdate(*sb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Handle statusbar garbage collection.
|
||||
*/
|
||||
static int
|
||||
|
@ -549,6 +600,7 @@ const struct luaL_reg awesome_statusbar_meta[] =
|
|||
{ "align_set", luaA_statusbar_align_set },
|
||||
{ "add", luaA_statusbar_add },
|
||||
{ "remove", luaA_statusbar_remove },
|
||||
{ "transparency_set", luaA_statusbar_transparency_set },
|
||||
{ "__gc", luaA_statusbar_gc },
|
||||
{ "__eq", luaA_statusbar_eq },
|
||||
{ "__tostring", luaA_statusbar_tostring },
|
||||
|
|
|
@ -213,6 +213,8 @@ struct statusbar_t
|
|||
widget_node_t *widgets;
|
||||
/** Draw context */
|
||||
draw_context_t *ctx;
|
||||
/** Transparency */
|
||||
bool transparency;
|
||||
/** Need update */
|
||||
struct
|
||||
{
|
||||
|
|
|
@ -113,6 +113,7 @@ tasklist_draw(widget_node_t *w, statusbar_t *statusbar, int offset, int used)
|
|||
area.height = statusbar->height;
|
||||
area.width = box_width;
|
||||
|
||||
if(!statusbar->transparency)
|
||||
draw_rectangle(statusbar->ctx, area, 1.0, true,
|
||||
statusbar->colors.bg);
|
||||
|
||||
|
|
Loading…
Reference in New Issue