~3v1n0/gtk/unity-maximized-headerbar-buttons-hide

« back to all changes in this revision

Viewing changes to debian/patches/git_xrandr15_output.patch

  • Committer: Sebastien Bacher
  • Date: 2016-02-24 22:52:27 UTC
  • Revision ID: seb128@ubuntu.com-20160224225227-yo0lmj9k9o3pckvh
* New upstream version
* debian/patches/git_xrandr15_output.patch,
  debian/patches/git_assistant_margins.patch:
  - included in the new version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From 1dda932109f10d7582a8da9fd22626da835e9124 Mon Sep 17 00:00:00 2001
2
 
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
3
 
Date: Sat, 20 Feb 2016 01:31:59 +0100
4
 
Subject: X11, GdkScreen: properly implement init_randr15 including output name
5
 
 
6
 
https://bugzilla.gnome.org/show_bug.cgi?id=762319
7
 
---
8
 
 gdk/x11/gdkscreen-x11.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++---
9
 
 1 file changed, 53 insertions(+), 3 deletions(-)
10
 
 
11
 
diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
12
 
index abd3cae..2bbac70 100644
13
 
--- a/gdk/x11/gdkscreen-x11.c
14
 
+++ b/gdk/x11/gdkscreen-x11.c
15
 
@@ -621,6 +621,10 @@ init_randr15 (GdkScreen *screen)
16
 
   GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
17
 
   GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
18
 
   XRRMonitorInfo *rr_monitors;
19
 
+  XRRScreenResources *resources;
20
 
+  RROutput output;
21
 
+  RROutput first_output = None;
22
 
+  gboolean randr12_compat = FALSE;
23
 
   int num_rr_monitors;
24
 
   int i;
25
 
   GArray *monitors;
26
 
@@ -629,6 +633,11 @@ init_randr15 (GdkScreen *screen)
27
 
   if (!display_x11->have_randr15)
28
 
     return FALSE;
29
 
 
30
 
+  resources = XRRGetScreenResourcesCurrent (x11_screen->xdisplay,
31
 
+                                            x11_screen->xroot_window);
32
 
+  if (!resources)
33
 
+    return FALSE;
34
 
+
35
 
   rr_monitors = XRRGetMonitors (x11_screen->xdisplay,
36
 
                                 x11_screen->xroot_window,
37
 
                                 True,
38
 
@@ -638,8 +647,25 @@ init_randr15 (GdkScreen *screen)
39
 
 
40
 
   monitors = g_array_sized_new (FALSE, TRUE, sizeof (GdkX11Monitor),
41
 
                                 num_rr_monitors);
42
 
+
43
 
   for (i = 0; i < num_rr_monitors; i++)
44
 
     {
45
 
+      output = rr_monitors[i].outputs[0];
46
 
+      XRROutputInfo *output_info =
47
 
+        XRRGetOutputInfo (x11_screen->xdisplay, resources, output);
48
 
+
49
 
+      /* Non RandR1.2+ X driver have output name "default" */
50
 
+      randr12_compat |= !g_strcmp0 (output_info->name, "default");
51
 
+
52
 
+      if (output_info->connection == RR_Disconnected)
53
 
+        {
54
 
+          XRRFreeOutputInfo (output_info);
55
 
+          continue;
56
 
+        }
57
 
+
58
 
+      if (first_output == None)
59
 
+        first_output = output;
60
 
+
61
 
       GdkX11Monitor monitor;
62
 
       init_monitor_geometry (&monitor,
63
 
                              rr_monitors[i].x,
64
 
@@ -649,28 +675,52 @@ init_randr15 (GdkScreen *screen)
65
 
 
66
 
       monitor.width_mm = rr_monitors[i].mwidth;
67
 
       monitor.height_mm = rr_monitors[i].mheight;
68
 
-      monitor.output = rr_monitors[i].outputs[0];
69
 
+      monitor.output = output;
70
 
+      monitor.output_name = g_strndup (output_info->name, output_info->nameLen);
71
 
+
72
 
       if (rr_monitors[i].primary)
73
 
         primary_output = monitor.output;
74
 
 
75
 
       g_array_append_val (monitors, monitor);
76
 
+      XRRFreeOutputInfo (output_info);
77
 
     }
78
 
   XRRFreeMonitors (rr_monitors);
79
 
 
80
 
+  /* non RandR 1.2+ X driver doesn't return any usable multihead data */
81
 
+  if (randr12_compat)
82
 
+    {
83
 
+      guint n_monitors = monitors->len;
84
 
+
85
 
+      free_monitors ((GdkX11Monitor *)g_array_free (monitors, FALSE),
86
 
+                    n_monitors);
87
 
+      return FALSE;
88
 
+    }
89
 
+
90
 
   g_array_sort (monitors,
91
 
                 (GCompareFunc) monitor_compare_function);
92
 
   x11_screen->n_monitors = monitors->len;
93
 
   x11_screen->monitors = (GdkX11Monitor *) g_array_free (monitors, FALSE);
94
 
-
95
 
   x11_screen->primary_monitor = 0;
96
 
 
97
 
-  for (i = 0; i < x11_screen->n_monitors; i++)
98
 
+  for (i = 0; i < x11_screen->n_monitors; ++i)
99
 
     {
100
 
       if (x11_screen->monitors[i].output == primary_output)
101
 
         {
102
 
           x11_screen->primary_monitor = i;
103
 
           break;
104
 
         }
105
 
+
106
 
+      /* No RandR1.3+ available or no primary set, fall back to prefer LVDS as primary if present */
107
 
+      if (primary_output == None &&
108
 
+          g_ascii_strncasecmp (x11_screen->monitors[i].output_name, "LVDS", 4) == 0)
109
 
+        {
110
 
+          x11_screen->primary_monitor = i;
111
 
+          break;
112
 
+        }
113
 
+
114
 
+      /* No primary specified and no LVDS found */
115
 
+      if (x11_screen->monitors[i].output == first_output)
116
 
+        x11_screen->primary_monitor = i;
117
 
     }
118
 
 
119
 
   return x11_screen->n_monitors > 0;
120
 
cgit v0.12
121