summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);