From patchwork Tue Jan 22 09:28:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 1029207 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43kP1s0nbKz9s2P for ; Tue, 22 Jan 2019 20:56:00 +1100 (AEDT) Received: from localhost ([127.0.0.1]:41849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1glsmk-0003nn-OI for incoming@patchwork.ozlabs.org; Tue, 22 Jan 2019 04:55:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1glsVw-0006nx-Jt for qemu-devel@nongnu.org; Tue, 22 Jan 2019 04:38:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1glsM4-0003TZ-Dj for qemu-devel@nongnu.org; Tue, 22 Jan 2019 04:28:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42284) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1glsM3-0003Qf-WC for qemu-devel@nongnu.org; Tue, 22 Jan 2019 04:28:24 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4085C8667B for ; Tue, 22 Jan 2019 09:28:23 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-38.ams2.redhat.com [10.36.116.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0969F6013B; Tue, 22 Jan 2019 09:28:20 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 329CF423A4; Tue, 22 Jan 2019 10:28:15 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 22 Jan 2019 10:28:11 +0100 Message-Id: <20190122092814.14919-6-kraxel@redhat.com> In-Reply-To: <20190122092814.14919-1-kraxel@redhat.com> References: <20190122092814.14919-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 22 Jan 2019 09:28:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [RFC PATCH v3 5/8] kbd-state: use state tracker for gtk X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Use the new keyboard state tracked for gtk. Allows to drop the gtk-specific modifier state tracking code. Signed-off-by: Gerd Hoffmann Reviewed-by: Daniel P. Berrangé --- include/ui/gtk.h | 2 ++ ui/gtk.c | 38 ++++++-------------------------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/include/ui/gtk.h b/include/ui/gtk.h index 99edd3c085..d9eedad976 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -22,6 +22,7 @@ #include #endif +#include "ui/kbd-state.h" #if defined(CONFIG_OPENGL) #include "ui/egl-helpers.h" #include "ui/egl-context.h" @@ -32,6 +33,7 @@ typedef struct GtkDisplayState GtkDisplayState; typedef struct VirtualGfxConsole { GtkWidget *drawing_area; DisplayChangeListener dcl; + QKbdState *kbd; DisplaySurface *ds; pixman_image_t *convert; cairo_surface_t *surface; diff --git a/ui/gtk.c b/ui/gtk.c index 579990b865..1be65025f2 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -122,17 +122,6 @@ #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 size_t keycode_maplen; @@ -187,7 +176,6 @@ struct GtkDisplayState { bool external_pause_update; - bool modifier_pressed[ARRAY_SIZE(modifier_keycode)]; bool ignore_keys; DisplayOptions *opts; @@ -426,20 +414,12 @@ static void gd_update_full_redraw(VirtualConsole *vc) static void gtk_release_modifiers(GtkDisplayState *s) { VirtualConsole *vc = gd_vc_find_current(s); - int i, qcode; if (vc->type != GD_VC_GFX || !qemu_console_is_graphic(vc->gfx.dcl.con)) { return; } - for (i = 0; i < ARRAY_SIZE(modifier_keycode); i++) { - 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; - } + qkbd_state_lift_all_keys(vc->gfx.kbd); } static void gd_widget_reparent(GtkWidget *from, GtkWidget *to, @@ -1113,7 +1093,6 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque) VirtualConsole *vc = opaque; GtkDisplayState *s = vc->s; int qcode; - int i; if (s->ignore_keys) { s->ignore_keys = (key->type == GDK_KEY_PRESS); @@ -1134,8 +1113,8 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque) || 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); + qkbd_state_key_event(vc->gfx.kbd, Q_KEY_CODE_PAUSE, + key->type == GDK_KEY_PRESS); return TRUE; } @@ -1144,14 +1123,8 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque) trace_gd_key_event(vc->label, key->hardware_keycode, qcode, (key->type == GDK_KEY_PRESS) ? "down" : "up"); - for (i = 0; i < ARRAY_SIZE(modifier_keycode); i++) { - if (qcode == modifier_keycode[i]) { - 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); + qkbd_state_key_event(vc->gfx.kbd, qcode, + key->type == GDK_KEY_PRESS); return TRUE; } @@ -2052,6 +2025,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc, gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), vc->tab_item, gtk_label_new(vc->label)); + vc->gfx.kbd = qkbd_state_init(con); vc->gfx.dcl.con = con; register_displaychangelistener(&vc->gfx.dcl);