Codebase list virt-viewer / 47c22dc
src: enable remote desktop resize with VNC GTK-VNC has native support for remote desktop resize, provided that we always give the widget the full available allocation. This requires that we turn off VirtViewerDisplay's code for keeping aspect ratio, and instead enable GTK-VNC's equivalent. Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Daniel P. Berrangé 3 years ago
1 changed file(s) with 45 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
2323
2424 #include <config.h>
2525
26 #include <gvnc.h>
27
2628 #include "virt-viewer-auth.h"
2729 #include "virt-viewer-display-vnc.h"
2830 #include "virt-viewer-util.h"
2931
3032 #include <glib/gi18n.h>
33
34 #ifndef VNC_CHECK_VERSION
35 # define VNC_CHECK_VERSION(a, b, c) 0
36 #endif
37 #if VNC_CHECK_VERSION(1, 2, 0)
38 # define HAVE_VNC_REMOTE_RESIZE
39 #endif
3140
3241 struct _VirtViewerDisplayVnc {
3342 VirtViewerDisplay parent;
209218 vnc_display_set_grab_keys(vnc, NULL);
210219 }
211220 }
221
222
223 #ifdef HAVE_VNC_REMOTE_RESIZE
224 static void
225 resize_policy_changed(VirtViewerDisplayVnc *self,
226 GParamSpec *pspec G_GNUC_UNUSED,
227 VncDisplay *vnc)
228 {
229 gboolean enable = virt_viewer_display_get_auto_resize(VIRT_VIEWER_DISPLAY(self));
230
231 vnc_display_set_allow_resize(vnc, enable);
232 }
233
234 static void
235 zoom_level_changed(VirtViewerDisplay *display,
236 GParamSpec *pspec G_GNUC_UNUSED,
237 VncDisplay *vnc)
238 {
239 guint zoom = virt_viewer_display_get_zoom_level(display);
240
241 vnc_display_set_zoom(vnc, zoom);
242 }
243 #endif
212244
213245
214246 GtkWidget *
239271 vnc_display_set_force_size(self->vnc, FALSE);
240272 vnc_display_set_scaling(self->vnc, TRUE);
241273
274 #ifdef HAVE_VNC_REMOTE_RESIZE
275 vnc_display_set_keep_aspect_ratio(self->vnc, TRUE);
276 g_object_set(self, "force-aspect", FALSE, NULL);
277 #endif
278
242279 /* When VNC desktop resizes, we have to resize the containing widget */
243280 g_signal_connect(self->vnc, "vnc-desktop-resize",
244281 G_CALLBACK(virt_viewer_display_vnc_resize_desktop), self);
259296 G_CALLBACK(enable_accel_changed), self->vnc, 0);
260297 enable_accel_changed(app, NULL, self->vnc);
261298
299 #ifdef HAVE_VNC_REMOTE_RESIZE
300 virt_viewer_signal_connect_object(self, "notify::auto-resize",
301 G_CALLBACK(resize_policy_changed), self->vnc, 0);
302 virt_viewer_signal_connect_object(self, "notify::zoom-level",
303 G_CALLBACK(zoom_level_changed), self->vnc, 0);
304 resize_policy_changed(self, NULL, self->vnc);
305 #endif
306
262307 return GTK_WIDGET(self);
263308 }
264309