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>