From nobody Sun May 19 12:01:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1687168517; cv=none; d=zohomail.com; s=zohoarc; b=FrJ3QVQCZmxBp5mqVY/vhTsr7H3CsClwpt3sZc3bmYmyCzjswFP2dblmdQfyqiCTh2rHC7DtfFH6bMHzc0Aq8gTkKJDUVv46V6TuA19pXA3ipWl+6YC5Rcgr7fNXrOcblUYi+pljy84/LBs3PBu4Eg/FPnyF70dfgl0c2nqdgB4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687168517; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KfmfqkW+a82RtbiHxgsBxYiNZNa9bE4b3igtJ1Gi6AE=; b=U5Iu5X9lPYyafnWUJqLnImuKmFFfX/jME+h3ePY30kvk59/EToO7Cxm52iGSN0nU3aC3PCyUGw22lyuf8IuNbc8GOwbywTcmZQRiYHjMkuX+vjJawxpOXBwjplV+nAj0BMvtCDjKlV2IaPu7nDUYekh599F53Xls4fUW9OREdNY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168716851777973.74495662542893; Mon, 19 Jun 2023 02:55:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBBa1-0007d1-KM; Mon, 19 Jun 2023 05:53:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBBZy-0007cL-3K for qemu-devel@nongnu.org; Mon, 19 Jun 2023 05:53:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBBZw-0001iA-3X for qemu-devel@nongnu.org; Mon, 19 Jun 2023 05:53:45 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-422-3eQVgsn6OeK1gVe0OlZ33g-1; Mon, 19 Jun 2023 05:53:41 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6EF0580006E for ; Mon, 19 Jun 2023 09:53:41 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.45.224.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F8102166B27; Mon, 19 Jun 2023 09:53:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687168423; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KfmfqkW+a82RtbiHxgsBxYiNZNa9bE4b3igtJ1Gi6AE=; b=TN0OGIoXG+tvVsGSJPSnpRdm4TU74SIJVL8eb21QFckIDmUlQkjjVUyEQR9q1gl/Ke6Qx9 JRhLWhWGbUKky/v2oTICwY4osoIE35rkAEGA3WTgRBU7tEjCZ0OTLuHddrjVyZlpPkx5M6 iZk15bf8gpkbakRSF8xy4c/1cZU173M= X-MC-Unique: 3eQVgsn6OeK1gVe0OlZ33g-1 From: Bilal Elmoussaoui To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Bilal Elmoussaoui Subject: [PATCH v4 1/2] ui/touch: Move event handling to a common helper Date: Mon, 19 Jun 2023 11:53:36 +0200 Message-ID: <20230619095337.9899-2-belmouss@redhat.com> In-Reply-To: <20230619095337.9899-1-belmouss@redhat.com> References: <20230619095337.9899-1-belmouss@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=belmouss@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1687168519633100003 To share code between the GTK and DBus UI bakcends see the next commit for details Signed-off-by: Bilal Elmoussaoui Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/ui/console.h | 15 ++++++++++ ui/console.c | 65 ++++++++++++++++++++++++++++++++++++++++++++ ui/gtk.c | 61 ++++------------------------------------- 3 files changed, 85 insertions(+), 56 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index ae5ec46..2093e2a 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -5,6 +5,7 @@ #include "qom/object.h" #include "qemu/notify.h" #include "qapi/qapi-types-ui.h" +#include "ui/input.h" =20 #ifdef CONFIG_OPENGL # include @@ -95,6 +96,20 @@ bool kbd_put_qcode_console(QemuConsole *s, int qcode, bo= ol ctrl); void kbd_put_string_console(QemuConsole *s, const char *str, int len); void kbd_put_keysym(int keysym); =20 +/* Touch devices */ +typedef struct touch_slot { + int x; + int y; + int tracking_id; +} touch_slot; + +void console_handle_touch_event(QemuConsole *con, + struct touch_slot touch_slots[INPUT_EVENT_= SLOTS_MAX], + uint64_t num_slot, + int width, int height, + double x, double y, + InputMultiTouchType type, + Error **errp); /* consoles */ =20 #define TYPE_QEMU_CONSOLE "qemu-console" diff --git a/ui/console.c b/ui/console.c index e173731..63e952e 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1635,6 +1635,71 @@ static bool console_compatible_with(QemuConsole *con, return true; } =20 +void console_handle_touch_event(QemuConsole *con, + struct touch_slot touch_slots[INPUT_EVENT_= SLOTS_MAX], + uint64_t num_slot, + int width, int height, + double x, double y, + InputMultiTouchType type, + Error **errp) +{ + struct touch_slot *slot; + bool needs_sync =3D false; + int update; + int i; + + if (num_slot >=3D INPUT_EVENT_SLOTS_MAX) { + error_setg(errp, + "Unexpected touch slot number: % " PRId64" >=3D %d", + num_slot, INPUT_EVENT_SLOTS_MAX); + return; + } + + slot =3D &touch_slots[num_slot]; + slot->x =3D x; + slot->y =3D y; + + if (type =3D=3D INPUT_MULTI_TOUCH_TYPE_BEGIN) { + slot->tracking_id =3D num_slot; + } + + for (i =3D 0; i < INPUT_EVENT_SLOTS_MAX; ++i) { + if (i =3D=3D num_slot) { + update =3D type; + } else { + update =3D INPUT_MULTI_TOUCH_TYPE_UPDATE; + } + + slot =3D &touch_slots[i]; + + if (slot->tracking_id =3D=3D -1) { + continue; + } + + if (update =3D=3D INPUT_MULTI_TOUCH_TYPE_END) { + slot->tracking_id =3D -1; + qemu_input_queue_mtt(con, update, i, slot->tracking_id); + needs_sync =3D true; + } else { + qemu_input_queue_mtt(con, update, i, slot->tracking_id); + qemu_input_queue_btn(con, INPUT_BUTTON_TOUCH, true); + qemu_input_queue_mtt_abs(con, + INPUT_AXIS_X, (int) slot->x, + 0, width, + i, slot->tracking_id); + qemu_input_queue_mtt_abs(con, + INPUT_AXIS_Y, (int) slot->y, + 0, height, + i, slot->tracking_id); + needs_sync =3D true; + } + } + + if (needs_sync) { + qemu_input_event_sync(); + } +} + void qemu_console_set_display_gl_ctx(QemuConsole *con, DisplayGLCtx *gl) { /* display has opengl support */ diff --git a/ui/gtk.c b/ui/gtk.c index e50f950..e09e164 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -130,11 +130,6 @@ typedef struct VCChardev VCChardev; DECLARE_INSTANCE_CHECKER(VCChardev, VC_CHARDEV, TYPE_CHARDEV_VC) =20 -struct touch_slot { - int x; - int y; - int tracking_id; -}; static struct touch_slot touch_slots[INPUT_EVENT_SLOTS_MAX]; =20 bool gtk_use_gl_area; @@ -1068,27 +1063,12 @@ static gboolean gd_touch_event(GtkWidget *widget, G= dkEventTouch *touch, void *opaque) { VirtualConsole *vc =3D opaque; - struct touch_slot *slot; uint64_t num_slot =3D GPOINTER_TO_UINT(touch->sequence); - bool needs_sync =3D false; - int update; int type =3D -1; - int i; - - if (num_slot >=3D INPUT_EVENT_SLOTS_MAX) { - warn_report("gtk: unexpected touch slot number: % " PRId64" >=3D %= d\n", - num_slot, INPUT_EVENT_SLOTS_MAX); - return FALSE; - } - - slot =3D &touch_slots[num_slot]; - slot->x =3D touch->x; - slot->y =3D touch->y; =20 switch (touch->type) { case GDK_TOUCH_BEGIN: type =3D INPUT_MULTI_TOUCH_TYPE_BEGIN; - slot->tracking_id =3D num_slot; break; case GDK_TOUCH_UPDATE: type =3D INPUT_MULTI_TOUCH_TYPE_UPDATE; @@ -1099,44 +1079,13 @@ static gboolean gd_touch_event(GtkWidget *widget, G= dkEventTouch *touch, break; default: warn_report("gtk: unexpected touch event type\n"); + return FALSE; } =20 - for (i =3D 0; i < INPUT_EVENT_SLOTS_MAX; ++i) { - if (i =3D=3D num_slot) { - update =3D type; - } else { - update =3D INPUT_MULTI_TOUCH_TYPE_UPDATE; - } - - slot =3D &touch_slots[i]; - - if (slot->tracking_id =3D=3D -1) { - continue; - } - - if (update =3D=3D INPUT_MULTI_TOUCH_TYPE_END) { - slot->tracking_id =3D -1; - qemu_input_queue_mtt(vc->gfx.dcl.con, update, i, slot->trackin= g_id); - needs_sync =3D true; - } else { - qemu_input_queue_mtt(vc->gfx.dcl.con, update, i, slot->trackin= g_id); - qemu_input_queue_btn(vc->gfx.dcl.con, INPUT_BUTTON_TOUCH, true= ); - qemu_input_queue_mtt_abs(vc->gfx.dcl.con, - INPUT_AXIS_X, (int) slot->x, - 0, surface_width(vc->gfx.ds), - i, slot->tracking_id); - qemu_input_queue_mtt_abs(vc->gfx.dcl.con, - INPUT_AXIS_Y, (int) slot->y, - 0, surface_height(vc->gfx.ds), - i, slot->tracking_id); - needs_sync =3D true; - } - } - - if (needs_sync) { - qemu_input_event_sync(); - } - + console_handle_touch_event(vc->gfx.dcl.con, touch_slots, + num_slot, surface_width(vc->gfx.ds), + surface_height(vc->gfx.ds), touch->x, + touch->y, type, &error_warn); return TRUE; } =20 --=20 2.41.0 From nobody Sun May 19 12:01:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1687168502; cv=none; d=zohomail.com; s=zohoarc; b=Eujh7B7gQy6bBniaUafyE5YC4U4/IrYgXwosoutIdHHuyYj3VYV8W2jq2gxH74CXqsc2mRJQ0CSqnRz01ZyFhVj/IlPv6YFnE5yMurshQimq13mRdX256M7zGDbeP2hvnmb5U5ADJAudjHHgy4BhUVUyjDandw2beSqi89GMLZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687168502; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wkdoducEiRL0rmlxujIWIGv+A0qNGAFdmjzP0bguqUI=; b=SsYGZcj+KnizaxBGqGSQJ8MKE0T8M8Hz5gGoKXalaa3jqeiXMKDboKAkQ9tqZPrpegOnoYofVrR735W3BJhhePe0LHr0BM5MeyX2m7P2oQj3Ikxmsx/TBvtAo/Z9tDNuccBFVCsirCii+nPWf5OthUkvyh+g9ufC5l3YIM5pLi8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16871685027031017.1052041143217; Mon, 19 Jun 2023 02:55:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qBBa2-0007dG-5m; Mon, 19 Jun 2023 05:53:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBBZz-0007cb-Qh for qemu-devel@nongnu.org; Mon, 19 Jun 2023 05:53:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qBBZy-0001iP-3m for qemu-devel@nongnu.org; Mon, 19 Jun 2023 05:53:47 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-452-zWgYZHYCPe6set3gVwcc9A-1; Mon, 19 Jun 2023 05:53:43 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 38FF280123E for ; Mon, 19 Jun 2023 09:53:43 +0000 (UTC) Received: from toolbox.redhat.com (unknown [10.45.224.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1EFC2166B26; Mon, 19 Jun 2023 09:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687168425; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wkdoducEiRL0rmlxujIWIGv+A0qNGAFdmjzP0bguqUI=; b=CJ/umr72lTozjjVaZlufZzKb+GR/CyQpfZfnx8Dr6L2oq2yvwdVLCOiXOMc9HBc0DPZbvm ETAAR3mLp+js4+QVGwXpykZPowFWBhUpzj1QszkLelZ9V99u7tlGnwWv5aBa+u6d9r6QkQ 5l5ke7SzgUQj5HiHlVoJ4OC7IjgwLj0= X-MC-Unique: zWgYZHYCPe6set3gVwcc9A-1 From: Bilal Elmoussaoui To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Bilal Elmoussaoui Subject: [PATCH v4 2/2] ui/dbus: Expose a touch device interface Date: Mon, 19 Jun 2023 11:53:37 +0200 Message-ID: <20230619095337.9899-3-belmouss@redhat.com> In-Reply-To: <20230619095337.9899-1-belmouss@redhat.com> References: <20230619095337.9899-1-belmouss@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=belmouss@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1687168504845100012 So that clients making use of the DBus backend could send touch events through the new org.qemu.Display1.Touch interface Signed-off-by: Bilal Elmoussaoui Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Bilal Elmoussaoui --- ui/dbus-console.c | 59 +++++++++++++++++++++++++++++++++++++++++++- ui/dbus-display1.xml | 45 +++++++++++++++++++++++++++++++-- ui/trace-events | 1 + 3 files changed, 102 insertions(+), 3 deletions(-) diff --git a/ui/dbus-console.c b/ui/dbus-console.c index f77bc49..bc97614 100644 --- a/ui/dbus-console.c +++ b/ui/dbus-console.c @@ -32,6 +32,8 @@ =20 #include "dbus.h" =20 +static struct touch_slot touch_slots[INPUT_EVENT_SLOTS_MAX]; + struct _DBusDisplayConsole { GDBusObjectSkeleton parent_instance; DisplayChangeListener dcl; @@ -44,6 +46,7 @@ struct _DBusDisplayConsole { QKbdState *kbd; =20 QemuDBusDisplay1Mouse *iface_mouse; + QemuDBusDisplay1MultiTouch *iface_touch; gboolean last_set; guint last_x; guint last_y; @@ -345,6 +348,46 @@ dbus_mouse_rel_motion(DBusDisplayConsole *ddc, return DBUS_METHOD_INVOCATION_HANDLED; } =20 +static gboolean +dbus_touch_send_event(DBusDisplayConsole *ddc, + GDBusMethodInvocation *invocation, + guint kind, uint64_t num_slot, + double x, double y) +{ + Error *error =3D NULL; + int width, height; + trace_dbus_touch_send_event(kind, num_slot, x, y); + + if (kind !=3D INPUT_MULTI_TOUCH_TYPE_BEGIN && + kind !=3D INPUT_MULTI_TOUCH_TYPE_UPDATE && + kind !=3D INPUT_MULTI_TOUCH_TYPE_CANCEL && + kind !=3D INPUT_MULTI_TOUCH_TYPE_END) + { + g_dbus_method_invocation_return_error( + invocation, DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_INVALID, + "Invalid touch event kind"); + return DBUS_METHOD_INVOCATION_HANDLED; + } + width =3D qemu_console_get_width(ddc->dcl.con, 0); + height =3D qemu_console_get_height(ddc->dcl.con, 0); + + console_handle_touch_event(ddc->dcl.con, touch_slots, + num_slot, width, height, + x, y, kind, &error); + if (error !=3D NULL) { + g_dbus_method_invocation_return_error( + invocation, DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_INVALID, + error_get_pretty(error), NULL); + error_free(error); + } else { + qemu_dbus_display1_multi_touch_complete_send_event(ddc->iface_touc= h, + invocation); + } + return DBUS_METHOD_INVOCATION_HANDLED; +} + static gboolean dbus_mouse_set_pos(DBusDisplayConsole *ddc, GDBusMethodInvocation *invocation, @@ -440,7 +483,7 @@ dbus_display_console_new(DBusDisplay *display, QemuCons= ole *con) g_autofree char *label =3D NULL; char device_addr[256] =3D ""; DBusDisplayConsole *ddc; - int idx; + int idx, i; =20 assert(display); assert(con); @@ -495,6 +538,20 @@ dbus_display_console_new(DBusDisplay *display, QemuCon= sole *con) g_dbus_object_skeleton_add_interface(G_DBUS_OBJECT_SKELETON(ddc), G_DBUS_INTERFACE_SKELETON(ddc->iface_mouse)); =20 + ddc->iface_touch =3D qemu_dbus_display1_multi_touch_skeleton_new(); + g_object_connect(ddc->iface_touch, + "swapped-signal::handle-send-event", dbus_touch_send_event, ddc, + NULL); + qemu_dbus_display1_multi_touch_set_max_slots(ddc->iface_touch, + INPUT_EVENT_SLOTS_MAX); + g_dbus_object_skeleton_add_interface(G_DBUS_OBJECT_SKELETON(ddc), + G_DBUS_INTERFACE_SKELETON(ddc->iface_touch)); + + for (i =3D 0; i < INPUT_EVENT_SLOTS_MAX; i++) { + struct touch_slot *slot =3D &touch_slots[i]; + slot->tracking_id =3D -1; + } + register_displaychangelistener(&ddc->dcl); ddc->mouse_mode_notifier.notify =3D dbus_mouse_mode_change; qemu_add_mouse_mode_change_notifier(&ddc->mouse_mode_notifier); diff --git a/ui/dbus-display1.xml b/ui/dbus-display1.xml index c3b2293..cc0c9b6 100644 --- a/ui/dbus-display1.xml +++ b/ui/dbus-display1.xml @@ -39,8 +39,9 @@ "Text" (see :dbus:prop:`Type` and other properties). =20 Interactions with a console may be done with - :dbus:iface:`org.qemu.Display1.Keyboard` and - :dbus:iface:`org.qemu.Display1.Mouse` interfaces when available. + :dbus:iface:`org.qemu.Display1.Keyboard`, + :dbus:iface:`org.qemu.Display1.Mouse` and + :dbus:iface:`org.qemu.Display1.MultiTouch` interfaces when available. --> + + + + + + + + + + + + +