summaryrefslogtreecommitdiffstats
path: root/compton.h
diff options
context:
space:
mode:
authorRichard Grenville <[email protected]>2012-09-13 21:38:55 +0800
committerRichard Grenville <[email protected]>2012-09-13 21:38:55 +0800
commit3a0ba85d3b5872221d21891be06bf3c8dfabd851 (patch)
treed0d709c38e7b51c50f07a38b89bf591ec843a587 /compton.h
parenta447b5d3101398af1b85cd6eed81b0676982032a (diff)
downloadtdebase-3a0ba85d3b5872221d21891be06bf3c8dfabd851.tar.gz
tdebase-3a0ba85d3b5872221d21891be06bf3c8dfabd851.zip
Improvement: Use find_toplevel() to find WM frame
Use find_toplevel() to find out the WM frame of a client window. I didn't noticed it beforehand. Fallback to the old method as compton does not always get correct client windows. - Clean up find_client_win() a bit. A BFS search algorithm could be more optimal yet it requires a queue implementation.
Diffstat (limited to 'compton.h')
-rw-r--r--compton.h51
1 files changed, 49 insertions, 2 deletions
diff --git a/compton.h b/compton.h
index 9a8dd8506..c85992bb5 100644
--- a/compton.h
+++ b/compton.h
@@ -144,6 +144,7 @@ typedef struct _fade {
} fade;
extern int root_height, root_width;
+extern Atom atom_client_attr;
/**
* Functions
@@ -249,6 +250,51 @@ static inline void print_timestamp(void) {
}
#endif
+/**
+ * Determine if a window has a specific attribute.
+ *
+ * @param dpy Display to use
+ * @param w window to check
+ * @param atom atom of attribute to check
+ * @return 1 if it has the attribute, 0 otherwise
+ */
+static inline Bool win_has_attr(Display *dpy, Window w, Atom atom) {
+ Atom type = None;
+ int format;
+ unsigned long nitems, after;
+ unsigned char *data;
+
+ if (Success == XGetWindowProperty(dpy, w, atom, 0, 0, False,
+ AnyPropertyType, &type, &format, &nitems, &after, &data)) {
+ XFree(data);
+ if (type)
+ return True;
+ }
+
+ return False;
+}
+
+/**
+ * Get the children of a window.
+ *
+ * @param dpy Display to use
+ * @param w window to check
+ * @param children [out] an array of child window IDs
+ * @param nchildren [out] number of children
+ * @return 1 if successful, 0 otherwise
+ */
+static inline Bool win_get_children(Display *dpy, Window w,
+ Window **children, unsigned *nchildren) {
+ Window troot, tparent;
+
+ if (!XQueryTree(dpy, w, &troot, &tparent, children, nchildren)) {
+ *nchildren = 0;
+ return False;
+ }
+
+ return True;
+}
+
static int
get_time_in_milliseconds();
@@ -328,8 +374,9 @@ win_extents(Display *dpy, win *w);
static XserverRegion
border_size(Display *dpy, win *w);
-static Window
-find_client_win(Display *dpy, Window win);
+Window find_client_win(Display *dpy, Window w);
+
+Window find_client_win2(Display *dpy, Window w);
static void
get_frame_extents(Display *dpy, Window w,