Commit 0c074246 authored by Marco Trevisan's avatar Marco Trevisan 🎺

x11, monitor-manager: update screen size after we updated from server

When the randr transformation increases the screen size, we need to update the
screen area, because after calling XRRUpdateConfiguration in this case the
values don't change.

So, we need to read actual values, in case scale them, and finally update
the screen size again if needed.
parent 11a790a5
...@@ -626,6 +626,60 @@ meta_monitor_manager_xrandr_ensure_initial_config (MetaMonitorManager *manager) ...@@ -626,6 +626,60 @@ meta_monitor_manager_xrandr_ensure_initial_config (MetaMonitorManager *manager)
meta_monitor_manager_update_logical_state_derived (manager, config); meta_monitor_manager_update_logical_state_derived (manager, config);
} }
static void
meta_monitor_manager_xrandr_rebuild_derived (MetaMonitorManager *manager,
MetaMonitorsConfig *config)
{
MetaMonitorManagerXrandr *manager_xrandr =
META_MONITOR_MANAGER_XRANDR(manager);
meta_monitor_manager_rebuild_derived (manager, config);
/* Compute the new size of the screen (framebuffer) */
int screen_width = 0;
int screen_height = 0;
unsigned n_crtcs = 0;
float average_scale = 0;
GList *l;
for (l = meta_gpu_get_crtcs (manager_xrandr->gpu); l; l = l->next)
{
float scale;
MetaCrtc *crtc = l->data;
if (crtc->current_mode == NULL)
continue;
/* When scaling up we should not reduce the screen size, or X will fail
* miserabily, while we must do it when scaling down, in order to increase
* the available screen area we can use. */
scale = crtc->scale > 1.0f ? crtc->scale : 1.0f;
if (meta_monitor_transform_is_rotated (crtc->transform))
{
screen_width = MAX (screen_width, roundf ((crtc->rect.x + crtc->rect.height) * scale));
screen_height = MAX (screen_height, roundf ((crtc->rect.y + crtc->rect.width) * scale));
}
else
{
screen_width = MAX (screen_width, roundf ((crtc->rect.x + crtc->rect.width) * scale));
screen_height = MAX (screen_height, roundf ((crtc->rect.y + crtc->rect.height) * scale));
}
++n_crtcs;
/* This value isn't completely exact, since it doesn't take care of the
* actual crtc sizes, however, since w're going to use this only to set
* the MM size of the screen, and given that this value is just an
* estimation, we don't need to be super precise. */
average_scale += (scale - average_scale) / (float) n_crtcs;
}
meta_monitor_manager_xrandr_update_screen_size (manager_xrandr,
screen_width, screen_height,
average_scale);
}
static gboolean static gboolean
meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *manager, meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *manager,
MetaMonitorsConfig *config, MetaMonitorsConfig *config,
...@@ -637,7 +691,7 @@ meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *mana ...@@ -637,7 +691,7 @@ meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *mana
if (!config) if (!config)
{ {
meta_monitor_manager_rebuild_derived (manager, NULL); meta_monitor_manager_xrandr_rebuild_derived (manager, NULL);
return TRUE; return TRUE;
} }
...@@ -671,7 +725,7 @@ meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *mana ...@@ -671,7 +725,7 @@ meta_monitor_manager_xrandr_apply_monitors_config (MetaMonitorManager *mana
} }
else else
{ {
meta_monitor_manager_rebuild_derived (manager, config); meta_monitor_manager_xrandr_rebuild_derived (manager, config);
} }
} }
...@@ -1122,7 +1176,7 @@ meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xra ...@@ -1122,7 +1176,7 @@ meta_monitor_manager_xrandr_handle_xevent (MetaMonitorManagerXrandr *manager_xra
config = NULL; config = NULL;
} }
meta_monitor_manager_rebuild_derived (manager, config); meta_monitor_manager_xrandr_rebuild_derived (manager, config);
} }
return TRUE; return TRUE;
......
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