summaryrefslogtreecommitdiff
path: root/src/xrandr.c
diff options
context:
space:
mode:
authorMathieu OTHACEHE <m.othacehe@gmail.com>2016-12-07 10:03:54 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2016-12-08 17:41:37 +0100
commitf7c9339d236a9742b15700457787b7f6e64fb7c4 (patch)
tree786c4c5e6f06d3cec1a25045de8930d6ecd05637 /src/xrandr.c
parent61516d64eb81d872d4e4d2a4ed50dbcb5d950557 (diff)
downloadratpoison-f7c9339d236a9742b15700457787b7f6e64fb7c4.zip
Add primary screen detection
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.
Diffstat (limited to 'src/xrandr.c')
-rw-r--r--src/xrandr.c15
1 files changed, 14 insertions, 1 deletions
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);