[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RP] [PATCH 5/7] Add a function to find a screen matching a given XWindo
From: |
Mathieu OTHACEHE |
Subject: |
[RP] [PATCH 5/7] Add a function to find a screen matching a given XWindowAttributes |
Date: |
Wed, 7 Dec 2016 10:03:56 +0100 |
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
- [RP] [PATCH 0/7] Add xrandr primary screen support, Mathieu OTHACEHE, 2016/12/07
- [RP] [PATCH 2/7] Move function declaration to the right header, Mathieu OTHACEHE, 2016/12/07
- [RP] [PATCH 1/7] Remove useless argument from is_rp_window_for_screen function, Mathieu OTHACEHE, 2016/12/07
- [RP] [PATCH 4/7] Store RootWindow in global_screen structure, Mathieu OTHACEHE, 2016/12/07
- [RP] [PATCH 5/7] Add a function to find a screen matching a given XWindowAttributes,
Mathieu OTHACEHE <=
- [RP] [PATCH 3/7] Add primary screen detection, Mathieu OTHACEHE, 2016/12/07
- [RP] [PATCH 7/7] Select xrandr primary screen at startup if possible, Mathieu OTHACEHE, 2016/12/07
- [RP] [PATCH 6/7] Simplify scanwins function, Mathieu OTHACEHE, 2016/12/07
- Re: [RP] [PATCH 0/7] Add xrandr primary screen support, Jeremie Courreges-Anglas, 2016/12/09