Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Alexander_Naumov:SLE-12:Update
qemu.4227
0053-gtk-Add-handling-for-the-xfree86-ke.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0053-gtk-Add-handling-for-the-xfree86-ke.patch of Package qemu.4227
From bddd4afa25e745f6924c2dbf5b2729aa61715090 Mon Sep 17 00:00:00 2001 From: Bruce Rogers <brogers@suse.com> Date: Wed, 30 Apr 2014 17:04:52 -0600 Subject: [PATCH] gtk: Add handling for the xfree86 keycodes Currently only evdev keycodes are handled by the gtk-ui. SDL has code to handle both. This patch adds similar processing so that both keycode types will be handled via the gtk-ui. Signed-off-by: Bruce Rogers <brogers@suse.com> --- ui/gtk.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/ui/gtk.c b/ui/gtk.c index 00fbbccb34..461c65e7e5 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -67,6 +67,10 @@ #include "x_keymap.h" #include "keymaps.h" #include "sysemu/char.h" +#ifndef _WIN32 +#include <gdk/gdkx.h> +#include <X11/XKBlib.h> +#endif #define MAX_VCS 10 @@ -173,6 +177,7 @@ typedef struct GtkDisplayState bool external_pause_update; bool modifier_pressed[ARRAY_SIZE(modifier_keycode)]; + bool has_evdev; } GtkDisplayState; static GtkDisplayState *global_state; @@ -757,7 +762,11 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque) } else if (gdk_keycode < 97) { qemu_keycode = gdk_keycode - 8; } else if (gdk_keycode < 158) { - qemu_keycode = translate_evdev_keycode(gdk_keycode - 97); + if (s->has_evdev) { + qemu_keycode = translate_evdev_keycode(gdk_keycode - 97); + } else { + qemu_keycode = translate_xfree86_keycode(gdk_keycode - 97); + } } else if (gdk_keycode == 208) { /* Hiragana_Katakana */ qemu_keycode = 0x70; } else if (gdk_keycode == 211) { /* backslash */ @@ -1487,6 +1496,29 @@ static void gd_create_menus(GtkDisplayState *s) s->accel_group = accel_group; } +static void gd_set_keycode_type(GtkDisplayState *s) +{ +#ifndef _WIN32 + char *keycodes = NULL; + GdkDisplay *display = gtk_widget_get_display(s->drawing_area); + Display *x11_display = gdk_x11_display_get_xdisplay(display); + XkbDescPtr desc = XkbGetKeyboard(x11_display, XkbGBN_AllComponentsMask, + XkbUseCoreKbd); + + if (desc && desc->names) { + keycodes = XGetAtomName(x11_display, desc->names->keycodes); + } + if (keycodes == NULL) { + fprintf(stderr, "could not lookup keycode name\n"); + } else if (strstart(keycodes, "evdev", NULL)) { + s->has_evdev = true; + } else if (!strstart(keycodes, "xfree86", NULL)) { + fprintf(stderr, "unknown keycodes `%s', please report to " + "qemu-devel@nongnu.org\n", keycodes); + } +#endif +} + static const DisplayChangeListenerOps dcl_ops = { .dpy_name = "gtk", .dpy_gfx_update = gd_update, @@ -1581,5 +1613,7 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover) register_displaychangelistener(&s->dcl); + gd_set_keycode_type(s); + global_state = s; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor