From nobody Mon Feb 9 11:32:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1549364308941339.9745083589024; Tue, 5 Feb 2019 02:58:28 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C654A10F8F; Tue, 5 Feb 2019 10:58:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 84246608C5; Tue, 5 Feb 2019 10:58:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2586618033A5; Tue, 5 Feb 2019 10:58:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x15Aw78p025080 for ; Tue, 5 Feb 2019 05:58:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4A2DC5FCA0; Tue, 5 Feb 2019 10:58:07 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-249.ams2.redhat.com [10.36.116.249]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDA67183DE; Tue, 5 Feb 2019 10:58:06 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2E8D87850; Tue, 5 Feb 2019 11:57:59 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2019 11:57:55 +0100 Message-Id: <20190205105758.4230-12-kraxel@redhat.com> In-Reply-To: <20190205105758.4230-1-kraxel@redhat.com> References: <20190205105758.4230-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com, Paolo Bonzini , Gerd Hoffmann , Peter Maydell Subject: [libvirt] [PULL 11/14] kbd-state: use state tracker for gtk X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 05 Feb 2019 10:58:27 +0000 (UTC) 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=C3=A9 Message-id: 20190122092814.14919-6-kraxel@redhat.com --- 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 =20 +#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 57af69b0c4..949b143e4e 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -122,17 +122,6 @@ =20 #define HOTKEY_MODIFIERS (GDK_CONTROL_MASK | GDK_MOD1_MASK) =20 -static const int modifier_keycode[] =3D { - 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; =20 @@ -187,7 +176,6 @@ struct GtkDisplayState { =20 bool external_pause_update; =20 - bool modifier_pressed[ARRAY_SIZE(modifier_keycode)]; bool ignore_keys; =20 DisplayOptions *opts; @@ -426,20 +414,12 @@ static void gd_update_full_redraw(VirtualConsole *vc) static void gtk_release_modifiers(GtkDisplayState *s) { VirtualConsole *vc =3D gd_vc_find_current(s); - int i, qcode; =20 if (vc->type !=3D GD_VC_GFX || !qemu_console_is_graphic(vc->gfx.dcl.con)) { return; } - for (i =3D 0; i < ARRAY_SIZE(modifier_keycode); i++) { - qcode =3D 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] =3D false; - } + qkbd_state_lift_all_keys(vc->gfx.kbd); } =20 static void gd_widget_reparent(GtkWidget *from, GtkWidget *to, @@ -1115,7 +1095,6 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEv= entKey *key, void *opaque) VirtualConsole *vc =3D opaque; GtkDisplayState *s =3D vc->s; int qcode; - int i; =20 if (s->ignore_keys) { s->ignore_keys =3D (key->type =3D=3D GDK_KEY_PRESS); @@ -1136,8 +1115,8 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEv= entKey *key, void *opaque) || key->hardware_keycode =3D=3D VK_PAUSE #endif ) { - qemu_input_event_send_key_qcode(vc->gfx.dcl.con, Q_KEY_CODE_PAUSE, - key->type =3D=3D GDK_KEY_PRESS); + qkbd_state_key_event(vc->gfx.kbd, Q_KEY_CODE_PAUSE, + key->type =3D=3D GDK_KEY_PRESS); return TRUE; } =20 @@ -1146,14 +1125,8 @@ static gboolean gd_key_event(GtkWidget *widget, GdkE= ventKey *key, void *opaque) trace_gd_key_event(vc->label, key->hardware_keycode, qcode, (key->type =3D=3D GDK_KEY_PRESS) ? "down" : "up"); =20 - for (i =3D 0; i < ARRAY_SIZE(modifier_keycode); i++) { - if (qcode =3D=3D modifier_keycode[i]) { - s->modifier_pressed[i] =3D (key->type =3D=3D GDK_KEY_PRESS); - } - } - - qemu_input_event_send_key_qcode(vc->gfx.dcl.con, qcode, - key->type =3D=3D GDK_KEY_PRESS); + qkbd_state_key_event(vc->gfx.kbd, qcode, + key->type =3D=3D GDK_KEY_PRESS); =20 return TRUE; } @@ -2055,6 +2028,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vir= tualConsole *vc, gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), vc->tab_item, gtk_label_new(vc->label)); =20 + vc->gfx.kbd =3D qkbd_state_init(con); vc->gfx.dcl.con =3D con; register_displaychangelistener(&vc->gfx.dcl); =20 --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list