Commit 54a00926 authored by Marco Trevisan's avatar Marco Trevisan 🎺

monitor-manager: add tiling as capability

Instead of having a private method for xrandr only, just use
MetaMonitorManagerCapability to store this feature.

In this way we can just store the randr version and do the versioning check
using few utility macros.

Tiling was available since randr 1.5
parent 0472a6f5
......@@ -368,6 +368,15 @@ meta_output_dummy_notify_destroy (MetaOutput *output)
g_clear_pointer (&output->driver_private, g_free);
}
static gboolean
has_tiled_monitors (void)
{
const char *tiled_monitors_str;
tiled_monitors_str = g_getenv ("MUTTER_DEBUG_TILED_DUMMY_MONITORS");
return g_strcmp0 (tiled_monitors_str, "1") == 0;
}
static void
meta_monitor_manager_dummy_read_current (MetaMonitorManager *manager)
{
......@@ -377,7 +386,6 @@ meta_monitor_manager_dummy_read_current (MetaMonitorManager *manager)
float *monitor_scales = NULL;
const char *num_monitors_str;
const char *monitor_scales_str;
const char *tiled_monitors_str;
gboolean tiled_monitors;
unsigned int i;
GList *outputs;
......@@ -454,8 +462,7 @@ meta_monitor_manager_dummy_read_current (MetaMonitorManager *manager)
g_strfreev (scales_str_list);
}
tiled_monitors_str = g_getenv ("MUTTER_DEBUG_TILED_DUMMY_MONITORS");
tiled_monitors = g_strcmp0 (tiled_monitors_str, "1") == 0;
tiled_monitors = has_tiled_monitors ();
modes = NULL;
crtcs = NULL;
......@@ -739,6 +746,9 @@ meta_monitor_manager_dummy_get_capabilities (MetaMonitorManager *manager)
capabilities |= META_MONITOR_MANAGER_CAPABILITY_MIRRORING;
if (has_tiled_monitors ())
capabilities |= META_MONITOR_MANAGER_CAPABILITY_TILING;
if (meta_settings_is_experimental_feature_enabled (
settings,
META_EXPERIMENTAL_FEATURE_SCALE_MONITOR_FRAMEBUFFER))
......
......@@ -44,7 +44,8 @@ typedef enum _MetaMonitorManagerCapability
META_MONITOR_MANAGER_CAPABILITY_NONE = 0,
META_MONITOR_MANAGER_CAPABILITY_MIRRORING = (1 << 0),
META_MONITOR_MANAGER_CAPABILITY_LAYOUT_MODE = (1 << 1),
META_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED = (1 << 2)
META_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED = (1 << 2),
META_MONITOR_MANAGER_CAPABILITY_TILING = (1 << 3),
} MetaMonitorManagerCapability;
/* Equivalent to the 'method' enum in org.gnome.Mutter.DisplayConfig */
......
......@@ -2775,6 +2775,10 @@ static void
rebuild_monitors (MetaMonitorManager *manager)
{
GList *l;
gboolean has_tiling;
has_tiling = meta_monitor_manager_get_capabilities (manager) &
META_MONITOR_MANAGER_CAPABILITY_TILING;
if (manager->monitors)
{
......@@ -2791,7 +2795,7 @@ rebuild_monitors (MetaMonitorManager *manager)
{
MetaOutput *output = k->data;
if (output->tile_info.group_id)
if (has_tiling && output->tile_info.group_id)
{
if (is_main_tiled_monitor_output (output))
{
......
......@@ -556,7 +556,7 @@ meta_monitor_manager_kms_get_capabilities (MetaMonitorManager *manager)
MetaRenderer *renderer = meta_backend_get_renderer (backend);
MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
MetaMonitorManagerCapability capabilities =
META_MONITOR_MANAGER_CAPABILITY_NONE;
META_MONITOR_MANAGER_CAPABILITY_TILING;
if (meta_settings_is_experimental_feature_enabled (
settings,
......
......@@ -63,6 +63,8 @@
* http://git.gnome.org/browse/gnome-settings-daemon/tree/plugins/xsettings/gsd-xsettings-manager.c
* for the reasoning */
#define DPI_FALLBACK 96.0
#define RANDR_VERSION_FORMAT(major, minor) ((major * 100) + minor)
#define RANDR_TILING_MIN_VERSION RANDR_VERSION_FORMAT (1, 5)
struct _MetaMonitorManagerXrandr
{
......@@ -71,7 +73,7 @@ struct _MetaMonitorManagerXrandr
Display *xdisplay;
int rr_event_base;
int rr_error_base;
gboolean has_randr15;
int randr_version;
/*
* The X server deals with multiple GPUs for us, soe just see what the X
......@@ -106,12 +108,6 @@ meta_monitor_manager_xrandr_get_xdisplay (MetaMonitorManagerXrandr *manager_xran
return manager_xrandr->xdisplay;
}
gboolean
meta_monitor_manager_xrandr_has_randr15 (MetaMonitorManagerXrandr *manager_xrandr)
{
return manager_xrandr->has_randr15;
}
static GBytes *
meta_monitor_manager_xrandr_read_edid (MetaMonitorManager *manager,
MetaOutput *output)
......@@ -735,7 +731,8 @@ meta_monitor_manager_xrandr_tiled_monitor_added (MetaMonitorManager *manager,
GList *l;
int i;
if (manager_xrandr->has_randr15 == FALSE)
if (!(meta_monitor_manager_get_capabilities (manager) &
META_MONITOR_MANAGER_CAPABILITY_TILING))
return;
product = meta_monitor_get_product (monitor);
......@@ -784,7 +781,8 @@ meta_monitor_manager_xrandr_tiled_monitor_removed (MetaMonitorManager *manager,
int monitor_count;
if (manager_xrandr->has_randr15 == FALSE)
if (!(meta_monitor_manager_get_capabilities (manager) &
META_MONITOR_MANAGER_CAPABILITY_TILING))
return;
monitor_xrandr_data = meta_monitor_xrandr_data_from_monitor (monitor);
......@@ -802,10 +800,12 @@ meta_monitor_manager_xrandr_tiled_monitor_removed (MetaMonitorManager *manager,
static void
meta_monitor_manager_xrandr_init_monitors (MetaMonitorManagerXrandr *manager_xrandr)
{
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_xrandr);
XRRMonitorInfo *m;
int n, i;
if (manager_xrandr->has_randr15 == FALSE)
if (!(meta_monitor_manager_get_capabilities (manager) &
META_MONITOR_MANAGER_CAPABILITY_TILING))
return;
/* delete any tiled monitors setup, as mutter will want to recreate
......@@ -866,8 +866,16 @@ meta_monitor_manager_xrandr_calculate_supported_scales (MetaMonitorManager
static MetaMonitorManagerCapability
meta_monitor_manager_xrandr_get_capabilities (MetaMonitorManager *manager)
{
return (META_MONITOR_MANAGER_CAPABILITY_MIRRORING |
META_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED);
MetaMonitorManagerCapability capabilities;
MetaMonitorManagerXrandr *xrandr_manager = META_MONITOR_MANAGER_XRANDR (manager);
capabilities = META_MONITOR_MANAGER_CAPABILITY_MIRRORING |
META_MONITOR_MANAGER_CAPABILITY_GLOBAL_SCALE_REQUIRED;
if (xrandr_manager->randr_version >= RANDR_TILING_MIN_VERSION)
capabilities |= META_MONITOR_MANAGER_CAPABILITY_TILING;
return capabilities;
}
static gboolean
......@@ -921,16 +929,13 @@ meta_monitor_manager_xrandr_constructed (GObject *object)
| RRCrtcChangeNotifyMask
| RROutputPropertyNotifyMask);
manager_xrandr->has_randr15 = FALSE;
XRRQueryVersion (manager_xrandr->xdisplay, &major_version,
&minor_version);
if (major_version > 1 ||
(major_version == 1 &&
minor_version >= 5))
{
manager_xrandr->has_randr15 = TRUE;
manager_xrandr->tiled_monitor_atoms = g_hash_table_new (NULL, NULL);
}
manager_xrandr->randr_version = RANDR_VERSION_FORMAT (major_version,
minor_version);
if (manager_xrandr->randr_version >= RANDR_TILING_MIN_VERSION)
manager_xrandr->tiled_monitor_atoms = g_hash_table_new (NULL, NULL);
meta_monitor_manager_xrandr_init_monitors (manager_xrandr);
}
......
......@@ -33,8 +33,6 @@ G_DECLARE_FINAL_TYPE (MetaMonitorManagerXrandr, meta_monitor_manager_xrandr,
Display * meta_monitor_manager_xrandr_get_xdisplay (MetaMonitorManagerXrandr *manager_xrandr);
gboolean meta_monitor_manager_xrandr_has_randr15 (MetaMonitorManagerXrandr *manager_xrandr);
gboolean meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager,
XEvent *event);
......
......@@ -644,8 +644,6 @@ output_get_tile_info (MetaOutput *output)
{
MetaGpu *gpu = meta_output_get_gpu (output);
MetaMonitorManager *monitor_manager = meta_gpu_get_monitor_manager (gpu);
MetaMonitorManagerXrandr *monitor_manager_xrandr =
META_MONITOR_MANAGER_XRANDR (monitor_manager);
Display *xdisplay = xdisplay_from_output (output);
Atom tile_atom;
unsigned char *prop;
......@@ -653,7 +651,8 @@ output_get_tile_info (MetaOutput *output)
int actual_format;
Atom actual_type;
if (!meta_monitor_manager_xrandr_has_randr15 (monitor_manager_xrandr))
if (!(meta_monitor_manager_get_capabilities (monitor_manager) &
META_MONITOR_MANAGER_CAPABILITY_TILING))
return;
tile_atom = XInternAtom (xdisplay, "TILE", FALSE);
......
......@@ -411,10 +411,10 @@ is_monitor_framebuffer_scaled (void)
static MetaMonitorManagerCapability
meta_monitor_manager_test_get_capabilities (MetaMonitorManager *manager)
{
MetaMonitorManagerCapability capabilities =
META_MONITOR_MANAGER_CAPABILITY_NONE;
MetaMonitorManagerCapability capabilities;
capabilities |= META_MONITOR_MANAGER_CAPABILITY_MIRRORING;
capabilities = META_MONITOR_MANAGER_CAPABILITY_MIRRORING |
META_MONITOR_MANAGER_CAPABILITY_TILING;
if (is_monitor_framebuffer_scaled ())
capabilities |= META_MONITOR_MANAGER_CAPABILITY_LAYOUT_MODE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment