[mutter/gbsneto/underscan: 296/299] output-xrandr: Support different values for underscan atom



commit 803b460538d13417c3aff9f00527c3589292c177
Author: Cosimo Cecchi <cosimo endlessm com>
Date:   Thu Apr 14 18:51:25 2016 -0700

    output-xrandr: Support different values for underscan atom
    
    Some driver implementation may use a different value. For example, the
    Intel driver shipped with Endless uses "crop" to trigger a behavior
    that would not be compatible with the definition of what "on" means.
    
    This commit just adds infrastructure for a modular value, but does not
    actually add support for any other value.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767804
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/549

 src/backends/x11/meta-output-xrandr.c | 49 ++++++++++++++++++++++++++++++-----
 1 file changed, 42 insertions(+), 7 deletions(-)
---
diff --git a/src/backends/x11/meta-output-xrandr.c b/src/backends/x11/meta-output-xrandr.c
index 42f22d1ae..34fb7218e 100644
--- a/src/backends/x11/meta-output-xrandr.c
+++ b/src/backends/x11/meta-output-xrandr.c
@@ -46,6 +46,22 @@
 #include "backends/x11/meta-monitor-manager-xrandr.h"
 #include "meta/util.h"
 
+typedef struct
+{
+  char *underscan_value;
+} MetaOutputXrandr;
+
+static void
+meta_output_xrandr_destroy_notify (MetaOutput *output)
+{
+  MetaOutputXrandr *output_xrandr;
+
+  output_xrandr = output->driver_private;
+  g_clear_pointer (&output_xrandr->underscan_value, g_free);
+
+  g_slice_free (MetaOutputXrandr, output_xrandr);
+}
+
 static Display *
 xdisplay_from_output (MetaOutput *output)
 {
@@ -80,15 +96,20 @@ static void
 output_set_underscanning_xrandr (MetaOutput *output,
                                  gboolean    underscanning)
 {
+  MetaOutputXrandr *output_xrandr = output->driver_private;
   Display *xdisplay = xdisplay_from_output (output);
   Atom prop, valueatom;
   const char *value;
 
-  prop = XInternAtom (xdisplay, "underscan", False);
+  if (underscanning)
+    value = output_xrandr->underscan_value;
+  else
+    value = "off";
 
-  value = underscanning ? "on" : "off";
   valueatom = XInternAtom (xdisplay, value, False);
 
+  prop = XInternAtom (xdisplay, "underscan", False);
+
   xcb_randr_change_output_property (XGetXCBConnection (xdisplay),
                                     (XID) output->winsys_id,
                                     prop, XCB_ATOM_ATOM, 32,
@@ -260,6 +281,7 @@ output_get_presentation_xrandr (MetaOutput *output)
 static gboolean
 output_get_underscanning_xrandr (MetaOutput *output)
 {
+  MetaOutputXrandr *output_xrandr = output->driver_private;
   Display *xdisplay = xdisplay_from_output (output);
   Atom atom, actual_type;
   int actual_format;
@@ -279,11 +301,12 @@ output_get_underscanning_xrandr (MetaOutput *output)
     return FALSE;
 
   str = XGetAtomName (xdisplay, *(Atom *)buffer);
-  return (strcmp (str, "on") == 0);
+  return g_strcmp0 (str, output_xrandr->underscan_value) == 0;
 }
 
 static gboolean
-output_get_supports_underscanning_xrandr (MetaOutput *output)
+output_get_supports_underscanning_xrandr (MetaOutput  *output,
+                                          char       **underscan_value)
 {
   Display *xdisplay = xdisplay_from_output (output);
   Atom atom, actual_type;
@@ -317,9 +340,16 @@ output_get_supports_underscanning_xrandr (MetaOutput *output)
        */
       char *name = XGetAtomName (xdisplay, values[i]);
       if (strcmp (name, "on") == 0)
-        supports_underscanning = TRUE;
+        {
+          supports_underscanning = TRUE;
+          if (underscan_value)
+            *underscan_value = g_strdup (name);
+        }
 
       XFree (name);
+
+      if (supports_underscanning)
+        break;
     }
 
   XFree (property_info);
@@ -764,6 +794,7 @@ meta_create_xrandr_output (MetaGpuXrandr *gpu_xrandr,
                            RROutput       output_id,
                            RROutput       primary_output)
 {
+  MetaOutputXrandr *output_xrandr;
   MetaOutput *output;
   GBytes *edid;
   unsigned int i;
@@ -773,6 +804,10 @@ meta_create_xrandr_output (MetaGpuXrandr *gpu_xrandr,
   output->winsys_id = output_id;
   output->name = g_strdup (xrandr_output->name);
 
+  output_xrandr = g_slice_new0 (MetaOutputXrandr);
+  output->driver_private = output_xrandr;
+  output->driver_notify = (GDestroyNotify)meta_output_xrandr_destroy_notify;
+
   edid = meta_output_xrandr_read_edid (output);
   meta_output_parse_edid (output, edid);
   g_bytes_unref (edid);
@@ -816,9 +851,9 @@ meta_create_xrandr_output (MetaGpuXrandr *gpu_xrandr,
 
   output->is_primary = ((XID) output->winsys_id == primary_output);
   output->is_presentation = output_get_presentation_xrandr (output);
-  output->is_underscanning = output_get_underscanning_xrandr (output);
   output->supports_underscanning =
-    output_get_supports_underscanning_xrandr (output);
+    output_get_supports_underscanning_xrandr (output, &output_xrandr->underscan_value);
+  output->is_underscanning = output_get_underscanning_xrandr (output);
   output_get_backlight_limits_xrandr (output);
 
   if (!(output->backlight_min == 0 && output->backlight_max == 0))


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