summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2012-11-01 14:40:57 +0000
committerJon TURNEY <jon.turney@dronecode.org.uk>2012-11-21 14:02:37 +0000
commit5454711a0365522e44c5ad6258e9319898b2c1fc (patch)
tree7b3241319521caddfb2281c7c98de5c38526e832
parentd20bbf60b5e0bbc6486d74b4648b3bcd578159a5 (diff)
Add xcwm_window_get_opacity()
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
-rw-r--r--include/xcwm/window.h9
-rw-r--r--src/libxcwm/atoms.c33
-rw-r--r--src/libxcwm/window.c7
-rw-r--r--src/libxcwm/xcwm_internal.h1
4 files changed, 47 insertions, 3 deletions
diff --git a/include/xcwm/window.h b/include/xcwm/window.h
index b510571..ad28790 100644
--- a/include/xcwm/window.h
+++ b/include/xcwm/window.h
@@ -104,6 +104,7 @@ struct xcwm_window_t {
int override_redirect;
int initial_damage; /* Set to 1 for override-redirect windows */
void *local_data; /* Area for data client cares about */
+ unsigned int opacity;
};
/**
@@ -268,4 +269,12 @@ xcwm_window_iconify(xcwm_window_t *window);
void
xcwm_window_deiconify(xcwm_window_t *window);
+/**
+ * Get the opacity for the window.
+ * @param window The window to get opacity data for.
+ * @return The window opacity, in the range 0 (transparent) to 0xFFFFFFFF (opaque)
+ */
+unsigned int
+xcwm_window_get_opacity(xcwm_window_t const *window);
+
#endif /* _XCWM_WINDOW_H_ */
diff --git a/src/libxcwm/atoms.c b/src/libxcwm/atoms.c
index dac552a..45542dc 100644
--- a/src/libxcwm/atoms.c
+++ b/src/libxcwm/atoms.c
@@ -51,9 +51,12 @@ static void
setup_window_type(xcwm_window_t *window);
/* Get and set the size hints for the window */
-void
+static void
set_window_size_hints(xcwm_window_t *window);
+/* Get opacity hint */
+static void
+set_window_opacity(xcwm_window_t *window);
static xcb_atom_t
_xcwm_atom_get(xcwm_context_t *context, const char *atomName)
@@ -137,12 +140,14 @@ _xcwm_atoms_init(xcwm_context_t *context)
if (!check_wm_cm_owner(context)) {
return XCB_WINDOW;
}
+ create_wm_cm_window(context);
/* WM_STATE atom */
context->atoms->wm_state_atom = _xcwm_atom_get(context, "WM_STATE");
- create_wm_cm_window(context);
-
+ /* NET_WM_OPACITY */
+ context->atoms->wm_opacity_atom = _xcwm_atom_get(context, "_NET_WM_WINDOW_OPACITY");
+
return 0;
}
@@ -197,6 +202,7 @@ _xcwm_atoms_init_window(xcwm_window_t *window)
_xcwm_atoms_set_wm_delete(window);
setup_window_type(window);
set_window_size_hints(window);
+ set_window_opacity(window);
}
@@ -352,6 +358,27 @@ set_window_size_hints(xcwm_window_t *window)
}
void
+set_window_opacity(xcwm_window_t *window)
+{
+ xcb_get_property_cookie_t cookie;
+ cookie = xcb_get_property(window->context->conn, 0, window->window_id, window->context->atoms->wm_opacity_atom, XCB_ATOM_CARDINAL, 0L, 4L);
+
+ xcb_get_property_reply_t *reply = xcb_get_property_reply(window->context->conn, cookie, NULL);
+ if (reply)
+ {
+ int nitems = xcb_get_property_value_length(reply);
+ uint32_t *value = xcb_get_property_value(reply);
+
+ if (value && nitems == 4)
+ {
+ window->opacity = *value;
+ }
+
+ free(reply);
+ }
+}
+
+void
_xcwm_atoms_set_wm_state(xcwm_window_t *window, xcwm_window_state_t state)
{
/* xcb_icccm_wm_state_t icccm_state; */
diff --git a/src/libxcwm/window.c b/src/libxcwm/window.c
index 7a2aaeb..eaa38ce 100644
--- a/src/libxcwm/window.c
+++ b/src/libxcwm/window.c
@@ -127,6 +127,7 @@ _xcwm_window_create(xcwm_context_t *context, xcb_window_t new_window,
window->bounds->y = geom->y;
window->bounds->width = geom->width;
window->bounds->height = geom->height;
+ window->opacity = ~0;
/* Find an set the parent */
window->parent = _xcwm_get_window_node_by_window_id(parent);
@@ -368,6 +369,12 @@ xcwm_window_copy_name(xcwm_window_t const *window)
return strdup(window->name);
}
+unsigned int
+xcwm_window_get_opacity(xcwm_window_t const *window)
+{
+ return window->opacity;
+}
+
xcwm_window_sizing_t const *
xcwm_window_get_sizing(xcwm_window_t const *window)
{
diff --git a/src/libxcwm/xcwm_internal.h b/src/libxcwm/xcwm_internal.h
index 11858f6..1a3716f 100644
--- a/src/libxcwm/xcwm_internal.h
+++ b/src/libxcwm/xcwm_internal.h
@@ -56,6 +56,7 @@ struct xcwm_wm_atoms_t {
xcb_atom_t wm_name_atom;
xcb_atom_t wm_state_atom;
xcb_ewmh_connection_t ewmh_conn;
+ xcb_atom_t wm_opacity_atom;
};
/**