wayland: Add getter for the current surface of a tablet device

That would be the surface under the tool that is being currently used
on the device. This will be used by MetaWaylandSeat to implement the
default MetaWaylandEventInterface.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3420>
This commit is contained in:
Carlos Garnacho 2023-11-14 23:24:23 +01:00
parent fe71588a2d
commit 20f7a60e11
4 changed files with 43 additions and 0 deletions

View File

@ -603,3 +603,25 @@ meta_wayland_tablet_seat_get_grab_info (MetaWaylandTabletSeat *tablet_seat,
return FALSE;
}
MetaWaylandSurface *
meta_wayland_tablet_seat_get_current_surface (MetaWaylandTabletSeat *tablet_seat,
ClutterInputDevice *device)
{
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))
return meta_wayland_tablet_tool_get_current_surface (tool);
}
return NULL;
}

View File

@ -84,3 +84,6 @@ gboolean meta_wayland_tablet_seat_get_grab_info (MetaWaylandTabletSeat *tablet_s
ClutterInputDevice **device_out,
float *x,
float *y);
MetaWaylandSurface * meta_wayland_tablet_seat_get_current_surface (MetaWaylandTabletSeat *tablet_seat,
ClutterInputDevice *device);

View File

@ -937,3 +937,16 @@ meta_wayland_tablet_tool_can_popup (MetaWaylandTabletTool *tool,
{
return tool->down_serial == serial || tool->button_serial == serial;
}
gboolean
meta_wayland_tablet_tool_has_current_tablet (MetaWaylandTabletTool *tool,
MetaWaylandTablet *tablet)
{
return tool->current_tablet == tablet;
}
MetaWaylandSurface *
meta_wayland_tablet_tool_get_current_surface (MetaWaylandTabletTool *tool)
{
return tool->current;
}

View File

@ -81,3 +81,8 @@ gboolean meta_wayland_tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
uint32_t serial);
gboolean meta_wayland_tablet_tool_can_popup (MetaWaylandTabletTool *tool,
uint32_t serial);
gboolean meta_wayland_tablet_tool_has_current_tablet (MetaWaylandTabletTool *tool,
MetaWaylandTablet *tablet);
MetaWaylandSurface * meta_wayland_tablet_tool_get_current_surface (MetaWaylandTabletTool *tool);