[virt-tools-list] [PATCH virt-viewer 4/4] virt-viewer-window: Allow to resize window to any size
Pavel Grunt
pgrunt at redhat.com
Thu Jul 16 10:06:45 UTC 2015
On Wed, 2015-07-15 at 14:15 -0500, Jonathon Jongsma wrote:
> Considering the issue I mentioned in my last email for patch 3, I'd say
> that this simpler approach is better. It is both easier to understand
> and results in more expected behavior. It may be a better idea to just
> drop patch 3 since it doesn't appear to be a great intermediate
> downstream solution.
>
> It would be good to get a decent amount of testing to make sure that it
> doesn't introduce any regressions. I haven't tested it in windows or
> non-gnome3 environments to see how the window manager handles things,
> but in gnome3 it seems fine from my initial testing.
>
> Jonathon
>
Ok, I will drop the patch 3 and summarize changes for GNOME2, GNOME3 and Windows
Pavel
>
> On Tue, 2015-07-14 at 16:13 +0200, Pavel Grunt wrote:
> > The function virt_viewer_window_resize restricts window to be bigger
> > than a client's screen. It avoids extending the window to more client's
> > screens, it causes changes of the zoom level if the guest does not fit
> > into a screen.
> >
> > Lets remove virt_viewer_window_resize (its behaviour was introduced
> > by the commit 6acb3856b6d8007752388f22f97aa8aaffdb7a5e). It will let
> > the window managers to handle resizing of the window.
> >
> > Resolves:
> > https://bugzilla.redhat.com/show_bug.cgi?id=1205804
> > ---
> > src/virt-viewer-window.c | 67 +++------------------------------------------
> > ---
> > 1 file changed, 3 insertions(+), 64 deletions(-)
> >
> > diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> > index a851022..3af51a4 100644
> > --- a/src/virt-viewer-window.c
> > +++ b/src/virt-viewer-window.c
> > @@ -66,7 +66,7 @@ void virt_viewer_window_menu_preferences_cb(GtkWidget
> > *menu, VirtViewerWindow *s
> > /* Internal methods */
> > static void virt_viewer_window_enable_modifiers(VirtViewerWindow *self);
> > static void virt_viewer_window_disable_modifiers(VirtViewerWindow *self);
> > -static void virt_viewer_window_resize(VirtViewerWindow *self);
> > +static void virt_viewer_window_queue_resize(VirtViewerWindow *self);
> > static void virt_viewer_window_toolbar_setup(VirtViewerWindow *self);
> > static GtkMenu* virt_viewer_window_get_keycombo_menu(VirtViewerWindow
> > *self);
> > static void virt_viewer_window_get_minimal_dimensions(VirtViewerWindow
> > *self, guint *width, guint *height);
> > @@ -365,7 +365,7 @@ virt_viewer_window_desktop_resize(VirtViewerDisplay
> > *display G_GNUC_UNUSED,
> > self->priv->desktop_resize_pending = TRUE;
> > return;
> > }
> > - virt_viewer_window_resize(self);
> > + virt_viewer_window_queue_resize(self);
> > }
> >
> > static gint
> > @@ -419,67 +419,6 @@ virt_viewer_window_queue_resize(VirtViewerWindow *self)
> > #endif
> > }
> >
> > -/*
> > - * This code attempts to resize the top level window to be large enough
> > - * to contain the entire display desktop at 1:1 ratio. If the local desktop
> > - * isn't large enough that it goes as large as possible and lets the
> > display
> > - * scale down to fit, maintaining aspect ratio
> > - */
> > -static void
> > -virt_viewer_window_resize(VirtViewerWindow *self)
> > -{
> > - GdkRectangle fullscreen;
> > - GdkScreen *screen;
> > - double desktopAspect;
> > - double screenAspect;
> > - guint desktopWidth, display_width;
> > - guint desktopHeight, display_height;
> > - VirtViewerWindowPrivate *priv = self->priv;
> > -
> > - if (priv->fullscreen)
> > - return;
> > -
> > - g_debug("Preparing main window resize");
> > - if (!priv->display) {
> > - g_debug("Skipping inactive resize");
> > - return;
> > - }
> > -
> > - virt_viewer_display_get_desktop_size(VIRT_VIEWER_DISPLAY(priv
> > ->display),
> > - &desktopWidth, &desktopHeight);
> > -
> > - screen = gtk_widget_get_screen(priv->window);
> > - gdk_screen_get_monitor_geometry(screen,
> > - gdk_screen_get_monitor_at_window
> > - (screen, gtk_widget_get_window(priv
> > ->window)),
> > - &fullscreen);
> > -
> > - g_return_if_fail(desktopWidth > 0);
> > - g_return_if_fail(desktopHeight > 0);
> > -
> > - desktopAspect = (double)desktopWidth / (double)desktopHeight;
> > - screenAspect = (double)fullscreen.width / (double)fullscreen.height;
> > -
> > - display_width = desktopWidth * priv->zoomlevel / (double)
> > NORMAL_ZOOM_LEVEL;
> > - display_height = desktopHeight * priv->zoomlevel / (double)
> > NORMAL_ZOOM_LEVEL;
> > -
> > - if ((display_width > fullscreen.width) ||
> > - (display_height > fullscreen.height)) {
> > - gint new_zoom;
> > - /* Doesn't fit native res, so go as large as possible
> > - maintaining aspect ratio */
> > - if (screenAspect > desktopAspect) {
> > - new_zoom = NORMAL_ZOOM_LEVEL * fullscreen.height /
> > desktopHeight;
> > - } else {
> > - new_zoom = NORMAL_ZOOM_LEVEL * fullscreen.width / desktopWidth;
> > - }
> > - g_debug("scaling down, desktop does not fit into screen");
> > - virt_viewer_window_set_zoom_level(self, new_zoom);
> > - } else {
> > - virt_viewer_window_queue_resize(self);
> > - }
> > -}
> > -
> > static void
> > virt_viewer_window_move_to_monitor(VirtViewerWindow *self)
> > {
> > @@ -1420,7 +1359,7 @@ virt_viewer_window_show(VirtViewerWindow *self)
> > gtk_widget_show(self->priv->window);
> >
> > if (self->priv->desktop_resize_pending) {
> > - virt_viewer_window_resize(self);
> > + virt_viewer_window_queue_resize(self);
> > self->priv->desktop_resize_pending = FALSE;
> > }
> >
>
>
More information about the virt-tools-list
mailing list