Commit bad65346 authored by Marco Trevisan's avatar Marco Trevisan 🎺

All the shit in!

parent 59b80634
Pipeline #69076 failed with stages
in 1 minute and 9 seconds
......@@ -55,6 +55,13 @@ configure_file(
install_dir: schemadir
)
configure_file(
input: 'org.gnome.mutter.x11.gschema.xml.in',
output: 'org.gnome.mutter.x11.gschema.xml',
configuration: gschema_config,
install_dir: schemadir
)
install_data(['mutter-schemas.convert'],
install_dir: join_paths(datadir, 'GConf/gsettings'),
)
......@@ -125,6 +125,8 @@
using xrandr scaling. It might reduce
performances.
Does not require a restart.
USE FLAAAAAAAGS
</description>
</key>
......
<schemalist>
<enum id="org.gnome.mutter.X11.scale-mode">
<value nick="scale-up" value="1"/>
<value nick="scale-ui-down" value="2"/>
</enum>
<schema id="org.gnome.mutter.x11" path="/org/gnome/mutter/x11/"
gettext-domain="@GETTEXT_DOMAIN@">
<key name="fractional-scale-mode" enum="org.gnome.mutter.X11.scale-mode">
<default>"scale-ui-down"</default>
</key>
</schema>
</schemalist>
......@@ -179,6 +179,7 @@ assign_monitor_crtc (MetaMonitor *monitor,
gboolean assign_output_as_primary;
gboolean assign_output_as_presentation;
float scale;
// int i;
output = monitor_crtc_mode->output;
......@@ -201,6 +202,21 @@ assign_monitor_crtc (MetaMonitor *monitor,
crtc_transform))
crtc_transform = META_MONITOR_TRANSFORM_NORMAL;
// scale = 1.0f;
// for (i = 0; i < 2; ++i)
// {
// float s = !(i % 2) ? data->logical_monitor_config->scale :
// roundf (data->logical_monitor_config->scale);
// if (meta_monitor_manager_is_scale_supported (data->monitor_manager,
// data->config->layout_mode,
// monitor, mode, s))
// {
// scale = s;
// break;
// }
// }
scale = data->logical_monitor_config->scale;
if (!meta_monitor_manager_is_scale_supported (data->monitor_manager,
data->config->layout_mode,
......@@ -266,6 +282,9 @@ assign_monitor_crtc (MetaMonitor *monitor,
.is_underscanning = data->monitor_config->enable_underscanning
};
g_print("XRANDR: Creating crtc at %dx%d, scale %f\n",
crtc_info->x,crtc_info->y,crtc_info->scale);
g_ptr_array_add (data->crtc_infos, crtc_info);
g_ptr_array_add (data->output_infos, output_info);
......@@ -503,7 +522,11 @@ meta_monitor_config_manager_get_stored (MetaMonitorConfigManager *config_manager
typedef enum _MonitorMatchRule
{
MONITOR_MATCH_ALL = 0,
MONITOR_MATCH_EXTERNAL = (1 << 0)
MONITOR_MATCH_EXTERNAL = (1 << 0),
MONITOR_MATCH_BUILTIN = (1 << 1),
MONITOR_MATCH_PRIMARY = (1 << 2),
MONITOR_MATCH_VISIBLE = (1 << 3),
MONITOR_MATCH_WITH_POSITION = (1 << 4),
} MonitorMatchRule;
static MetaMonitor *
......@@ -609,11 +632,69 @@ create_monitor_config (MetaMonitor *monitor,
return monitor_config;
}
static float
get_preferred_preferred_max_scale (MetaMonitorManager *monitor_manager,
MetaLogicalMonitorLayoutMode layout_mode,
MonitorMatchRule match_rule)
{
float scale = 1.0f;
GList *monitors, *l;
monitors = meta_monitor_manager_get_monitors (monitor_manager);
for (l = monitors; l; l = l->next)
{
float s;
MetaMonitor *monitor = l->data;
MetaMonitorMode *mode = meta_monitor_get_preferred_mode (monitor);
if (match_rule & MONITOR_MATCH_PRIMARY)
{
if (!meta_monitor_is_primary (monitor))
continue;
}
if (match_rule & MONITOR_MATCH_BUILTIN)
{
if (!meta_monitor_is_laptop_panel (monitor))
continue;
}
else if (match_rule & MONITOR_MATCH_EXTERNAL)
{
if (meta_monitor_is_laptop_panel (monitor))
continue;
}
if (match_rule & MONITOR_MATCH_VISIBLE)
{
if (meta_monitor_is_laptop_panel (monitor) &&
is_lid_closed (monitor_manager))
continue;
}
if (match_rule & MONITOR_MATCH_WITH_POSITION)
{
if (!meta_monitor_get_suggested_position (monitor, NULL, NULL))
continue;
}
s = meta_monitor_manager_calculate_monitor_mode_scale (monitor_manager,
layout_mode,
monitor,
mode);
scale = MAX (scale, s);
}
return scale;
}
static MetaLogicalMonitorConfig *
create_preferred_logical_monitor_config (MetaMonitorManager *monitor_manager,
MetaMonitor *monitor,
int x,
int y,
float max_scale,
MetaLogicalMonitorConfig *primary_logical_monitor_config,
MetaLogicalMonitorLayoutMode layout_mode)
{
......@@ -642,6 +723,13 @@ create_preferred_logical_monitor_config (MetaMonitorManager *monitor_ma
width = (int) roundf (width / scale);
height = (int) roundf (height / scale);
break;
case META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL:
{
float ui_scale = scale / ceilf (max_scale);
width = (int) roundf (width / ui_scale);
height = (int) roundf (height / ui_scale);
}
break;
case META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL:
break;
}
......@@ -671,6 +759,7 @@ meta_monitor_config_manager_create_linear (MetaMonitorConfigManager *config_mana
MetaMonitor *primary_monitor;
MetaLogicalMonitorLayoutMode layout_mode;
MetaLogicalMonitorConfig *primary_logical_monitor_config;
float max_scale = 1.0f;
int x;
GList *monitors;
GList *l;
......@@ -681,10 +770,16 @@ meta_monitor_config_manager_create_linear (MetaMonitorConfigManager *config_mana
layout_mode = meta_monitor_manager_get_default_layout_mode (monitor_manager);
if (layout_mode == META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL)
max_scale = get_preferred_preferred_max_scale (monitor_manager,
layout_mode,
MONITOR_MATCH_VISIBLE);
primary_logical_monitor_config =
create_preferred_logical_monitor_config (monitor_manager,
primary_monitor,
0, 0,
max_scale,
NULL,
layout_mode);
primary_logical_monitor_config->is_primary = TRUE;
......@@ -709,6 +804,7 @@ meta_monitor_config_manager_create_linear (MetaMonitorConfigManager *config_mana
create_preferred_logical_monitor_config (monitor_manager,
monitor,
x, 0,
max_scale,
primary_logical_monitor_config,
layout_mode);
logical_monitor_configs = g_list_append (logical_monitor_configs,
......@@ -731,6 +827,7 @@ meta_monitor_config_manager_create_fallback (MetaMonitorConfigManager *config_ma
GList *logical_monitor_configs;
MetaLogicalMonitorLayoutMode layout_mode;
MetaLogicalMonitorConfig *primary_logical_monitor_config;
float max_scale = 1.0f;
primary_monitor = find_primary_monitor (monitor_manager);
if (!primary_monitor)
......@@ -738,10 +835,16 @@ meta_monitor_config_manager_create_fallback (MetaMonitorConfigManager *config_ma
layout_mode = meta_monitor_manager_get_default_layout_mode (monitor_manager);
if (layout_mode == META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL)
max_scale = get_preferred_preferred_max_scale (monitor_manager,
layout_mode,
MONITOR_MATCH_PRIMARY);
primary_logical_monitor_config =
create_preferred_logical_monitor_config (monitor_manager,
primary_monitor,
0, 0,
max_scale,
NULL,
layout_mode);
primary_logical_monitor_config->is_primary = TRUE;
......@@ -764,6 +867,7 @@ meta_monitor_config_manager_create_suggested (MetaMonitorConfigManager *config_m
GList *logical_monitor_configs;
GList *region;
int x, y;
float max_scale = 1;
GList *monitors;
GList *l;
......@@ -776,10 +880,16 @@ meta_monitor_config_manager_create_suggested (MetaMonitorConfigManager *config_m
layout_mode = meta_monitor_manager_get_default_layout_mode (monitor_manager);
if (layout_mode == META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL)
max_scale = get_preferred_preferred_max_scale (monitor_manager,
layout_mode,
MONITOR_MATCH_WITH_POSITION);
primary_logical_monitor_config =
create_preferred_logical_monitor_config (monitor_manager,
primary_monitor,
x, y,
max_scale,
NULL,
layout_mode);
primary_logical_monitor_config->is_primary = TRUE;
......@@ -803,6 +913,7 @@ meta_monitor_config_manager_create_suggested (MetaMonitorConfigManager *config_m
create_preferred_logical_monitor_config (monitor_manager,
monitor,
x, y,
max_scale,
primary_logical_monitor_config,
layout_mode);
logical_monitor_configs = g_list_append (logical_monitor_configs,
......@@ -1035,6 +1146,7 @@ create_for_switch_config_all_mirror (MetaMonitorConfigManager *config_manager)
.layout = (MetaRectangle) {
.x = 0,
.y = 0,
/* FIXME, probably need to compute global size here too */
.width = common_mode_w,
.height = common_mode_h
},
......@@ -1056,12 +1168,18 @@ create_for_switch_config_external (MetaMonitorConfigManager *config_manager)
MetaMonitorManager *monitor_manager = config_manager->monitor_manager;
GList *logical_monitor_configs = NULL;
int x = 0;
float max_scale = 1.0f;
MetaLogicalMonitorLayoutMode layout_mode;
GList *monitors;
GList *l;
layout_mode = meta_monitor_manager_get_default_layout_mode (monitor_manager);
if (layout_mode == META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL)
max_scale = get_preferred_preferred_max_scale (monitor_manager,
layout_mode,
MONITOR_MATCH_EXTERNAL);
monitors = meta_monitor_manager_get_monitors (monitor_manager);
for (l = monitors; l; l = l->next)
{
......@@ -1075,6 +1193,7 @@ create_for_switch_config_external (MetaMonitorConfigManager *config_manager)
create_preferred_logical_monitor_config (monitor_manager,
monitor,
x, 0,
max_scale,
NULL,
layout_mode);
logical_monitor_configs = g_list_append (logical_monitor_configs,
......@@ -1100,6 +1219,7 @@ create_for_switch_config_builtin (MetaMonitorConfigManager *config_manager)
GList *logical_monitor_configs;
MetaLogicalMonitorConfig *primary_logical_monitor_config;
MetaMonitor *monitor;
float max_scale = 1.0f;
monitor = meta_monitor_manager_get_laptop_panel (monitor_manager);
if (!monitor)
......@@ -1107,10 +1227,16 @@ create_for_switch_config_builtin (MetaMonitorConfigManager *config_manager)
layout_mode = meta_monitor_manager_get_default_layout_mode (monitor_manager);
if (layout_mode == META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL)
max_scale = get_preferred_preferred_max_scale (monitor_manager,
layout_mode,
MONITOR_MATCH_BUILTIN);
primary_logical_monitor_config =
create_preferred_logical_monitor_config (monitor_manager,
monitor,
0, 0,
max_scale,
NULL,
layout_mode);
primary_logical_monitor_config->is_primary = TRUE;
......@@ -1551,6 +1677,7 @@ meta_verify_logical_monitor_config (MetaLogicalMonitorConfig *logical_monitor
switch (layout_mode)
{
case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL:
case META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL:
expected_mode_width = roundf (expected_mode_width *
logical_monitor_config->scale);
expected_mode_height = roundf (expected_mode_height *
......@@ -1568,7 +1695,9 @@ meta_verify_logical_monitor_config (MetaLogicalMonitorConfig *logical_monitor
monitor_config->mode_spec->height != expected_mode_height)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Monitor modes in logical monitor conflict");
"Monitor modes in logical monitor conflict %dx%d vs %dx%d",
monitor_config->mode_spec->width, monitor_config->mode_spec->height,
expected_mode_width,expected_mode_height);
return FALSE;
}
}
......@@ -1662,6 +1791,15 @@ meta_verify_monitors_config (MetaMonitorsConfig *config,
min_y = INT_MAX;
region = NULL;
has_primary = FALSE;
for (l = config->logical_monitor_configs; l; l = l->next)
{
MetaLogicalMonitorConfig *logical_monitor_config = l->data;
g_print("XRANDR: has adjacent, Logical monitor config %p (%d): %dx%d, %dx%d @ %f\n",
logical_monitor_config,logical_monitor_config->is_primary,
logical_monitor_config->layout.x,logical_monitor_config->layout.y,
logical_monitor_config->layout.width,logical_monitor_config->layout.height,
logical_monitor_config->scale);
}
for (l = config->logical_monitor_configs; l; l = l->next)
{
MetaLogicalMonitorConfig *logical_monitor_config = l->data;
......
......@@ -534,6 +534,7 @@ derive_logical_monitor_layout (MetaLogicalMonitorConfig *logical_monitor_conf
switch (layout_mode)
{
case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL:
case META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL:
width = roundf (width / logical_monitor_config->scale);
height = roundf (height / logical_monitor_config->scale);
break;
......
......@@ -714,6 +714,7 @@ meta_monitor_manager_dummy_calculate_supported_scales (MetaMonitorManager
switch (layout_mode)
{
case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL:
case META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL:
break;
case META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL:
constraints |= META_MONITOR_SCALES_CONSTRAINT_NO_FRAC;
......
......@@ -61,7 +61,8 @@ typedef enum _MetaMonitorsConfigMethod
typedef enum _MetaLogicalMonitorLayoutMode
{
META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL = 1,
META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL = 2
META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL = 2,
META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL = 3
} MetaLogicalMonitorLayoutMode;
/*
......
......@@ -108,6 +108,15 @@ static gboolean
is_global_scale_matching_in_config (MetaMonitorsConfig *config,
float scale);
static gboolean
meta_monitor_manager_is_scale_supported_with_threshold (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode,
float scale,
float threshold,
float *out_scale);
MetaBackend *
meta_monitor_manager_get_backend (MetaMonitorManager *manager)
{
......@@ -198,7 +207,7 @@ meta_monitor_manager_get_maximum_scale (MetaMonitorManager *manager)
float scale;
scale = 1.0f;
/* Use config if available, otherwise or */
for (l = manager->monitors; l != NULL; l = l->next)
{
MetaMonitor *monitor = l->data;
......@@ -322,6 +331,45 @@ derive_scale_from_config (MetaMonitorManager *manager,
return 1.0;
}
static gboolean
derive_scale_from_crtc (MetaMonitorManager *manager,
MetaMonitor *monitor,
float *scale)
{
MetaMonitorMode *monitor_mode;
float threshold = FLT_EPSILON;
MetaOutput *output = meta_monitor_get_main_output (monitor);
MetaCrtc *crtc = meta_output_get_assigned_crtc (output);
g_print("XRANDR: meta output %p, has crtc %p, with scale %f\n",
output, crtc, crtc ? crtc->scale : -1);
if (!crtc)
return FALSE;
monitor_mode = meta_monitor_get_current_mode (monitor);
/* Due to inverse scaling applied to the output the result could not match
* exactly, so we apply a more relaxed threshold in this case. */
if (meta_monitor_manager_get_capabilities (manager) &
META_MONITOR_MANAGER_CAPABILITY_NATIVE_OUTPUT_SCALING)
threshold = 0.01f;
if (meta_monitor_manager_is_scale_supported_with_threshold (manager,
manager->layout_mode,
monitor,
monitor_mode,
crtc->scale,
threshold,
scale))
return TRUE;
return FALSE;
// monitor_mode = meta_monitor_get_current_mode (monitor);
// constraints = meta_monitor_manager_get
// meta_monitor_calculate_supported_scales (monitor, monitor_mode, )
}
static void
meta_monitor_manager_rebuild_logical_monitors_derived (MetaMonitorManager *manager,
MetaMonitorsConfig *config)
......@@ -360,6 +408,10 @@ meta_monitor_manager_rebuild_logical_monitors_derived (MetaMonitorManager *manag
meta_monitor_derive_layout (monitor, &layout);
logical_monitor = logical_monitor_from_layout (manager, logical_monitors,
&layout);
g_print("XRANDR. Deriving monitor, is it logical %p, layout %dx%d\n",logical_monitor,
layout.width,layout.height);
// layout.width *= 0.75;
// layout.height *= 0.75;
if (logical_monitor)
{
meta_logical_monitor_add_monitor (logical_monitor, monitor);
......@@ -372,18 +424,18 @@ meta_monitor_manager_rebuild_logical_monitors_derived (MetaMonitorManager *manag
scale = global_scale;
else
{
MetaOutput *output = meta_monitor_get_main_output (monitor);
MetaCrtc *crtc = meta_output_get_assigned_crtc (output);
if (crtc)
scale = crtc->scale;
else if (config)
scale = derive_scale_from_config (manager, config, &layout);
else
scale = calculate_monitor_scale (manager, monitor);
if (!derive_scale_from_crtc (manager, monitor, &scale))
{
if (config)
scale = derive_scale_from_config (manager, config, &layout);
else
scale = calculate_monitor_scale (manager, monitor);
}
}
g_assert (scale > 0);
g_print("XRANDR: creating new monitor %dx%d + %dx%d with scale %f, config %p\n",
layout.width,layout.height, layout.x, layout.y, scale, config);
logical_monitor = meta_logical_monitor_new_derived (manager,
monitor,
&layout,
......@@ -617,6 +669,7 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
if (use_stored_config)
{
config = meta_monitor_config_manager_get_stored (manager->config_manager);
g_print("config = meta_monitor_config_manager_get_stored (manager->config_manager); = %p\n",config);
if (config)
{
if (!meta_monitor_manager_apply_monitors_config (manager,
......@@ -638,6 +691,7 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
}
config = meta_monitor_config_manager_create_suggested (manager->config_manager);
g_print("config = meta_monitor_config_manager_create_suggested (manager->config_manager); = %p\n",config);
if (config)
{
if (!meta_monitor_manager_apply_monitors_config (manager,
......@@ -657,6 +711,7 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
}
config = meta_monitor_config_manager_get_previous (manager->config_manager);
g_print("config = meta_monitor_config_manager_get_previous (manager->config_manager); = %p\n",config);
if (config)
{
config = g_object_ref (config);
......@@ -682,6 +737,7 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
}
config = meta_monitor_config_manager_create_linear (manager->config_manager);
g_print("config = meta_monitor_config_manager_create_linear (manager->config_manager); = %p\n",config);
if (config)
{
if (!meta_monitor_manager_apply_monitors_config (manager,
......@@ -701,6 +757,7 @@ meta_monitor_manager_ensure_configured (MetaMonitorManager *manager)
}
config = meta_monitor_config_manager_create_fallback (manager->config_manager);
g_print("config = meta_monitor_config_manager_create_fallback (manager->config_manager); = %p\n",config);
if (config)
{
if (!meta_monitor_manager_apply_monitors_config (manager,
......@@ -1417,8 +1474,14 @@ gboolean
meta_monitor_manager_disable_scale_for_monitor (MetaMonitorManager *manager,
MetaLogicalMonitor *monitor)
{
if (manager->layout_mode != META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL)
return FALSE;
switch (manager->layout_mode)
{
case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL:
case META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL:
break;
default:
return FALSE;
}
if (monitor && monitor->scale != 1.0f)
{
......@@ -1611,7 +1674,10 @@ meta_monitor_manager_handle_get_current_state (MetaDBusDisplayConfig *skeleton,
monitor_spec->product,
monitor_spec->serial);
}
g_print("XRANDR: getting state for monitor %dx%d + %dx%d: %f\n",
logical_monitor->rect.width,logical_monitor->rect.height,
logical_monitor->rect.x,logical_monitor->rect.y,
logical_monitor->scale);
g_variant_builder_add (&logical_monitors_builder,
LOGICAL_MONITOR_FORMAT,
logical_monitor->rect.x,
......@@ -1631,6 +1697,7 @@ meta_monitor_manager_handle_get_current_state (MetaDBusDisplayConfig *skeleton,
g_variant_builder_add (&properties_builder, "{sv}",
"renderer",
g_variant_new_take_string (renderer));
g_print("XRANDR: Manager type is %s\n", renderer);
capabilities = meta_monitor_manager_get_capabilities (manager);
if ((capabilities & META_MONITOR_MANAGER_CAPABILITY_MIRRORING) == 0)
......@@ -1707,12 +1774,14 @@ meta_monitor_manager_handle_get_current_state (MetaDBusDisplayConfig *skeleton,
#undef LOGICAL_MONITOR_FORMAT
#undef LOGICAL_MONITORS_FORMAT
gboolean
meta_monitor_manager_is_scale_supported (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode,
float scale)
static gboolean
meta_monitor_manager_is_scale_supported_with_threshold (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode,
float scale,
float threshold,
float *out_scale)
{
g_autofree float *supported_scales = NULL;
int n_supported_scales;
......@@ -1726,13 +1795,34 @@ meta_monitor_manager_is_scale_supported (MetaMonitorManager *manager,
&n_supported_scales);
for (i = 0; i < n_supported_scales; i++)
{
if (supported_scales[i] == scale)
return TRUE;
if (fabs (supported_scales[i] - scale) < threshold)
{
if (out_scale)
*out_scale = supported_scales[i];
return TRUE;
}
}
return FALSE;
}
gboolean
meta_monitor_manager_is_scale_supported (MetaMonitorManager *manager,
MetaLogicalMonitorLayoutMode layout_mode,
MetaMonitor *monitor,
MetaMonitorMode *monitor_mode,
float scale)
{
return meta_monitor_manager_is_scale_supported_with_threshold (manager,
layout_mode,
monitor,
monitor_mode,
scale,
FLT_EPSILON,
NULL);
}
static gboolean
is_global_scale_matching_in_config (MetaMonitorsConfig *config,
float scale)
......@@ -2021,6 +2111,7 @@ derive_logical_monitor_size (MetaMonitorConfig *monitor_config,
switch (layout_mode)
{
case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL:
case META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL:
width = roundf (width / scale);
height = roundf (height / scale);
break;
......@@ -2120,6 +2211,12 @@ create_logical_monitor_config_from_variant (MetaMonitorManager *manager
.monitor_configs = monitor_configs
};
g_print("XRANDR: GOT monitor monitor config %p (%d): %dx%d, %dx%d @ %f\n",
logical_monitor_config,logical_monitor_config->is_primary,
logical_monitor_config->layout.x,logical_monitor_config->layout.y,
logical_monitor_config->layout.width,logical_monitor_config->layout.height,
logical_monitor_config->scale);
if (!meta_verify_logical_monitor_config (logical_monitor_config,
layout_mode,
manager,
......@@ -2143,6 +2240,7 @@ is_valid_layout_mode (MetaLogicalMonitorLayoutMode layout_mode)
{
case META_LOGICAL_MONITOR_LAYOUT_MODE_LOGICAL:
case META_LOGICAL_MONITOR_LAYOUT_MODE_PHYSICAL:
case META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL:
return TRUE;
}
......@@ -2165,6 +2263,7 @@ meta_monitor_manager_handle_apply_monitors_config (MetaDBusDisplayConfig *skelet
MetaMonitorsConfig *config;
GList *logical_monitor_configs = NULL;
GError *error = NULL;
float max_scale = 1;
if (serial != manager->serial)
{
......@@ -2236,10 +2335,26 @@ meta_monitor_manager_handle_apply_monitors_config (MetaDBusDisplayConfig *skelet
return TRUE;
}
max_scale = MAX(max_scale, logical_monitor_config->scale);
logical_monitor_configs = g_list_append (logical_monitor_configs,
logical_monitor_config);
}
if (manager->layout_mode == META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL)
{
GList *l;
int ui_scale = ceilf (max_scale);
for (l = logical_monitor_configs; l; l = l->next)
{
MetaLogicalMonitorConfig *logical_monitor_config = l->data;
logical_monitor_config->layout.width =
roundf (logical_monitor_config->layout.width * ui_scale);
logical_monitor_config->layout.height =
roundf (logical_monitor_config->layout.height * ui_scale);
}
}
config = meta_monitors_config_new (manager,
logical_monitor_configs,
layout_mode,
......
......@@ -34,8 +34,8 @@
#define SCALE_FACTORS_STEPS (1.0 / (float) SCALE_FACTORS_PER_INTEGER)
#define MINIMUM_SCALE_FACTOR 1.0f
#define MAXIMUM_SCALE_FACTOR 4.0f
#define MINIMUM_LOGICAL_WIDTH 800
#define MINIMUM_LOGICAL_HEIGHT 480
#define MINIMUM_LOGICAL_WIDTH 100
#define MINIMUM_LOGICAL_HEIGHT 180
#define MAXIMUM_REFRESH_RATE_DIFF 0.001
typedef struct _MetaMonitorMode
......@@ -608,8 +608,11 @@ meta_monitor_normal_get_suggested_position (MetaMonitor *monitor,
if (output->suggested_x < 0 && output->suggested_y < 0)
return FALSE;
*x = output->suggested_x;
*y = output->suggested_y;
if (x)
*x = output->suggested_x;
if (y)
*y = output->suggested_y;
return TRUE;
}
......@@ -1560,6 +1563,9 @@ meta_monitor_calculate_mode_scale (MetaMonitor *monitor,
&global_scaling_factor))
return global_scaling_factor;
if (g_strcmp0 (meta_monitor_get_connector (monitor), "Virtual1") == 0)
return 1.5;
return calculate_scale (monitor, monitor_mode, constraints);
}
......
......@@ -36,6 +36,12 @@ typedef enum _MetaExperimentalFeature
META_EXPERIMENTAL_FEATURE_X11_RANDR_FRACTIONAL_SCALING = (1 << 2),
} MetaExperimentalFeature;
typedef enum _MetaX11ScaleMode
{
META_X11_SCALE_MODE_UP = 1,
META_X11_SCALE_MODE_UI_DOWN,
} MetaX11ScaleMode;
#define META_TYPE_SETTINGS (meta_settings_get_type ())