[mutter/wip/wayland-display: 39/55] MonitorManager: store the presentation mode bit in XRandR



commit f884c1ae2c6c7546284823468ebc6d31cd756d34
Author: Giovanni Campagna <gcampagn redhat com>
Date:   Thu Jul 25 11:16:51 2013 +0200

    MonitorManager: store the presentation mode bit in XRandR
    
    Use a private output property to store if the output is in
    presentation mode or not, so that this information is not lost
    after the configuration read back from the server.

 src/core/monitor.c   |   52 ++++++++++++++++++++++++++++++++++++++++++++++++-
 src/meta/atomnames.h |    1 +
 2 files changed, 51 insertions(+), 2 deletions(-)
---
diff --git a/src/core/monitor.c b/src/core/monitor.c
index ee89520..65d79df 100644
--- a/src/core/monitor.c
+++ b/src/core/monitor.c
@@ -32,6 +32,7 @@
 #include <clutter/clutter.h>
 
 #ifdef HAVE_RANDR
+#include <X11/Xatom.h>
 #include <X11/extensions/Xrandr.h>
 #include <X11/extensions/dpms.h>
 #endif
@@ -349,6 +350,34 @@ wl_transform_from_xrandr_all (Rotation rotation)
   return ret;
 }
 
+static gboolean
+output_get_presentation_xrandr (MetaMonitorManager *manager,
+                                MetaOutput         *output)
+{
+  MetaDisplay *display = meta_get_display ();
+  gboolean value;
+  Atom actual_type;
+  int actual_format;
+  unsigned long nitems, bytes_after;
+  unsigned char *buffer;
+
+  XRRGetOutputProperty (manager->xdisplay,
+                        (XID)output->output_id,
+                        display->atom__MUTTER_PRESENTATION_OUTPUT,
+                        0, G_MAXLONG, False, False, XA_CARDINAL,
+                        &actual_type, &actual_format,
+                        &nitems, &bytes_after, &buffer);
+
+  if (actual_type != XA_CARDINAL || actual_format != 32 ||
+      nitems < 1)
+    return FALSE;
+
+  value = ((int*)buffer)[0];
+
+  XFree (buffer);
+  return value;
+}
+
 static int
 compare_outputs (const void *one,
                  const void *two)
@@ -556,7 +585,7 @@ read_monitor_infos_from_xrandr (MetaMonitorManager *manager)
               }
 
             meta_output->is_primary = ((XID)meta_output->output_id == primary_output);
-            meta_output->is_presentation = FALSE;
+            meta_output->is_presentation = output_get_presentation_xrandr (manager, meta_output);
 
             n_actual_outputs++;
           }
@@ -1143,7 +1172,22 @@ wl_transform_to_xrandr (enum wl_output_transform transform)
 
   g_assert_not_reached ();
 }
-     
+
+static void
+output_set_presentation_xrandr (MetaMonitorManager *manager,
+                                MetaOutput         *output,
+                                gboolean            presentation)
+{
+  MetaDisplay *display = meta_get_display ();
+  int value = presentation;
+
+  XRRChangeOutputProperty (manager->xdisplay,
+                           (XID)output->output_id,
+                           display->atom__MUTTER_PRESENTATION_OUTPUT,
+                           XA_CARDINAL, 32, PropModeReplace,
+                           (unsigned char*) &value, 1);
+}
+
 static void
 apply_config_xrandr (MetaMonitorManager *manager,
                      MetaCRTCInfo       **crtcs,
@@ -1216,6 +1260,10 @@ apply_config_xrandr (MetaMonitorManager *manager,
                                DefaultRootWindow (manager->xdisplay),
                                (XID)output_info->output->output_id);
         }
+
+      output_set_presentation_xrandr (manager,
+                                      output_info->output,
+                                      output_info->is_presentation);
     }
 
   /* Disable CRTCs not mentioned in the list */
diff --git a/src/meta/atomnames.h b/src/meta/atomnames.h
index 1223151..4aa54fe 100644
--- a/src/meta/atomnames.h
+++ b/src/meta/atomnames.h
@@ -74,6 +74,7 @@ item(_MUTTER_TIMESTAMP_PING)
 item(_MUTTER_FOCUS_SET)
 item(_MUTTER_SENTINEL)
 item(_MUTTER_VERSION)
+item(_MUTTER_PRESENTATION_OUTPUT)
 item(WM_CLIENT_MACHINE)
 item(MANAGER)
 item(TARGETS)


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