From 13b2430ee3e55b0a84918d97a6469ea87cebeda7 Mon Sep 17 00:00:00 2001 From: Victor Kareh Date: Mon, 4 May 2026 15:49:10 -0400 Subject: xrandr: Handle hotplug_mode_update for VM guest resizing When an output has the hotplug_mode_update property (e.g. SPICE/QXL virtual displays), auto-configure to the new preferred mode on hotplug events instead of applying stored configuration from monitors.xml. This allows VM guest resolutions to follow host window resizes, which stopped working when spice-vdagent switched from reconfiguring displays directly to sending hotplug events expecting the DE to handle them. Fixes #78 --- plugins/xrandr/msd-xrandr-manager.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'plugins') diff --git a/plugins/xrandr/msd-xrandr-manager.c b/plugins/xrandr/msd-xrandr-manager.c index 78e538f..4402fd9 100644 --- a/plugins/xrandr/msd-xrandr-manager.c +++ b/plugins/xrandr/msd-xrandr-manager.c @@ -1572,6 +1572,22 @@ apply_color_profiles (void) } } +static gboolean +has_hotplug_mode_update (MateRRScreen *screen) +{ + MateRROutput **outputs; + int i; + + outputs = mate_rr_screen_list_outputs (screen); + + for (i = 0; outputs[i] != NULL; i++) { + if (mate_rr_output_get_hotplug_mode_update (outputs[i])) + return TRUE; + } + + return FALSE; +} + static void on_randr_event (MateRRScreen *screen, gpointer data) { @@ -1600,6 +1616,24 @@ on_randr_event (MateRRScreen *screen, gpointer data) */ show_timestamps_dialog (manager, "ignoring since change > config"); log_msg (" Ignoring event since change >= config\n"); + } else if (has_hotplug_mode_update (screen)) { + /* An output has the hotplug_mode_update property, which + * means that the driver is requesting that the desktop + * environment apply a new preferred mode on hotplug events + * to handle dynamic guest resizing (e.g. SPICE/QXL in VMs). + * + * In this case, always auto-configure to use the new + * preferred mode rather than applying stored configurations. + */ + + show_timestamps_dialog (manager, "hotplug_mode_update detected, auto-configuring"); + + if (config_timestamp != priv->last_config_timestamp) { + priv->last_config_timestamp = config_timestamp; + auto_configure_outputs (manager, config_timestamp); + log_msg (" Automatically configured outputs for hotplug_mode_update\n"); + } else + log_msg (" Ignored hotplug_mode_update event as timestamps are the same\n"); } else { /* Here, config_timestamp > change_timestamp. This means that * the screen got reconfigured because of hotplug/unplug; the X -- cgit v1.2.1