wayland: Refactor tablet tool grab checks

Move the bulk of the implementation inside MetaWaylandTabletTool
files, so MetaWaylandTablet does not need to access at tool struct
fields.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3627>
This commit is contained in:
Carlos Garnacho 2024-02-27 23:08:28 +01:00 committed by Marge Bot
parent 314ab7c3cb
commit f17300a22e
3 changed files with 42 additions and 17 deletions

View File

@ -587,19 +587,13 @@ meta_wayland_tablet_seat_get_grab_info (MetaWaylandTabletSeat *tablet_seat,
{
MetaWaylandTabletTool *tool = l->data;
if ((!require_pressed || tool->button_count > 0) &&
meta_wayland_tablet_tool_can_grab_surface (tool, surface, serial))
{
if (device_out)
*device_out = tool->device;
if (x)
*x = tool->grab_x;
if (y)
*y = tool->grab_y;
return TRUE;
}
if (meta_wayland_tablet_tool_get_grab_info (tool,
surface,
serial,
require_pressed,
device_out,
x, y))
return TRUE;
}
return FALSE;

View File

@ -913,7 +913,7 @@ tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
return FALSE;
}
gboolean
static gboolean
meta_wayland_tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
MetaWaylandSurface *surface,
uint32_t serial)
@ -922,6 +922,32 @@ meta_wayland_tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
tablet_tool_can_grab_surface (tool, surface));
}
gboolean
meta_wayland_tablet_tool_get_grab_info (MetaWaylandTabletTool *tool,
MetaWaylandSurface *surface,
uint32_t serial,
gboolean require_pressed,
ClutterInputDevice **device_out,
float *x,
float *y)
{
if ((!require_pressed || tool->button_count > 0) &&
meta_wayland_tablet_tool_can_grab_surface (tool, surface, serial))
{
if (device_out)
*device_out = tool->device;
if (x)
*x = tool->grab_x;
if (y)
*y = tool->grab_y;
return TRUE;
}
return FALSE;
}
gboolean
meta_wayland_tablet_tool_can_popup (MetaWaylandTabletTool *tool,
uint32_t serial)

View File

@ -76,9 +76,14 @@ void meta_wayland_tablet_tool_update (MetaWaylandTabletTool *t
gboolean meta_wayland_tablet_tool_handle_event (MetaWaylandTabletTool *tool,
const ClutterEvent *event);
gboolean meta_wayland_tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
MetaWaylandSurface *surface,
uint32_t serial);
gboolean meta_wayland_tablet_tool_get_grab_info (MetaWaylandTabletTool *tool,
MetaWaylandSurface *surface,
uint32_t serial,
gboolean require_pressed,
ClutterInputDevice **device_out,
float *x,
float *y);
gboolean meta_wayland_tablet_tool_can_popup (MetaWaylandTabletTool *tool,
uint32_t serial);