All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL v2 00/11] ui patch queue
@ 2017-01-09 13:09 Gerd Hoffmann
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 01/11] ui/gtk: fix crash at startup when no console is available Gerd Hoffmann
                   ` (11 more replies)
  0 siblings, 12 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2017-01-09 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

Here comes the ui patch queue with a bunch of small changes and fixes
all over the place: gtk, vnc, curses, sdl, keyboard.

v2 changes:  Replace the ps2 fix (v3 instead of v2 of the patch).

please pull,
  Gerd

The following changes since commit dbe2b65566e76d3c3a0c3358285c0336ac61e757:

  Merge remote-tracking branch 'remotes/vivier/tags/m68k-for-2.9-pull-request' into staging (2016-12-28 17:11:11 +0000)

are available in the git repository at:


  git://git.kraxel.org/qemu tags/pull-ui-20170109-1

for you to fetch changes up to f46c4259f489d2e7742890ddfaa862bde3731e3e:

  ps2: Fix lost scancodes by recent changes (2017-01-06 10:36:49 +0100)

----------------------------------------------------------------
gtk,vnc: misc bugfixes.
kbd: add jp keys, fix ps2 regressions.
sdl: export window id for baum, remove sdl hooks from baum.
egl: egl-helpers.c license change.

----------------------------------------------------------------
Daniel P. Berrange (1):
      ui: use evdev keymap when running under wayland

Frediano Ziglio (1):
      egl-helpers: Change file licensing to LGPLv2

Gerd Hoffmann (1):
      ui: drop unused MOUSE_EVENT_WHEEL{UP, DN} defines

Hervé Poussineau (1):
      ui/gtk: fix crash at startup when no console is available

Marc-André Lureau (1):
      gtk: avoid oob array access

OGAWA Hirofumi (1):
      ps2: Fix lost scancodes by recent changes

Samuel Thibault (3):
      console: add API to get underlying gui window ID
      console: move window ID code from baum to sdl
      sdl2: set window ID

Stefan Weil (1):
      curses: Fix compiler warnings (Mingw-w64 redefinition of macro KEY_EVENT)

Thomas Huth (1):
      ui/vnc: Fix problem with sending too many bytes as server name

 backends/baum.c      | 31 ++++++++-----------------------
 hw/input/ps2.c       | 10 ++++++++++
 include/ui/console.h | 12 ++++++++----
 include/ui/gtk.h     |  4 ++++
 qapi-schema.json     |  6 +++++-
 ui/console.c         | 11 +++++++++++
 ui/curses.c          |  1 -
 ui/egl-helpers.c     | 16 ++++++++++++++++
 ui/gtk.c             | 18 +++++++++++++++++-
 ui/input-keymap.c    |  3 +++
 ui/sdl.c             | 25 +++++++++++++++++++++++++
 ui/sdl2.c            |  7 +++++++
 ui/vnc.c             |  8 ++++++--
 13 files changed, 120 insertions(+), 32 deletions(-)

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

* [Qemu-devel] [PULL v2 01/11] ui/gtk: fix crash at startup when no console is available
  2017-01-09 13:09 [Qemu-devel] [PULL v2 00/11] ui patch queue Gerd Hoffmann
@ 2017-01-09 13:09 ` Gerd Hoffmann
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 02/11] ui: use evdev keymap when running under wayland Gerd Hoffmann
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2017-01-09 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Hervé Poussineau, Gerd Hoffmann

From: Hervé Poussineau <hpoussin@reactos.org>

This patch fixes a segfault at QEMU startup, introduced in a08156321ab9a7d2fed9ee77dbfeea2a61ffd153.
gd_vc_find_current() return NULL, which is dereferenced without checking it.

While at it, disable the whole 'View' menu if no console exists.

Reproducer: qemu-system-i386 -M none -nodefaults

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1483263585-8101-1-git-send-email-hpoussin@reactos.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/gtk.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index a216216..406de4f 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -2171,6 +2171,8 @@ static gboolean gtkinit;
 
 void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
 {
+    VirtualConsole *vc;
+
     GtkDisplayState *s = g_malloc0(sizeof(*s));
     char *filename;
     GdkDisplay *window_display;
@@ -2249,9 +2251,11 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
     }
 #endif
 
+    vc = gd_vc_find_current(s);
+    gtk_widget_set_sensitive(s->view_menu, vc != NULL);
 #ifdef CONFIG_VTE
     gtk_widget_set_sensitive(s->copy_item,
-                             gd_vc_find_current(s)->type == GD_VC_VTE);
+                             vc && vc->type == GD_VC_VTE);
 #endif
 
     if (full_screen) {
-- 
1.8.3.1

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

* [Qemu-devel] [PULL v2 02/11] ui: use evdev keymap when running under wayland
  2017-01-09 13:09 [Qemu-devel] [PULL v2 00/11] ui patch queue Gerd Hoffmann
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 01/11] ui/gtk: fix crash at startup when no console is available Gerd Hoffmann
@ 2017-01-09 13:09 ` Gerd Hoffmann
  2017-01-16  9:31   ` Daniel P. Berrange
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 03/11] console: add API to get underlying gui window ID Gerd Hoffmann
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 20+ messages in thread
From: Gerd Hoffmann @ 2017-01-09 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel P. Berrange, Gerd Hoffmann

From: "Daniel P. Berrange" <berrange@redhat.com>

Wayland always uses evdev as its input source, so QEMU
can use the existing evdev keymap data

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Tested-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20161201094117.16407-1-berrange@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/gtk.h | 4 ++++
 ui/gtk.c         | 7 +++++++
 2 files changed, 11 insertions(+)

diff --git a/include/ui/gtk.h b/include/ui/gtk.h
index 42ca0fe..b3b5005 100644
--- a/include/ui/gtk.h
+++ b/include/ui/gtk.h
@@ -18,6 +18,10 @@
 #include <X11/XKBlib.h>
 #endif
 
+#ifdef GDK_WINDOWING_WAYLAND
+#include <gdk/gdkwayland.h>
+#endif
+
 #if defined(CONFIG_OPENGL)
 #include "ui/egl-helpers.h"
 #include "ui/egl-context.h"
diff --git a/ui/gtk.c b/ui/gtk.c
index 406de4f..356f400 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -90,6 +90,9 @@
 #ifndef GDK_IS_X11_DISPLAY
 #define GDK_IS_X11_DISPLAY(dpy) (dpy == dpy)
 #endif
+#ifndef GDK_IS_WAYLAND_DISPLAY
+#define GDK_IS_WAYLAND_DISPLAY(dpy) (dpy == dpy)
+#endif
 #ifndef GDK_IS_WIN32_DISPLAY
 #define GDK_IS_WIN32_DISPLAY(dpy) (dpy == dpy)
 #endif
@@ -1054,6 +1057,10 @@ static int gd_map_keycode(GtkDisplayState *s, GdkDisplay *dpy, int gdk_keycode)
             qemu_keycode = translate_xfree86_keycode(gdk_keycode - 97);
         }
 #endif
+#ifdef GDK_WINDOWING_WAYLAND
+    } else if (GDK_IS_WAYLAND_DISPLAY(dpy) && gdk_keycode < 158) {
+        qemu_keycode = translate_evdev_keycode(gdk_keycode - 97);
+#endif
     } else if (gdk_keycode == 208) { /* Hiragana_Katakana */
         qemu_keycode = 0x70;
     } else if (gdk_keycode == 211) { /* backslash */
-- 
1.8.3.1

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

* [Qemu-devel] [PULL v2 03/11] console: add API to get underlying gui window ID
  2017-01-09 13:09 [Qemu-devel] [PULL v2 00/11] ui patch queue Gerd Hoffmann
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 01/11] ui/gtk: fix crash at startup when no console is available Gerd Hoffmann
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 02/11] ui: use evdev keymap when running under wayland Gerd Hoffmann
@ 2017-01-09 13:09 ` Gerd Hoffmann
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 04/11] console: move window ID code from baum to sdl Gerd Hoffmann
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2017-01-09 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Samuel Thibault, Gerd Hoffmann

From: Samuel Thibault <samuel.thibault@ens-lyon.org>

This adds two console functions, qemu_console_set_window_id and
qemu_graphic_console_get_window_id, to let graphical backend record the
window id in the QemuConsole structure, and let the baum driver read it.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Message-id: 20161221003806.22412-2-samuel.thibault@ens-lyon.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h |  4 ++++
 ui/console.c         | 11 +++++++++++
 2 files changed, 15 insertions(+)

diff --git a/include/ui/console.h b/include/ui/console.h
index e2589e2..ee8c407 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -394,6 +394,10 @@ uint32_t qemu_console_get_head(QemuConsole *con);
 QemuUIInfo *qemu_console_get_ui_info(QemuConsole *con);
 int qemu_console_get_width(QemuConsole *con, int fallback);
 int qemu_console_get_height(QemuConsole *con, int fallback);
+/* Return the low-level window id for the console */
+int qemu_console_get_window_id(QemuConsole *con);
+/* Set the low-level window id for the console */
+void qemu_console_set_window_id(QemuConsole *con, int window_id);
 
 void console_select(unsigned int index);
 void qemu_console_resize(QemuConsole *con, int width, int height);
diff --git a/ui/console.c b/ui/console.c
index ed888e5..b9575f2 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -124,6 +124,7 @@ struct QemuConsole {
     int dcls;
     DisplayChangeListener *gl;
     bool gl_block;
+    int window_id;
 
     /* Graphic console state.  */
     Object *device;
@@ -273,6 +274,16 @@ void graphic_hw_gl_block(QemuConsole *con, bool block)
     }
 }
 
+int qemu_console_get_window_id(QemuConsole *con)
+{
+    return con->window_id;
+}
+
+void qemu_console_set_window_id(QemuConsole *con, int window_id)
+{
+    con->window_id = window_id;
+}
+
 void graphic_hw_invalidate(QemuConsole *con)
 {
     if (!con) {
-- 
1.8.3.1

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

* [Qemu-devel] [PULL v2 04/11] console: move window ID code from baum to sdl
  2017-01-09 13:09 [Qemu-devel] [PULL v2 00/11] ui patch queue Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 03/11] console: add API to get underlying gui window ID Gerd Hoffmann
@ 2017-01-09 13:09 ` Gerd Hoffmann
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 05/11] sdl2: set window ID Gerd Hoffmann
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2017-01-09 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Samuel Thibault, Gerd Hoffmann

From: Samuel Thibault <samuel.thibault@ens-lyon.org>

This moves the SDL bits for window ID from the baum driver to SDL, as
well as fixing the build for non-X11.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Message-id: 20161221003806.22412-3-samuel.thibault@ens-lyon.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 backends/baum.c | 31 ++++++++-----------------------
 ui/sdl.c        | 25 +++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/backends/baum.c b/backends/baum.c
index b92369d..b045ef4 100644
--- a/backends/baum.c
+++ b/backends/baum.c
@@ -27,12 +27,10 @@
 #include "sysemu/char.h"
 #include "qemu/timer.h"
 #include "hw/usb.h"
+#include "ui/console.h"
 #include <brlapi.h>
 #include <brlapi_constants.h>
 #include <brlapi_keycodes.h>
-#ifdef CONFIG_SDL
-#include <SDL_syswm.h>
-#endif
 
 #if 0
 #define DPRINTF(fmt, ...) \
@@ -227,12 +225,8 @@ static const uint8_t nabcc_translation[2][256] = {
 /* The guest OS has started discussing with us, finish initializing BrlAPI */
 static int baum_deferred_init(BaumDriverState *baum)
 {
-#if defined(CONFIG_SDL)
-#if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 0)
-    SDL_SysWMinfo info;
-#endif
-#endif
-    int tty;
+    int tty = BRLAPI_TTY_DEFAULT;
+    QemuConsole *con;
 
     if (baum->deferred_init) {
         return 1;
@@ -243,21 +237,12 @@ static int baum_deferred_init(BaumDriverState *baum)
         return 0;
     }
 
-#if defined(CONFIG_SDL)
-#if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 0)
-    memset(&info, 0, sizeof(info));
-    SDL_VERSION(&info.version);
-    if (SDL_GetWMInfo(&info)) {
-        tty = info.info.x11.wmwindow;
-    } else {
-#endif
-#endif
-        tty = BRLAPI_TTY_DEFAULT;
-#if defined(CONFIG_SDL)
-#if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 0)
+    con = qemu_console_lookup_by_index(0);
+    if (con && qemu_console_is_graphic(con)) {
+        tty = qemu_console_get_window_id(con);
+        if (tty == -1)
+            tty = BRLAPI_TTY_DEFAULT;
     }
-#endif
-#endif
 
     if (brlapi__enterTtyMode(baum->brlapi, tty, NULL) == -1) {
         brlapi_perror("baum: brlapi__enterTtyMode");
diff --git a/ui/sdl.c b/ui/sdl.c
index d8cf5bc..19e8a84 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -947,6 +947,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
     int flags;
     uint8_t data = 0;
     const SDL_VideoInfo *vi;
+    SDL_SysWMinfo info;
     char *filename;
 
 #if defined(__APPLE__)
@@ -1023,5 +1024,29 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
     sdl_cursor_hidden = SDL_CreateCursor(&data, &data, 8, 1, 0, 0);
     sdl_cursor_normal = SDL_GetCursor();
 
+    memset(&info, 0, sizeof(info));
+    SDL_VERSION(&info.version);
+    if (SDL_GetWMInfo(&info)) {
+        int i;
+        for (i = 0; ; i++) {
+            /* All consoles share the same window */
+            QemuConsole *con = qemu_console_lookup_by_index(i);
+            if (con) {
+#if defined(SDL_VIDEO_DRIVER_X11)
+                qemu_console_set_window_id(con, info.info.x11.wmwindow);
+#elif defined(SDL_VIDEO_DRIVER_NANOX) || \
+      defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || \
+      defined(SDL_VIDEO_DRIVER_GAPI) || \
+      defined(SDL_VIDEO_DRIVER_RISCOS)
+                qemu_console_set_window_id(con, (int) (uintptr_t) info.window);
+#else
+                qemu_console_set_window_id(con, info.data);
+#endif
+            } else {
+                break;
+            }
+        }
+    }
+
     atexit(sdl_cleanup);
 }
-- 
1.8.3.1

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

* [Qemu-devel] [PULL v2 05/11] sdl2: set window ID
  2017-01-09 13:09 [Qemu-devel] [PULL v2 00/11] ui patch queue Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 04/11] console: move window ID code from baum to sdl Gerd Hoffmann
@ 2017-01-09 13:09 ` Gerd Hoffmann
  2017-01-12 15:10   ` Stefan Weil
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 06/11] egl-helpers: Change file licensing to LGPLv2 Gerd Hoffmann
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 20+ messages in thread
From: Gerd Hoffmann @ 2017-01-09 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Samuel Thibault, Gerd Hoffmann

From: Samuel Thibault <samuel.thibault@ens-lyon.org>

This uses the console API to record the window ID of the SDL2 windows.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Message-id: 20161221003806.22412-4-samuel.thibault@ens-lyon.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/sdl2.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/ui/sdl2.c b/ui/sdl2.c
index 30d2a3c..9a79b17 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -761,6 +761,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
     uint8_t data = 0;
     char *filename;
     int i;
+    SDL_SysWMinfo info;
 
     if (no_frame) {
         gui_noframe = 1;
@@ -786,6 +787,8 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
         exit(1);
     }
     SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "1");
+    memset(&info, 0, sizeof(info));
+    SDL_VERSION(&info.version);
 
     for (i = 0;; i++) {
         QemuConsole *con = qemu_console_lookup_by_index(i);
@@ -813,6 +816,10 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
 #endif
         sdl2_console[i].dcl.con = con;
         register_displaychangelistener(&sdl2_console[i].dcl);
+
+        if (SDL_GetWindowWMInfo(sdl2_console[i].real_window, &info)) {
+            qemu_console_set_window_id(con, info.info.x11.window);
+        }
     }
 
     /* Load a 32x32x4 image. White pixels are transparent. */
-- 
1.8.3.1

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

* [Qemu-devel] [PULL v2 06/11] egl-helpers: Change file licensing to LGPLv2
  2017-01-09 13:09 [Qemu-devel] [PULL v2 00/11] ui patch queue Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 05/11] sdl2: set window ID Gerd Hoffmann
@ 2017-01-09 13:09 ` Gerd Hoffmann
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 07/11] gtk: avoid oob array access Gerd Hoffmann
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2017-01-09 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Frediano Ziglio, Gerd Hoffmann

From: Frediano Ziglio <fziglio@redhat.com>

The relicense permits sharing the code with Spice which
is LGPL.

All people listed below have agreed to the
relicense:
- Arei Gonglei;
- Cole Robinson;
- Gerd Hoffmann;
- Peter Maydell.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Cole Robinson <crobinso@redhat.com>
Acked-by: Gonglei <arei.gonglei@huawei.com>
Acked-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20161208104539.3045-1-fziglio@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/egl-helpers.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c
index 79cee05..cd24568 100644
--- a/ui/egl-helpers.c
+++ b/ui/egl-helpers.c
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2015-2016 Gerd Hoffmann <kraxel@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
 #include "qemu/osdep.h"
 #include <glob.h>
 #include <dirent.h>
-- 
1.8.3.1

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

* [Qemu-devel] [PULL v2 07/11] gtk: avoid oob array access
  2017-01-09 13:09 [Qemu-devel] [PULL v2 00/11] ui patch queue Gerd Hoffmann
                   ` (5 preceding siblings ...)
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 06/11] egl-helpers: Change file licensing to LGPLv2 Gerd Hoffmann
@ 2017-01-09 13:09 ` Gerd Hoffmann
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 08/11] ui: drop unused MOUSE_EVENT_WHEEL{UP, DN} defines Gerd Hoffmann
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2017-01-09 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Marc-André Lureau, Gerd Hoffmann

From: Marc-André Lureau <marcandre.lureau@redhat.com>

When too many consoles are created, vcs[] may be write out-of-bounds.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: 20161207105511.25173-1-marcandre.lureau@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/gtk.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ui/gtk.c b/ui/gtk.c
index 356f400..86368e3 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1706,6 +1706,11 @@ static CharDriverState *gd_vc_handler(ChardevVC *vc, Error **errp)
     ChardevCommon *common = qapi_ChardevVC_base(vc);
     CharDriverState *chr;
 
+    if (nb_vcs == MAX_VCS) {
+        error_setg(errp, "Maximum number of consoles reached");
+        return NULL;
+    }
+
     chr = qemu_chr_alloc(common, errp);
     if (!chr) {
         return NULL;
-- 
1.8.3.1

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

* [Qemu-devel] [PULL v2 08/11] ui: drop unused MOUSE_EVENT_WHEEL{UP, DN} defines
  2017-01-09 13:09 [Qemu-devel] [PULL v2 00/11] ui patch queue Gerd Hoffmann
                   ` (6 preceding siblings ...)
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 07/11] gtk: avoid oob array access Gerd Hoffmann
@ 2017-01-09 13:09 ` Gerd Hoffmann
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 09/11] ui/vnc: Fix problem with sending too many bytes as server name Gerd Hoffmann
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2017-01-09 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

Also update comment to make clear this
is for legacy mouse emulation only.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 1480409632-6163-1-git-send-email-kraxel@redhat.com
---
 include/ui/console.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index ee8c407..753ae93 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -13,13 +13,10 @@
 # include <epoxy/gl.h>
 #endif
 
-/* keyboard/mouse support */
-
+/* mouse buttons, used by legacy handlers (qemu_add_mouse_event_handler) */
 #define MOUSE_EVENT_LBUTTON 0x01
 #define MOUSE_EVENT_RBUTTON 0x02
 #define MOUSE_EVENT_MBUTTON 0x04
-#define MOUSE_EVENT_WHEELUP 0x08
-#define MOUSE_EVENT_WHEELDN 0x10
 
 /* identical to the ps/2 keyboard bits */
 #define QEMU_SCROLL_LOCK_LED (1 << 0)
-- 
1.8.3.1

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

* [Qemu-devel] [PULL v2 09/11] ui/vnc: Fix problem with sending too many bytes as server name
  2017-01-09 13:09 [Qemu-devel] [PULL v2 00/11] ui patch queue Gerd Hoffmann
                   ` (7 preceding siblings ...)
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 08/11] ui: drop unused MOUSE_EVENT_WHEEL{UP, DN} defines Gerd Hoffmann
@ 2017-01-09 13:09 ` Gerd Hoffmann
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 10/11] curses: Fix compiler warnings (Mingw-w64 redefinition of macro KEY_EVENT) Gerd Hoffmann
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2017-01-09 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth, Gerd Hoffmann

From: Thomas Huth <thuth@redhat.com>

If the buffer is not big enough, snprintf() does not return the number
of bytes that have been written to the buffer, but the number of bytes
that would be needed for writing the whole string. By using this value
for the following vnc_write() calls, we send some junk at the end of
the name in case the qemu_name is longer than 1017 bytes, which could
confuse the VNC clients. Fix this by adding an additional size check
here.

Buglink: https://bugs.launchpad.net/qemu/+bug/1637447
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1479749115-21932-1-git-send-email-thuth@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/vnc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 2c28a59..29aa9c4 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2459,10 +2459,14 @@ static int protocol_client_init(VncState *vs, uint8_t *data, size_t len)
 
     pixel_format_message(vs);
 
-    if (qemu_name)
+    if (qemu_name) {
         size = snprintf(buf, sizeof(buf), "QEMU (%s)", qemu_name);
-    else
+        if (size > sizeof(buf)) {
+            size = sizeof(buf);
+        }
+    } else {
         size = snprintf(buf, sizeof(buf), "QEMU");
+    }
 
     vnc_write_u32(vs, size);
     vnc_write(vs, buf, size);
-- 
1.8.3.1

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

* [Qemu-devel] [PULL v2 10/11] curses: Fix compiler warnings (Mingw-w64 redefinition of macro KEY_EVENT)
  2017-01-09 13:09 [Qemu-devel] [PULL v2 00/11] ui patch queue Gerd Hoffmann
                   ` (8 preceding siblings ...)
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 09/11] ui/vnc: Fix problem with sending too many bytes as server name Gerd Hoffmann
@ 2017-01-09 13:09 ` Gerd Hoffmann
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 11/11] ps2: Fix lost scancodes by recent changes Gerd Hoffmann
  2017-01-09 13:49 ` [Qemu-devel] [PULL v2 00/11] ui patch queue Peter Maydell
  11 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2017-01-09 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Weil, Gerd Hoffmann

From: Stefan Weil <sw@weilnetz.de>

For builds with Mingw-w64 as it is included in Cygwin, there are two
header files which define KEY_EVENT with different values.

This results in lots of compiler warnings like this one:

  CC      vl.o
In file included from /qemu/include/ui/console.h:340:0,
                 from /qemu/vl.c:76:
/usr/i686-w64-mingw32/sys-root/mingw/include/curses.h:1522:0: warning: "KEY_EVENT" redefined
 #define KEY_EVENT 0633  /* We were interrupted by an event */

In file included from /usr/share/mingw-w64/include/windows.h:74:0,
                 from /usr/share/mingw-w64/include/winsock2.h:23,
                 from /qemu/include/sysemu/os-win32.h:29,
                 from /qemu/include/qemu/osdep.h:100,
                 from /qemu/vl.c:24:
/usr/share/mingw-w64/include/wincon.h:101:0: note: this is the location of the previous definition
 #define KEY_EVENT 0x1

QEMU only uses the KEY_EVENT macro from wincon.h.
Therefore we can undefine the macro coming from curses.h.

The explicit include statement for curses.h in ui/curses.c is not needed
and was removed.

Those two modifications fix the redefinition warnings.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Message-id: 20161119185318.10564-1-sw@weilnetz.de
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/console.h | 3 +++
 ui/curses.c          | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 753ae93..7fb351f 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -334,7 +334,10 @@ static inline pixman_format_code_t surface_format(DisplaySurface *s)
 }
 
 #ifdef CONFIG_CURSES
+/* KEY_EVENT is defined in wincon.h and in curses.h. Avoid redefinition. */
+#undef KEY_EVENT
 #include <curses.h>
+#undef KEY_EVENT
 typedef chtype console_ch_t;
 extern chtype vga_to_curses[];
 #else
diff --git a/ui/curses.c b/ui/curses.c
index 2e132a7..03cefdf 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -22,7 +22,6 @@
  * THE SOFTWARE.
  */
 #include "qemu/osdep.h"
-#include <curses.h>
 
 #ifndef _WIN32
 #include <sys/ioctl.h>
-- 
1.8.3.1

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

* [Qemu-devel] [PULL v2 11/11] ps2: Fix lost scancodes by recent changes
  2017-01-09 13:09 [Qemu-devel] [PULL v2 00/11] ui patch queue Gerd Hoffmann
                   ` (9 preceding siblings ...)
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 10/11] curses: Fix compiler warnings (Mingw-w64 redefinition of macro KEY_EVENT) Gerd Hoffmann
@ 2017-01-09 13:09 ` Gerd Hoffmann
  2017-01-09 13:49 ` [Qemu-devel] [PULL v2 00/11] ui patch queue Peter Maydell
  11 siblings, 0 replies; 20+ messages in thread
From: Gerd Hoffmann @ 2017-01-09 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: OGAWA Hirofumi, Gerd Hoffmann, Eric Blake, Markus Armbruster

From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

With "ps2: use QEMU qcodes instead of scancodes", key handling was
changed to qcode base. But all scancodes are not converted to new one.

This adds some missing qcodes/scancodes what I found in using.

[set1 and set3 are from <hpoussin@reactos.org>]
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Reviewed-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/input/ps2.c    | 10 ++++++++++
 qapi-schema.json  |  6 +++++-
 ui/input-keymap.c |  3 +++
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 0d14de0..8485a4e 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -252,6 +252,9 @@ static const uint16_t qcode_to_keycode_set1[Q_KEY_CODE__MAX] = {
     [Q_KEY_CODE_ASTERISK] = 0x37,
     [Q_KEY_CODE_LESS] = 0x56,
     [Q_KEY_CODE_RO] = 0x73,
+    [Q_KEY_CODE_HIRAGANA] = 0x70,
+    [Q_KEY_CODE_HENKAN] = 0x79,
+    [Q_KEY_CODE_YEN] = 0x7d,
     [Q_KEY_CODE_KP_COMMA] = 0x7e,
 };
 
@@ -394,6 +397,9 @@ static const uint16_t qcode_to_keycode_set2[Q_KEY_CODE__MAX] = {
     [Q_KEY_CODE_LESS] = 0x61,
     [Q_KEY_CODE_SYSRQ] = 0x7f,
     [Q_KEY_CODE_RO] = 0x51,
+    [Q_KEY_CODE_HIRAGANA] = 0x13,
+    [Q_KEY_CODE_HENKAN] = 0x64,
+    [Q_KEY_CODE_YEN] = 0x6a,
     [Q_KEY_CODE_KP_COMMA] = 0x6d,
 };
 
@@ -504,6 +510,10 @@ static const uint16_t qcode_to_keycode_set3[Q_KEY_CODE__MAX] = {
     [Q_KEY_CODE_COMMA] = 0x41,
     [Q_KEY_CODE_DOT] = 0x49,
     [Q_KEY_CODE_SLASH] = 0x4a,
+
+    [Q_KEY_CODE_HIRAGANA] = 0x87,
+    [Q_KEY_CODE_HENKAN] = 0x86,
+    [Q_KEY_CODE_YEN] = 0x5d,
 };
 
 static uint8_t translate_table[256] = {
diff --git a/qapi-schema.json b/qapi-schema.json
index a0d3b5d..eab8d4a 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3618,6 +3618,9 @@
 # @kp_comma: since 2.4
 # @kp_equals: since 2.6
 # @power: since 2.6
+# @hiragana: since 2.9
+# @henkan: since 2.9
+# @yen: since 2.9
 #
 # An enumeration of key name.
 #
@@ -3642,7 +3645,8 @@
             'kp_9', 'less', 'f11', 'f12', 'print', 'home', 'pgup', 'pgdn', 'end',
             'left', 'up', 'down', 'right', 'insert', 'delete', 'stop', 'again',
             'props', 'undo', 'front', 'copy', 'open', 'paste', 'find', 'cut',
-            'lf', 'help', 'meta_l', 'meta_r', 'compose', 'pause', 'ro',
+            'lf', 'help', 'meta_l', 'meta_r', 'compose', 'pause',
+            'ro', 'hiragana', 'henkan', 'yen',
             'kp_comma', 'kp_equals', 'power' ] }
 
 ##
diff --git a/ui/input-keymap.c b/ui/input-keymap.c
index f1e700d..8a1476f 100644
--- a/ui/input-keymap.c
+++ b/ui/input-keymap.c
@@ -131,6 +131,9 @@ static const int qcode_to_number[] = {
     [Q_KEY_CODE_DELETE] = 0xd3,
 
     [Q_KEY_CODE_RO] = 0x73,
+    [Q_KEY_CODE_HIRAGANA] = 0x70,
+    [Q_KEY_CODE_HENKAN] = 0x79,
+    [Q_KEY_CODE_YEN] = 0x7d,
     [Q_KEY_CODE_KP_COMMA] = 0x7e,
 
     [Q_KEY_CODE__MAX] = 0,
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PULL v2 00/11] ui patch queue
  2017-01-09 13:09 [Qemu-devel] [PULL v2 00/11] ui patch queue Gerd Hoffmann
                   ` (10 preceding siblings ...)
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 11/11] ps2: Fix lost scancodes by recent changes Gerd Hoffmann
@ 2017-01-09 13:49 ` Peter Maydell
  2017-01-10  7:18   ` Gerd Hoffmann
  11 siblings, 1 reply; 20+ messages in thread
From: Peter Maydell @ 2017-01-09 13:49 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On 9 January 2017 at 13:09, Gerd Hoffmann <kraxel@redhat.com> wrote:
>   Hi,
>
> Here comes the ui patch queue with a bunch of small changes and fixes
> all over the place: gtk, vnc, curses, sdl, keyboard.
>
> v2 changes:  Replace the ps2 fix (v3 instead of v2 of the patch).
>
> please pull,
>   Gerd
>
> The following changes since commit dbe2b65566e76d3c3a0c3358285c0336ac61e757:
>
>   Merge remote-tracking branch 'remotes/vivier/tags/m68k-for-2.9-pull-request' into staging (2016-12-28 17:11:11 +0000)
>
> are available in the git repository at:
>
>
>   git://git.kraxel.org/qemu tags/pull-ui-20170109-1
>
> for you to fetch changes up to f46c4259f489d2e7742890ddfaa862bde3731e3e:
>
>   ps2: Fix lost scancodes by recent changes (2017-01-06 10:36:49 +0100)
>
> ----------------------------------------------------------------
> gtk,vnc: misc bugfixes.
> kbd: add jp keys, fix ps2 regressions.
> sdl: export window id for baum, remove sdl hooks from baum.
> egl: egl-helpers.c license change.

Hi. I'm afraid this fails to build on OSX:

/Users/pm215/src/qemu-for-merges/ui/cocoa.m:688:21: error: use of
undeclared identifier 'MOUSE_EVENT_WHEELUP'
                    MOUSE_EVENT_WHEELUP : MOUSE_EVENT_WHEELDN;
                    ^
/Users/pm215/src/qemu-for-merges/ui/cocoa.m:710:45: error: use of
undeclared identifier 'MOUSE_EVENT_WHEELUP'
                [INPUT_BUTTON_WHEEL_UP]   = MOUSE_EVENT_WHEELUP,
                                            ^
/Users/pm215/src/qemu-for-merges/ui/cocoa.m:711:45: error: use of
undeclared identifier 'MOUSE_EVENT_WHEELDN'
                [INPUT_BUTTON_WHEEL_DOWN] = MOUSE_EVENT_WHEELDN,
                                            ^

thanks
-- PMM

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

* Re: [Qemu-devel] [PULL v2 00/11] ui patch queue
  2017-01-09 13:49 ` [Qemu-devel] [PULL v2 00/11] ui patch queue Peter Maydell
@ 2017-01-10  7:18   ` Gerd Hoffmann
  2017-01-10 17:32     ` Peter Maydell
  0 siblings, 1 reply; 20+ messages in thread
From: Gerd Hoffmann @ 2017-01-10  7:18 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers

  Hi,

> >   git://git.kraxel.org/qemu tags/pull-ui-20170109-1

> Hi. I'm afraid this fails to build on OSX:
> 
> /Users/pm215/src/qemu-for-merges/ui/cocoa.m:688:21: error: use of
> undeclared identifier 'MOUSE_EVENT_WHEELUP'
>                     MOUSE_EVENT_WHEELUP : MOUSE_EVENT_WHEELDN;
>                     ^
> /Users/pm215/src/qemu-for-merges/ui/cocoa.m:710:45: error: use of
> undeclared identifier 'MOUSE_EVENT_WHEELUP'
>                 [INPUT_BUTTON_WHEEL_UP]   = MOUSE_EVENT_WHEELUP,
>                                             ^
> /Users/pm215/src/qemu-for-merges/ui/cocoa.m:711:45: error: use of
> undeclared identifier 'MOUSE_EVENT_WHEELDN'
>                 [INPUT_BUTTON_WHEEL_DOWN] = MOUSE_EVENT_WHEELDN,

Pushed new tag:

  git://git.kraxel.org/qemu tags/pull-ui-20170110-1

Dropped offending patch (8/11), no other changes.

cheers,
  Gerd

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

* Re: [Qemu-devel] [PULL v2 00/11] ui patch queue
  2017-01-10  7:18   ` Gerd Hoffmann
@ 2017-01-10 17:32     ` Peter Maydell
  0 siblings, 0 replies; 20+ messages in thread
From: Peter Maydell @ 2017-01-10 17:32 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On 10 January 2017 at 07:18, Gerd Hoffmann <kraxel@redhat.com> wrote:
>   Hi,
>
>> >   git://git.kraxel.org/qemu tags/pull-ui-20170109-1
>
>> Hi. I'm afraid this fails to build on OSX:
>>
>> /Users/pm215/src/qemu-for-merges/ui/cocoa.m:688:21: error: use of
>> undeclared identifier 'MOUSE_EVENT_WHEELUP'
>>                     MOUSE_EVENT_WHEELUP : MOUSE_EVENT_WHEELDN;
>>                     ^
>> /Users/pm215/src/qemu-for-merges/ui/cocoa.m:710:45: error: use of
>> undeclared identifier 'MOUSE_EVENT_WHEELUP'
>>                 [INPUT_BUTTON_WHEEL_UP]   = MOUSE_EVENT_WHEELUP,
>>                                             ^
>> /Users/pm215/src/qemu-for-merges/ui/cocoa.m:711:45: error: use of
>> undeclared identifier 'MOUSE_EVENT_WHEELDN'
>>                 [INPUT_BUTTON_WHEEL_DOWN] = MOUSE_EVENT_WHEELDN,
>
> Pushed new tag:
>
>   git://git.kraxel.org/qemu tags/pull-ui-20170110-1
>
> Dropped offending patch (8/11), no other changes.

Applied, thanks.

PS: to guarantee getting my attention on a respun pull request
you need to resend a proper cover email (but you don't need
to resend the rest of the emails). You got lucky this time :-)

thanks
-- PMM

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

* Re: [Qemu-devel] [PULL v2 05/11] sdl2: set window ID
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 05/11] sdl2: set window ID Gerd Hoffmann
@ 2017-01-12 15:10   ` Stefan Weil
  2017-01-12 15:56     ` Gerd Hoffmann
  0 siblings, 1 reply; 20+ messages in thread
From: Stefan Weil @ 2017-01-12 15:10 UTC (permalink / raw)
  To: Gerd Hoffmann, qemu-devel; +Cc: Samuel Thibault

This commit breaks builds for Windows. See below for details.

Regards
Stefan

Am 09.01.2017 um 14:09 schrieb Gerd Hoffmann:
> From: Samuel Thibault <samuel.thibault@ens-lyon.org>
> 
> This uses the console API to record the window ID of the SDL2 windows.
> 
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> Message-id: 20161221003806.22412-4-samuel.thibault@ens-lyon.org
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  ui/sdl2.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/ui/sdl2.c b/ui/sdl2.c
> index 30d2a3c..9a79b17 100644
> --- a/ui/sdl2.c
> +++ b/ui/sdl2.c
> @@ -761,6 +761,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
>      uint8_t data = 0;
>      char *filename;
>      int i;
> +    SDL_SysWMinfo info;
>  
>      if (no_frame) {
>          gui_noframe = 1;
> @@ -786,6 +787,8 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
>          exit(1);
>      }
>      SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "1");
> +    memset(&info, 0, sizeof(info));
> +    SDL_VERSION(&info.version);
>  
>      for (i = 0;; i++) {
>          QemuConsole *con = qemu_console_lookup_by_index(i);
> @@ -813,6 +816,10 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
>  #endif
>          sdl2_console[i].dcl.con = con;
>          register_displaychangelistener(&sdl2_console[i].dcl);
> +
> +        if (SDL_GetWindowWMInfo(sdl2_console[i].real_window, &info)) {
> +            qemu_console_set_window_id(con, info.info.x11.window);

Windows does not use X11. gcc fails:

  CC      ui/sdl2.o
/qemu/ui/sdl2.c: In function ‘sdl_display_init’:
/qemu/ui/sdl2.c:821:54: error: ‘union <anonymous>’ has no member named ‘x11’
             qemu_console_set_window_id(con, info.info.x11.window);

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

* Re: [Qemu-devel] [PULL v2 05/11] sdl2: set window ID
  2017-01-12 15:10   ` Stefan Weil
@ 2017-01-12 15:56     ` Gerd Hoffmann
  2017-01-12 17:05       ` Samuel Thibault
  0 siblings, 1 reply; 20+ messages in thread
From: Gerd Hoffmann @ 2017-01-12 15:56 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-devel, Samuel Thibault

On Do, 2017-01-12 at 16:10 +0100, Stefan Weil wrote:
> This commit breaks builds for Windows. See below for details.

> Windows does not use X11. gcc fails:
> 
>   CC      ui/sdl2.o
> /qemu/ui/sdl2.c: In function ‘sdl_display_init’:
> /qemu/ui/sdl2.c:821:54: error: ‘union <anonymous>’ has no member named ‘x11’
>              qemu_console_set_window_id(con, info.info.x11.window);

Oops.  Any chance you can look into this?  sdl1 builds, and IIRC it has
#ifdefs to support qemu_console_set_window_id on windows too, which can
possibly ported over to sdl2 ...

thanks,
  Gerd

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

* Re: [Qemu-devel] [PULL v2 05/11] sdl2: set window ID
  2017-01-12 15:56     ` Gerd Hoffmann
@ 2017-01-12 17:05       ` Samuel Thibault
  2017-01-12 19:07         ` Stefan Weil
  0 siblings, 1 reply; 20+ messages in thread
From: Samuel Thibault @ 2017-01-12 17:05 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Stefan Weil, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 592 bytes --]

Hello,

Gerd Hoffmann, on Thu 12 Jan 2017 16:56:49 +0100, wrote:
> On Do, 2017-01-12 at 16:10 +0100, Stefan Weil wrote:
> > This commit breaks builds for Windows. See below for details.
> 
> > Windows does not use X11. gcc fails:
> > 
> >   CC      ui/sdl2.o
> > /qemu/ui/sdl2.c: In function ‘sdl_display_init’:
> > /qemu/ui/sdl2.c:821:54: error: ‘union <anonymous>’ has no member named ‘x11’
> >              qemu_console_set_window_id(con, info.info.x11.window);
> 
> Oops.

Oops, sorry, it seems to have been overlooked indeed.  Can you easily
test the attached patch?

Samuel

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1145 bytes --]

diff --git a/ui/sdl2.c b/ui/sdl2.c
index 9a79b17b92..0f41d1fa90 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -762,6 +762,9 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
     char *filename;
     int i;
     SDL_SysWMinfo info;
+#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_X11)
+    int window_id;
+#endif
 
     if (no_frame) {
         gui_noframe = 1;
@@ -817,9 +820,17 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
         sdl2_console[i].dcl.con = con;
         register_displaychangelistener(&sdl2_console[i].dcl);
 
+#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_X11)
         if (SDL_GetWindowWMInfo(sdl2_console[i].real_window, &info)) {
-            qemu_console_set_window_id(con, info.info.x11.window);
+#ifdef SDL_VIDEO_DRIVER_WINDOWS
+            window_id = (int)(uintptr_t) info.info.win.hwnd;
+#endif
+#ifdef SDL_VIDEO_DRIVER_X11
+            window_id = info.info.x11.window;
+#endif
+            qemu_console_set_window_id(con, window_id);
         }
+#endif
     }
 
     /* Load a 32x32x4 image. White pixels are transparent. */

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

* Re: [Qemu-devel] [PULL v2 05/11] sdl2: set window ID
  2017-01-12 17:05       ` Samuel Thibault
@ 2017-01-12 19:07         ` Stefan Weil
  0 siblings, 0 replies; 20+ messages in thread
From: Stefan Weil @ 2017-01-12 19:07 UTC (permalink / raw)
  To: Samuel Thibault, Gerd Hoffmann; +Cc: qemu-devel

On 01/12/17 18:05, Samuel Thibault wrote:
> Hello,
>
> Gerd Hoffmann, on Thu 12 Jan 2017 16:56:49 +0100, wrote:
>> On Do, 2017-01-12 at 16:10 +0100, Stefan Weil wrote:
>>> This commit breaks builds for Windows. See below for details.
>>
>>> Windows does not use X11. gcc fails:
>>>
>>>   CC      ui/sdl2.o
>>> /qemu/ui/sdl2.c: In function ‘sdl_display_init’:
>>> /qemu/ui/sdl2.c:821:54: error: ‘union <anonymous>’ has no member named ‘x11’
>>>              qemu_console_set_window_id(con, info.info.x11.window);
>>
>> Oops.
>
> Oops, sorry, it seems to have been overlooked indeed.  Can you easily
> test the attached patch?
>
> Samuel
>

It does not compile. I fixed it and simplified the code a little bit
(see below, please fix line wrap which my mailer enforced). That code
compiles. I did not run tests.

Stefan


diff --git a/ui/sdl2.c b/ui/sdl2.c
index 9a79b17b92..91fb111aa5 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -817,9 +817,15 @@ void sdl_display_init(DisplayState *ds, int 
full_screen, int no_frame)
          sdl2_console[i].dcl.con = con;
          register_displaychangelistener(&sdl2_console[i].dcl);

+#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_X11)
          if (SDL_GetWindowWMInfo(sdl2_console[i].real_window, &info)) {
+#if defined(SDL_VIDEO_DRIVER_WINDOWS)
+            qemu_console_set_window_id(con, 
(uintptr_t)info.info.win.window);
+#elif defined(SDL_VIDEO_DRIVER_X11)
              qemu_console_set_window_id(con, info.info.x11.window);
+#endif
          }
+#endif
      }

      /* Load a 32x32x4 image. White pixels are transparent. */

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

* Re: [Qemu-devel] [PULL v2 02/11] ui: use evdev keymap when running under wayland
  2017-01-09 13:09 ` [Qemu-devel] [PULL v2 02/11] ui: use evdev keymap when running under wayland Gerd Hoffmann
@ 2017-01-16  9:31   ` Daniel P. Berrange
  0 siblings, 0 replies; 20+ messages in thread
From: Daniel P. Berrange @ 2017-01-16  9:31 UTC (permalink / raw)
  To: Gerd Hoffmann, qemu-stable; +Cc: qemu-devel

CC qemu-stable

This patch should go into active stable branches given that wayland is
now the default on some OS distro....

On Mon, Jan 09, 2017 at 02:09:36PM +0100, Gerd Hoffmann wrote:
> From: "Daniel P. Berrange" <berrange@redhat.com>
> 
> Wayland always uses evdev as its input source, so QEMU
> can use the existing evdev keymap data
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> Tested-by: Stefan Hajnoczi <stefanha@redhat.com>
> Message-id: 20161201094117.16407-1-berrange@redhat.com
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  include/ui/gtk.h | 4 ++++
>  ui/gtk.c         | 7 +++++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/include/ui/gtk.h b/include/ui/gtk.h
> index 42ca0fe..b3b5005 100644
> --- a/include/ui/gtk.h
> +++ b/include/ui/gtk.h
> @@ -18,6 +18,10 @@
>  #include <X11/XKBlib.h>
>  #endif
>  
> +#ifdef GDK_WINDOWING_WAYLAND
> +#include <gdk/gdkwayland.h>
> +#endif
> +
>  #if defined(CONFIG_OPENGL)
>  #include "ui/egl-helpers.h"
>  #include "ui/egl-context.h"
> diff --git a/ui/gtk.c b/ui/gtk.c
> index 406de4f..356f400 100644
> --- a/ui/gtk.c
> +++ b/ui/gtk.c
> @@ -90,6 +90,9 @@
>  #ifndef GDK_IS_X11_DISPLAY
>  #define GDK_IS_X11_DISPLAY(dpy) (dpy == dpy)
>  #endif
> +#ifndef GDK_IS_WAYLAND_DISPLAY
> +#define GDK_IS_WAYLAND_DISPLAY(dpy) (dpy == dpy)
> +#endif
>  #ifndef GDK_IS_WIN32_DISPLAY
>  #define GDK_IS_WIN32_DISPLAY(dpy) (dpy == dpy)
>  #endif
> @@ -1054,6 +1057,10 @@ static int gd_map_keycode(GtkDisplayState *s, GdkDisplay *dpy, int gdk_keycode)
>              qemu_keycode = translate_xfree86_keycode(gdk_keycode - 97);
>          }
>  #endif
> +#ifdef GDK_WINDOWING_WAYLAND
> +    } else if (GDK_IS_WAYLAND_DISPLAY(dpy) && gdk_keycode < 158) {
> +        qemu_keycode = translate_evdev_keycode(gdk_keycode - 97);
> +#endif
>      } else if (gdk_keycode == 208) { /* Hiragana_Katakana */
>          qemu_keycode = 0x70;
>      } else if (gdk_keycode == 211) { /* backslash */
> -- 
> 1.8.3.1
> 

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|

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

end of thread, other threads:[~2017-01-16  9:31 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-09 13:09 [Qemu-devel] [PULL v2 00/11] ui patch queue Gerd Hoffmann
2017-01-09 13:09 ` [Qemu-devel] [PULL v2 01/11] ui/gtk: fix crash at startup when no console is available Gerd Hoffmann
2017-01-09 13:09 ` [Qemu-devel] [PULL v2 02/11] ui: use evdev keymap when running under wayland Gerd Hoffmann
2017-01-16  9:31   ` Daniel P. Berrange
2017-01-09 13:09 ` [Qemu-devel] [PULL v2 03/11] console: add API to get underlying gui window ID Gerd Hoffmann
2017-01-09 13:09 ` [Qemu-devel] [PULL v2 04/11] console: move window ID code from baum to sdl Gerd Hoffmann
2017-01-09 13:09 ` [Qemu-devel] [PULL v2 05/11] sdl2: set window ID Gerd Hoffmann
2017-01-12 15:10   ` Stefan Weil
2017-01-12 15:56     ` Gerd Hoffmann
2017-01-12 17:05       ` Samuel Thibault
2017-01-12 19:07         ` Stefan Weil
2017-01-09 13:09 ` [Qemu-devel] [PULL v2 06/11] egl-helpers: Change file licensing to LGPLv2 Gerd Hoffmann
2017-01-09 13:09 ` [Qemu-devel] [PULL v2 07/11] gtk: avoid oob array access Gerd Hoffmann
2017-01-09 13:09 ` [Qemu-devel] [PULL v2 08/11] ui: drop unused MOUSE_EVENT_WHEEL{UP, DN} defines Gerd Hoffmann
2017-01-09 13:09 ` [Qemu-devel] [PULL v2 09/11] ui/vnc: Fix problem with sending too many bytes as server name Gerd Hoffmann
2017-01-09 13:09 ` [Qemu-devel] [PULL v2 10/11] curses: Fix compiler warnings (Mingw-w64 redefinition of macro KEY_EVENT) Gerd Hoffmann
2017-01-09 13:09 ` [Qemu-devel] [PULL v2 11/11] ps2: Fix lost scancodes by recent changes Gerd Hoffmann
2017-01-09 13:49 ` [Qemu-devel] [PULL v2 00/11] ui patch queue Peter Maydell
2017-01-10  7:18   ` Gerd Hoffmann
2017-01-10 17:32     ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.