It allows to find the screen associated to a Window, using it's x and y position. --- src/screen.c | 18 ++++++++++++++++++ src/screen.h | 2 ++ 2 files changed, 20 insertions(+)
diff --git a/src/screen.c b/src/screen.c index 0d45701..811a947 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); -- 2.10.0 _______________________________________________ Ratpoison-devel mailing list Ratpoison-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/ratpoison-devel