[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH 2/3] virt_viewer_window_enter_fullscreen: Pass in monitor for fullscreen window



Rather then passing in a move boolean + coordinates to move the window
to for fullscreen mode, simply pass in the monitor, so that the underlying
objects can also use the monitors size to determine the display size.

Note: pass in -1 to use the monitor the window is currently on.

Signed-off-by: Hans de Goede <hdegoede redhat com>
---
 src/virt-viewer-app.c    |  4 +---
 src/virt-viewer-window.c | 36 ++++++++++++++++++++----------------
 src/virt-viewer-window.h |  2 +-
 3 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 25df5c8..90fcb6c 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -1696,14 +1696,12 @@ static void fullscreen_cb(gpointer key,
     DEBUG_LOG("fullscreen display %d: %d", nth, options->fullscreen);
     if (options->fullscreen) {
         GdkScreen *screen = gdk_screen_get_default();
-        GdkRectangle mon;
 
         if (nth >= gdk_screen_get_n_monitors(screen)) {
             DEBUG_LOG("skipping display %d", nth);
             return;
         }
-        gdk_screen_get_monitor_geometry(screen, nth, &mon);
-        virt_viewer_window_enter_fullscreen(vwin, options->move, mon.x, mon.y);
+        virt_viewer_window_enter_fullscreen(vwin, options->move ? nth : -1);
     } else
         virt_viewer_window_leave_fullscreen(vwin);
 }
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index c5b485c..df59db0 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -100,7 +100,6 @@ struct _VirtViewerWindowPrivate {
     gboolean grabbed;
     gboolean before_saved;
     GdkRectangle before_fullscreen;
-    GdkPoint fullscreen_coordinate;
     gboolean desktop_resize_pending;
 
     gint zoomlevel;
@@ -289,7 +288,6 @@ virt_viewer_window_init (VirtViewerWindow *self)
     priv = self->priv;
 
     priv->auto_resize = TRUE;
-    priv->fullscreen_coordinate.x = priv->fullscreen_coordinate.y = -1;
     g_value_init(&priv->accel_setting, G_TYPE_STRING);
 
     priv->notebook = virt_viewer_notebook_new();
@@ -469,6 +467,21 @@ virt_viewer_window_resize(VirtViewerWindow *self, gboolean keep_win_size)
                                          width, height);
 }
 
+static void
+virt_viewer_window_move_to_monitor(VirtViewerWindow *self)
+{
+    VirtViewerWindowPrivate *priv = self->priv;
+    GdkRectangle mon;
+    gint n;
+
+    n = virt_viewer_display_get_monitor(priv->display);
+    if (n == -1 || !priv->fullscreen)
+        return;
+
+    gdk_screen_get_monitor_geometry(gdk_screen_get_default(), n, &mon);
+    gtk_window_move(GTK_WINDOW(priv->window), mon.x, mon.y);
+}
+
 void
 virt_viewer_window_leave_fullscreen(VirtViewerWindow *self)
 {
@@ -481,7 +494,7 @@ virt_viewer_window_leave_fullscreen(VirtViewerWindow *self)
 
     gtk_check_menu_item_set_active(check, FALSE);
     priv->fullscreen = FALSE;
-    priv->fullscreen_coordinate.x = priv->fullscreen_coordinate.y = -1;
+    virt_viewer_display_set_monitor(priv->display, -1);
     ViewAutoDrawer_SetActive(VIEW_AUTODRAWER(priv->layout), FALSE);
     gtk_widget_show(menu);
     gtk_widget_hide(priv->toolbar);
@@ -502,7 +515,7 @@ virt_viewer_window_leave_fullscreen(VirtViewerWindow *self)
 }
 
 void
-virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gboolean move, gint x, gint y)
+virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gint monitor)
 {
     VirtViewerWindowPrivate *priv = self->priv;
     GtkWidget *menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "top-menu"));
@@ -528,12 +541,8 @@ virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gboolean move, gint
     ViewAutoDrawer_SetActive(VIEW_AUTODRAWER(priv->layout), TRUE);
     ViewAutoDrawer_Close(VIEW_AUTODRAWER(priv->layout));
 
-    /* g_debug("enter fullscreen move:%d %d+%d", move, x, y); */
-    if (move) {
-        gtk_window_move(GTK_WINDOW(priv->window), x, y);
-        priv->fullscreen_coordinate.x = x;
-        priv->fullscreen_coordinate.y = y;
-    }
+    virt_viewer_display_set_monitor(priv->display, monitor);
+    virt_viewer_window_move_to_monitor(self);
 
     gtk_window_fullscreen(GTK_WINDOW(priv->window));
 #ifdef G_OS_WIN32
@@ -1133,8 +1142,6 @@ virt_viewer_window_set_display(VirtViewerWindow *self, VirtViewerDisplay *displa
 void
 virt_viewer_window_show(VirtViewerWindow *self)
 {
-    VirtViewerWindowPrivate *priv = self->priv;
-
     gtk_widget_show(self->priv->window);
 
     if (self->priv->display)
@@ -1145,10 +1152,7 @@ virt_viewer_window_show(VirtViewerWindow *self)
         self->priv->desktop_resize_pending = FALSE;
     }
 
-    if (priv->fullscreen && priv->fullscreen_coordinate.x != -1)
-        gtk_window_move(GTK_WINDOW(priv->window),
-                        priv->fullscreen_coordinate.x,
-                        priv->fullscreen_coordinate.y);
+    virt_viewer_window_move_to_monitor(self);
 }
 
 void
diff --git a/src/virt-viewer-window.h b/src/virt-viewer-window.h
index 44db585..41ac5e2 100644
--- a/src/virt-viewer-window.h
+++ b/src/virt-viewer-window.h
@@ -71,7 +71,7 @@ void virt_viewer_window_hide(VirtViewerWindow *self);
 void virt_viewer_window_set_zoom_level(VirtViewerWindow *self, gint zoom_level);
 gint virt_viewer_window_get_zoom_level(VirtViewerWindow *self);
 void virt_viewer_window_leave_fullscreen(VirtViewerWindow *self);
-void virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gboolean move, gint x, gint y);
+void virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gint monitor);
 GtkMenuItem *virt_viewer_window_get_menu_displays(VirtViewerWindow *self);
 GtkBuilder* virt_viewer_window_get_builder(VirtViewerWindow *window);
 
-- 
1.8.1.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]