Re: [Qemu-devel] [PATCH 5/6] gtk: add support for screen scaling and full screen

2012-02-25 Thread Stefan Weil

Am 20.02.2012 00:45, schrieb Anthony Liguori:

Basic menu items to enter full screen mode and zoom in/out. Unlike SDL, we
don't allow arbitrary scaling based on window resizing. The current 
behavior

with SDL causes a lot of problems for me.

Sometimes I accidentally resize the window a tiny bit while trying to 
move it
(Ubuntu's 1-pixel window decorations don't help here). After that, 
scaling is

now active and if the screen changes size again, badness ensues since the
aspect ratio is skewed.

Allowing zooming by 25% in and out should cover most use cases. We can 
add a

more flexible scaling later but for now, I think this is a more friendly
behavior.

Signed-off-by: Anthony Liguori 
---
ui/gtk.c | 89 
+++---

1 files changed, 85 insertions(+), 4 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 73051db..b9a9bc3 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c

[...]
+ s->zoom_in_item = 
gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_IN, NULL);

+ gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->zoom_in_item),
+ "/View/Zoom In");
+ gtk_accel_map_add_entry("/View/Zoom In", GDK_KEY_equal, 
GDK_CONTROL_MASK | GDK_MOD1_MASK);

+ gtk_menu_append(GTK_MENU(s->view_menu), s->zoom_in_item);
+
+ s->zoom_out_item = 
gtk_image_menu_item_new_from_stock(GTK_STOCK_ZOOM_OUT, NULL);

+ gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->zoom_out_item),
+ "/View/Zoom Out");
+ gtk_accel_map_add_entry("/View/Zoom Out", GDK_KEY_minus, 
GDK_CONTROL_MASK | GDK_MOD1_MASK);

+ gtk_menu_append(GTK_MENU(s->view_menu), s->zoom_out_item);
+
separator = gtk_separator_menu_item_new();
gtk_menu_append(GTK_MENU(s->view_menu), separator);


I think GDK_KEY_plus would be a better choice instead of GDK_KEY_equal
because that's the key used to zoom in by GNOME terminal, most web browsers
and many more programs.

Usually there is also a "Zoom 100 %" with GDK_KEY_0 which resets
zooming to 100 %.

Regards,

Stefan Weil




Re: [Qemu-devel] [PATCH 5/6] gtk: add support for screen scaling and full screen

2012-02-20 Thread Anthony Liguori

On 02/20/2012 01:41 AM, Paolo Bonzini wrote:

On 02/20/2012 12:45 AM, Anthony Liguori wrote:

+static void gd_menu_zoom_in(GtkMenuItem *item, void *opaque)
+{
+GtkDisplayState *s = opaque;
+
+s->scale_x *= 1.25;
+s->scale_y *= 1.25;
+
+gd_resize(s->ds);
+}
+
+static void gd_menu_zoom_out(GtkMenuItem *item, void *opaque)
+{
+GtkDisplayState *s = opaque;
+
+s->scale_x *= .75;
+s->scale_y *= .75;


This should be /= 1.25, because the inverse of 1.25 is _not_ 0.75. :)


Indeed, thanks :-)

Regards,

Anthony Liguori



Paolo






Re: [Qemu-devel] [PATCH 5/6] gtk: add support for screen scaling and full screen

2012-02-19 Thread Paolo Bonzini
On 02/20/2012 12:45 AM, Anthony Liguori wrote:
> +static void gd_menu_zoom_in(GtkMenuItem *item, void *opaque)
> +{
> +GtkDisplayState *s = opaque;
> +
> +s->scale_x *= 1.25;
> +s->scale_y *= 1.25;
> +
> +gd_resize(s->ds);
> +}
> +
> +static void gd_menu_zoom_out(GtkMenuItem *item, void *opaque)
> +{
> +GtkDisplayState *s = opaque;
> +
> +s->scale_x *= .75;
> +s->scale_y *= .75;

This should be /= 1.25, because the inverse of 1.25 is _not_ 0.75. :)

Paolo