summaryrefslogtreecommitdiff
blob: 55fb423bb498cb0ef9d229daa2e804e14dfdcd49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Description: fix XRandr use
Author: Guillem Jover <guillem@debian.org>

--- a/src/platform/C4AppGTK.cpp
+++ b/src/platform/C4AppGTK.cpp
@@ -212,20 +212,25 @@ static XRROutputInfo* GetXRROutputInfoFo
 	XRRScreenResources * r = XRRGetScreenResources(dpy, w);
 	if (!r) return NULL;
 
-	XRROutputInfo * info = XRRGetOutputInfo(dpy, r, XRRGetOutputPrimary(dpy, w));
-	if (!info)
+	XRROutputInfo * info;
+	RROutput primary = XRRGetOutputPrimary(dpy, w);
+	if (primary == None)
+		info = NULL;
+	else
 	{
-		XRRFreeScreenResources(r);
-		return NULL;
+		info = XRRGetOutputInfo(dpy, r, primary);
+		if (info->connection == RR_Disconnected || info->crtc == 0)
+		{
+			XRRFreeOutputInfo(info);
+			info = NULL;
+		}
 	}
 
-	if(info->connection == RR_Disconnected || info->crtc == 0)
+	if (info == NULL)
 	{
 		// The default "primary" output does not seem to be connected
 		// to a piece of actual hardware. As a fallback, go through
 		// all outputs and choose the first active one.
-		XRRFreeOutputInfo(info);
-		info = NULL;
 		for(int i = 0; i < r->noutput; ++i)
 		{
 			info = XRRGetOutputInfo(dpy, r, r->outputs[i]);