qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/2] sdl: hotkey updates and cleanups
@ 2018-01-15 14:17 Gerd Hoffmann
  2018-01-15 14:17 ` [Qemu-devel] [PATCH v2 1/2] sdl: use ctrl-alt-g as grab hotkey Gerd Hoffmann
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2018-01-15 14:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann



Gerd Hoffmann (2):
  sdl: use ctrl-alt-g as grab hotkey
  sdl: reorganize -no-frame support

 include/sysemu/sysemu.h |  1 +
 include/ui/console.h    |  5 ++---
 ui/sdl.c                | 38 +++++++++++++++-----------------------
 ui/sdl2.c               | 34 ++++++++++++----------------------
 vl.c                    |  4 ++--
 5 files changed, 32 insertions(+), 50 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 1/2] sdl: use ctrl-alt-g as grab hotkey
  2018-01-15 14:17 [Qemu-devel] [PATCH v2 0/2] sdl: hotkey updates and cleanups Gerd Hoffmann
@ 2018-01-15 14:17 ` Gerd Hoffmann
  2018-01-15 14:17 ` [Qemu-devel] [PATCH v2 2/2] sdl: reorganize -no-frame support Gerd Hoffmann
  2018-01-15 14:51 ` [Qemu-devel] [PATCH v2 0/2] sdl: hotkey updates and cleanups no-reply
  2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2018-01-15 14:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Be consistent with gtk and cocoa.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/sdl.c  | 30 +++++++++++++-----------------
 ui/sdl2.c | 27 +++++++++++----------------
 2 files changed, 24 insertions(+), 33 deletions(-)

diff --git a/ui/sdl.c b/ui/sdl.c
index 7b71a9ac58..9c664c86a0 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -368,11 +368,11 @@ static void sdl_update_caption(void)
         status = " [Stopped]";
     else if (gui_grab) {
         if (alt_grab)
-            status = " - Press Ctrl-Alt-Shift to exit mouse grab";
+            status = " - Press Ctrl-Alt-Shift-G to exit mouse grab";
         else if (ctrl_grab)
-            status = " - Press Right-Ctrl to exit mouse grab";
+            status = " - Press Right-Ctrl-G to exit mouse grab";
         else
-            status = " - Press Ctrl-Alt to exit mouse grab";
+            status = " - Press Ctrl-Alt-G to exit mouse grab";
     }
 
     if (qemu_name) {
@@ -576,6 +576,16 @@ static void handle_keydown(SDL_Event *ev)
             toggle_full_screen();
             gui_keysym = 1;
             break;
+        case 0x22: /* 'g' key */
+            if (!gui_grab) {
+                if (qemu_console_is_graphic(NULL)) {
+                    sdl_grab_start();
+                }
+            } else if (!gui_fullscreen) {
+                sdl_grab_end();
+            }
+            gui_keysym = 1;
+            break;
         case 0x16: /* 'u' key on US keyboard */
             if (scaling_active) {
                 scaling_active = 0;
@@ -711,20 +721,6 @@ static void handle_keyup(SDL_Event *ev)
     }
     if (!mod_state && gui_key_modifier_pressed) {
         gui_key_modifier_pressed = 0;
-        if (gui_keysym == 0) {
-            /* exit/enter grab if pressing Ctrl-Alt */
-            if (!gui_grab) {
-                if (qemu_console_is_graphic(NULL)) {
-                    sdl_grab_start();
-                }
-            } else if (!gui_fullscreen) {
-                sdl_grab_end();
-            }
-            /* SDL does not send back all the modifiers key, so we must
-             * correct it. */
-            reset_keys();
-            return;
-        }
         gui_keysym = 0;
     }
     if (qemu_console_is_graphic(NULL) && !gui_keysym) {
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 89c6a2633c..1db5dd6f5f 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -141,11 +141,11 @@ static void sdl_update_caption(struct sdl2_console *scon)
         status = " [Stopped]";
     } else if (gui_grab) {
         if (alt_grab) {
-            status = " - Press Ctrl-Alt-Shift to exit grab";
+            status = " - Press Ctrl-Alt-Shift-G to exit grab";
         } else if (ctrl_grab) {
-            status = " - Press Right-Ctrl to exit grab";
+            status = " - Press Right-Ctrl-G to exit grab";
         } else {
-            status = " - Press Ctrl-Alt to exit grab";
+            status = " - Press Ctrl-Alt-G to exit grab";
         }
     }
 
@@ -364,6 +364,14 @@ static void handle_keydown(SDL_Event *ev)
             toggle_full_screen(scon);
             gui_keysym = 1;
             break;
+        case SDL_SCANCODE_G:
+            gui_keysym = 1;
+            if (!gui_grab) {
+                sdl_grab_start(scon);
+            } else if (!gui_fullscreen) {
+                sdl_grab_end(scon);
+            }
+            break;
         case SDL_SCANCODE_U:
             sdl2_window_destroy(scon);
             sdl2_window_create(scon);
@@ -416,19 +424,6 @@ static void handle_keyup(SDL_Event *ev)
     }
     if (!mod_state && gui_key_modifier_pressed) {
         gui_key_modifier_pressed = 0;
-        if (gui_keysym == 0) {
-            /* exit/enter grab if pressing Ctrl-Alt */
-            if (!gui_grab) {
-                sdl_grab_start(scon);
-            } else if (!gui_fullscreen) {
-                sdl_grab_end(scon);
-            }
-            /* SDL does not send back all the modifiers key, so we must
-             * correct it. */
-            sdl2_reset_keys(scon);
-            return;
-        }
-        sdl2_reset_keys(scon);
         gui_keysym = 0;
     }
     if (!gui_keysym) {
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 2/2] sdl: reorganize -no-frame support
  2018-01-15 14:17 [Qemu-devel] [PATCH v2 0/2] sdl: hotkey updates and cleanups Gerd Hoffmann
  2018-01-15 14:17 ` [Qemu-devel] [PATCH v2 1/2] sdl: use ctrl-alt-g as grab hotkey Gerd Hoffmann
@ 2018-01-15 14:17 ` Gerd Hoffmann
  2018-01-15 14:51 ` [Qemu-devel] [PATCH v2 0/2] sdl: hotkey updates and cleanups no-reply
  2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2018-01-15 14:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Paolo Bonzini

Drop no_frame flag from sdl_display_init argument list, use a global
variable instead.  This is temporary until -no-frame support is dropped
altogether when we remove sdl1 support.

Remove any traces of noframe from sdl2 code.  It is just dead code as
sdl2 doesn't support the SDL_NOFRAME window flag any more.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/sysemu/sysemu.h | 1 +
 include/ui/console.h    | 5 ++---
 ui/sdl.c                | 8 ++------
 ui/sdl2.c               | 7 +------
 vl.c                    | 4 ++--
 5 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 31612caf10..1c925309e3 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -112,6 +112,7 @@ extern const char *keyboard_layout;
 extern int win2k_install_hack;
 extern int alt_grab;
 extern int ctrl_grab;
+extern int no_frame;
 extern int smp_cpus;
 extern unsigned int max_cpus;
 extern int cursor_hide;
diff --git a/include/ui/console.h b/include/ui/console.h
index 580dfc57ee..7b35778444 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -436,7 +436,7 @@ void surface_gl_setup_viewport(QemuGLShader *gls,
 /* sdl.c */
 #ifdef CONFIG_SDL
 void sdl_display_early_init(int opengl);
-void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
+void sdl_display_init(DisplayState *ds, int full_screen);
 #else
 static inline void sdl_display_early_init(int opengl)
 {
@@ -444,8 +444,7 @@ static inline void sdl_display_early_init(int opengl)
     error_report("SDL support is disabled");
     abort();
 }
-static inline void sdl_display_init(DisplayState *ds, int full_screen,
-                                    int no_frame)
+static inline void sdl_display_init(DisplayState *ds, int full_screen)
 {
     /* This must never be called if CONFIG_SDL is disabled */
     error_report("SDL support is disabled");
diff --git a/ui/sdl.c b/ui/sdl.c
index 9c664c86a0..0a6a94bf7c 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -48,7 +48,6 @@ static int gui_saved_width;
 static int gui_saved_height;
 static int gui_saved_grab;
 static int gui_fullscreen;
-static int gui_noframe;
 static int gui_key_modifier_pressed;
 static int gui_keysym;
 static int gui_grab_code = KMOD_LALT | KMOD_LCTRL;
@@ -114,7 +113,7 @@ static void do_sdl_resize(int width, int height, int bpp)
     } else {
         flags |= SDL_RESIZABLE;
     }
-    if (gui_noframe)
+    if (no_frame)
         flags |= SDL_NOFRAME;
 
     tmp_screen = SDL_SetVideoMode(width, height, bpp, flags);
@@ -940,7 +939,7 @@ void sdl_display_early_init(int opengl)
     }
 }
 
-void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
+void sdl_display_init(DisplayState *ds, int full_screen)
 {
     int flags;
     uint8_t data = 0;
@@ -959,9 +958,6 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
             exit(1);
     }
 
-    if (no_frame)
-        gui_noframe = 1;
-
     if (!full_screen) {
         setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
     }
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 1db5dd6f5f..812c315891 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -38,7 +38,6 @@ static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
 
 static int gui_saved_grab;
 static int gui_fullscreen;
-static int gui_noframe;
 static int gui_key_modifier_pressed;
 static int gui_keysym;
 static int gui_grab_code = KMOD_LALT | KMOD_LCTRL;
@@ -767,7 +766,7 @@ void sdl_display_early_init(int opengl)
     }
 }
 
-void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
+void sdl_display_init(DisplayState *ds, int full_screen)
 {
     int flags;
     uint8_t data = 0;
@@ -775,10 +774,6 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
     int i;
     SDL_SysWMinfo info;
 
-    if (no_frame) {
-        gui_noframe = 1;
-    }
-
 #ifdef __linux__
     /* on Linux, SDL may use fbcon|directfb|svgalib when run without
      * accessible $DISPLAY to open X11 window.  This is often the case
diff --git a/vl.c b/vl.c
index 444b7507da..24d89ddca8 100644
--- a/vl.c
+++ b/vl.c
@@ -150,7 +150,7 @@ static int rtc_date_offset = -1; /* -1 means no change */
 QEMUClockType rtc_clock;
 int vga_interface_type = VGA_NONE;
 static int full_screen = 0;
-static int no_frame = 0;
+int no_frame = 0;
 int no_quit = 0;
 static bool grab_on_hover;
 Chardev *serial_hds[MAX_SERIAL_PORTS];
@@ -4692,7 +4692,7 @@ int main(int argc, char **argv, char **envp)
         curses_display_init(ds, full_screen);
         break;
     case DT_SDL:
-        sdl_display_init(ds, full_screen, no_frame);
+        sdl_display_init(ds, full_screen);
         break;
     case DT_COCOA:
         cocoa_display_init(ds, full_screen);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/2] sdl: hotkey updates and cleanups
  2018-01-15 14:17 [Qemu-devel] [PATCH v2 0/2] sdl: hotkey updates and cleanups Gerd Hoffmann
  2018-01-15 14:17 ` [Qemu-devel] [PATCH v2 1/2] sdl: use ctrl-alt-g as grab hotkey Gerd Hoffmann
  2018-01-15 14:17 ` [Qemu-devel] [PATCH v2 2/2] sdl: reorganize -no-frame support Gerd Hoffmann
@ 2018-01-15 14:51 ` no-reply
  2 siblings, 0 replies; 4+ messages in thread
From: no-reply @ 2018-01-15 14:51 UTC (permalink / raw)
  To: kraxel; +Cc: famz, qemu-devel

Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20180115141759.11857-1-kraxel@redhat.com
Subject: [Qemu-devel] [PATCH v2 0/2] sdl: hotkey updates and cleanups

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]               patchew/20180115143500.22631-1-f4bug@amsat.org -> patchew/20180115143500.22631-1-f4bug@amsat.org
Switched to a new branch 'test'
069b912d67 sdl: reorganize -no-frame support
e25380fb5c sdl: use ctrl-alt-g as grab hotkey

=== OUTPUT BEGIN ===
Checking PATCH 1/2: sdl: use ctrl-alt-g as grab hotkey...
Checking PATCH 2/2: sdl: reorganize -no-frame support...
ERROR: braces {} are necessary for all arms of this statement
#68: FILE: ui/sdl.c:116:
+    if (no_frame)
[...]

ERROR: do not initialise globals to 0 or NULL
#132: FILE: vl.c:153:
+int no_frame = 0;

total: 2 errors, 0 warnings, 97 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-15 14:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-15 14:17 [Qemu-devel] [PATCH v2 0/2] sdl: hotkey updates and cleanups Gerd Hoffmann
2018-01-15 14:17 ` [Qemu-devel] [PATCH v2 1/2] sdl: use ctrl-alt-g as grab hotkey Gerd Hoffmann
2018-01-15 14:17 ` [Qemu-devel] [PATCH v2 2/2] sdl: reorganize -no-frame support Gerd Hoffmann
2018-01-15 14:51 ` [Qemu-devel] [PATCH v2 0/2] sdl: hotkey updates and cleanups no-reply

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).