Patchwork [13/15] sdl: Add zoom hot keys

login
register
mail settings
Submitter Jan Kiszka
Date July 30, 2011, 9:39 a.m.
Message ID <afd088372bf1b678133740dd37fa91ff173f8bb4.1312018756.git.jan.kiszka@web.de>
Download mbox | patch
Permalink /patch/107498/
State New
Headers show

Comments

Jan Kiszka - July 30, 2011, 9:39 a.m.
From: Jan Kiszka <jan.kiszka@siemens.com>

Allow to enlarge or shrink the screen via CTRL-ALT-+/-. In contrast to
scaling the window, these controls always preserve the aspect ratio of
the current console.

CC: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 qemu-doc.texi |    8 ++++++++
 ui/sdl.c      |   13 +++++++++++++
 2 files changed, 21 insertions(+), 0 deletions(-)

Patch

diff --git a/qemu-doc.texi b/qemu-doc.texi
index 47e1991..31199f6 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -288,6 +288,14 @@  then the modifier is Ctrl-Alt-Shift (instead of Ctrl-Alt) and if you use
 @kindex Ctrl-Alt-f
 Toggle full screen
 
+@item Ctrl-Alt-+
+@kindex Ctrl-Alt-+
+Enlarge the screen
+
+@item Ctrl-Alt--
+@kindex Ctrl-Alt--
+Shrink the screen
+
 @item Ctrl-Alt-u
 @kindex Ctrl-Alt-u
 Restore the screen's un-scaled dimensions
diff --git a/ui/sdl.c b/ui/sdl.c
index e8ac3bb..fc63c8e 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -651,6 +651,19 @@  static void sdl_refresh(DisplayState *ds)
                             absolute_mouse_grab();
                         }
                         break;
+                    case 0x1b: /* '+' */
+                    case 0x35: /* '-' */
+                        if (!gui_fullscreen) {
+                            int width = MAX(real_screen->w +
+                                            (keycode == 0x1b ? 50 : -50), 160);
+                            int height = (ds_get_height(ds) * width) /
+                                         ds_get_width(ds);
+
+                            sdl_scale(ds, width, height);
+                            vga_hw_invalidate();
+                            vga_hw_update();
+                            gui_keysym = 1;
+                        }
                     default:
                         break;
                     }