[virt-tools-list] [PATCH] [RFC] Drop zooming operations
Fabiano Fidêncio
fidencio at redhat.com
Mon Jun 13 07:55:50 UTC 2016
Zooming operations have been a big source of bugs since they were
introduced. My suggestion is that we drop the zooming operations before
start merging Sagar's work[0], which I would like to have in for Fedora
25.
Dropping those while re-designing the UI seems something sane. A major
version bump would be needed as well. And for those who like zooming
options for testing high resolutions, let's keep it on spicy (which is
already a playground tool).
Maybe would be good to have a release before start thinking on merging
Sagar's work? We are with ~80 commits on top of our v3.0 release. Seems
like a safe approach have a release soon and then start moving things
around.
Opinions? Suggestions?
[0]: https://fidencio.fedorapeople.org/Sagar/
---
src/virt-viewer-app.c | 15 -----
src/virt-viewer-display.c | 61 +------------------
src/virt-viewer-window.c | 150 ----------------------------------------------
src/virt-viewer-window.h | 7 ---
src/virt-viewer.xml | 55 -----------------
5 files changed, 2 insertions(+), 286 deletions(-)
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index b99ed32..3c9fdeb 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -857,8 +857,6 @@ virt_viewer_app_window_new(VirtViewerApp *self, gint nth)
window = g_object_new(VIRT_VIEWER_TYPE_WINDOW, "app", self, NULL);
virt_viewer_window_set_kiosk(window, self->priv->kiosk);
- if (self->priv->main_window)
- virt_viewer_window_set_zoom_level(window, virt_viewer_window_get_zoom_level(self->priv->main_window));
self->priv->windows = g_list_append(self->priv->windows, window);
virt_viewer_app_set_window_subtitle(self, window, nth);
@@ -1683,7 +1681,6 @@ gboolean virt_viewer_app_start(VirtViewerApp *self, GError **error)
return self->priv->started;
}
-static int opt_zoom = NORMAL_ZOOM_LEVEL;
static gchar *opt_hotkeys = NULL;
static gboolean opt_version = FALSE;
static gboolean opt_verbose = FALSE;
@@ -1801,20 +1798,10 @@ virt_viewer_app_on_application_startup(GApplication *app)
virt_viewer_app_set_kiosk(self, opt_kiosk);
virt_viewer_app_set_hotkeys(self, opt_hotkeys);
- if (opt_zoom < MIN_ZOOM_LEVEL || opt_zoom > MAX_ZOOM_LEVEL) {
- g_printerr(_("Zoom level must be within %d-%d\n"), MIN_ZOOM_LEVEL, MAX_ZOOM_LEVEL);
- opt_zoom = NORMAL_ZOOM_LEVEL;
- }
-
- virt_viewer_window_set_zoom_level(self->priv->main_window, opt_zoom);
-
virt_viewer_set_insert_smartcard_accel(self, GDK_KEY_F8, GDK_SHIFT_MASK);
virt_viewer_set_remove_smartcard_accel(self, GDK_KEY_F9, GDK_SHIFT_MASK);
gtk_accel_map_add_entry("<virt-viewer>/view/toggle-fullscreen", GDK_KEY_F11, 0);
gtk_accel_map_add_entry("<virt-viewer>/view/release-cursor", GDK_KEY_F12, GDK_SHIFT_MASK);
- gtk_accel_map_add_entry("<virt-viewer>/view/zoom-reset", GDK_KEY_0, GDK_CONTROL_MASK);
- gtk_accel_map_add_entry("<virt-viewer>/view/zoom-out", GDK_KEY_minus, GDK_CONTROL_MASK);
- gtk_accel_map_add_entry("<virt-viewer>/view/zoom-in", GDK_KEY_plus, GDK_CONTROL_MASK);
gtk_accel_map_add_entry("<virt-viewer>/send/secure-attention", GDK_KEY_End, GDK_CONTROL_MASK | GDK_MOD1_MASK);
if (!virt_viewer_app_start(self, &error)) {
@@ -2559,8 +2546,6 @@ virt_viewer_app_add_option_entries(G_GNUC_UNUSED VirtViewerApp *self,
static const GOptionEntry options [] = {
{ "version", 'V', 0, G_OPTION_ARG_NONE, &opt_version,
N_("Display version information"), NULL },
- { "zoom", 'z', 0, G_OPTION_ARG_INT, &opt_zoom,
- N_("Zoom level of window, in percentage"), "ZOOM" },
{ "full-screen", 'f', 0, G_OPTION_ARG_NONE, &opt_fullscreen,
N_("Open in full screen mode (adjusts guest resolution to fit the client)"), NULL },
{ "hotkeys", 'H', 0, G_OPTION_ARG_STRING, &opt_hotkeys,
diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index 2dbaba1..9326c58 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -37,7 +37,6 @@ struct _VirtViewerDisplayPrivate
{
guint desktopWidth;
guint desktopHeight;
- guint zoom_level;
gint nth_display; /* Monitor number inside the guest */
gint monitor; /* Monitor number on the client */
guint show_hint;
@@ -115,16 +114,6 @@ virt_viewer_display_class_init(VirtViewerDisplayClass *class)
G_PARAM_READWRITE));
g_object_class_install_property(object_class,
- PROP_ZOOM_LEVEL,
- g_param_spec_int("zoom-level",
- "Zoom",
- "Zoom level",
- MIN_ZOOM_LEVEL,
- MAX_ZOOM_LEVEL,
- NORMAL_ZOOM_LEVEL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property(object_class,
PROP_NTH_DISPLAY,
g_param_spec_int("nth-display",
"Nth display",
@@ -253,7 +242,6 @@ virt_viewer_display_init(VirtViewerDisplay *display)
display->priv->desktopWidth = MIN_DISPLAY_WIDTH;
display->priv->desktopHeight = MIN_DISPLAY_HEIGHT;
- display->priv->zoom_level = NORMAL_ZOOM_LEVEL;
}
GtkWidget*
@@ -353,14 +341,8 @@ static void virt_viewer_display_get_preferred_dimension_from_desktop(VirtViewerD
{
int border_width = gtk_container_get_border_width(GTK_CONTAINER(display));
- if (virt_viewer_display_get_zoom(display)) {
- guint zoom_level = virt_viewer_display_get_zoom_level(display);
- *preferred_dim = round(desktop_dim * zoom_level / (double) NORMAL_ZOOM_LEVEL);
- *minimal_dim = round(minimal_size * zoom_level / (double) NORMAL_ZOOM_LEVEL);
- } else {
- *preferred_dim = desktop_dim;
- *minimal_dim = minimal_size;
- }
+ *preferred_dim = desktop_dim;
+ *minimal_dim = minimal_size;
*preferred_dim += 2 * border_width;
*minimal_dim += 2 * border_width;
}
@@ -479,38 +461,6 @@ void virt_viewer_display_queue_resize(VirtViewerDisplay *display)
}
}
-void virt_viewer_display_set_zoom_level(VirtViewerDisplay *display,
- guint zoom)
-{
- VirtViewerDisplayPrivate *priv = display->priv;
-
- if (zoom < MIN_ZOOM_LEVEL)
- zoom = MIN_ZOOM_LEVEL;
- if (zoom > MAX_ZOOM_LEVEL)
- zoom = MAX_ZOOM_LEVEL;
-
- if (priv->zoom_level == zoom)
- return;
-
- priv->zoom_level = zoom;
-
- virt_viewer_display_queue_resize(display);
- g_object_notify(G_OBJECT(display), "zoom-level");
-}
-
-
-guint virt_viewer_display_get_zoom_level(VirtViewerDisplay *display)
-{
- VirtViewerDisplayPrivate *priv = display->priv;
- return priv->zoom_level;
-}
-
-gboolean virt_viewer_display_get_zoom(VirtViewerDisplay *display)
-{
- return virt_viewer_display_get_zoom_level(display) != NORMAL_ZOOM_LEVEL;
-}
-
-
void virt_viewer_display_send_keys(VirtViewerDisplay *display,
const guint *keyvals, int nkeyvals)
{
@@ -718,13 +668,6 @@ void virt_viewer_display_get_preferred_monitor_geometry(VirtViewerDisplay* self,
preferred->x = topx;
preferred->y = topy;
}
-
- if (virt_viewer_display_get_zoom(self)) {
- guint zoom = virt_viewer_display_get_zoom_level(self);
-
- preferred->width = round(preferred->width * NORMAL_ZOOM_LEVEL / (double) zoom);
- preferred->height = round(preferred->height * NORMAL_ZOOM_LEVEL / (double) zoom);
- }
}
gint
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index efbc705..6d42955 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -44,9 +44,6 @@
#include "view/autoDrawer.h"
/* Signal handlers for main window (move in a VirtViewerMainWindow?) */
-void virt_viewer_window_menu_view_zoom_out(GtkWidget *menu, VirtViewerWindow *self);
-void virt_viewer_window_menu_view_zoom_in(GtkWidget *menu, VirtViewerWindow *self);
-void virt_viewer_window_menu_view_zoom_reset(GtkWidget *menu, VirtViewerWindow *self);
gboolean virt_viewer_window_delete(GtkWidget *src, void *dummy, VirtViewerWindow *self);
void virt_viewer_window_menu_file_quit(GtkWidget *src, VirtViewerWindow *self);
void virt_viewer_window_guest_details_response(GtkDialog *dialog, gint response_id, gpointer user_data);
@@ -68,8 +65,6 @@ static void virt_viewer_window_disable_modifiers(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);
-static gint virt_viewer_window_get_minimal_zoom_level(VirtViewerWindow *self);
G_DEFINE_TYPE (VirtViewerWindow, virt_viewer_window, G_TYPE_OBJECT)
@@ -106,10 +101,8 @@ struct _VirtViewerWindowPrivate {
gboolean desktop_resize_pending;
gboolean kiosk;
- gint zoomlevel;
gboolean fullscreen;
gchar *subtitle;
- gboolean initial_zoom_set;
};
static void
@@ -306,7 +299,6 @@ virt_viewer_window_init (VirtViewerWindow *self)
priv->builder = virt_viewer_util_load_ui("virt-viewer.xml");
gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, "menu-send")), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, "menu-view-zoom")), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, "menu-file-screenshot")), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, "menu-preferences")), FALSE);
@@ -323,12 +315,6 @@ virt_viewer_window_init (VirtViewerWindow *self)
"can-activate-accel", G_CALLBACK(can_activate_cb), self);
g_signal_connect(gtk_builder_get_object(priv->builder, "menu-view-release-cursor"),
"can-activate-accel", G_CALLBACK(can_activate_cb), self);
- g_signal_connect(gtk_builder_get_object(priv->builder, "menu-view-zoom-reset"),
- "can-activate-accel", G_CALLBACK(can_activate_cb), self);
- g_signal_connect(gtk_builder_get_object(priv->builder, "menu-view-zoom-in"),
- "can-activate-accel", G_CALLBACK(can_activate_cb), self);
- g_signal_connect(gtk_builder_get_object(priv->builder, "menu-view-zoom-out"),
- "can-activate-accel", G_CALLBACK(can_activate_cb), self);
vbox = GTK_WIDGET(gtk_builder_get_object(priv->builder, "viewer-box"));
virt_viewer_window_toolbar_setup(self);
@@ -357,8 +343,6 @@ virt_viewer_window_init (VirtViewerWindow *self)
priv->accel_list = g_slist_append(priv->accel_list, accels->data);
g_object_ref(G_OBJECT(accels->data));
}
-
- priv->zoomlevel = NORMAL_ZOOM_LEVEL;
}
static void
@@ -372,41 +356,6 @@ virt_viewer_window_desktop_resize(VirtViewerDisplay *display G_GNUC_UNUSED,
virt_viewer_window_queue_resize(self);
}
-static gint
-virt_viewer_window_get_real_zoom_level(VirtViewerWindow *self)
-{
- GtkAllocation allocation;
- guint width, height;
-
- gtk_widget_get_allocation(GTK_WIDGET(self->priv->display), &allocation);
- virt_viewer_display_get_desktop_size(self->priv->display, &width, &height);
-
- return round((double) NORMAL_ZOOM_LEVEL * allocation.width / width);
-}
-
-G_MODULE_EXPORT void
-virt_viewer_window_menu_view_zoom_out(GtkWidget *menu G_GNUC_UNUSED,
- VirtViewerWindow *self)
-{
- virt_viewer_window_set_zoom_level(self,
- virt_viewer_window_get_real_zoom_level(self) - ZOOM_STEP);
-}
-
-G_MODULE_EXPORT void
-virt_viewer_window_menu_view_zoom_in(GtkWidget *menu G_GNUC_UNUSED,
- VirtViewerWindow *self)
-{
- virt_viewer_window_set_zoom_level(self,
- virt_viewer_window_get_real_zoom_level(self) + ZOOM_STEP);
-}
-
-G_MODULE_EXPORT void
-virt_viewer_window_menu_view_zoom_reset(GtkWidget *menu G_GNUC_UNUSED,
- VirtViewerWindow *self)
-{
- virt_viewer_window_set_zoom_level(self, NORMAL_ZOOM_LEVEL);
-}
-
/* Kick GtkWindow to tell it to adjust to our new widget sizes */
static void
virt_viewer_window_queue_resize(VirtViewerWindow *self)
@@ -1255,9 +1204,6 @@ virt_viewer_window_set_menus_sensitive(VirtViewerWindow *self, gboolean sensitiv
menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-file-screenshot"));
gtk_widget_set_sensitive(menu, sensitive);
- menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-view-zoom"));
- gtk_widget_set_sensitive(menu, sensitive);
-
menu = GTK_WIDGET(gtk_builder_get_object(priv->builder, "menu-send"));
gtk_widget_set_sensitive(menu, sensitive);
}
@@ -1273,11 +1219,6 @@ display_show_hint(VirtViewerDisplay *display,
hint = (hint & VIRT_VIEWER_DISPLAY_SHOW_HINT_READY);
- if (!self->priv->initial_zoom_set && hint && virt_viewer_display_get_enabled(display)) {
- self->priv->initial_zoom_set = TRUE;
- virt_viewer_window_set_zoom_level(self, self->priv->zoomlevel);
- }
-
gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, "menu-file-screenshot")), hint);
}
static gboolean
@@ -1341,7 +1282,6 @@ virt_viewer_window_set_display(VirtViewerWindow *self, VirtViewerDisplay *displa
virt_viewer_window_desktop_resize(display, self);
gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, "menu-preferences")), TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, "menu-view-zoom")), TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(gtk_builder_get_object(self->priv->builder, "menu-send")), TRUE);
gtk_widget_set_sensitive(self->priv->toolbar_send_key, TRUE);
}
@@ -1400,47 +1340,6 @@ virt_viewer_window_hide(VirtViewerWindow *self)
}
}
-void
-virt_viewer_window_set_zoom_level(VirtViewerWindow *self, gint zoom_level)
-{
- VirtViewerWindowPrivate *priv;
- gint min_zoom;
-
- g_return_if_fail(VIRT_VIEWER_IS_WINDOW(self));
- priv = self->priv;
-
- if (zoom_level < MIN_ZOOM_LEVEL)
- zoom_level = MIN_ZOOM_LEVEL;
- if (zoom_level > MAX_ZOOM_LEVEL)
- zoom_level = MAX_ZOOM_LEVEL;
- priv->zoomlevel = zoom_level;
-
- if (!priv->display)
- return;
-
- min_zoom = virt_viewer_window_get_minimal_zoom_level(self);
- if (min_zoom > priv->zoomlevel) {
- g_debug("Cannot set zoom level %d, using %d", priv->zoomlevel, min_zoom);
- priv->zoomlevel = min_zoom;
- }
-
- if (priv->zoomlevel == virt_viewer_display_get_zoom_level(priv->display) &&
- priv->zoomlevel == virt_viewer_window_get_real_zoom_level(self)) {
- g_debug("Zoom level not changed, using: %d", priv->zoomlevel);
- return;
- }
-
- virt_viewer_display_set_zoom_level(VIRT_VIEWER_DISPLAY(priv->display), priv->zoomlevel);
-
- virt_viewer_window_queue_resize(self);
-}
-
-gint virt_viewer_window_get_zoom_level(VirtViewerWindow *self)
-{
- g_return_val_if_fail(VIRT_VIEWER_IS_WINDOW(self), NORMAL_ZOOM_LEVEL);
- return self->priv->zoomlevel;
-}
-
GtkMenuItem*
virt_viewer_window_get_menu_displays(VirtViewerWindow *self)
{
@@ -1482,55 +1381,6 @@ virt_viewer_window_set_kiosk(VirtViewerWindow *self, gboolean enabled)
g_debug("disabling kiosk not implemented yet");
}
-static void
-virt_viewer_window_get_minimal_dimensions(VirtViewerWindow *self,
- guint *width,
- guint *height)
-{
- GtkRequisition req;
- GtkWidget *top_menu;
-
- top_menu = GTK_WIDGET(gtk_builder_get_object(virt_viewer_window_get_builder(self), "top-menu"));
- gtk_widget_get_preferred_size(top_menu, &req, NULL);
- /* minimal dimensions of the window are the maximum of dimensions of the top-menu
- * and minimal dimension of the display
- */
- *height = MIN_DISPLAY_HEIGHT;
- *width = MAX(MIN_DISPLAY_WIDTH, req.width);
-}
-
-/**
- * virt_viewer_window_get_minimal_zoom_level:
- * @self: a #VirtViewerWindow
- *
- * Calculates the zoom level with respect to the desktop dimensions
- *
- * Returns: minimal possible zoom level (multiple of ZOOM_STEP)
- */
-static gint
-virt_viewer_window_get_minimal_zoom_level(VirtViewerWindow *self)
-{
- guint min_width, min_height;
- guint width, height; /* desktop dimensions */
- gint zoom;
- double width_ratio, height_ratio;
-
- g_return_val_if_fail(VIRT_VIEWER_IS_WINDOW(self) &&
- self->priv->display != NULL, MIN_ZOOM_LEVEL);
-
- virt_viewer_window_get_minimal_dimensions(self, &min_width, &min_height);
- virt_viewer_display_get_desktop_size(virt_viewer_window_get_display(self), &width, &height);
-
- /* e.g. minimal width = 200, desktop width = 550 => width ratio = 0.36
- * which means that the minimal zoom level is 40 (4 * ZOOM_STEP)
- */
- width_ratio = (double) min_width / width;
- height_ratio = (double) min_height / height;
- zoom = ceil(10 * MAX(width_ratio, height_ratio));
-
- /* make sure that the returned zoom level is in the range from MIN_ZOOM_LEVEL to NORMAL_ZOOM_LEVEL */
- return CLAMP(zoom * ZOOM_STEP, MIN_ZOOM_LEVEL, NORMAL_ZOOM_LEVEL);
-}
/*
* Local variables:
diff --git a/src/virt-viewer-window.h b/src/virt-viewer-window.h
index c25e9c9..3275a9f 100644
--- a/src/virt-viewer-window.h
+++ b/src/virt-viewer-window.h
@@ -30,11 +30,6 @@
G_BEGIN_DECLS
-#define MIN_ZOOM_LEVEL 10
-#define MAX_ZOOM_LEVEL 400
-#define NORMAL_ZOOM_LEVEL 100
-#define ZOOM_STEP 10
-
#define VIRT_VIEWER_TYPE_WINDOW virt_viewer_window_get_type()
#define VIRT_VIEWER_WINDOW(obj) \
@@ -75,8 +70,6 @@ void virt_viewer_window_set_menus_sensitive(VirtViewerWindow *self, gboolean sen
void virt_viewer_window_update_title(VirtViewerWindow *self);
void virt_viewer_window_show(VirtViewerWindow *self);
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, gint monitor);
GtkMenuItem *virt_viewer_window_get_menu_displays(VirtViewerWindow *self);
diff --git a/src/virt-viewer.xml b/src/virt-viewer.xml
index 830a451..1edf247 100644
--- a/src/virt-viewer.xml
+++ b/src/virt-viewer.xml
@@ -122,61 +122,6 @@
</object>
</child>
<child>
- <object class="GtkMenuItem" id="menu-view-zoom">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="label" translatable="yes">_Zoom</property>
- <property name="use_underline">True</property>
- <child type="submenu">
- <object class="GtkMenu" id="menu4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="accel_group">accelgroup</property>
- <child>
- <object class="GtkMenuItem" id="menu-view-zoom-in">
- <property name="accel_path"><virt-viewer>/view/zoom-in</property>
- <property name="label" translatable="yes">Zoom _In</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <signal name="activate" handler="virt_viewer_window_menu_view_zoom_in" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem" id="menu-view-zoom-out">
- <property name="accel_path"><virt-viewer>/view/zoom-out</property>
- <property name="label" translatable="yes">Zoom _Out</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <signal name="activate" handler="virt_viewer_window_menu_view_zoom_out" swapped="no"/>
- </object>
- </child>
- <child>
- <object class="GtkSeparatorMenuItem" id="separatormenuitem4">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem" id="menu-view-zoom-reset">
- <property name="accel_path"><virt-viewer>/view/zoom-reset</property>
- <property name="label" translatable="yes">_Normal Size</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="use_underline">True</property>
- <signal name="activate" handler="virt_viewer_window_menu_view_zoom_reset" swapped="no"/>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
<object class="GtkMenuItem" id="menu-displays">
<property name="visible">True</property>
<property name="can_focus">False</property>
--
2.7.4
More information about the virt-tools-list
mailing list