From 77ec0d1e411bf839b30fe7d6ec3b34092bccb14c Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 15 Nov 2023 14:49:29 +0100 Subject: [PATCH] wayland: Add API to change a tool focus surface Part-of: --- src/wayland/meta-wayland-tablet-seat.c | 21 +++++++++++++++++++++ src/wayland/meta-wayland-tablet-seat.h | 4 ++++ src/wayland/meta-wayland-tablet-tool.c | 7 +++++++ src/wayland/meta-wayland-tablet-tool.h | 3 +++ 4 files changed, 35 insertions(+) diff --git a/src/wayland/meta-wayland-tablet-seat.c b/src/wayland/meta-wayland-tablet-seat.c index 5a8cf62c3..be4ee976f 100644 --- a/src/wayland/meta-wayland-tablet-seat.c +++ b/src/wayland/meta-wayland-tablet-seat.c @@ -625,3 +625,24 @@ meta_wayland_tablet_seat_get_current_surface (MetaWaylandTabletSeat *tablet_seat return NULL; } + +void +meta_wayland_tablet_seat_focus_surface (MetaWaylandTabletSeat *tablet_seat, + ClutterInputDevice *device, + MetaWaylandSurface *surface) +{ + MetaWaylandTablet *tablet; + g_autoptr (GList) tools = NULL; + GList *l; + + tools = g_hash_table_get_values (tablet_seat->tools); + tablet = meta_wayland_tablet_seat_lookup_tablet (tablet_seat, device); + + for (l = tools; l; l = l->next) + { + MetaWaylandTabletTool *tool = l->data; + + if (meta_wayland_tablet_tool_has_current_tablet (tool, tablet)) + meta_wayland_tablet_tool_focus_surface (tool, surface); + } +} diff --git a/src/wayland/meta-wayland-tablet-seat.h b/src/wayland/meta-wayland-tablet-seat.h index 834e6a65a..56fb57613 100644 --- a/src/wayland/meta-wayland-tablet-seat.h +++ b/src/wayland/meta-wayland-tablet-seat.h @@ -87,3 +87,7 @@ gboolean meta_wayland_tablet_seat_get_grab_info (MetaWaylandTabletSeat *tablet_s MetaWaylandSurface * meta_wayland_tablet_seat_get_current_surface (MetaWaylandTabletSeat *tablet_seat, ClutterInputDevice *device); + +void meta_wayland_tablet_seat_focus_surface (MetaWaylandTabletSeat *tablet_seat, + ClutterInputDevice *device, + MetaWaylandSurface *surface); diff --git a/src/wayland/meta-wayland-tablet-tool.c b/src/wayland/meta-wayland-tablet-tool.c index 8f8be2c17..c680919b6 100644 --- a/src/wayland/meta-wayland-tablet-tool.c +++ b/src/wayland/meta-wayland-tablet-tool.c @@ -950,3 +950,10 @@ meta_wayland_tablet_tool_get_current_surface (MetaWaylandTabletTool *tool) { return tool->current; } + +void +meta_wayland_tablet_tool_focus_surface (MetaWaylandTabletTool *tool, + MetaWaylandSurface *surface) +{ + meta_wayland_tablet_tool_set_focus (tool, surface, NULL); +} diff --git a/src/wayland/meta-wayland-tablet-tool.h b/src/wayland/meta-wayland-tablet-tool.h index 9afd13e75..448aec559 100644 --- a/src/wayland/meta-wayland-tablet-tool.h +++ b/src/wayland/meta-wayland-tablet-tool.h @@ -86,3 +86,6 @@ gboolean meta_wayland_tablet_tool_has_current_tablet (MetaWaylandTabletTool *too MetaWaylandTablet *tablet); MetaWaylandSurface * meta_wayland_tablet_tool_get_current_surface (MetaWaylandTabletTool *tool); + +void meta_wayland_tablet_tool_focus_surface (MetaWaylandTabletTool *tool, + MetaWaylandSurface *surface);