[mutter] crtc-xrandr: Respect configured RANDR panning



commit 0462208d4e27a763f1ce3548597d7fadbc309d7f
Author: Jonas Ådahl <jadahl gmail com>
Date:   Mon Feb 24 17:37:34 2020 +0100

    crtc-xrandr: Respect configured RANDR panning
    
    A user may have configured an output to be panning, e.g. using xrandr
    --output <output> --mode <mode> --panning <size>. Respect this by making
    the logical monitor use the panning size, instead of the mode. This
    makes e.g. makes the background cover the whole panning size, and panels
    etc will cover the whole top of the panned area, instead of just the top
    left part covering the monitor if having panned to (0, 0).
    
    No support is added to configuring panning, i.e. a panned monitor
    configuration cannot be stored in monitors.xml.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/1085

 src/backends/x11/meta-crtc-xrandr.c | 36 ++++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)
---
diff --git a/src/backends/x11/meta-crtc-xrandr.c b/src/backends/x11/meta-crtc-xrandr.c
index 678e68a9b..89115ca52 100644
--- a/src/backends/x11/meta-crtc-xrandr.c
+++ b/src/backends/x11/meta-crtc-xrandr.c
@@ -234,20 +234,23 @@ meta_create_xrandr_crtc (MetaGpuXrandr      *gpu_xrandr,
                          RRCrtc              crtc_id,
                          XRRScreenResources *resources)
 {
+  MetaGpu *gpu = META_GPU (gpu_xrandr);
+  MetaBackend *backend = meta_gpu_get_backend (gpu);
+  MetaMonitorManager *monitor_manager =
+    meta_backend_get_monitor_manager (backend);
+  MetaMonitorManagerXrandr *monitor_manager_xrandr =
+    META_MONITOR_MANAGER_XRANDR (monitor_manager);
+  Display *xdisplay =
+    meta_monitor_manager_xrandr_get_xdisplay (monitor_manager_xrandr);
   MetaCrtc *crtc;
   MetaCrtcXrandr *crtc_xrandr;
+  XRRPanning *panning;
   unsigned int i;
   GList *modes;
 
   crtc = g_object_new (META_TYPE_CRTC, NULL);
 
   crtc_xrandr = g_new0 (MetaCrtcXrandr, 1);
-  crtc_xrandr->rect = (MetaRectangle) {
-    .x = xrandr_crtc->x,
-    .y = xrandr_crtc->y,
-    .width = xrandr_crtc->width,
-    .height = xrandr_crtc->height,
-  };
   crtc_xrandr->transform =
     meta_monitor_transform_from_xrandr (xrandr_crtc->rotation);
 
@@ -255,6 +258,27 @@ meta_create_xrandr_crtc (MetaGpuXrandr      *gpu_xrandr,
   crtc->driver_notify = (GDestroyNotify) meta_crtc_destroy_notify;
   crtc->gpu = META_GPU (gpu_xrandr);
   crtc->crtc_id = crtc_id;
+
+  panning = XRRGetPanning (xdisplay, resources, crtc_id);
+  if (panning && panning->width > 0 && panning->height > 0)
+    {
+      crtc_xrandr->rect = (MetaRectangle) {
+        .x = panning->left,
+        .y = panning->top,
+        .width = panning->width,
+        .height = panning->height,
+      };
+    }
+  else
+    {
+      crtc_xrandr->rect = (MetaRectangle) {
+        .x = xrandr_crtc->x,
+        .y = xrandr_crtc->y,
+        .width = xrandr_crtc->width,
+        .height = xrandr_crtc->height,
+      };
+    }
+
   crtc->is_dirty = FALSE;
   crtc->all_transforms =
     meta_monitor_transform_from_xrandr_all (xrandr_crtc->rotations);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]