From 2b05748d5c0e4572f9b14008cc1105d0e5184c88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 1 May 2017 11:55:10 +0800 Subject: [PATCH] monitor: Move get_suggested() behind behind vfunc Only support suggested monitor positioning if the monitor is non-tiled. Normally this functionality is used by virtual machines to provide a hint of how to place the virtual monitors, and they don't tend to use tiled monitors anyway. https://bugzilla.gnome.org/show_bug.cgi?id=781723 --- src/backends/meta-monitor.c | 39 +++++++++++++++++++++++++++---------- src/backends/meta-monitor.h | 3 +++ 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c index af1287888..8310472ab 100644 --- a/src/backends/meta-monitor.c +++ b/src/backends/meta-monitor.c @@ -418,6 +418,23 @@ meta_monitor_normal_derive_dimensions (MetaMonitor *monitor, *height = output->crtc->rect.height; } +static gboolean +meta_monitor_normal_get_suggested_position (MetaMonitor *monitor, + int *x, + int *y) +{ + MetaOutput *output; + + output = meta_monitor_get_main_output (monitor); + if (output->suggested_x < 0 && output->suggested_y < 0) + return FALSE; + + *x = output->suggested_x; + *y = output->suggested_y; + + return TRUE; +} + static void meta_monitor_normal_calculate_crtc_pos (MetaMonitor *monitor, MetaMonitorMode *monitor_mode, @@ -443,6 +460,7 @@ meta_monitor_normal_class_init (MetaMonitorNormalClass *klass) monitor_class->get_main_output = meta_monitor_normal_get_main_output; monitor_class->derive_dimensions = meta_monitor_normal_derive_dimensions; monitor_class->calculate_crtc_pos = meta_monitor_normal_calculate_crtc_pos; + monitor_class->get_suggested_position = meta_monitor_normal_get_suggested_position; } uint32_t @@ -456,16 +474,8 @@ meta_monitor_get_suggested_position (MetaMonitor *monitor, int *x, int *y) { - MetaOutput *main_output; - - main_output = meta_monitor_get_main_output (monitor); - if (main_output->suggested_x < 0 && main_output->suggested_y < 0) - return FALSE; - - *x = main_output->suggested_x; - *y = main_output->suggested_y; - - return TRUE; + return META_MONITOR_GET_CLASS (monitor)->get_suggested_position (monitor, + x, y); } static void @@ -804,6 +814,14 @@ meta_monitor_tiled_derive_dimensions (MetaMonitor *monitor, *out_height = max_y - min_y; } +static gboolean +meta_monitor_tiled_get_suggested_position (MetaMonitor *monitor, + int *x, + int *y) +{ + return FALSE; +} + static void meta_monitor_tiled_calculate_crtc_pos (MetaMonitor *monitor, MetaMonitorMode *monitor_mode, @@ -854,6 +872,7 @@ meta_monitor_tiled_class_init (MetaMonitorTiledClass *klass) monitor_class->get_main_output = meta_monitor_tiled_get_main_output; monitor_class->derive_dimensions = meta_monitor_tiled_derive_dimensions; monitor_class->calculate_crtc_pos = meta_monitor_tiled_calculate_crtc_pos; + monitor_class->get_suggested_position = meta_monitor_tiled_get_suggested_position; } static void diff --git a/src/backends/meta-monitor.h b/src/backends/meta-monitor.h index e3adb6a7e..e1358e373 100644 --- a/src/backends/meta-monitor.h +++ b/src/backends/meta-monitor.h @@ -70,6 +70,9 @@ struct _MetaMonitorClass MetaMonitorTransform crtc_transform, int *out_x, int *out_y); + gboolean (* get_suggested_position) (MetaMonitor *monitor, + int *width, + int *height); }; #define META_TYPE_MONITOR_NORMAL (meta_monitor_normal_get_type ())