[mutter/wip/underscan: 1/2] monitor-manager: add a property to discover if underscan is supported
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/underscan: 1/2] monitor-manager: add a property to discover if underscan is supported
- Date: Thu, 2 Jul 2015 01:04:46 +0000 (UTC)
commit 5459dd1e5974b31a2306826cb3e659f0a7a671b2
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Jul 1 17:42:46 2015 -0700
monitor-manager: add a property to discover if underscan is supported
So that clients such as the control center can decide to hide an
underscanning checkbutton when the output does not support it.
src/backends/meta-monitor-manager-private.h | 1 +
src/backends/meta-monitor-manager.c | 2 +
src/backends/native/meta-monitor-manager-kms.c | 17 +++++++++
src/backends/x11/meta-monitor-manager-xrandr.c | 46 ++++++++++++++++++++++++
4 files changed, 66 insertions(+), 0 deletions(-)
---
diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h
index d21888e..e73aec9 100644
--- a/src/backends/meta-monitor-manager-private.h
+++ b/src/backends/meta-monitor-manager-private.h
@@ -145,6 +145,7 @@ struct _MetaOutput
gboolean is_primary;
gboolean is_presentation;
gboolean is_underscanning;
+ gboolean supports_underscanning;
gpointer driver_private;
GDestroyNotify driver_notify;
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index 21ab215..4fe9717 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -647,6 +647,8 @@ meta_monitor_manager_handle_get_resources (MetaDBusDisplayConfig *skeleton,
g_variant_new_string (get_connector_type_name (output->connector_type)));
g_variant_builder_add (&properties, "{sv}", "underscanning",
g_variant_new_boolean (output->is_underscanning));
+ g_variant_builder_add (&properties, "{sv}", "supports-underscanning",
+ g_variant_new_boolean (output->supports_underscanning));
edid_file = manager_class->get_edid_file (manager, output);
if (edid_file)
diff --git a/src/backends/native/meta-monitor-manager-kms.c b/src/backends/native/meta-monitor-manager-kms.c
index cc2b18e..b8f271d 100644
--- a/src/backends/native/meta-monitor-manager-kms.c
+++ b/src/backends/native/meta-monitor-manager-kms.c
@@ -863,6 +863,22 @@ crtc_free (CoglKmsCrtc *crtc)
g_slice_free (CoglKmsCrtc, crtc);
}
+static gboolean
+get_supports_underscan (MetaMonitorManagerKms *manager_kms,
+ MetaOutput *output)
+{
+ MetaCRTC *crtc = output->crtc;
+
+ if (!crtc)
+ return FALSE;
+
+ MetaCRTCKms *crtc_kms = crtc->driver_private;
+ if (!crtc_kms->underscan_prop_id)
+ return FALSE;
+
+ return TRUE;
+}
+
static void
set_underscan (MetaMonitorManagerKms *manager_kms,
MetaOutput *output)
@@ -1059,6 +1075,7 @@ meta_monitor_manager_kms_apply_configuration (MetaMonitorManager *manager,
output->is_primary = output_info->is_primary;
output->is_presentation = output_info->is_presentation;
output->is_underscanning = output_info->is_underscanning;
+ output->supports_underscanning = get_supports_underscan (manager_kms, output);
set_underscan (manager_kms, output);
}
diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c
index 13010b0..86d24b5 100644
--- a/src/backends/x11/meta-monitor-manager-xrandr.c
+++ b/src/backends/x11/meta-monitor-manager-xrandr.c
@@ -246,6 +246,51 @@ output_get_underscanning_xrandr (MetaMonitorManagerXrandr *manager_xrandr,
return (strcmp (str, "on") == 0);
}
+static gboolean
+output_get_supports_underscanning_xrandr (MetaMonitorManagerXrandr *manager_xrandr,
+ MetaOutput *output)
+{
+ Atom atom, actual_type;
+ int actual_format, i;
+ unsigned long nitems, bytes_after;
+ g_autofree unsigned char *buffer = NULL;
+ XRRPropertyInfo *property_info;
+ Atom *values;
+ gboolean supports_underscanning = FALSE;
+
+ atom = XInternAtom (manager_xrandr->xdisplay, "underscan", False);
+ XRRGetOutputProperty (manager_xrandr->xdisplay,
+ (XID)output->winsys_id,
+ atom,
+ 0, G_MAXLONG, False, False, XA_ATOM,
+ &actual_type, &actual_format,
+ &nitems, &bytes_after, &buffer);
+
+ if (actual_type != XA_ATOM || actual_format != 32 || nitems < 1)
+ return FALSE;
+
+ property_info = XRRQueryOutputProperty (manager_xrandr->xdisplay,
+ (XID) output->winsys_id,
+ atom);
+ values = (Atom *) property_info->values;
+
+ for (i = 0; i < property_info->num_values; i++)
+ {
+ /* The output supports underscanning if "on" is a valid value
+ * for the underscan property.
+ */
+ char *name = XGetAtomName (manager_xrandr->xdisplay, values[i]);
+ if (strcmp (name, "on") == 0)
+ supports_underscanning = TRUE;
+
+ XFree (name);
+ }
+
+ XFree (property_info);
+
+ return supports_underscanning;
+}
+
static int
normalize_backlight (MetaOutput *output,
int hw_value)
@@ -804,6 +849,7 @@ meta_monitor_manager_xrandr_read_current (MetaMonitorManager *manager)
meta_output->is_primary = ((XID)meta_output->winsys_id == primary_output);
meta_output->is_presentation = output_get_presentation_xrandr (manager_xrandr, meta_output);
meta_output->is_underscanning = output_get_underscanning_xrandr (manager_xrandr, meta_output);
+ meta_output->supports_underscanning = output_get_supports_underscanning_xrandr (manager_xrandr,
meta_output);
output_get_backlight_limits_xrandr (manager_xrandr, meta_output);
if (!(meta_output->backlight_min == 0 && meta_output->backlight_max == 0))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]