[gtk/wip/nacho/tool-api: 83/83] seat: improve api to take into account the tool type
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/nacho/tool-api: 83/83] seat: improve api to take into account the tool type
- Date: Thu, 7 Jan 2021 11:31:06 +0000 (UTC)
commit a9df862a2b0814098ac6c96f47dda0972ca1db05
Author: Ignacio Casal Quinteiro <qignacio amazon com>
Date: Thu Jan 7 12:27:26 2021 +0100
seat: improve api to take into account the tool type
Otherwise if we have several tools with the same serial
and hardware id we might match the wrong tool.
gdk/gdkseat.c | 9 +++++----
gdk/gdkseatdefault.c | 2 +-
gdk/x11/gdkdevicemanager-xi2.c | 11 ++++++-----
3 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/gdk/gdkseat.c b/gdk/gdkseat.c
index 75ef348a2d..83af3b88a4 100644
--- a/gdk/gdkseat.c
+++ b/gdk/gdkseat.c
@@ -436,9 +436,10 @@ gdk_seat_tool_removed (GdkSeat *seat,
}
GdkDeviceTool *
-gdk_seat_get_tool (GdkSeat *seat,
- guint64 serial,
- guint64 hw_id)
+gdk_seat_get_tool (GdkSeat *seat,
+ guint64 serial,
+ guint64 hw_id,
+ GdkDeviceToolType type)
{
GdkDeviceTool *match = NULL;
GList *tools, *l;
@@ -449,7 +450,7 @@ gdk_seat_get_tool (GdkSeat *seat,
{
GdkDeviceTool *tool = l->data;
- if (tool->serial == serial && tool->hw_id == hw_id)
+ if (tool->serial == serial && tool->hw_id == hw_id && tool->type == type)
{
match = tool;
break;
diff --git a/gdk/gdkseatdefault.c b/gdk/gdkseatdefault.c
index c9595bafdf..2226d36da1 100644
--- a/gdk/gdkseatdefault.c
+++ b/gdk/gdkseatdefault.c
@@ -442,7 +442,7 @@ gdk_seat_default_remove_tool (GdkSeatDefault *seat,
priv = gdk_seat_default_get_instance_private (seat);
- if (tool != gdk_seat_get_tool (GDK_SEAT (seat), tool->serial, tool->hw_id))
+ if (tool != gdk_seat_get_tool (GDK_SEAT (seat), tool->serial, tool->hw_id, tool->type))
return;
g_signal_emit_by_name (seat, "tool-removed", tool);
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index 3165205a5f..07073ee395 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -1097,15 +1097,16 @@ handle_property_change (GdkX11DeviceManagerXI2 *device_manager,
if (ev->what != XIPropertyDeleted &&
device_get_tool_serial_and_id (device, &serial_id, &tool_id))
{
+ GdkDeviceToolType tool_type;
+
seat = gdk_device_get_seat (device);
- tool = gdk_seat_get_tool (seat, serial_id, tool_id);
+ tool_type = device_get_tool_type (device);
- if (!tool && serial_id > 0)
+ if (tool_type != GDK_DEVICE_TOOL_TYPE_UNKNOWN)
{
- GdkDeviceToolType tool_type;
+ tool = gdk_seat_get_tool (seat, serial_id, tool_id, tool_type);
- tool_type = device_get_tool_type (device);
- if (tool_type != GDK_DEVICE_TOOL_TYPE_UNKNOWN)
+ if (!tool && serial_id > 0)
{
tool = gdk_device_tool_new (serial_id, tool_id, tool_type, 0);
gdk_seat_default_add_tool (GDK_SEAT_DEFAULT (seat), tool);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]