From 0b93a6a6a886d24ffd5ebd6bcfe2c455dd415e29 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Mon, 25 May 2009 16:27:17 +0200 Subject: [PATCH] swindow: cache the opacity Signed-off-by: Uli Schlachter --- property.c | 20 ++++++++++++++++++++ swindow.c | 3 ++- swindow.h | 5 ++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/property.c b/property.c index b93cb590..206be214 100644 --- a/property.c +++ b/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 diff --git a/swindow.c b/swindow.c index d06a7066..061d680a 100644 --- a/swindow.c +++ b/swindow.c @@ -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, diff --git a/swindow.h b/swindow.h index c9db525d..74e3e678 100644 --- a/swindow.h +++ b/swindow.h @@ -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