diff mbox

[v2] ui: use evdev keymap when running under wayland

Message ID 20161201094117.16407-1-berrange@redhat.com
State New
Headers show

Commit Message

Daniel P. Berrangé Dec. 1, 2016, 9:41 a.m. UTC
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>
---

Changed in v2

 - Actually add all changed files to commit - gtk.h :-)

 include/ui/gtk.h | 4 ++++
 ui/gtk.c         | 7 +++++++
 2 files changed, 11 insertions(+)

Comments

Stefan Hajnoczi Dec. 1, 2016, 11:20 a.m. UTC | #1
On Thu, Dec 1, 2016 at 9:41 AM, Daniel P. Berrange <berrange@redhat.com> wrote:
> 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>
> ---
>
> Changed in v2
>
>  - Actually add all changed files to commit - gtk.h :-)
>
>  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 e816428..81dba57 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 */
> --
> 2.9.3
>

Great, you've fixed Wayland!

This is GTK3-only so I used ./configure --with-gtkabi=3.0 on my system
that has both GTK2 and GTK3 headers installed.  ./configure will
select GTK2 by default and I'm not sure if that is a good idea
nowadays.

Tested-by: Stefan Hajnoczi <stefanha@redhat.com>
Stefan Hajnoczi Dec. 1, 2016, 11:25 a.m. UTC | #2
On Thu, Dec 1, 2016 at 11:20 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> On Thu, Dec 1, 2016 at 9:41 AM, Daniel P. Berrange <berrange@redhat.com> wrote:
>> 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>
>> ---
>>
>> Changed in v2
>>
>>  - Actually add all changed files to commit - gtk.h :-)
>>
>>  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 e816428..81dba57 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 */
>> --
>> 2.9.3
>>
>
> Great, you've fixed Wayland!
>
> This is GTK3-only so I used ./configure --with-gtkabi=3.0 on my system
> that has both GTK2 and GTK3 headers installed.  ./configure will
> select GTK2 by default and I'm not sure if that is a good idea
> nowadays.
>
> Tested-by: Stefan Hajnoczi <stefanha@redhat.com>
Stefan Hajnoczi Dec. 1, 2016, 11:26 a.m. UTC | #3
On Thu, Dec 1, 2016 at 11:25 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> On Thu, Dec 1, 2016 at 11:20 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
>> On Thu, Dec 1, 2016 at 9:41 AM, Daniel P. Berrange <berrange@redhat.com> wrote:
>>> 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>
>>> ---
>>>
>>> Changed in v2
>>>
>>>  - Actually add all changed files to commit - gtk.h :-)
>>>
>>>  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 e816428..81dba57 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 */
>>> --
>>> 2.9.3
>>>
>>
>> Great, you've fixed Wayland!
>>
>> This is GTK3-only so I used ./configure --with-gtkabi=3.0 on my system
>> that has both GTK2 and GTK3 headers installed.  ./configure will
>> select GTK2 by default and I'm not sure if that is a good idea
>> nowadays.
>>
>> Tested-by: Stefan Hajnoczi <stefanha@redhat.com>

Sorry, Cole.  I pressed Send too quickly :).  I meant to add:

This patch is especially relevant for Fedora 25 where Wayland is the
default.  Without the GTK UI will not handle cursor and other keys
correctly.

Dan: Come to think of it, ui/sdl.c also has X11 keycode mangling.
Perhaps that is broken too... :(

Stefan
Daniel P. Berrangé Dec. 1, 2016, 11:28 a.m. UTC | #4
On Thu, Dec 01, 2016 at 11:26:59AM +0000, Stefan Hajnoczi wrote:
> On Thu, Dec 1, 2016 at 11:25 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> > On Thu, Dec 1, 2016 at 11:20 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> >> On Thu, Dec 1, 2016 at 9:41 AM, Daniel P. Berrange <berrange@redhat.com> wrote:
> >>> 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>
> >>> ---
> >>>
> >>> Changed in v2
> >>>
> >>>  - Actually add all changed files to commit - gtk.h :-)
> >>>
> >>>  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 e816428..81dba57 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 */
> >>> --
> >>> 2.9.3
> >>>
> >>
> >> Great, you've fixed Wayland!
> >>
> >> This is GTK3-only so I used ./configure --with-gtkabi=3.0 on my system
> >> that has both GTK2 and GTK3 headers installed.  ./configure will
> >> select GTK2 by default and I'm not sure if that is a good idea
> >> nowadays.
> >>
> >> Tested-by: Stefan Hajnoczi <stefanha@redhat.com>
> 
> Sorry, Cole.  I pressed Send too quickly :).  I meant to add:
> 
> This patch is especially relevant for Fedora 25 where Wayland is the
> default.  Without the GTK UI will not handle cursor and other keys
> correctly.
> 
> Dan: Come to think of it, ui/sdl.c also has X11 keycode mangling.
> Perhaps that is broken too... :(

SDL doesn't have native Wayland support, so it will be running
via Xwayland, which will use regulard Xorg evdev mapping, so that
should be fine still.

Regards,
Daniel
Daniel P. Berrangé Dec. 1, 2016, 11:29 a.m. UTC | #5
On Thu, Dec 01, 2016 at 11:20:36AM +0000, Stefan Hajnoczi wrote:
> On Thu, Dec 1, 2016 at 9:41 AM, Daniel P. Berrange <berrange@redhat.com> wrote:
> > 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>
> > ---
> >
> > Changed in v2
> >
> >  - Actually add all changed files to commit - gtk.h :-)
> >
> >  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 e816428..81dba57 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 */
> > --
> > 2.9.3
> >
> 
> Great, you've fixed Wayland!
> 
> This is GTK3-only so I used ./configure --with-gtkabi=3.0 on my system
> that has both GTK2 and GTK3 headers installed.  ./configure will
> select GTK2 by default and I'm not sure if that is a good idea
> nowadays.

We had a discussion on IRC a few weeks back about default UI frontends.

We should certainly prefer GTK3 over GTK2 if both a present, since GTK2
is essentially a dead technology at this time.

> Tested-by: Stefan Hajnoczi <stefanha@redhat.com>

Regards,
Daniel
Cole Robinson Dec. 4, 2016, 9:28 p.m. UTC | #6
On 12/01/2016 06:26 AM, Stefan Hajnoczi wrote:
> On Thu, Dec 1, 2016 at 11:25 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
>> On Thu, Dec 1, 2016 at 11:20 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
>>> On Thu, Dec 1, 2016 at 9:41 AM, Daniel P. Berrange <berrange@redhat.com> wrote:
>>>> 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>
>>>> ---
>>>>
>>>> Changed in v2
>>>>
>>>>  - Actually add all changed files to commit - gtk.h :-)
>>>>
>>>>  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 e816428..81dba57 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 */
>>>> --
>>>> 2.9.3
>>>>
>>>
>>> Great, you've fixed Wayland!
>>>
>>> This is GTK3-only so I used ./configure --with-gtkabi=3.0 on my system
>>> that has both GTK2 and GTK3 headers installed.  ./configure will
>>> select GTK2 by default and I'm not sure if that is a good idea
>>> nowadays.
>>>
>>> Tested-by: Stefan Hajnoczi <stefanha@redhat.com>
> 
> Sorry, Cole.  I pressed Send too quickly :).  I meant to add:
> 
> This patch is especially relevant for Fedora 25 where Wayland is the
> default.  Without the GTK UI will not handle cursor and other keys
> correctly.
> 

Thanks for the pointer, I made a note in
https://bugzilla.redhat.com/show_bug.cgi?id=1401211 and I'll do a build ASAP

- Cole
Daniel P. Berrangé Jan. 3, 2017, 12:55 p.m. UTC | #7
CC'ing Gerd as the ui/ maintainer

On Thu, Dec 01, 2016 at 09:41:17AM +0000, Daniel P. Berrange wrote:
> 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>
> ---
> 
> Changed in v2
> 
>  - Actually add all changed files to commit - gtk.h :-)
> 
>  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 e816428..81dba57 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 */
> -- 
> 2.9.3
> 

Regards,
Daniel
diff mbox

Patch

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 e816428..81dba57 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 */