From 9e8ee491e64cb878b835693c4069dabc26675429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 26 Jan 2017 17:14:32 +0800 Subject: [PATCH] monitor-manager: Add API to get scales supported by the backend For the Xrandr backend, only scale 1 is supported, for the others, 1 and 2 are reported as supported. https://bugzilla.gnome.org/show_bug.cgi?id=777732 --- src/backends/meta-monitor-manager-dummy.c | 15 +++++++++++++++ src/backends/meta-monitor-manager-private.h | 4 ++++ src/backends/native/meta-monitor-manager-kms.c | 15 +++++++++++++++ src/backends/x11/meta-monitor-manager-xrandr.c | 14 ++++++++++++++ src/tests/meta-monitor-manager-test.c | 15 +++++++++++++++ 5 files changed, 63 insertions(+) diff --git a/src/backends/meta-monitor-manager-dummy.c b/src/backends/meta-monitor-manager-dummy.c index 3cfabff73..5f1ec1d97 100644 --- a/src/backends/meta-monitor-manager-dummy.c +++ b/src/backends/meta-monitor-manager-dummy.c @@ -39,6 +39,11 @@ #define MAX_CRTCS (MAX_MONITORS * 2) #define MAX_MODES (MAX_MONITORS * 4) +static float supported_scales_dummy[] = { + 1.0, + 2.0 +}; + struct _MetaMonitorManagerDummy { MetaMonitorManager parent_instance; @@ -585,6 +590,15 @@ meta_monitor_manager_dummy_calculate_monitor_mode_scale (MetaMonitorManager *man return output_dummy->scale; } +static void +meta_monitor_manager_dummy_get_supported_scales (MetaMonitorManager *manager, + float **scales, + int *n_scales) +{ + *scales = supported_scales_dummy; + *n_scales = G_N_ELEMENTS (supported_scales_dummy); +} + static void meta_monitor_manager_dummy_class_init (MetaMonitorManagerDummyClass *klass) { @@ -596,6 +610,7 @@ meta_monitor_manager_dummy_class_init (MetaMonitorManagerDummyClass *klass) manager_class->apply_configuration = meta_monitor_manager_dummy_apply_config; manager_class->is_transform_handled = meta_monitor_manager_dummy_is_transform_handled; manager_class->calculate_monitor_mode_scale = meta_monitor_manager_dummy_calculate_monitor_mode_scale; + manager_class->get_supported_scales = meta_monitor_manager_dummy_get_supported_scales; } static void diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h index 83dccf430..5548cda0b 100644 --- a/src/backends/meta-monitor-manager-private.h +++ b/src/backends/meta-monitor-manager-private.h @@ -353,6 +353,10 @@ struct _MetaMonitorManagerClass int (*calculate_monitor_mode_scale) (MetaMonitorManager *, MetaMonitor *, MetaMonitorMode *); + + void (*get_supported_scales) (MetaMonitorManager *, + float **, + int *); }; void meta_monitor_manager_rebuild (MetaMonitorManager *manager, diff --git a/src/backends/native/meta-monitor-manager-kms.c b/src/backends/native/meta-monitor-manager-kms.c index dc7988f5d..12fa394ef 100644 --- a/src/backends/native/meta-monitor-manager-kms.c +++ b/src/backends/native/meta-monitor-manager-kms.c @@ -52,6 +52,11 @@ #define ALL_TRANSFORMS_MASK ((1 << ALL_TRANSFORMS) - 1) #define SYNC_TOLERANCE 0.01 /* 1 percent */ +static float supported_scales_kms[] = { + 1.0, + 2.0 +}; + typedef struct { drmModeConnector *connector; @@ -1904,6 +1909,15 @@ meta_monitor_manager_kms_calculate_monitor_mode_scale (MetaMonitorManager *manag return compute_scale (monitor, monitor_mode); } +static void +meta_monitor_manager_kms_get_supported_scales (MetaMonitorManager *manager, + float **scales, + int *n_scales) +{ + *scales = supported_scales_kms; + *n_scales = G_N_ELEMENTS (supported_scales_kms); +} + static void meta_monitor_manager_kms_dispose (GObject *object) { @@ -1945,4 +1959,5 @@ meta_monitor_manager_kms_class_init (MetaMonitorManagerKmsClass *klass) manager_class->set_crtc_gamma = meta_monitor_manager_kms_set_crtc_gamma; manager_class->is_transform_handled = meta_monitor_manager_kms_is_transform_handled; manager_class->calculate_monitor_mode_scale = meta_monitor_manager_kms_calculate_monitor_mode_scale; + manager_class->get_supported_scales = meta_monitor_manager_kms_get_supported_scales; } diff --git a/src/backends/x11/meta-monitor-manager-xrandr.c b/src/backends/x11/meta-monitor-manager-xrandr.c index 3349c31a1..8507143f3 100644 --- a/src/backends/x11/meta-monitor-manager-xrandr.c +++ b/src/backends/x11/meta-monitor-manager-xrandr.c @@ -52,6 +52,10 @@ * for the reasoning */ #define DPI_FALLBACK 96.0 +static float supported_scales_xrandr[] = { + 1.0 +}; + struct _MetaMonitorManagerXrandr { MetaMonitorManager parent_instance; @@ -1583,6 +1587,15 @@ meta_monitor_manager_xrandr_calculate_monitor_mode_scale (MetaMonitorManager *ma return 1; } +static void +meta_monitor_manager_xrandr_get_supported_scales (MetaMonitorManager *manager, + float **scales, + int *n_scales) +{ + *scales = supported_scales_xrandr; + *n_scales = G_N_ELEMENTS (supported_scales_xrandr); +} + static void meta_monitor_manager_xrandr_init (MetaMonitorManagerXrandr *manager_xrandr) { @@ -1660,6 +1673,7 @@ meta_monitor_manager_xrandr_class_init (MetaMonitorManagerXrandrClass *klass) #endif manager_class->is_transform_handled = meta_monitor_manager_xrandr_is_transform_handled; manager_class->calculate_monitor_mode_scale = meta_monitor_manager_xrandr_calculate_monitor_mode_scale; + manager_class->get_supported_scales = meta_monitor_manager_xrandr_get_supported_scales; quark_meta_monitor_xrandr_data = g_quark_from_static_string ("-meta-monitor-xrandr-data"); diff --git a/src/tests/meta-monitor-manager-test.c b/src/tests/meta-monitor-manager-test.c index 7769ec7d1..0d4033db3 100644 --- a/src/tests/meta-monitor-manager-test.c +++ b/src/tests/meta-monitor-manager-test.c @@ -23,6 +23,11 @@ #include "backends/meta-monitor-config-manager.h" +static float supported_scales_test[] = { + 1.0, + 2.0 +}; + struct _MetaMonitorManagerTest { MetaMonitorManager parent; @@ -360,6 +365,15 @@ meta_monitor_manager_test_calculate_monitor_mode_scale (MetaMonitorManager *mana return output_test->scale; } +static void +meta_monitor_manager_test_get_supported_scales (MetaMonitorManager *manager, + float **scales, + int *n_scales) +{ + *scales = supported_scales_test; + *n_scales = G_N_ELEMENTS (supported_scales_test); +} + static void meta_monitor_manager_test_dispose (GObject *object) { @@ -393,4 +407,5 @@ meta_monitor_manager_test_class_init (MetaMonitorManagerTestClass *klass) manager_class->tiled_monitor_removed = meta_monitor_manager_test_tiled_monitor_removed; manager_class->is_transform_handled = meta_monitor_manager_test_is_transform_handled; manager_class->calculate_monitor_mode_scale = meta_monitor_manager_test_calculate_monitor_mode_scale; + manager_class->get_supported_scales = meta_monitor_manager_test_get_supported_scales; }