mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-30 21:42:06 -06:00
kbd-state: use state tracker for gtk
Use the new keyboard state tracked for gtk. Allows to drop the gtk-specific modifier state tracking code. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-id: 20190122092814.14919-6-kraxel@redhat.com
This commit is contained in:
parent
06f894dbcc
commit
0c0d42737d
2 changed files with 8 additions and 32 deletions
|
@ -22,6 +22,7 @@
|
||||||
#include <gdk/gdkwayland.h>
|
#include <gdk/gdkwayland.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "ui/kbd-state.h"
|
||||||
#if defined(CONFIG_OPENGL)
|
#if defined(CONFIG_OPENGL)
|
||||||
#include "ui/egl-helpers.h"
|
#include "ui/egl-helpers.h"
|
||||||
#include "ui/egl-context.h"
|
#include "ui/egl-context.h"
|
||||||
|
@ -32,6 +33,7 @@ typedef struct GtkDisplayState GtkDisplayState;
|
||||||
typedef struct VirtualGfxConsole {
|
typedef struct VirtualGfxConsole {
|
||||||
GtkWidget *drawing_area;
|
GtkWidget *drawing_area;
|
||||||
DisplayChangeListener dcl;
|
DisplayChangeListener dcl;
|
||||||
|
QKbdState *kbd;
|
||||||
DisplaySurface *ds;
|
DisplaySurface *ds;
|
||||||
pixman_image_t *convert;
|
pixman_image_t *convert;
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
|
|
38
ui/gtk.c
38
ui/gtk.c
|
@ -122,17 +122,6 @@
|
||||||
|
|
||||||
#define HOTKEY_MODIFIERS (GDK_CONTROL_MASK | GDK_MOD1_MASK)
|
#define HOTKEY_MODIFIERS (GDK_CONTROL_MASK | GDK_MOD1_MASK)
|
||||||
|
|
||||||
static const int modifier_keycode[] = {
|
|
||||||
Q_KEY_CODE_SHIFT,
|
|
||||||
Q_KEY_CODE_SHIFT_R,
|
|
||||||
Q_KEY_CODE_CTRL,
|
|
||||||
Q_KEY_CODE_CTRL_R,
|
|
||||||
Q_KEY_CODE_ALT,
|
|
||||||
Q_KEY_CODE_ALT_R,
|
|
||||||
Q_KEY_CODE_META_L,
|
|
||||||
Q_KEY_CODE_META_R,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const guint16 *keycode_map;
|
static const guint16 *keycode_map;
|
||||||
static size_t keycode_maplen;
|
static size_t keycode_maplen;
|
||||||
|
|
||||||
|
@ -187,7 +176,6 @@ struct GtkDisplayState {
|
||||||
|
|
||||||
bool external_pause_update;
|
bool external_pause_update;
|
||||||
|
|
||||||
bool modifier_pressed[ARRAY_SIZE(modifier_keycode)];
|
|
||||||
bool ignore_keys;
|
bool ignore_keys;
|
||||||
|
|
||||||
DisplayOptions *opts;
|
DisplayOptions *opts;
|
||||||
|
@ -426,20 +414,12 @@ static void gd_update_full_redraw(VirtualConsole *vc)
|
||||||
static void gtk_release_modifiers(GtkDisplayState *s)
|
static void gtk_release_modifiers(GtkDisplayState *s)
|
||||||
{
|
{
|
||||||
VirtualConsole *vc = gd_vc_find_current(s);
|
VirtualConsole *vc = gd_vc_find_current(s);
|
||||||
int i, qcode;
|
|
||||||
|
|
||||||
if (vc->type != GD_VC_GFX ||
|
if (vc->type != GD_VC_GFX ||
|
||||||
!qemu_console_is_graphic(vc->gfx.dcl.con)) {
|
!qemu_console_is_graphic(vc->gfx.dcl.con)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (i = 0; i < ARRAY_SIZE(modifier_keycode); i++) {
|
qkbd_state_lift_all_keys(vc->gfx.kbd);
|
||||||
qcode = modifier_keycode[i];
|
|
||||||
if (!s->modifier_pressed[i]) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
qemu_input_event_send_key_qcode(vc->gfx.dcl.con, qcode, false);
|
|
||||||
s->modifier_pressed[i] = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gd_widget_reparent(GtkWidget *from, GtkWidget *to,
|
static void gd_widget_reparent(GtkWidget *from, GtkWidget *to,
|
||||||
|
@ -1115,7 +1095,6 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)
|
||||||
VirtualConsole *vc = opaque;
|
VirtualConsole *vc = opaque;
|
||||||
GtkDisplayState *s = vc->s;
|
GtkDisplayState *s = vc->s;
|
||||||
int qcode;
|
int qcode;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (s->ignore_keys) {
|
if (s->ignore_keys) {
|
||||||
s->ignore_keys = (key->type == GDK_KEY_PRESS);
|
s->ignore_keys = (key->type == GDK_KEY_PRESS);
|
||||||
|
@ -1136,8 +1115,8 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)
|
||||||
|| key->hardware_keycode == VK_PAUSE
|
|| key->hardware_keycode == VK_PAUSE
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
qemu_input_event_send_key_qcode(vc->gfx.dcl.con, Q_KEY_CODE_PAUSE,
|
qkbd_state_key_event(vc->gfx.kbd, Q_KEY_CODE_PAUSE,
|
||||||
key->type == GDK_KEY_PRESS);
|
key->type == GDK_KEY_PRESS);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1146,14 +1125,8 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)
|
||||||
trace_gd_key_event(vc->label, key->hardware_keycode, qcode,
|
trace_gd_key_event(vc->label, key->hardware_keycode, qcode,
|
||||||
(key->type == GDK_KEY_PRESS) ? "down" : "up");
|
(key->type == GDK_KEY_PRESS) ? "down" : "up");
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(modifier_keycode); i++) {
|
qkbd_state_key_event(vc->gfx.kbd, qcode,
|
||||||
if (qcode == modifier_keycode[i]) {
|
key->type == GDK_KEY_PRESS);
|
||||||
s->modifier_pressed[i] = (key->type == GDK_KEY_PRESS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
qemu_input_event_send_key_qcode(vc->gfx.dcl.con, qcode,
|
|
||||||
key->type == GDK_KEY_PRESS);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -2055,6 +2028,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
|
||||||
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook),
|
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook),
|
||||||
vc->tab_item, gtk_label_new(vc->label));
|
vc->tab_item, gtk_label_new(vc->label));
|
||||||
|
|
||||||
|
vc->gfx.kbd = qkbd_state_init(con);
|
||||||
vc->gfx.dcl.con = con;
|
vc->gfx.dcl.con = con;
|
||||||
register_displaychangelistener(&vc->gfx.dcl);
|
register_displaychangelistener(&vc->gfx.dcl);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue