diff options
author | Dave Airlie <airlied@redhat.com> | 2014-10-14 12:06:11 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2014-10-16 09:55:16 +1000 |
commit | eb40a5c7d69c741d41fa1c4f03288fe37a989944 (patch) | |
tree | 4b8a059a6bd530f6e8062a2651a5c1254ee6bf47 | |
parent | 0ae4c8ebd98c178837bda7dddbf222072108272c (diff) |
meta-monitor-manager: pass tile info to the dbus interface as a propertytile-monitor-1
-rw-r--r-- | src/backends/meta-monitor-manager.c | 19 | ||||
-rw-r--r-- | src/backends/meta-monitor-manager.h | 3 | ||||
-rw-r--r-- | src/backends/native/meta-monitor-manager-kms.c | 8 | ||||
-rw-r--r-- | src/backends/x11/meta-monitor-manager-xrandr.c | 57 |
4 files changed, 78 insertions, 9 deletions
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index c4c62192..03c636ae 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -394,6 +394,13 @@ meta_monitor_manager_real_read_edid (MetaMonitorManager *manager, return NULL; } +static GBytes * +meta_monitor_manager_real_read_tile_info (MetaMonitorManager *manager, + MetaOutput *output) +{ + return NULL; +} + static char * meta_monitor_manager_real_get_edid_file (MetaMonitorManager *manager, MetaOutput *output) @@ -412,6 +419,7 @@ meta_monitor_manager_class_init (MetaMonitorManagerClass *klass) klass->get_edid_file = meta_monitor_manager_real_get_edid_file; klass->read_edid = meta_monitor_manager_real_read_edid; + klass->read_tile_info = meta_monitor_manager_real_read_tile_info; signals[CONFIRM_DISPLAY_CHANGE] = g_signal_new ("confirm-display-change", @@ -545,7 +553,7 @@ meta_monitor_manager_handle_get_resources (MetaDBusDisplayConfig *skeleton, { MetaOutput *output = &manager->outputs[i]; GVariantBuilder crtcs, modes, clones, properties; - GBytes *edid; + GBytes *edid, *tile; char *edid_file; g_variant_builder_init (&crtcs, G_VARIANT_TYPE ("au")); @@ -605,6 +613,15 @@ meta_monitor_manager_handle_get_resources (MetaDBusDisplayConfig *skeleton, } } + tile = manager_class->read_tile_info(manager, output); + if (tile) + { + g_variant_builder_add(&properties, "{sv}", "tile", + g_variant_new_from_bytes (G_VARIANT_TYPE ("ay"), + tile, TRUE)); + g_bytes_unref(tile); + } + g_variant_builder_add (&output_builder, "(uxiausauaua{sv})", i, /* ID */ (gint64)output->winsys_id, diff --git a/src/backends/meta-monitor-manager.h b/src/backends/meta-monitor-manager.h index 77d90c40..66b5df22 100644 --- a/src/backends/meta-monitor-manager.h +++ b/src/backends/meta-monitor-manager.h @@ -279,6 +279,9 @@ struct _MetaMonitorManagerClass GBytes* (*read_edid) (MetaMonitorManager *, MetaOutput *); + GBytes* (*read_tile_info) (MetaMonitorManager *, + MetaOutput *); + void (*apply_configuration) (MetaMonitorManager *, MetaCRTCInfo **, unsigned int , diff --git a/src/backends/native/meta-monitor-manager-kms.c b/src/backends/native/meta-monitor-manager-kms.c index ad37df6a..b522d5ee 100644 --- a/src/backends/native/meta-monitor-manager-kms.c +++ b/src/backends/native/meta-monitor-manager-kms.c @@ -630,6 +630,13 @@ meta_monitor_manager_kms_read_edid (MetaMonitorManager *manager, return read_output_edid (manager_kms, output); } +static GBytes * +meta_monitor_manager_kms_read_tile_info (MetaMonitorManager *manager, + MetaOutput *output) +{ + return NULL; /* TODO */ +} + static void meta_monitor_manager_kms_set_power_save_mode (MetaMonitorManager *manager, MetaPowerSave mode) @@ -929,6 +936,7 @@ meta_monitor_manager_kms_class_init (MetaMonitorManagerKmsClass *klass) manager_class->read_current = meta_monitor_manager_kms_read_current; manager_class->read_edid = meta_monitor_manager_kms_read_edid; + manager_class->read_tile_info = meta_monitor_manager_kms_read_tile_info; manager_class->apply_configuration = meta_monitor_manager_kms_apply_configuration; manager_class->set_power_save_mode = meta_monitor_manager_kms_set_power_save_mode; manager_class->get_crtc_gamma = meta_monitor_manager_kms_get_crtc_gamma; diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c index 2a300734..860fdd5c 100644 --- a/src/backends/x11/meta-monitor-manager-xrandr.c +++ b/src/backends/x11/meta-monitor-manager-xrandr.c @@ -326,26 +326,57 @@ read_output_edid (MetaMonitorManagerXrandr *manager_xrandr, return NULL; } -static gboolean -output_get_tile_info(MetaMonitorManagerXrandr *manager_xrandr, - MetaOutput *output) +static char * +output_get_tile_property(MetaMonitorManagerXrandr *manager_xrandr, + XID winsys_id, + gsize *len) { - unsigned char *prop; Atom tile_atom; - int actual_format; + unsigned char *prop; unsigned long nitems, bytes_after; + int actual_format; Atom actual_type; - gboolean ret = False; + char *result = NULL; tile_atom = XInternAtom(manager_xrandr->xdisplay, "TILE", FALSE); XRRGetOutputProperty(manager_xrandr->xdisplay, - (XID)output->winsys_id, + winsys_id, tile_atom, 0, 100, False, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &prop); if (actual_type == XA_INTEGER && actual_format == 8) { + result = g_memdup(prop, nitems); + if (len) + *len = nitems; + } + XFree(prop); + return result; +} + +static GBytes * +read_tile_property (MetaMonitorManagerXrandr *manager_xrandr, + XID winsys_id) +{ + char *prop; + gsize len; + prop = output_get_tile_property(manager_xrandr, winsys_id, &len); + if (prop) { + return g_bytes_new_take(prop, len); + } + return NULL; +} + +static gboolean +output_get_tile_info(MetaMonitorManagerXrandr *manager_xrandr, + MetaOutput *output) +{ + char *prop; + gboolean ret = False; + + prop = output_get_tile_property(manager_xrandr, output->winsys_id, NULL); + if (prop) { int single_mon; int ret; @@ -372,7 +403,7 @@ output_get_tile_info(MetaMonitorManagerXrandr *manager_xrandr, ret = True; } out: - XFree(prop); + g_free(prop); return ret; } @@ -676,6 +707,15 @@ meta_monitor_manager_xrandr_read_edid (MetaMonitorManager *manager, return read_output_edid (manager_xrandr, output->winsys_id); } +static GBytes * +meta_monitor_manager_xrandr_read_tile_info (MetaMonitorManager *manager, + MetaOutput *output) +{ + MetaMonitorManagerXrandr *manager_xrandr = META_MONITOR_MANAGER_XRANDR (manager); + + return read_tile_property (manager_xrandr, output->winsys_id); +} + static void meta_monitor_manager_xrandr_set_power_save_mode (MetaMonitorManager *manager, MetaPowerSave mode) @@ -1110,6 +1150,7 @@ meta_monitor_manager_xrandr_class_init (MetaMonitorManagerXrandrClass *klass) manager_class->read_current = meta_monitor_manager_xrandr_read_current; manager_class->read_edid = meta_monitor_manager_xrandr_read_edid; + manager_class->read_tile_info = meta_monitor_manager_xrandr_read_tile_info; manager_class->apply_configuration = meta_monitor_manager_xrandr_apply_configuration; manager_class->set_power_save_mode = meta_monitor_manager_xrandr_set_power_save_mode; manager_class->change_backlight = meta_monitor_manager_xrandr_change_backlight; |