From b2ad584c7ba10d1f7cd7a94b50bf6f3f636f6561 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Mon, 25 May 2009 13:39:58 +0200 Subject: [PATCH] Add window_opacity_get_from_reply() Signed-off-by: Uli Schlachter --- window.c | 16 +++++++++++++--- window.h | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/window.c b/window.c index 5d150fa7b..1d21ec40b 100644 --- a/window.c +++ b/window.c @@ -116,6 +116,8 @@ window_buttons_grab(xcb_window_t win, button_array_t *buttons) double window_opacity_get(xcb_window_t win) { + double ret; + xcb_get_property_cookie_t prop_c = xcb_get_property_unchecked(globalconf.connection, false, win, _NET_WM_WINDOW_OPACITY, CARDINAL, 0L, 1L); @@ -123,15 +125,23 @@ window_opacity_get(xcb_window_t win) xcb_get_property_reply_t *prop_r = xcb_get_property_reply(globalconf.connection, prop_c, NULL); + ret = window_opacity_get_from_reply(prop_r); + p_delete(&prop_r); + return ret; +} + +/** Get the opacity of a window. + * \param A reply to a get property request for _NET_WM_WINDOW_OPACITY. + * \return The opacity, between 0 and 1. + */ +double window_opacity_get_from_reply(xcb_get_property_reply_t *prop_r) +{ if(prop_r && prop_r->value_len && prop_r->format == 32) { uint32_t value = *(uint32_t *) xcb_get_property_value(prop_r); - p_delete(&prop_r); return (double) value / (double) 0xffffffff; } - p_delete(&prop_r); - return -1; } diff --git a/window.h b/window.h index 093e88e78..9bd42d2eb 100644 --- a/window.h +++ b/window.h @@ -30,6 +30,7 @@ uint32_t window_state_get_reply(xcb_get_property_cookie_t); void window_configure(xcb_window_t, area_t, int); void window_buttons_grab(xcb_window_t, button_array_t *); double window_opacity_get(xcb_window_t); +double window_opacity_get_from_reply(xcb_get_property_reply_t *); void window_opacity_set(xcb_window_t, double); void window_grabbuttons(xcb_window_t, xcb_window_t, button_array_t *); void window_takefocus(xcb_window_t);