Skip to contentSkip to conversation

Ui 20180125 patches

GIT PULL Gerd Hoffmann 4 participants 16 messages Jan 25, 2018 – Feb 1, 2018 Kbuild

lore
Share & tools
lore
#0 lore raw

The following changes since commit 834a336eb911db8a8ca00e760ee6a85faca19414:

Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2018-01-24 19:24:26 +0000)

are available in the git repository at:

git://git.kraxel.org/qemu tags/ui-20180125-pull-request

for you to fetch changes up to 04ff1a398a8d6e912eceaca9b62af0a09e927d63:

sdl: reorganize -no-frame support (2018-01-25 15:22:28 +0100)

----------------------------------------------------------------
ui: convert to keycodedb, fix sign extension
sdl: cleanups, deprecate sdl 1.2

----------------------------------------------------------------

Daniel P. Berrange (6):
ui: avoid sign extension using client width/height
ui: convert the SDL2 frontend to keycodemapdb
ui: convert GTK and SDL1 frontends to keycodemapdb
ui: add fix for GTK Pause key handling on Win32
ui: ignore hardware keycode 255 on win32
ui: deprecate use of SDL 1.2 in favour of 2.0 series

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

 configure               |   6 ++
 Makefile                |   8 ++
 include/sysemu/sysemu.h |   1 +
 include/ui/console.h    |   5 +-
 include/ui/input.h      |  24 +++++
 ui/sdl2-keymap.h        | 267 ------------------------------------------------
 ui/vnc.h                |   4 +-
 ui/x_keymap.h           |   8 +-
 ui/gtk.c                | 220 ++++++++++++++++++++++++---------------
 ui/input-keymap.c       |   8 ++
 ui/sdl.c                | 145 +++++++++-----------------
 ui/sdl2-input.c         |  16 ++-
 ui/sdl2.c               |  34 +++---
 ui/vnc.c                |   9 ++
 ui/x_keymap.c           | 250 +++++++++++++++++----------------------------
 vl.c                    |   4 +-
 qemu-doc.texi           |   7 ++
 ui/Makefile.objs        |   5 +-
 ui/trace-events         |   9 +-
 19 files changed, 389 insertions(+), 641 deletions(-)
 delete mode 100644 ui/sdl2-keymap.h
Signature · 1 line
2.9.3
#1 lore raw

[Qemu-devel] [PULL 1/8] ui: avoid sign extension using client width/height

From: "Daniel P. Berrange" <[email protected]>

Pixman returns a signed int for the image width/height, but the VNC protocol only permits a unsigned int16. Effective framebuffer size is determined by the guest, limited by the video RAM size, so the dimensions are unlikely to exceed the range of an unsigned int16, but this is not currently validated.

With the current use of 'int' for client width/height, the calculation of offsets in vnc_update_throttle_offset() suffers from integer size promotion and sign extension, causing coverity warnings

*** CID 1385147: Integer handling issues (SIGN_EXTENSION) /ui/vnc.c: 979 in vnc_update_throttle_offset()

973      * than that the client would already suffering awful audio
974      * glitches, so dropping samples is no worse really).
975      */

976 static void vnc_update_throttle_offset(VncState *vs)
977 {
978 size_t offset =

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CID 1385147: Integer handling issues (SIGN_EXTENSION) Suspicious implicit sign extension:

    "vs->client_pf.bytes_per_pixel" with type "unsigned char" (8 bits,
    unsigned) is promoted in "vs->client_width * vs->client_height *
    vs->client_pf.bytes_per_pixel" to type "int" (32 bits, signed), then
    sign-extended to type "unsigned long" (64 bits, unsigned).  If
    "vs->client_width * vs->client_height * vs->client_pf.bytes_per_pixel"
    is greater than 0x7FFFFFFF, the upper bits of the result will all be 1.

979 vs->client_width * vs->client_height * vs->client_pf.bytes_per_pixel;

Change client_width / client_height to be a size_t to avoid sign extension and integer promotion. Then validate that dimensions are in range wrt the RFB protocol u16 limits.

Message-id: [email protected]

---
 ui/vnc.h | 4 ++--
 ui/vnc.c | 9 +++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)
ui/vnc.h +2 -2
index 0c33a5f7fe..bbda0540a7 100644
@@ -278,8 +278,8 @@ struct VncState
     int last_x;
     int last_y;
     uint32_t last_bmask;
-    int client_width;
-    int client_height;
+    size_t client_width; /* limited to u16 by RFB proto */
+    size_t client_height; /* limited to u16 by RFB proto */
     VncShareMode share_mode;
 
     uint32_t vnc_encoding;
ui/vnc.c +9 -0
index 665a143578..33b087221f 100644
@@ -672,6 +672,11 @@ static void vnc_desktop_resize(VncState *vs)
         vs->client_height == pixman_image_get_height(vs->vd->server)) {
         return;
     }
+
+    assert(pixman_image_get_width(vs->vd->server) < 65536 &&
+           pixman_image_get_width(vs->vd->server) >= 0);
+    assert(pixman_image_get_height(vs->vd->server) < 65536 &&
+           pixman_image_get_height(vs->vd->server) >= 0);
     vs->client_width = pixman_image_get_width(vs->vd->server);
     vs->client_height = pixman_image_get_height(vs->vd->server);
     vnc_lock_output(vs);
@@ -2490,6 +2495,10 @@ static int protocol_client_init(VncState *vs, uint8_t *data, size_t len)
         return 0;
     }
 
+    assert(pixman_image_get_width(vs->vd->server) < 65536 &&
+           pixman_image_get_width(vs->vd->server) >= 0);
+    assert(pixman_image_get_height(vs->vd->server) < 65536 &&
+           pixman_image_get_height(vs->vd->server) >= 0);
     vs->client_width = pixman_image_get_width(vs->vd->server);
     vs->client_height = pixman_image_get_height(vs->vd->server);
     vnc_write_u16(vs, vs->client_width);
Signature · 1 line
2.9.3
#2 lore raw

[Qemu-devel] [PULL 2/8] ui: convert the SDL2 frontend to keycodemapdb

In reply to Gerd Hoffmann

From: "Daniel P. Berrange" <[email protected]>

The SDL2 scancodes are conveniently identical to the USB scancodes. Replace the sdl2_scancode_to_qcode table with an automatically generated table.

Missing entries in sdl2_scancode_to_qcode now fixed:

- 0x32 -> Q_KEY_CODE_BACKSLASH
- 0x66 -> Q_KEY_CODE_POWER
- 0x67 -> Q_KEY_CODE_KP_EQUALS
- 0x74 -> Q_KEY_CODE_OPEN
- 0x77 -> Q_KEY_CODE_FRONT
- 0x7f -> Q_KEY_CODE_AUDIOMUTE
- 0x80 -> Q_KEY_CODE_VOLUMEUP
- 0x81 -> Q_KEY_CODE_VOLUMEDOWN
- 0x85 -> Q_KEY_CODE_KP_COMMA
- 0x87 -> Q_KEY_CODE_RO
- 0x89 -> Q_KEY_CODE_YEN
- 0x8a -> Q_KEY_CODE_HENKAN
- 0x93 -> Q_KEY_CODE_HIRAGANA
- 0xe8 -> Q_KEY_CODE_AUDIOPLAY
- 0xe9 -> Q_KEY_CODE_AUDIOSTOP
- 0xea -> Q_KEY_CODE_AUDIOPREV
- 0xeb -> Q_KEY_CODE_AUDIONEXT
- 0xed -> Q_KEY_CODE_VOLUMEUP
- 0xee -> Q_KEY_CODE_VOLUMEDOWN
- 0xef -> Q_KEY_CODE_AUDIOMUTE
- 0xf1 -> Q_KEY_CODE_AC_BACK
- 0xf2 -> Q_KEY_CODE_AC_FORWARD
- 0xf3 -> Q_KEY_CODE_STOP
- 0xf4 -> Q_KEY_CODE_FIND
- 0xf8 -> Q_KEY_CODE_SLEEP
- 0xfa -> Q_KEY_CODE_AC_REFRESH
- 0xfb -> Q_KEY_CODE_CALCULATOR

And some mistakes corrected:

- 0x65 -> Q_KEY_CODE_COMPOSE, not duplicating Q_KEY_CODE_MENU

Message-id: [email protected]

---
 Makefile           |   1 +
 include/ui/input.h |   3 +
 ui/sdl2-keymap.h   | 267 -----------------------------------------------------
 ui/input-keymap.c  |   1 +
 ui/sdl2-input.c    |  16 +++-
 5 files changed, 16 insertions(+), 272 deletions(-)
 delete mode 100644 ui/sdl2-keymap.h
Makefile +1 -0
index d835bb92e7..24ed2b3e63 100644
@@ -236,6 +236,7 @@ KEYCODEMAP_FILES = \
 		 ui/input-keymap-qcode-to-qnum.c \
 		 ui/input-keymap-qnum-to-qcode.c \
 		 ui/input-keymap-qcode-to-linux.c \
+		 ui/input-keymap-usb-to-qcode.c \
 		 $(NULL)
 
 GENERATED_FILES += $(KEYCODEMAP_FILES)
include/ui/input.h +3 -0
index 5cc76d6e41..0d289e4142 100644
@@ -80,4 +80,7 @@ extern const guint16 qemu_input_map_qnum_to_qcode[];
 extern const guint qemu_input_map_qcode_to_linux_len;
 extern const guint16 qemu_input_map_qcode_to_linux[];
 
+extern const guint qemu_input_map_usb_to_qcode_len;
+extern const guint16 qemu_input_map_usb_to_qcode[];
+
 #endif /* INPUT_H */
ui/sdl2-keymap.h deleted +0 -267

267 lines not on this page · raw message

ui/input-keymap.c +1 -0
index 663986a17b..3be6dedea5 100644
@@ -9,6 +9,7 @@
 #include "ui/input-keymap-qcode-to-qnum.c"
 #include "ui/input-keymap-qnum-to-qcode.c"
 #include "ui/input-keymap-qcode-to-linux.c"
+#include "ui/input-keymap-usb-to-qcode.c"
 
 int qemu_input_linux_to_qcode(unsigned int lnx)
 {
ui/sdl2-input.c +11 -5
index 6e315ae800..605d781971 100644
@@ -30,8 +30,6 @@
 #include "ui/sdl2.h"
 #include "sysemu/sysemu.h"
 
-#include "sdl2-keymap.h"
-
 static uint8_t modifiers_state[SDL_NUM_SCANCODES];
 
 void sdl2_reset_keys(struct sdl2_console *scon)
@@ -39,9 +37,11 @@ void sdl2_reset_keys(struct sdl2_console *scon)
     QemuConsole *con = scon ? scon->dcl.con : NULL;
     int i;
 
-    for (i = 0; i < SDL_NUM_SCANCODES; i++) {
+    for (i = 0 ;
+         i < SDL_NUM_SCANCODES && i < qemu_input_map_usb_to_qcode_len ;
+         i++) {
         if (modifiers_state[i]) {
-            int qcode = sdl2_scancode_to_qcode[i];
+            int qcode = qemu_input_map_usb_to_qcode[i];
             qemu_input_event_send_key_qcode(con, qcode, false);
             modifiers_state[i] = 0;
         }
@@ -51,9 +51,15 @@ void sdl2_reset_keys(struct sdl2_console *scon)
 void sdl2_process_key(struct sdl2_console *scon,
                       SDL_KeyboardEvent *ev)
 {
-    int qcode = sdl2_scancode_to_qcode[ev->keysym.scancode];
+    int qcode;
     QemuConsole *con = scon ? scon->dcl.con : NULL;
 
+    if (ev->keysym.scancode >= qemu_input_map_usb_to_qcode_len) {
+        return;
+    }
+
+    qcode = qemu_input_map_usb_to_qcode[ev->keysym.scancode];
+
     if (!qemu_console_is_graphic(con)) {
         if (ev->type == SDL_KEYDOWN) {
             switch (ev->keysym.scancode) {
Signature · 1 line
2.9.3
#3 lore raw

Re: [Qemu-devel] [PULL 2/8] ui: convert the SDL2 frontend to keycodemapdb

include/ui/input.h extern const guint16 qemu_input_map_qnum_to_qcode[]; · line 81

Quoted 5 lines · Gerd Hoffmann
include/ui/input.h +0 -0
@@ -80,4 +80,7 @@ extern const guint16 qemu_input_map_qnum_to_qcode[];
 extern const guint qemu_input_map_qcode_to_linux_len;
 extern const guint16 qemu_input_map_qcode_to_linux[];

Is there any reason to use the length variables rather than just ARRAY_SIZE()? Coverity isn't able to see through the initializer and incorrectly complains that

    for (i = 0 ;
         i < SDL_NUM_SCANCODES && i < qemu_input_map_usb_to_qcode_len ;
         i++) {

might access past the end of qemu_input_map_usb_to_qcode.

Thanks,

Paolo

#4 lore raw

Re: [Qemu-devel] [PULL 2/8] ui: convert the SDL2 frontend to keycodemapdb

Quoted 10 lines · Paolo Bonzini

include/ui/input.h extern const guint16 qemu_input_map_qnum_to_qcode[]; · line 81

Quoted 5 lines · Gerd Hoffmann
include/ui/input.h +0 -0
@@ -80,4 +80,7 @@ extern const guint16 qemu_input_map_qnum_to_qcode[];
 extern const guint qemu_input_map_qcode_to_linux_len;
 extern const guint16 qemu_input_map_qcode_to_linux[];

Is there any reason to use the length variables rather than just ARRAY_SIZE()? Coverity isn't able to see through the initializer and incorrectly complains that

ARRAY_SIZE can only be used if you can see the array variable initialization, but this is the header file so all we have is the extern declaration and thus the array size is unknown from the places that need to use the _len variable.

We do in fact initalize the _len variable based on the ARRAY_SIZE, but that's in the .c files.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#5 lore raw

Re: [Qemu-devel] [PULL 2/8] ui: convert the SDL2 frontend to keycodemapdb

Quoted 12 lines · Daniel P. Berrangé
Quoted 10 lines · Paolo Bonzini

include/ui/input.h extern const guint16 qemu_input_map_qnum_to_qcode[]; · line 81

Quoted 5 lines · Gerd Hoffmann
include/ui/input.h +0 -0
@@ -80,4 +80,7 @@ extern const guint16 qemu_input_map_qnum_to_qcode[];
 extern const guint qemu_input_map_qcode_to_linux_len;
 extern const guint16 qemu_input_map_qcode_to_linux[];

Is there any reason to use the length variables rather than just ARRAY_SIZE()? Coverity isn't able to see through the initializer and incorrectly complains that

Quoted 7 lines

ARRAY_SIZE can only be used if you can see the array variable initialization, but this is the header file so all we have is the extern declaration and thus the array size is unknown from the places that need to use the _len variable.

We do in fact initalize the _len variable based on the ARRAY_SIZE, but that's in the .c files.

Would it make sense for keymap-gen to also generate the header file, so that we can use an "extern const guint x[NNN]" declaration rather instead of "x[]"?

Thanks,

Paolo

#6 lore raw

Re: [Qemu-devel] [PULL 2/8] ui: convert the SDL2 frontend to keycodemapdb

Quoted 18 lines · Paolo Bonzini
Quoted 17 lines · Daniel P. Berrangé
Quoted 10 lines · Paolo Bonzini

include/ui/input.h extern const guint16 qemu_input_map_qnum_to_qcode[]; · line 81

Quoted 5 lines · Gerd Hoffmann
include/ui/input.h +0 -0
@@ -80,4 +80,7 @@ extern const guint16 qemu_input_map_qnum_to_qcode[];
 extern const guint qemu_input_map_qcode_to_linux_len;
 extern const guint16 qemu_input_map_qcode_to_linux[];

Is there any reason to use the length variables rather than just ARRAY_SIZE()? Coverity isn't able to see through the initializer and incorrectly complains that

ARRAY_SIZE can only be used if you can see the array variable initialization, but this is the header file so all we have is the extern declaration and thus the array size is unknown from the places that need to use the _len variable.

Quoted 6 lines
Quoted 2 lines

We do in fact initalize the _len variable based on the ARRAY_SIZE, but that's in the .c files.

Would it make sense for keymap-gen to also generate the header file, so that we can use an "extern const guint x[NNN]" declaration rather instead of "x[]"?

I could probably add such a feature to it....

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#7 lore raw

Re: [Qemu-devel] [PULL 2/8] ui: convert the SDL2 frontend to keycodemapdb

Quoted 19 lines · Daniel P. Berrangé
Quoted 18 lines · Paolo Bonzini
Quoted 17 lines · Daniel P. Berrangé
Quoted 10 lines · Paolo Bonzini

include/ui/input.h extern const guint16 qemu_input_map_qnum_to_qcode[]; · line 81

Quoted 5 lines · Gerd Hoffmann
include/ui/input.h +0 -0
@@ -80,4 +80,7 @@ extern const guint16 qemu_input_map_qnum_to_qcode[];
 extern const guint qemu_input_map_qcode_to_linux_len;
 extern const guint16 qemu_input_map_qcode_to_linux[];

Is there any reason to use the length variables rather than just ARRAY_SIZE()? Coverity isn't able to see through the initializer and incorrectly complains that

ARRAY_SIZE can only be used if you can see the array variable initialization, but this is the header file so all we have is the extern declaration and thus the array size is unknown from the places that need to use the _len variable.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

We do in fact initalize the _len variable based on the ARRAY_SIZE, but that's in the .c files.

Would it make sense for keymap-gen to also generate the header file, so that we can use an "extern const guint x[NNN]" declaration rather instead of "x[]"?

I could probably add such a feature to it....

I could too if I know it will be accepted! I'll send you a patch.

Thanks,

Paolo

#8 lore raw

Re: [Qemu-devel] [PULL 2/8] ui: convert the SDL2 frontend to keycodemapdb

Quoted 23 lines · Paolo Bonzini
Quoted 22 lines · Daniel P. Berrangé
Quoted 21 lines · Paolo Bonzini
Quoted 19 lines · Daniel P. Berrangé
Quoted 10 lines · Paolo Bonzini

include/ui/input.h extern const guint16 qemu_input_map_qnum_to_qcode[]; · line 81

Quoted 5 lines · Gerd Hoffmann
include/ui/input.h +0 -0
@@ -80,4 +80,7 @@ extern const guint16 qemu_input_map_qnum_to_qcode[];
 extern const guint qemu_input_map_qcode_to_linux_len;
 extern const guint16 qemu_input_map_qcode_to_linux[];

Is there any reason to use the length variables rather than just ARRAY_SIZE()? Coverity isn't able to see through the initializer and incorrectly complains that

ARRAY_SIZE can only be used if you can see the array variable initialization, but this is the header file so all we have is the extern declaration and thus the array size is unknown from the places that need to use the _len variable.

We do in fact initalize the _len variable based on the ARRAY_SIZE, but that's in the .c files.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Would it make sense for keymap-gen to also generate the header file, so that we can use an "extern const guint x[NNN]" declaration rather instead of "x[]"?

I could probably add such a feature to it....

I could too if I know it will be accepted! I'll send you a patch.

Cool, i accept patches on this list, or a pull request to the master keycodemap upstream gitlab repo.

My gut feeling is that it'll want to define a new output language "stdc-hdr" to generate the C header. See 'SRC_GENERATORS' table in the tool. There's also a tests/ directory ... :-)

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#9 lore raw

[Qemu-devel] [PULL 5/8] ui: ignore hardware keycode 255 on win32

In reply to Gerd Hoffmann

From: "Daniel P. Berrange" <[email protected]>

It is a reserved value and doesn't have a corresponding valid scancode.

Message-id: [email protected]

---
 ui/gtk.c | 6 ++++++
 1 file changed, 6 insertions(+)
ui/gtk.c +6 -0
index 188c40eef5..f0ad63e431 100644
@@ -1206,6 +1206,12 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)
         return TRUE;
     }
 
+#ifdef WIN32
+    /* on windows, we ought to ignore the reserved key event? */
+    if (key->hardware_keycode == 0xff)
+        return false;
+#endif
+
     if (key->keyval == GDK_KEY_Pause
 #ifdef G_OS_WIN32
         /* for some reason GDK does not fill keyval for VK_PAUSE
Signature · 1 line
2.9.3
#10 lore raw

[Qemu-devel] [PULL 7/8] sdl: use ctrl-alt-g as grab hotkey

In reply to Gerd Hoffmann

Be consistent with gtk and cocoa.

Message-id: [email protected]

---
 ui/sdl.c  | 30 +++++++++++++-----------------
 ui/sdl2.c | 27 +++++++++++----------------
 2 files changed, 24 insertions(+), 33 deletions(-)
ui/sdl.c +13 -17
index f26048d3a2..0017b4a912 100644
@@ -323,11 +323,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) {
@@ -531,6 +531,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;
@@ -666,20 +676,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) {
ui/sdl2.c +11 -16
index 89c6a2633c..1db5dd6f5f 100644
@@ -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) {
Signature · 1 line
2.9.3
#11 lore raw

[Qemu-devel] [PULL 8/8] sdl: reorganize -no-frame support

In reply to Gerd Hoffmann

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.

Message-id: [email protected]

---
 include/sysemu/sysemu.h | 1 +
 include/ui/console.h    | 5 ++---
 ui/sdl.c                | 9 +++------
 ui/sdl2.c               | 7 +------
 vl.c                    | 4 ++--
 5 files changed, 9 insertions(+), 17 deletions(-)
include/sysemu/sysemu.h +1 -0
index 31612caf10..1c925309e3 100644
@@ -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;
include/ui/console.h +2 -3
index 580dfc57ee..7b35778444 100644
@@ -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");
ui/sdl.c +3 -6
index 0017b4a912..c8f102bb9f 100644
@@ -50,7 +50,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;
@@ -118,8 +117,9 @@ 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);
     if (!real_screen) {
@@ -895,7 +895,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;
@@ -917,9 +917,6 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
     g_printerr("Running QEMU with SDL 1.2 is deprecated, and will be removed\n"
                "in a future release. Please switch to SDL 2.0 instead\n");
 
-    if (no_frame)
-        gui_noframe = 1;
-
     if (!full_screen) {
         setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
     }
ui/sdl2.c +1 -6
index 1db5dd6f5f..812c315891 100644
@@ -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
vl.c +2 -2
index e725ecbc08..6ab232095c 100644
@@ -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;
 int no_quit = 0;
 static bool grab_on_hover;
 Chardev *serial_hds[MAX_SERIAL_PORTS];
@@ -4694,7 +4694,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);
Signature · 1 line
2.9.3
#12 lore raw

[Qemu-devel] [PULL 4/8] ui: add fix for GTK Pause key handling on Win32

In reply to Gerd Hoffmann

From: "Daniel P. Berrange" <[email protected]>

Versions of GTK prior to 3.22 did not correctly set the keyval field when VK_PAUSE was received on Windows.

Message-id: [email protected]

---
 ui/gtk.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
ui/gtk.c +8 -1
index 1217160724..188c40eef5 100644
@@ -1206,7 +1206,14 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)
         return TRUE;
     }
 
-    if (key->keyval == GDK_KEY_Pause) {
+    if (key->keyval == GDK_KEY_Pause
+#ifdef G_OS_WIN32
+        /* for some reason GDK does not fill keyval for VK_PAUSE
+         * See https://bugzilla.gnome.org/show_bug.cgi?id=769214
+         */
+        || key->hardware_keycode == VK_PAUSE
+#endif
+        ) {
         qemu_input_event_send_key_qcode(vc->gfx.dcl.con, Q_KEY_CODE_PAUSE,
                                         key->type == GDK_KEY_PRESS);
         return TRUE;
Signature · 1 line
2.9.3
#13 lore raw

[Qemu-devel] [PULL 6/8] ui: deprecate use of SDL 1.2 in favour of 2.0 series

In reply to Gerd Hoffmann

From: "Daniel P. Berrange" <[email protected]>

The SDL 2.0 release was made in Aug, 2013:

https://www.libsdl.org/release/

That will soon be 4 + 1/2 years ago, which is enough time to consider the 2.0 series widely supported.

Thus we deprecate the SDL 1.2 support, which will allow us to delete it in the last release of 2018. By this time, SDL 2.0 will be more than 5 years old.

Message-id: [email protected]

---
 configure     | 6 ++++++
 ui/sdl.c      | 3 +++
 qemu-doc.texi | 7 +++++++
 3 files changed, 16 insertions(+)
configure +6 -0
index 044c6fafe2..96dee6572c 100755
@@ -5668,6 +5668,12 @@ if test "$gtkabi" = "2.0"; then
     echo "WARNING: future releases. Please switch to using GTK 3.0"
 fi
 
+if test "$sdlabi" = "1.2"; then
+    echo
+    echo "WARNING: Use of SDL 1.2 is deprecated and will be removed in"
+    echo "WARNING: future releases. Please switch to using SDL 2.0"
+fi
+
 if test "$supported_cpu" = "no"; then
     echo
     echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
ui/sdl.c +3 -0
index afb4992da2..f26048d3a2 100644
@@ -918,6 +918,9 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
             exit(1);
     }
 
+    g_printerr("Running QEMU with SDL 1.2 is deprecated, and will be removed\n"
+               "in a future release. Please switch to SDL 2.0 instead\n");
+
     if (no_frame)
         gui_noframe = 1;
 
qemu-doc.texi +7 -0
index 3e9eb819a6..79d08b3f04 100644
@@ -2596,6 +2596,13 @@ and 3.x series APIs. Support for the GTK 2.x builds will be
 discontinued, so maintainers should switch to using GTK 3.x,
 which is the default.
 
+@subsection SDL 1.2
+
+Previously QEMU has supported building against both SDL 1.2
+and 2.0 series APIs. Support for the SDL 1.2 builds will be
+discontinued, so maintainers should switch to using SDL 2.0,
+which is the default.
+
 @section System emulator command line arguments
 
 @subsection -tdf (since 1.3.0)
Signature · 1 line
2.9.3
#14 lore raw

[Qemu-devel] [PULL 3/8] ui: convert GTK and SDL1 frontends to keycodemapdb

In reply to Gerd Hoffmann

From: "Daniel P. Berrange" <[email protected]>

The x_keycode_to_pc_keycode and evdev_keycode_to_pc_keycode tables are replaced with automatically generated tables. In addition the X11 heuristics are improved to detect running on XQuartz and XWin X11 servers, to activate the correct OS-X and Win32 keycode maps.

Message-id: [email protected]

---
 Makefile           |   7 ++
 include/ui/input.h |  21 +++++
 ui/x_keymap.h      |   8 +-
 ui/gtk.c           | 205 +++++++++++++++++++++++++------------------
 ui/input-keymap.c  |   7 ++
 ui/sdl.c           | 105 +++++++---------------
 ui/x_keymap.c      | 250 ++++++++++++++++++++---------------------------------
 ui/Makefile.objs   |   5 +-
 ui/trace-events    |   9 +-
 9 files changed, 300 insertions(+), 317 deletions(-)
Makefile +7 -0
index 24ed2b3e63..af31e8981f 100644
@@ -232,11 +232,18 @@ KEYCODEMAP_GEN = $(SRC_PATH)/ui/keycodemapdb/tools/keymap-gen
 KEYCODEMAP_CSV = $(SRC_PATH)/ui/keycodemapdb/data/keymaps.csv
 
 KEYCODEMAP_FILES = \
+		 ui/input-keymap-atset1-to-qcode.c \
 		 ui/input-keymap-linux-to-qcode.c \
 		 ui/input-keymap-qcode-to-qnum.c \
 		 ui/input-keymap-qnum-to-qcode.c \
 		 ui/input-keymap-qcode-to-linux.c \
 		 ui/input-keymap-usb-to-qcode.c \
+		 ui/input-keymap-win32-to-qcode.c \
+		 ui/input-keymap-x11-to-qcode.c \
+		 ui/input-keymap-xorgevdev-to-qcode.c \
+		 ui/input-keymap-xorgkbd-to-qcode.c \
+		 ui/input-keymap-xorgxquartz-to-qcode.c \
+		 ui/input-keymap-xorgxwin-to-qcode.c \
 		 $(NULL)
 
 GENERATED_FILES += $(KEYCODEMAP_FILES)
include/ui/input.h +21 -0
index 0d289e4142..05aab2db5c 100644
@@ -68,6 +68,9 @@ void qemu_input_check_mode_change(void);
 void qemu_add_mouse_mode_change_notifier(Notifier *notify);
 void qemu_remove_mouse_mode_change_notifier(Notifier *notify);
 
+extern const guint qemu_input_map_atset1_to_qcode_len;
+extern const guint16 qemu_input_map_atset1_to_qcode[];
+
 extern const guint qemu_input_map_linux_to_qcode_len;
 extern const guint16 qemu_input_map_linux_to_qcode[];
 
@@ -83,4 +86,22 @@ extern const guint16 qemu_input_map_qcode_to_linux[];
 extern const guint qemu_input_map_usb_to_qcode_len;
 extern const guint16 qemu_input_map_usb_to_qcode[];
 
+extern const guint qemu_input_map_win32_to_qcode_len;
+extern const guint16 qemu_input_map_win32_to_qcode[];
+
+extern const guint qemu_input_map_x11_to_qcode_len;
+extern const guint16 qemu_input_map_x11_to_qcode[];
+
+extern const guint qemu_input_map_xorgevdev_to_qcode_len;
+extern const guint16 qemu_input_map_xorgevdev_to_qcode[];
+
+extern const guint qemu_input_map_xorgkbd_to_qcode_len;
+extern const guint16 qemu_input_map_xorgkbd_to_qcode[];
+
+extern const guint qemu_input_map_xorgxquartz_to_qcode_len;
+extern const guint16 qemu_input_map_xorgxquartz_to_qcode[];
+
+extern const guint qemu_input_map_xorgxwin_to_qcode_len;
+extern const guint16 qemu_input_map_xorgxwin_to_qcode[];
+
 #endif /* INPUT_H */
ui/x_keymap.h +4 -4
index afde2e94bf..0395e335ff 100644
@@ -1,7 +1,7 @@
 /*
- * QEMU SDL display driver
+ * QEMU X11 keymaps
  *
- * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2017 Red Hat, Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -25,8 +25,8 @@
 #ifndef QEMU_X_KEYMAP_H
 #define QEMU_X_KEYMAP_H
 
-uint8_t translate_xfree86_keycode(const int key);
+#include <X11/Xlib.h>
 
-uint8_t translate_evdev_keycode(const int key);
+const guint16 *qemu_xkeymap_mapping_table(Display *dpy, size_t *maplen);
 
 #endif
ui/gtk.c +123 -82

307 lines not on this page · raw message

ui/input-keymap.c +7 -0
index 3be6dedea5..95b1e0cbfa 100644
@@ -5,11 +5,18 @@
 
 #include "standard-headers/linux/input.h"
 
+#include "ui/input-keymap-atset1-to-qcode.c"
 #include "ui/input-keymap-linux-to-qcode.c"
 #include "ui/input-keymap-qcode-to-qnum.c"
 #include "ui/input-keymap-qnum-to-qcode.c"
 #include "ui/input-keymap-qcode-to-linux.c"
 #include "ui/input-keymap-usb-to-qcode.c"
+#include "ui/input-keymap-win32-to-qcode.c"
+#include "ui/input-keymap-x11-to-qcode.c"
+#include "ui/input-keymap-xorgevdev-to-qcode.c"
+#include "ui/input-keymap-xorgkbd-to-qcode.c"
+#include "ui/input-keymap-xorgxquartz-to-qcode.c"
+#include "ui/input-keymap-xorgxwin-to-qcode.c"
 
 int qemu_input_linux_to_qcode(unsigned int lnx)
 {
ui/sdl.c +31 -74

145 lines not on this page · raw message

ui/x_keymap.c +96 -154

265 lines not on this page · raw message

ui/Makefile.objs +3 -2
index ec8533d6d9..99195884b0 100644
@@ -11,11 +11,12 @@ common-obj-y += keymaps.o console.o cursor.o qemu-pixman.o
 common-obj-y += input.o input-keymap.o input-legacy.o
 common-obj-$(CONFIG_LINUX) += input-linux.o
 common-obj-$(CONFIG_SPICE) += spice-core.o spice-input.o spice-display.o
-common-obj-$(CONFIG_SDL) += sdl.mo x_keymap.o
+common-obj-$(CONFIG_SDL) += sdl.mo
 common-obj-$(CONFIG_COCOA) += cocoa.o
 common-obj-$(CONFIG_CURSES) += curses.o
 common-obj-$(CONFIG_VNC) += $(vnc-obj-y)
-common-obj-$(CONFIG_GTK) += gtk.o x_keymap.o
+common-obj-$(CONFIG_GTK) += gtk.o
+common-obj-$(if $(CONFIG_WIN32),n,$(if $(CONFIG_SDL),y,$(CONFIG_GTK))) += x_keymap.o
 
 ifeq ($(CONFIG_SDLABI),1.2)
 sdl.mo-objs := sdl.o sdl_zoom.o
ui/trace-events +8 -1
index 85f74f948b..34229e6747 100644
@@ -18,9 +18,10 @@ ppm_save(const char *filename, void *display_surface) "%s surface=%p"
 # ui/gtk.c
 gd_switch(const char *tab, int width, int height) "tab=%s, width=%d, height=%d"
 gd_update(const char *tab, int x, int y, int w, int h) "tab=%s, x=%d, y=%d, w=%d, h=%d"
-gd_key_event(const char *tab, int gdk_keycode, int qemu_keycode, const char *action) "tab=%s, translated GDK keycode %d to QEMU keycode %d (%s)"
+gd_key_event(const char *tab, int gdk_keycode, int qkeycode, const char *action) "tab=%s, translated GDK keycode %d to QKeyCode %d (%s)"
 gd_grab(const char *tab, const char *device, const char *reason) "tab=%s, dev=%s, reason=%s"
 gd_ungrab(const char *tab, const char *device) "tab=%s, dev=%s"
+gd_keymap_windowing(const char *name) "backend=%s"
 
 # ui/vnc.c
 vnc_key_guest_leds(bool caps, bool num, bool scroll) "caps %d, num %d, scroll %d"
@@ -79,3 +80,9 @@ qemu_spice_create_update(uint32_t left, uint32_t right, uint32_t top, uint32_t b
 keymap_parse(const char *file) "file %s"
 keymap_add(const char *type, int sym, int code, const char *line) "%-6s sym=0x%04x code=0x%04x (line: %s)"
 keymap_unmapped(int sym) "sym=0x%04x"
+
+# ui/x_keymap.c
+xkeymap_extension(const char *name) "extension '%s'"
+xkeymap_vendor(const char *name) "vendor '%s'"
+xkeymap_keycodes(const char *name) "keycodes '%s'"
+xkeymap_keymap(const char *name) "keymap '%s'"
Signature · 1 line
2.9.3
#15 lore raw
In reply to Gerd Hoffmann
Quoted 26 lines · Gerd Hoffmann

The following changes since commit 834a336eb911db8a8ca00e760ee6a85faca19414:

Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2018-01-24 19:24:26 +0000)

are available in the git repository at:

git://git.kraxel.org/qemu tags/ui-20180125-pull-request

for you to fetch changes up to 04ff1a398a8d6e912eceaca9b62af0a09e927d63:

sdl: reorganize -no-frame support (2018-01-25 15:22:28 +0100)

----------------------------------------------------------------
ui: convert to keycodedb, fix sign extension
sdl: cleanups, deprecate sdl 1.2

----------------------------------------------------------------

Daniel P. Berrange (6):
ui: avoid sign extension using client width/height
ui: convert the SDL2 frontend to keycodemapdb
ui: convert GTK and SDL1 frontends to keycodemapdb
ui: add fix for GTK Pause key handling on Win32
ui: ignore hardware keycode 255 on win32
ui: deprecate use of SDL 1.2 in favour of 2.0 series

Quoted 3 lines

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

Applied, thanks (and updated my buildtest machines to have SDL2 where necessary to avoid the configure warning).

thanks
-- PMM