summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu OTHACEHE <m.othacehe@gmail.com>2016-12-07 10:03:56 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2016-12-08 17:46:51 +0100
commitd8fab39242f683f84027402d8b174ff68a581811 (patch)
tree1ee1521c8550eb601de4e557cce54d29984eedf6
parentf7c9339d236a9742b15700457787b7f6e64fb7c4 (diff)
downloadratpoison-d8fab39242f683f84027402d8b174ff68a581811.zip
Add a function to find a screen matching a given XWindowAttributes
It allows to find the screen associated to a Window, using it's x and y position.
-rw-r--r--src/screen.c18
-rw-r--r--src/screen.h2
2 files changed, 20 insertions, 0 deletions
diff --git a/src/screen.c b/src/screen.c
index b9bb696..7bbc133 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -165,6 +165,24 @@ find_screen (Window w)
return NULL;
}
+/* Given a window attr, return the rp_screen struct */
+rp_screen *
+find_screen_by_attr (XWindowAttributes attr)
+{
+ rp_screen *cur;
+
+ list_for_each_entry (cur, &rp_screens, node)
+ {
+ if (attr.x >= cur->left &&
+ attr.x <= cur->left + cur->width &&
+ attr.y >= cur->top &&
+ attr.y <= cur->top + cur->height)
+ return cur;
+ }
+
+ return NULL;
+}
+
/* Return 1 if w is a root window of any of the screens. */
int
is_a_root_window (unsigned int w)
diff --git a/src/screen.h b/src/screen.h
index 67d8ab4..69bc032 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -36,6 +36,8 @@ rp_frame *screen_get_frame (rp_screen *s, int frame_num);
rp_frame *screen_find_frame_by_frame (rp_screen *s, rp_frame *f);
rp_screen *find_screen (Window w);
+rp_screen *find_screen_by_attr (XWindowAttributes w);
+
void init_screens (void);
void activate_screen (rp_screen *s);
void deactivate_screen (rp_screen *s);