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

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