mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/virt-viewer
synced 2026-01-03 15:39:31 +00:00
Avoid warning when loading initial monitor mapping
When started in fullscreen mode with a monitor-mapping configuration
option, we are getting the following warnings on the terminal:
(process:27428): Gdk-CRITICAL **: gdk_screen_get_n_monitors: assertion 'GDK_IS_SCREEN (screen)' failed
** (process:27428): WARNING **: Invalid monitor-mapping configuration: monitor #1 for display #1 does not exist
This is apparently because we were processing the fallback monitor
mapping before the graphic server display was opened, so
gdk_screen_get_default() returned NULL. This resulted in
gdk_screen_get_n_monitors() reporting that we had 0 monitors.
This patch moves the fallback monitor mapping parsing from
virt_viewer_app_init() to virt_viewer_app_on_application_startup(),
after chaining up to the base class startup() vfunc. The graphic server
display is opened in the base class vfunc, so by the time that returns,
we should be able to query the number of monitors.
The patch also adds a check in virt_viewer_parse_monitor_mappings() to
ensure that we pass a sane value for nmonitors.
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
This commit is contained in:
parent
47c7f4c064
commit
e1adf25b6a
@ -1730,7 +1730,6 @@ virt_viewer_app_init(VirtViewerApp *self)
|
||||
|
||||
g_clear_error(&error);
|
||||
|
||||
self->priv->initial_display_map = virt_viewer_app_get_monitor_mapping_for_section(self, "fallback");
|
||||
g_signal_connect(self, "notify::guest-name", G_CALLBACK(title_maybe_changed), NULL);
|
||||
g_signal_connect(self, "notify::title", G_CALLBACK(title_maybe_changed), NULL);
|
||||
g_signal_connect(self, "notify::guri", G_CALLBACK(title_maybe_changed), NULL);
|
||||
@ -1807,6 +1806,7 @@ virt_viewer_app_on_application_startup(GApplication *app)
|
||||
self->priv->main_window = virt_viewer_app_window_new(self,
|
||||
virt_viewer_app_get_first_monitor(self));
|
||||
self->priv->main_notebook = GTK_WIDGET(virt_viewer_window_get_notebook(self->priv->main_window));
|
||||
self->priv->initial_display_map = virt_viewer_app_get_monitor_mapping_for_section(self, "fallback");
|
||||
|
||||
virt_viewer_app_set_kiosk(self, opt_kiosk);
|
||||
virt_viewer_app_set_hotkeys(self, opt_hotkeys);
|
||||
|
||||
@ -641,11 +641,14 @@ virt_viewer_shift_monitors_to_origin(GHashTable *displays)
|
||||
GHashTable*
|
||||
virt_viewer_parse_monitor_mappings(gchar **mappings, const gsize nmappings, const gint nmonitors)
|
||||
{
|
||||
GHashTable *displaymap = g_hash_table_new(g_direct_hash, g_direct_equal);
|
||||
GHashTable *monitormap = g_hash_table_new(g_direct_hash, g_direct_equal);
|
||||
GHashTable *displaymap;
|
||||
GHashTable *monitormap;
|
||||
gint i, max_display_id = 0;
|
||||
gchar **tokens = NULL;
|
||||
|
||||
g_return_val_if_fail(nmonitors != 0, NULL);
|
||||
displaymap = g_hash_table_new(g_direct_hash, g_direct_equal);
|
||||
monitormap = g_hash_table_new(g_direct_hash, g_direct_equal);
|
||||
if (nmappings == 0) {
|
||||
g_warning("Empty monitor-mapping configuration");
|
||||
goto configerror;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user