From 228384e4772f13d3078c45e726a3940dd2913af5 Mon Sep 17 00:00:00 2001 From: songchuanfei Date: Tue, 7 Apr 2020 19:03:34 +0800 Subject: [PATCH] Always use preferred size for Virtual screens or when auto configure monitors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 对于接入的新输出,自动设置分辨率时总是使用最佳分辨率, Fix #24217 #24260 - 对于虚拟屏幕, 总是自动设置分辨率 Signed-off-by: songchuanfei --- plugins/xrandr/msd-xrandr-manager.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/plugins/xrandr/msd-xrandr-manager.c b/plugins/xrandr/msd-xrandr-manager.c index fff0c9b..ff6fa3c 100644 --- a/plugins/xrandr/msd-xrandr-manager.c +++ b/plugins/xrandr/msd-xrandr-manager.c @@ -1455,7 +1455,10 @@ auto_configure_outputs (MsdXrandrManager *manager, guint32 timestamp) int width, height; g_assert (mate_rr_output_info_is_connected (output)); - mate_rr_output_info_get_geometry (output, NULL, NULL, &width, &height); + width = mate_rr_output_info_get_preferred_width(output); + height = mate_rr_output_info_get_preferred_height(output); + + log_msg("Set output '%s' size to '%d x %d'\n", mate_rr_output_info_get_name(output), width, height); mate_rr_output_info_set_geometry (output, x, 0, width, height); x += width; @@ -1603,6 +1606,29 @@ on_randr_event (MateRRScreen *screen, gpointer data) show_timestamps_dialog (manager, "need to deal with reconfiguration, as config > change"); + do { + MsdXrandrManagerPrivate *priv = manager->priv; + MateRROutput **outputs = mate_rr_screen_list_outputs(priv->rw_screen); + int i; + + for (i = 0; outputs[i] != NULL; i++) { + MateRROutput *output = outputs[i]; + + if (!mate_rr_output_is_connected(output)) + continue; + + if (mate_rr_output_has_hotplug_mode_update(output)) { + log_msg (" Found output '%s' with property 'hotplug_mode_update'\n", + mate_rr_output_get_name(output)); + /* + * Virtual screen found, just do autoconfigure + */ + goto autoconfigure; + } + } + + } while (0); + intended_filename = mate_rr_config_get_intended_filename (); error = NULL; @@ -1628,6 +1654,7 @@ on_randr_event (MateRRScreen *screen, gpointer data) if (error) g_error_free (error); +autoconfigure: if (config_timestamp != priv->last_config_timestamp) { priv->last_config_timestamp = config_timestamp; auto_configure_outputs (manager, config_timestamp); -- 2.18.1