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
This commit is contained in:
Jonas Ådahl 2017-01-26 17:14:32 +08:00
parent 3b46345db4
commit 9e8ee491e6
5 changed files with 63 additions and 0 deletions

View File

@ -39,6 +39,11 @@
#define MAX_CRTCS (MAX_MONITORS * 2) #define MAX_CRTCS (MAX_MONITORS * 2)
#define MAX_MODES (MAX_MONITORS * 4) #define MAX_MODES (MAX_MONITORS * 4)
static float supported_scales_dummy[] = {
1.0,
2.0
};
struct _MetaMonitorManagerDummy struct _MetaMonitorManagerDummy
{ {
MetaMonitorManager parent_instance; MetaMonitorManager parent_instance;
@ -585,6 +590,15 @@ meta_monitor_manager_dummy_calculate_monitor_mode_scale (MetaMonitorManager *man
return output_dummy->scale; 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 static void
meta_monitor_manager_dummy_class_init (MetaMonitorManagerDummyClass *klass) 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->apply_configuration = meta_monitor_manager_dummy_apply_config;
manager_class->is_transform_handled = meta_monitor_manager_dummy_is_transform_handled; 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->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 static void

View File

@ -353,6 +353,10 @@ struct _MetaMonitorManagerClass
int (*calculate_monitor_mode_scale) (MetaMonitorManager *, int (*calculate_monitor_mode_scale) (MetaMonitorManager *,
MetaMonitor *, MetaMonitor *,
MetaMonitorMode *); MetaMonitorMode *);
void (*get_supported_scales) (MetaMonitorManager *,
float **,
int *);
}; };
void meta_monitor_manager_rebuild (MetaMonitorManager *manager, void meta_monitor_manager_rebuild (MetaMonitorManager *manager,

View File

@ -52,6 +52,11 @@
#define ALL_TRANSFORMS_MASK ((1 << ALL_TRANSFORMS) - 1) #define ALL_TRANSFORMS_MASK ((1 << ALL_TRANSFORMS) - 1)
#define SYNC_TOLERANCE 0.01 /* 1 percent */ #define SYNC_TOLERANCE 0.01 /* 1 percent */
static float supported_scales_kms[] = {
1.0,
2.0
};
typedef struct typedef struct
{ {
drmModeConnector *connector; drmModeConnector *connector;
@ -1904,6 +1909,15 @@ meta_monitor_manager_kms_calculate_monitor_mode_scale (MetaMonitorManager *manag
return compute_scale (monitor, monitor_mode); 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 static void
meta_monitor_manager_kms_dispose (GObject *object) 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->set_crtc_gamma = meta_monitor_manager_kms_set_crtc_gamma;
manager_class->is_transform_handled = meta_monitor_manager_kms_is_transform_handled; 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->calculate_monitor_mode_scale = meta_monitor_manager_kms_calculate_monitor_mode_scale;
manager_class->get_supported_scales = meta_monitor_manager_kms_get_supported_scales;
} }

View File

@ -52,6 +52,10 @@
* for the reasoning */ * for the reasoning */
#define DPI_FALLBACK 96.0 #define DPI_FALLBACK 96.0
static float supported_scales_xrandr[] = {
1.0
};
struct _MetaMonitorManagerXrandr struct _MetaMonitorManagerXrandr
{ {
MetaMonitorManager parent_instance; MetaMonitorManager parent_instance;
@ -1583,6 +1587,15 @@ meta_monitor_manager_xrandr_calculate_monitor_mode_scale (MetaMonitorManager *ma
return 1; 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 static void
meta_monitor_manager_xrandr_init (MetaMonitorManagerXrandr *manager_xrandr) meta_monitor_manager_xrandr_init (MetaMonitorManagerXrandr *manager_xrandr)
{ {
@ -1660,6 +1673,7 @@ meta_monitor_manager_xrandr_class_init (MetaMonitorManagerXrandrClass *klass)
#endif #endif
manager_class->is_transform_handled = meta_monitor_manager_xrandr_is_transform_handled; 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->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 = quark_meta_monitor_xrandr_data =
g_quark_from_static_string ("-meta-monitor-xrandr-data"); g_quark_from_static_string ("-meta-monitor-xrandr-data");

View File

@ -23,6 +23,11 @@
#include "backends/meta-monitor-config-manager.h" #include "backends/meta-monitor-config-manager.h"
static float supported_scales_test[] = {
1.0,
2.0
};
struct _MetaMonitorManagerTest struct _MetaMonitorManagerTest
{ {
MetaMonitorManager parent; MetaMonitorManager parent;
@ -360,6 +365,15 @@ meta_monitor_manager_test_calculate_monitor_mode_scale (MetaMonitorManager *mana
return output_test->scale; 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 static void
meta_monitor_manager_test_dispose (GObject *object) 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->tiled_monitor_removed = meta_monitor_manager_test_tiled_monitor_removed;
manager_class->is_transform_handled = meta_monitor_manager_test_is_transform_handled; 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->calculate_monitor_mode_scale = meta_monitor_manager_test_calculate_monitor_mode_scale;
manager_class->get_supported_scales = meta_monitor_manager_test_get_supported_scales;
} }