Blame SOURCES/0001-monitor-manager-xrandr-Move-dpms-state-and-screen-si.patch

657d8e
From 078547521dd709d41ac3791322f711030ccc50e9 Mon Sep 17 00:00:00 2001
657d8e
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
657d8e
Date: Wed, 27 Nov 2019 19:03:50 +0100
657d8e
Subject: [PATCH 1/2] monitor-manager-xrandr: Move dpms state and screen size
657d8e
 updating into helpers
657d8e
657d8e
To be used by no-Xrandr fallback path.
657d8e
---
657d8e
 src/backends/x11/meta-gpu-xrandr.c            | 37 +++++++++++++------
657d8e
 .../x11/meta-monitor-manager-xrandr.c         | 18 ++++++---
657d8e
 2 files changed, 38 insertions(+), 17 deletions(-)
657d8e
657d8e
diff --git a/src/backends/x11/meta-gpu-xrandr.c b/src/backends/x11/meta-gpu-xrandr.c
657d8e
index 90b33d486..1884278ca 100644
657d8e
--- a/src/backends/x11/meta-gpu-xrandr.c
657d8e
+++ b/src/backends/x11/meta-gpu-xrandr.c
657d8e
@@ -91,6 +91,30 @@ meta_gpu_xrandr_poll_hardware (MetaGpu *gpu)
657d8e
   gpu_xrandr->need_hardware_poll = TRUE;
657d8e
 }
657d8e
 
657d8e
+static void
657d8e
+update_screen_size (MetaGpuXrandr *gpu_xrandr)
657d8e
+{
657d8e
+  MetaGpu *gpu = META_GPU (gpu_xrandr);
657d8e
+  MetaMonitorManager *monitor_manager = meta_gpu_get_monitor_manager (gpu);
657d8e
+  MetaMonitorManagerXrandr *monitor_manager_xrandr =
657d8e
+    META_MONITOR_MANAGER_XRANDR (monitor_manager);
657d8e
+  Display *xdisplay =
657d8e
+    meta_monitor_manager_xrandr_get_xdisplay (monitor_manager_xrandr);
657d8e
+  int min_width, min_height;
657d8e
+  Screen *screen;
657d8e
+
657d8e
+  XRRGetScreenSizeRange (xdisplay, DefaultRootWindow (xdisplay),
657d8e
+                         &min_width,
657d8e
+                         &min_height,
657d8e
+                         &gpu_xrandr->max_screen_width,
657d8e
+                         &gpu_xrandr->max_screen_height);
657d8e
+
657d8e
+  screen = ScreenOfDisplay (xdisplay, DefaultScreen (xdisplay));
657d8e
+  /* This is updated because we called XRRUpdateConfiguration. */
657d8e
+  monitor_manager->screen_width = WidthOfScreen (screen);
657d8e
+  monitor_manager->screen_height = HeightOfScreen (screen);
657d8e
+}
657d8e
+
657d8e
 static gboolean
657d8e
 meta_gpu_xrandr_read_current (MetaGpu  *gpu,
657d8e
                               GError  **error)
657d8e
@@ -105,8 +129,6 @@ meta_gpu_xrandr_read_current (MetaGpu  *gpu,
657d8e
   RROutput primary_output;
657d8e
   unsigned int i, j;
657d8e
   GList *l;
657d8e
-  int min_width, min_height;
657d8e
-  Screen *screen;
657d8e
   GList *outputs = NULL;
657d8e
   GList *modes = NULL;
657d8e
   GList *crtcs = NULL;
657d8e
@@ -115,16 +137,7 @@ meta_gpu_xrandr_read_current (MetaGpu  *gpu,
657d8e
     XRRFreeScreenResources (gpu_xrandr->resources);
657d8e
   gpu_xrandr->resources = NULL;
657d8e
 
657d8e
-  XRRGetScreenSizeRange (xdisplay, DefaultRootWindow (xdisplay),
657d8e
-                         &min_width,
657d8e
-                         &min_height,
657d8e
-                         &gpu_xrandr->max_screen_width,
657d8e
-                         &gpu_xrandr->max_screen_height);
657d8e
-
657d8e
-  screen = ScreenOfDisplay (xdisplay, DefaultScreen (xdisplay));
657d8e
-  /* This is updated because we called XRRUpdateConfiguration. */
657d8e
-  monitor_manager->screen_width = WidthOfScreen (screen);
657d8e
-  monitor_manager->screen_height = HeightOfScreen (screen);
657d8e
+  update_screen_size (gpu_xrandr);
657d8e
 
657d8e
   if (gpu_xrandr->need_hardware_poll)
657d8e
     {
657d8e
diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c
657d8e
index b8d6342b6..7a0b43ac4 100644
657d8e
--- a/src/backends/x11/meta-monitor-manager-xrandr.c
657d8e
+++ b/src/backends/x11/meta-monitor-manager-xrandr.c
657d8e
@@ -146,12 +146,9 @@ x11_dpms_state_to_power_save (CARD16 dpms_state)
657d8e
 }
657d8e
 
657d8e
 static void
657d8e
-meta_monitor_manager_xrandr_read_current_state (MetaMonitorManager *manager)
657d8e
+meta_monitor_manager_xrandr_update_dpms_state (MetaMonitorManagerXrandr *manager_xrandr)
657d8e
 {
657d8e
-  MetaMonitorManagerXrandr *manager_xrandr =
657d8e
-    META_MONITOR_MANAGER_XRANDR (manager);
657d8e
-  MetaMonitorManagerClass *parent_class =
657d8e
-    META_MONITOR_MANAGER_CLASS (meta_monitor_manager_xrandr_parent_class);
657d8e
+  MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_xrandr);
657d8e
   Display *xdisplay = meta_monitor_manager_xrandr_get_xdisplay (manager_xrandr);
657d8e
   BOOL dpms_capable, dpms_enabled;
657d8e
   CARD16 dpms_state;
657d8e
@@ -167,6 +164,17 @@ meta_monitor_manager_xrandr_read_current_state (MetaMonitorManager *manager)
657d8e
     power_save_mode = META_POWER_SAVE_UNSUPPORTED;
657d8e
 
657d8e
   meta_monitor_manager_power_save_mode_changed (manager, power_save_mode);
657d8e
+}
657d8e
+
657d8e
+static void
657d8e
+meta_monitor_manager_xrandr_read_current_state (MetaMonitorManager *manager)
657d8e
+{
657d8e
+  MetaMonitorManagerXrandr *manager_xrandr =
657d8e
+    META_MONITOR_MANAGER_XRANDR (manager);
657d8e
+  MetaMonitorManagerClass *parent_class =
657d8e
+    META_MONITOR_MANAGER_CLASS (meta_monitor_manager_xrandr_parent_class);
657d8e
+
657d8e
+  meta_monitor_manager_xrandr_update_dpms_state (manager_xrandr);
657d8e
 
657d8e
   parent_class->read_current_state (manager);
657d8e
 }
657d8e
-- 
657d8e
2.23.0
657d8e