Patchwork Switch to disable SDL zoom

login
register
mail settings
Submitter Antoine Kaufmann
Date Aug. 19, 2009, 4:13 p.m.
Message ID <1250698389-23005-1-git-send-email-toni@tyndur.org>
Download mbox | patch
Permalink /patch/31659/
State Superseded
Headers show

Comments

Antoine Kaufmann - Aug. 19, 2009, 4:13 p.m.
Command line switch to disable SDL zoom, because zoom is quite ugly with
window managers that use fixed layouts (like awesomewm). Especially
because there is no possibility to reset the window to the "correct"
size.

Signed-off-by: Antoine Kaufmann <toni@tyndur.org>
---
 qemu-options.hx |   10 ++++++++++
 sdl.c           |    5 ++++-
 sdl_zoom.h      |    2 ++
 vl.c            |    5 +++++
 4 files changed, 21 insertions(+), 1 deletions(-)
Anthony Liguori - Aug. 28, 2009, 12:28 a.m.
Hi Antonie,

Antoine Kaufmann wrote:
> Command line switch to disable SDL zoom, because zoom is quite ugly with
> window managers that use fixed layouts (like awesomewm). Especially
> because there is no possibility to reset the window to the "correct"
> size.
>   

I think this is a valuable feature but I'd prefer to not add another 
-sdl-<feature> option.  In fact, I'd like to get rid of the existing ones.

I'd suggest that you look at introducing a new -display option.  The 
syntax would look like this:

-display sdl,frame=off,scaling=off
-display vnc,address=:3,tls

If you use the recently introduced QemuOptions framework, it should be 
very straight forward.  I would accept an initial patch that just 
converted sdl as vnc is a bit more difficult.

The advantages of this approach are numerous beyond just aesthetics.  
This would allow these display properties to be manipulated via the -set 
option which means that eventually, they'll be tunable via a host 
configuration file.  It also puts together some interfaces for 
supporting multiple graphics cards for guests and multiple display backends.

Regards,

Anthony Liguori
Samuel Thibault - Aug. 28, 2009, 8 a.m.
Anthony Liguori, le Thu 27 Aug 2009 19:28:46 -0500, a écrit :
> The advantages of this approach are numerous beyond just aesthetics.  
> This would allow these display properties to be manipulated via the -set 
> option which means that eventually, they'll be tunable via a host 
> configuration file.  It also puts together some interfaces for 
> supporting multiple graphics cards for guests and multiple display backends.

Also, it would permit a geometry parameter for the sdl case, which could
be useful.

Samuel
Gerd Hoffmann - Aug. 28, 2009, 8:27 a.m.
Hi,

> -display sdl,frame=off,scaling=off
> -display vnc,address=:3,tls
>
> If you use the recently introduced QemuOptions framework, it should be
> very straight forward. I would accept an initial patch that just
> converted sdl as vnc is a bit more difficult.

FYI: I'm busy looking at switching chardevs to QemuOpts, including the 
socket code, which in turn should make it alot easier to switch vnc too.

cheers,
   Gerd

Patch

diff --git a/qemu-options.hx b/qemu-options.hx
index 38989f1..529236e 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -487,6 +487,16 @@  STEXI
 Enable SDL.
 ETEXI
 
+#ifdef CONFIG_SDL
+DEF("sdl-no-zoom", 0, QEMU_OPTION_sdl_no_zoom,
+    "-sdl-no-zoom    Disable SDL zoom\n")
+#endif
+STEXI
+@item -sdl
+
+Disable SDL zoom.
+ETEXI
+
 DEF("portrait", 0, QEMU_OPTION_portrait,
     "-portrait       rotate graphical output 90 deg left (only PXA LCD)\n")
 STEXI
diff --git a/sdl.c b/sdl.c
index 36fb07f..69234fb 100644
--- a/sdl.c
+++ b/sdl.c
@@ -102,7 +102,10 @@  static void do_sdl_resize(int new_width, int new_height, int bpp)
 
     //    printf("resizing to %d %d\n", w, h);
 
-    flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL|SDL_RESIZABLE;
+    flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL;
+    if (!sdl_no_zoom) {
+        flags |= SDL_RESIZABLE;
+    }
     if (gui_fullscreen)
         flags |= SDL_FULLSCREEN;
     if (gui_noframe)
diff --git a/sdl_zoom.h b/sdl_zoom.h
index 74955bc..961b441 100644
--- a/sdl_zoom.h
+++ b/sdl_zoom.h
@@ -19,6 +19,8 @@ 
 #define SMOOTHING_OFF		0
 #define SMOOTHING_ON		1
 
+extern int sdl_no_zoom;
+
 int sdl_zoom_blit(SDL_Surface *src_sfc, SDL_Surface *dst_sfc,
                   int smooth, SDL_Rect *src_rect);
 
diff --git a/vl.c b/vl.c
index 8b2b289..be72594 100644
--- a/vl.c
+++ b/vl.c
@@ -122,6 +122,7 @@  int main(int argc, char **argv)
 #undef main
 #define main qemu_main
 #endif
+#include "sdl_zoom.h"
 #endif /* CONFIG_SDL */
 
 #ifdef CONFIG_COCOA
@@ -207,6 +208,7 @@  int graphic_depth = 15;
 static int full_screen = 0;
 #ifdef CONFIG_SDL
 static int no_frame = 0;
+int sdl_no_zoom = 0;
 #endif
 int no_quit = 0;
 CharDriverState *serial_hds[MAX_SERIAL_PORTS];
@@ -5348,6 +5350,9 @@  int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_sdl:
                 display_type = DT_SDL;
                 break;
+            case QEMU_OPTION_sdl_no_zoom:
+                sdl_no_zoom = 1;
+                break;
 #endif
             case QEMU_OPTION_pidfile:
                 pid_file = optarg;