[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RP] [PATCH 3/7] Add primary screen detection
From: |
Mathieu OTHACEHE |
Subject: |
[RP] [PATCH 3/7] Add primary screen detection |
Date: |
Wed, 7 Dec 2016 10:03:54 +0100 |
The user may specify that a screen is primary with xrandr. Save this
information in ratpoison for future use.
The use of XRRGetOutputPrimary forces us to bump xrandr supported
revision from >=1.2 to >=1.3.
---
src/data.h | 1 +
src/xrandr.c | 15 ++++++++++++++-
src/xrandr.h | 1 +
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/data.h b/src/data.h
index eb662ce..08f1667 100644
--- a/src/data.h
+++ b/src/data.h
@@ -161,6 +161,7 @@ struct rp_global_screen
struct xrandr_info {
int output;
int crtc;
+ int primary;
struct sbuf* name;
};
diff --git a/src/xrandr.c b/src/xrandr.c
index f1f3ef5..de0cde3 100644
--- a/src/xrandr.c
+++ b/src/xrandr.c
@@ -26,7 +26,7 @@
static int xrandr_evbase;
#define XRANDR_MAJOR 1
-#define XRANDR_MINOR 2
+#define XRANDR_MINOR 3
void
init_xrandr (void)
@@ -110,12 +110,19 @@ xrandr_screen_crtc (int rr_crtc)
return NULL;
}
+int
+xrandr_is_primary (rp_screen *screen)
+{
+ return screen->xrandr.primary;
+}
+
void
xrandr_fill_screen (int rr_output, rp_screen *screen)
{
XRRScreenResources *res;
XRROutputInfo *outinfo;
XRRCrtcInfo *crtinfo;
+ RROutput primary;
res = XRRGetScreenResourcesCurrent (dpy, RootWindow (dpy, DefaultScreen
(dpy)));
outinfo = XRRGetOutputInfo (dpy, res, rr_output);
@@ -126,6 +133,12 @@ xrandr_fill_screen (int rr_output, rp_screen *screen)
if (!crtinfo)
goto free_out;
+ primary = XRRGetOutputPrimary (dpy, RootWindow (dpy, DefaultScreen (dpy)));
+ if (rr_output == primary)
+ screen->xrandr.primary = 1;
+ else
+ screen->xrandr.primary = 0;
+
screen->xrandr.name = sbuf_new (0);
sbuf_concat (screen->xrandr.name, outinfo->name);
diff --git a/src/xrandr.h b/src/xrandr.h
index d765789..25ff830 100644
--- a/src/xrandr.h
+++ b/src/xrandr.h
@@ -26,6 +26,7 @@
void init_xrandr(void);
int *xrandr_query_screen(int *screen_count);
+int xrandr_is_primary (rp_screen *screen);
void xrandr_fill_screen(int rr_output, rp_screen *screen);
void xrandr_notify(XEvent *ev);
--
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, 2016/12/07
- [RP] [PATCH 3/7] Add primary screen detection,
Mathieu OTHACEHE <=
- [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