mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
wayland: Store and retrieve implicit grab information for tablet tools
Window moving and resizing depends on the `meta_wayland_seat_get_grab_info` function succeeding. At the moment, tablet tools do not generate implicit grabs like the pointer and touch. This commit adds the necessary elements to track implicit grabs and retrieve their information. https://bugzilla.gnome.org/show_bug.cgi?id=777333
This commit is contained in:
parent
4b8dd51c4d
commit
ca600973ba
@ -426,36 +426,58 @@ meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat,
|
||||
gfloat *x,
|
||||
gfloat *y)
|
||||
{
|
||||
ClutterEventSequence *sequence = NULL;
|
||||
gboolean can_grab_surface = FALSE;
|
||||
MetaWaylandCompositor *compositor;
|
||||
MetaWaylandTabletSeat *tablet_seat;
|
||||
GList *tools, *l;
|
||||
|
||||
compositor = meta_wayland_compositor_get_default ();
|
||||
tablet_seat = meta_wayland_tablet_manager_ensure_seat (compositor->tablet_manager, seat);
|
||||
tools = g_hash_table_get_values (tablet_seat->tools);
|
||||
|
||||
if (meta_wayland_seat_has_touch (seat))
|
||||
sequence = meta_wayland_touch_find_grab_sequence (seat->touch,
|
||||
surface,
|
||||
serial);
|
||||
|
||||
if (sequence)
|
||||
{
|
||||
meta_wayland_touch_get_press_coords (seat->touch, sequence, x, y);
|
||||
ClutterEventSequence *sequence;
|
||||
sequence = meta_wayland_touch_find_grab_sequence (seat->touch,
|
||||
surface,
|
||||
serial);
|
||||
if (sequence)
|
||||
{
|
||||
meta_wayland_touch_get_press_coords (seat->touch, sequence, x, y);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (meta_wayland_seat_has_pointer (seat) &&
|
||||
(!require_pressed || seat->pointer->button_count > 0))
|
||||
can_grab_surface = meta_wayland_pointer_can_grab_surface (seat->pointer,
|
||||
surface,
|
||||
serial);
|
||||
|
||||
if (can_grab_surface)
|
||||
if (meta_wayland_seat_has_pointer (seat))
|
||||
{
|
||||
if ((!require_pressed || seat->pointer->button_count > 0) &&
|
||||
meta_wayland_pointer_can_grab_surface (seat->pointer, surface, serial))
|
||||
{
|
||||
if (x)
|
||||
*x = seat->pointer->grab_x;
|
||||
if (y)
|
||||
*y = seat->pointer->grab_y;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return sequence || can_grab_surface;
|
||||
for (l = tools; l; l = l->next)
|
||||
{
|
||||
MetaWaylandTabletTool *tool = l->data;
|
||||
|
||||
if ((!require_pressed || tool->button_count > 0) &&
|
||||
meta_wayland_tablet_tool_can_grab_surface (tool, surface, serial))
|
||||
{
|
||||
if (x)
|
||||
*x = tool->grab_x;
|
||||
if (y)
|
||||
*y = tool->grab_y;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "meta-wayland-keyboard.h"
|
||||
#include "meta-wayland-touch.h"
|
||||
#include "meta-wayland-data-device.h"
|
||||
#include "meta-wayland-tablet-tool.h"
|
||||
|
||||
struct _MetaWaylandSeat
|
||||
{
|
||||
|
@ -572,9 +572,15 @@ meta_wayland_tablet_tool_account_button (MetaWaylandTabletTool *tool,
|
||||
const ClutterEvent *event)
|
||||
{
|
||||
if (event->type == CLUTTER_BUTTON_PRESS)
|
||||
tool->pressed_buttons |= 1 << (event->button.button - 1);
|
||||
{
|
||||
tool->pressed_buttons |= 1 << (event->button.button - 1);
|
||||
tool->button_count++;
|
||||
}
|
||||
else if (event->type == CLUTTER_BUTTON_RELEASE)
|
||||
tool->pressed_buttons &= ~(1 << (event->button.button - 1));
|
||||
{
|
||||
tool->pressed_buttons &= ~(1 << (event->button.button - 1));
|
||||
tool->button_count--;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -840,6 +846,9 @@ handle_button_event (MetaWaylandTabletTool *tool,
|
||||
if (!tool->focus_surface)
|
||||
return;
|
||||
|
||||
if (event->type == CLUTTER_BUTTON_PRESS && tool->button_count == 1)
|
||||
clutter_event_get_coords (event, &tool->grab_x, &tool->grab_y);
|
||||
|
||||
if (event->type == CLUTTER_BUTTON_PRESS && event->button.button == 1)
|
||||
broadcast_down (tool, event);
|
||||
else if (event->type == CLUTTER_BUTTON_RELEASE && event->button.button == 1)
|
||||
@ -918,3 +927,32 @@ meta_wayland_tablet_tool_set_cursor_position (MetaWaylandTabletTool *tool,
|
||||
if (tool->cursor_renderer)
|
||||
meta_cursor_renderer_set_position (tool->cursor_renderer, new_x, new_y);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
|
||||
MetaWaylandSurface *surface)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
if (tool->focus_surface == surface)
|
||||
return TRUE;
|
||||
|
||||
for (l = surface->subsurfaces; l; l = l->next)
|
||||
{
|
||||
MetaWaylandSurface *subsurface = l->data;
|
||||
|
||||
if (tablet_tool_can_grab_surface (tool, subsurface))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_wayland_tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
|
||||
MetaWaylandSurface *surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
return ((tool->down_serial == serial || tool->button_serial == serial) &&
|
||||
tablet_tool_can_grab_surface (tool, surface));
|
||||
}
|
||||
|
@ -48,11 +48,14 @@ struct _MetaWaylandTabletTool
|
||||
|
||||
MetaWaylandSurface *current;
|
||||
guint32 pressed_buttons;
|
||||
guint32 button_count;
|
||||
|
||||
guint32 proximity_serial;
|
||||
guint32 down_serial;
|
||||
guint32 button_serial;
|
||||
|
||||
float grab_x, grab_y;
|
||||
|
||||
MetaWaylandTablet *current_tablet;
|
||||
};
|
||||
|
||||
@ -79,5 +82,8 @@ void meta_wayland_tablet_tool_set_cursor_position (MetaWaylandTabletTool *t
|
||||
int new_x,
|
||||
int new_y);
|
||||
|
||||
gboolean meta_wayland_tablet_tool_can_grab_surface (MetaWaylandTabletTool *tool,
|
||||
MetaWaylandSurface *surface,
|
||||
uint32_t serial);
|
||||
|
||||
#endif /* META_WAYLAND_TABLET_TOOL_H */
|
||||
|
Loading…
Reference in New Issue
Block a user