swindow: cache the opacity
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
b2ad584c7b
commit
0b93a6a6a8
20
property.c
20
property.c
|
@ -28,6 +28,7 @@
|
|||
#include "wibox.h"
|
||||
#include "common/atoms.h"
|
||||
#include "common/xutil.h"
|
||||
#include "window.h"
|
||||
|
||||
void
|
||||
property_update_wm_transient_for(client_t *c, xcb_get_property_reply_t *reply)
|
||||
|
@ -405,6 +406,21 @@ property_handle_xrootpmap_id(void *data __attribute__ ((unused)),
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
property_handle_opacity(void *data __attribute__ ((unused)),
|
||||
xcb_connection_t *connection,
|
||||
uint8_t state,
|
||||
xcb_window_t window,
|
||||
xcb_atom_t name,
|
||||
xcb_get_property_reply_t *reply)
|
||||
{
|
||||
wibox_t *wibox = wibox_getbywin(window);
|
||||
|
||||
if (wibox)
|
||||
wibox->sw.opacity = window_opacity_get_from_reply(reply);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void a_xcb_set_property_handlers(void)
|
||||
{
|
||||
/* init */
|
||||
|
@ -443,6 +459,10 @@ void a_xcb_set_property_handlers(void)
|
|||
/* background change */
|
||||
xcb_property_set_handler(&globalconf.prophs, _XROOTPMAP_ID, 1,
|
||||
property_handle_xrootpmap_id, NULL);
|
||||
|
||||
/* Opacity */
|
||||
xcb_property_set_handler(&globalconf.prophs, _NET_WM_WINDOW_OPACITY, 1,
|
||||
property_handle_opacity, NULL);
|
||||
}
|
||||
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
|
@ -106,7 +106,8 @@ simplewindow_init(simple_window_t *sw,
|
|||
| XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_ENTER_WINDOW
|
||||
| XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_STRUCTURE_NOTIFY
|
||||
| XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE
|
||||
| XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE;
|
||||
| XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE
|
||||
| XCB_EVENT_MASK_PROPERTY_CHANGE;
|
||||
|
||||
sw->window = xcb_generate_id(globalconf.connection);
|
||||
xcb_create_window(globalconf.connection, s->root_depth, sw->window, s->root,
|
||||
|
|
|
@ -53,6 +53,8 @@ typedef struct simple_window_t
|
|||
draw_context_t ctx;
|
||||
/** Orientation */
|
||||
orientation_t orientation;
|
||||
/** Opacity */
|
||||
double opacity;
|
||||
} simple_window_t;
|
||||
|
||||
void simplewindow_init(simple_window_t *s,
|
||||
|
@ -85,6 +87,7 @@ simplewindow_refresh_pixmap(simple_window_t *sw)
|
|||
static inline void
|
||||
simplewindow_opacity_set(simple_window_t *sw, double opacity)
|
||||
{
|
||||
sw->opacity = opacity;
|
||||
window_opacity_set(sw->window, opacity);
|
||||
}
|
||||
|
||||
|
@ -94,7 +97,7 @@ simplewindow_opacity_set(simple_window_t *sw, double opacity)
|
|||
static inline double
|
||||
simplewindow_opacity_get(simple_window_t *sw)
|
||||
{
|
||||
return window_opacity_get(sw->window);
|
||||
return sw->opacity;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue