[PATCH remote-viewer 1/1] Remember monitor mapping on close.
Daniel P. Berrangé
berrange at redhat.com
Tue Jan 28 15:48:32 UTC 2020
On Tue, Jan 21, 2020 at 08:48:35AM +0100, Julien Ropé wrote:
> When the application is stopped, if the windows are in fullscreen, their
> position on the client will be remembered.
>
> This change uses the existing option 'monitor-mapping' in the settings
> file to save the position and reuse it on next launch.
>
> This implements part of the requirement from
> https://bugzilla.redhat.com/show_bug.cgi?id=1179070
>
> Signed-off-by: Julien Ropé <jrope at redhat.com>
> ---
> src/virt-viewer-app.c | 114 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 114 insertions(+)
>
> diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
> index da8cfa9..f955882 100644
> --- a/src/virt-viewer-app.c
> +++ b/src/virt-viewer-app.c
> @@ -106,6 +106,7 @@ static void virt_viewer_app_set_fullscreen(VirtViewerApp *self, gboolean fullscr
> static void virt_viewer_app_update_menu_displays(VirtViewerApp *self);
> static void virt_viewer_update_smartcard_accels(VirtViewerApp *self);
> static void virt_viewer_app_add_option_entries(VirtViewerApp *self, GOptionContext *context, GOptionGroup *group);
> +static VirtViewerWindow *virt_viewer_app_get_nth_window(VirtViewerApp *self, gint nth);
>
>
> struct _VirtViewerAppPrivate {
> @@ -400,6 +401,116 @@ virt_viewer_app_get_monitor_mapping_for_section(VirtViewerApp *self, const gchar
> return mapping;
> }
>
> +/*
> + * save the association display/monitor in the config for reuse on next connection
> + */
> +static void virt_viewer_app_set_monitor_mapping_for_display(VirtViewerApp *self, VirtViewerDisplay *display)
> +{
> + GError *error = NULL;
> + gsize nmappings = 0;
> + gchar **mappings = NULL;
> + gchar **tokens = NULL;
> +
> + int i;
> +
> + gint virt_viewer_display = virt_viewer_display_get_nth(display);
> + gint virt_viewer_monitor = virt_viewer_display_get_monitor(display);
> +
> + if (virt_viewer_monitor == -1) {
> + // find which monitor the window is on
> + GdkDisplay *gdk_dpy = gdk_display_get_default();
> + VirtViewerWindow *vvWindow = virt_viewer_app_get_nth_window(self, virt_viewer_display) ;
> + GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(virt_viewer_window_get_window(vvWindow)));
> + GdkMonitor *pMonitor = gdk_display_get_monitor_at_window(gdk_dpy, window);
This breaks the build due to using APIs that are newer than our min
reqiured GTK version:
virt-viewer-app.c: In function 'virt_viewer_app_set_monitor_mapping_for_display':
virt-viewer-app.c:428:9: warning: 'gdk_display_get_monitor_at_window' is deprecated: Not available before 3.22 [-Wdeprecated-declarations]
428 | GdkMonitor *pMonitor = gdk_display_get_monitor_at_window(gdk_dpy, window);
| ^~~~~~~~~~
In file included from /usr/include/gtk-3.0/gdk/gdkscreen.h:32,
from /usr/include/gtk-3.0/gdk/gdkapplaunchcontext.h:31,
from /usr/include/gtk-3.0/gdk/gdk.h:32,
from /usr/include/gtk-3.0/gtk/gtk.h:30,
from virt-viewer-app.c:28:
/usr/include/gtk-3.0/gdk/gdkdisplay.h:194:14: note: declared here
194 | GdkMonitor * gdk_display_get_monitor_at_window (GdkDisplay *display,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We currently request
GTK_REQUIRED="3.12"
GTK_ENCODED_VERSION="GDK_VERSION_3_12"
based on our CI platforms, Ubuntu 16.04 is the oldest GTK
at version 3.18.9
So we can bump our min GTK to 3.18, but we can't use
APIs from 3.22 yet
Once we drop Ubuntu 16.04 - most likely around the April 2020 timefram
when Ubuntu 20.04 is released, then Debian 9 & CentOS 7 will be the
oldest at version 3.22.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
More information about the virt-tools-list
mailing list