Commit 793b5f4d authored by Marco Trevisan's avatar Marco Trevisan 🎺

monitor-manager-xrandr: Trigger a rebuild if only crtc scale changed

When in logical global UI scale, and we change the scale from an integer value
to another integer value, we have de-facto to only change the UI scale, while
no crtc configuration has to be done.

So, avoid applying the crtc assignments in such case (as they wouldn't lead to
any xserver reconfiguration and RRScreenChangeNotify event anyway), but update
the logical configuration that will eventually lead to an UI scale factor
update and related signaling.
parent baa2326b
Pipeline #74174 passed with stages
in 7 minutes and 48 seconds
......@@ -299,14 +299,36 @@ xrandr_set_crtc_config (MetaMonitorManagerXrandr *manager_xrandr,
return TRUE;
}
static float
get_maximum_crtc_info_scale (MetaCrtcInfo **crtc_infos,
unsigned int n_crtc_infos)
{
float max_scale = 1.0f;
unsigned int i;
for (i = 0; i < n_crtc_infos; i++)
{
MetaCrtcInfo *crtc_info = crtc_infos[i];
if (crtc_info->mode)
max_scale = MAX (max_scale, crtc_info->scale);
}
return max_scale;
}
static gboolean
is_crtc_assignment_changed (MetaMonitorManager *monitor_manager,
MetaCrtc *crtc,
MetaCrtcInfo **crtc_infos,
unsigned int n_crtc_infos)
{
gboolean have_scaling;
unsigned int i;
have_scaling = meta_monitor_manager_get_capabilities (monitor_manager) &
META_MONITOR_MANAGER_CAPABILITY_NATIVE_OUTPUT_SCALING;
for (i = 0; i < n_crtc_infos; i++)
{
MetaCrtcInfo *crtc_info = crtc_infos[i];
......@@ -327,10 +349,34 @@ is_crtc_assignment_changed (MetaMonitorManager *monitor_manager,
if (crtc->transform != crtc_info->transform)
return TRUE;
if ((meta_monitor_manager_get_capabilities (monitor_manager) &
META_MONITOR_MANAGER_CAPABILITY_NATIVE_OUTPUT_SCALING))
if (have_scaling)
{
if (fabs (crtc->scale - crtc_info->scale) > 0.001)
float crtc_scale = crtc->scale;
float req_output_scale = crtc_info->scale;
MetaLogicalMonitorLayoutMode layout_mode =
meta_monitor_manager_get_default_layout_mode (monitor_manager);
if (layout_mode == META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL)
{
float max_crtc_scale =
meta_monitor_manager_get_maximum_crtc_scale (monitor_manager);
float max_req_scale =
get_maximum_crtc_info_scale (crtc_infos, n_crtc_infos);
/* In scale ui-down mode we need to check if the actual output
* scale that will be applied to the crtc has actually changed
* from the current value, so we need to compare the current crtc
* scale with the scale that will be applied taking care of the
* UI scale (max crtc scale) and of the requested maximum scale.
* If we don't do this, we'd try to call randr calls which won't
* ever trigger a RRScreenChangeNotify, as no actual change is
* needed, and thus we won't ever emit a monitors-changed signal.
*/
crtc_scale /= ceilf (max_crtc_scale);
req_output_scale /= ceilf (max_req_scale);
}
if (fabs (crtc_scale - req_output_scale) > 0.001)
return TRUE;
}
......@@ -435,6 +481,32 @@ is_assignments_changed (MetaMonitorManager *manager,
return TRUE;
}
if (meta_monitor_manager_get_default_layout_mode (manager) ==
META_LOGICAL_MONITOR_LAYOUT_MODE_GLOBAL_UI_LOGICAL)
{
/* If nothing has changed, ensure that the crtc logical scaling matches
* with the requested one, as in case of global UI logical layout we might
* assume that it is in fact equal, while it's techincally different.
* Not doing this would then cause a wrong computation of the max crtc
* scale and thus of the UI scaling. */
for (l = meta_gpu_get_crtcs (manager_xrandr->gpu); l; l = l->next)
{
MetaCrtc *crtc = l->data;
unsigned int i;
for (i = 0; i < n_crtc_infos; i++)
{
MetaCrtcInfo *crtc_info = crtc_infos[i];
if (crtc_info->crtc == crtc)
{
crtc->scale = crtc_info->scale;
break;
}
}
}
}
return FALSE;
}
......@@ -462,22 +534,11 @@ apply_crtc_assignments (MetaMonitorManager *manager,
have_scaling = meta_monitor_manager_get_capabilities (manager) &
META_MONITOR_MANAGER_CAPABILITY_NATIVE_OUTPUT_SCALING;
valid_crtcs = 0;
max_scale = 1.0f;
for (i = 0; i < n_crtcs; i++)
{
MetaCrtcInfo *crtc_info = crtcs[i];
if (crtc_info->mode == NULL)
continue;
valid_crtcs++;
max_scale = MAX (max_scale, crtc_info->scale);
}
/* Compute the new size of the screen (framebuffer) */
max_scale = get_maximum_crtc_info_scale (crtcs, n_crtcs);
width = 0; height = 0;
avg_screen_scale = 0;
valid_crtcs = 0;
for (i = 0; i < n_crtcs; i++)
{
MetaCrtcInfo *crtc_info = crtcs[i];
......@@ -507,7 +568,8 @@ apply_crtc_assignments (MetaMonitorManager *manager,
roundf (crtc_info->mode->height * scale));
}
avg_screen_scale += crtc_info->scale / (float) valid_crtcs;
avg_screen_scale += (crtc_info->scale - avg_screen_scale) /
(float) (++valid_crtcs);
}
/* Second disable all newly disabled CRTCs, or CRTCs that in the previous
......
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