Blame SOURCES/0001-gpu-xrandr-Move-dpms-state-and-screen-size-updating-.patch

ff08c5
From 8566bac05088708635e505709be656755f2849a0 Mon Sep 17 00:00:00 2001
ff08c5
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
ff08c5
Date: Wed, 3 Oct 2018 10:50:07 +0200
ff08c5
Subject: [PATCH 1/2] gpu/xrandr: Move dpms state and screen size updating into
ff08c5
 helpers
ff08c5
ff08c5
To be used by no-Xrandr fallback path.
ff08c5
---
ff08c5
 src/backends/x11/meta-gpu-xrandr.c | 70 ++++++++++++++++++++----------
ff08c5
 1 file changed, 46 insertions(+), 24 deletions(-)
ff08c5
ff08c5
diff --git a/src/backends/x11/meta-gpu-xrandr.c b/src/backends/x11/meta-gpu-xrandr.c
ff08c5
index add80c0d2..a4e187a49 100644
ff08c5
--- a/src/backends/x11/meta-gpu-xrandr.c
ff08c5
+++ b/src/backends/x11/meta-gpu-xrandr.c
ff08c5
@@ -91,31 +91,15 @@ meta_gpu_xrandr_poll_hardware (MetaGpu *gpu)
ff08c5
   gpu_xrandr->need_hardware_poll = TRUE;
ff08c5
 }
ff08c5
 
ff08c5
-static gboolean
ff08c5
-meta_gpu_xrandr_read_current (MetaGpu  *gpu,
ff08c5
-                              GError  **error)
ff08c5
+static void
ff08c5
+update_dpms_state (MetaMonitorManagerXrandr *monitor_manager_xrandr)
ff08c5
 {
ff08c5
-  MetaGpuXrandr *gpu_xrandr = META_GPU_XRANDR (gpu);
ff08c5
-  MetaMonitorManager *monitor_manager = meta_gpu_get_monitor_manager (gpu);
ff08c5
-  MetaMonitorManagerXrandr *monitor_manager_xrandr =
ff08c5
-    META_MONITOR_MANAGER_XRANDR (monitor_manager);
ff08c5
+  MetaMonitorManager *monitor_manager =
ff08c5
+    META_MONITOR_MANAGER (monitor_manager_xrandr);
ff08c5
   Display *xdisplay =
ff08c5
     meta_monitor_manager_xrandr_get_xdisplay (monitor_manager_xrandr);
ff08c5
-  XRRScreenResources *resources;
ff08c5
-  RROutput primary_output;
ff08c5
-  unsigned int i, j;
ff08c5
-  GList *l;
ff08c5
-  int min_width, min_height;
ff08c5
-  Screen *screen;
ff08c5
   BOOL dpms_capable, dpms_enabled;
ff08c5
   CARD16 dpms_state;
ff08c5
-  GList *outputs = NULL;
ff08c5
-  GList *modes = NULL;
ff08c5
-  GList *crtcs = NULL;
ff08c5
-
ff08c5
-  if (gpu_xrandr->resources)
ff08c5
-    XRRFreeScreenResources (gpu_xrandr->resources);
ff08c5
-  gpu_xrandr->resources = NULL;
ff08c5
 
ff08c5
   dpms_capable = DPMSCapable (xdisplay);
ff08c5
 
ff08c5
@@ -146,6 +130,47 @@ meta_gpu_xrandr_read_current (MetaGpu  *gpu,
ff08c5
     {
ff08c5
       monitor_manager->power_save_mode = META_POWER_SAVE_UNSUPPORTED;
ff08c5
     }
ff08c5
+}
ff08c5
+
ff08c5
+static void
ff08c5
+update_screen_size (MetaMonitorManagerXrandr *monitor_manager_xrandr)
ff08c5
+{
ff08c5
+  MetaMonitorManager *monitor_manager =
ff08c5
+    META_MONITOR_MANAGER (monitor_manager_xrandr);
ff08c5
+  Display *xdisplay =
ff08c5
+    meta_monitor_manager_xrandr_get_xdisplay (monitor_manager_xrandr);
ff08c5
+  Screen *screen;
ff08c5
+
ff08c5
+  screen = ScreenOfDisplay (xdisplay, DefaultScreen (xdisplay));
ff08c5
+
ff08c5
+  monitor_manager->screen_width = WidthOfScreen (screen);
ff08c5
+  monitor_manager->screen_height = HeightOfScreen (screen);
ff08c5
+}
ff08c5
+
ff08c5
+static gboolean
ff08c5
+meta_gpu_xrandr_read_current (MetaGpu  *gpu,
ff08c5
+                              GError  **error)
ff08c5
+{
ff08c5
+  MetaGpuXrandr *gpu_xrandr = META_GPU_XRANDR (gpu);
ff08c5
+  MetaMonitorManager *monitor_manager = meta_gpu_get_monitor_manager (gpu);
ff08c5
+  MetaMonitorManagerXrandr *monitor_manager_xrandr =
ff08c5
+    META_MONITOR_MANAGER_XRANDR (monitor_manager);
ff08c5
+  Display *xdisplay =
ff08c5
+    meta_monitor_manager_xrandr_get_xdisplay (monitor_manager_xrandr);
ff08c5
+  XRRScreenResources *resources;
ff08c5
+  RROutput primary_output;
ff08c5
+  unsigned int i, j;
ff08c5
+  GList *l;
ff08c5
+  int min_width, min_height;
ff08c5
+  GList *outputs = NULL;
ff08c5
+  GList *modes = NULL;
ff08c5
+  GList *crtcs = NULL;
ff08c5
+
ff08c5
+  if (gpu_xrandr->resources)
ff08c5
+    XRRFreeScreenResources (gpu_xrandr->resources);
ff08c5
+  gpu_xrandr->resources = NULL;
ff08c5
+
ff08c5
+  update_dpms_state (monitor_manager_xrandr);
ff08c5
 
ff08c5
   XRRGetScreenSizeRange (xdisplay, DefaultRootWindow (xdisplay),
ff08c5
                          &min_width,
ff08c5
@@ -153,10 +178,7 @@ meta_gpu_xrandr_read_current (MetaGpu  *gpu,
ff08c5
                          &gpu_xrandr->max_screen_width,
ff08c5
                          &gpu_xrandr->max_screen_height);
ff08c5
 
ff08c5
-  screen = ScreenOfDisplay (xdisplay, DefaultScreen (xdisplay));
ff08c5
-  /* This is updated because we called XRRUpdateConfiguration. */
ff08c5
-  monitor_manager->screen_width = WidthOfScreen (screen);
ff08c5
-  monitor_manager->screen_height = HeightOfScreen (screen);
ff08c5
+  update_screen_size (monitor_manager_xrandr);
ff08c5
 
ff08c5
   if (gpu_xrandr->need_hardware_poll)
ff08c5
     {
ff08c5
-- 
ff08c5
2.21.0
ff08c5