Merge branch 'wip/carlosg/use-press-serial' into 'main'

gdk/wayland: Use last implicit grab serial for DnD start requests

Closes #5048

See merge request GNOME/gtk!4889
This commit is contained in:
Matthias Clasen 2022-07-18 14:18:22 +00:00
commit f95f992d32
6 changed files with 12 additions and 76 deletions

View File

@ -1514,8 +1514,6 @@ pointer_handle_enter (void *data,
if (!GDK_IS_SURFACE (wl_surface_get_user_data (surface)))
return;
_gdk_wayland_display_update_serial (display_wayland, serial);
seat->pointer_info.focus = wl_surface_get_user_data (surface);
g_object_ref (seat->pointer_info.focus);
@ -1566,7 +1564,6 @@ pointer_handle_leave (void *data,
if (!seat->pointer_info.focus)
return;
_gdk_wayland_display_update_serial (display_wayland, serial);
grab = _gdk_display_get_last_device_grab (seat->display,
seat->logical_pointer);
@ -1666,8 +1663,6 @@ pointer_handle_button (void *data,
if (!seat->pointer_info.focus)
return;
_gdk_wayland_display_update_serial (display, serial);
switch (button)
{
case BTN_LEFT:
@ -1986,7 +1981,6 @@ keyboard_handle_enter (void *data,
{
GdkWaylandSeat *seat = data;
GdkEvent *event;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
if (!surface)
return;
@ -1994,8 +1988,6 @@ keyboard_handle_enter (void *data,
if (!GDK_IS_SURFACE (wl_surface_get_user_data (surface)))
return;
_gdk_wayland_display_update_serial (display, serial);
seat->keyboard_focus = wl_surface_get_user_data (surface);
g_object_ref (seat->keyboard_focus);
seat->repeat_key = 0;
@ -2021,7 +2013,6 @@ keyboard_handle_leave (void *data,
{
GdkWaylandSeat *seat = data;
GdkEvent *event;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
if (!seat->keyboard_focus)
return;
@ -2032,8 +2023,6 @@ keyboard_handle_leave (void *data,
*/
stop_key_repeat (seat);
_gdk_wayland_display_update_serial (display, serial);
event = gdk_focus_event_new (seat->keyboard_focus,
seat->logical_keyboard,
FALSE);
@ -2272,7 +2261,6 @@ keyboard_handle_key (void *data,
uint32_t state_w)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
if (!seat->keyboard_focus)
return;
@ -2280,7 +2268,6 @@ keyboard_handle_key (void *data,
seat->keyboard_time = time;
seat->keyboard_key_serial = serial;
seat->repeat_count = 0;
_gdk_wayland_display_update_serial (display, serial);
deliver_key_event (data, time, key + 8, state_w, FALSE);
}
@ -2470,12 +2457,9 @@ touch_handle_down (void *data,
wl_fixed_t y)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
GdkWaylandTouchData *touch;
GdkEvent *event;
_gdk_wayland_display_update_serial (display, serial);
if (!wl_surface)
return;
@ -2519,12 +2503,9 @@ touch_handle_up (void *data,
int32_t id)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
GdkWaylandTouchData *touch;
GdkEvent *event;
_gdk_wayland_display_update_serial (display, serial);
touch = gdk_wayland_seat_get_touch (seat, id);
if (!touch)
return;
@ -2704,9 +2685,6 @@ gesture_swipe_begin (void *data,
uint32_t fingers)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
_gdk_wayland_display_update_serial (display, serial);
emit_gesture_swipe_event (seat,
GDK_TOUCHPAD_GESTURE_PHASE_BEGIN,
@ -2739,11 +2717,8 @@ gesture_swipe_end (void *data,
int32_t cancelled)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
GdkTouchpadGesturePhase phase;
_gdk_wayland_display_update_serial (display, serial);
phase = (cancelled) ?
GDK_TOUCHPAD_GESTURE_PHASE_CANCEL :
GDK_TOUCHPAD_GESTURE_PHASE_END;
@ -2806,9 +2781,7 @@ gesture_pinch_begin (void *data,
uint32_t fingers)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
_gdk_wayland_display_update_serial (display, serial);
emit_gesture_pinch_event (seat,
GDK_TOUCHPAD_GESTURE_PHASE_BEGIN,
time, fingers, 0, 0, 1, 0);
@ -2843,11 +2816,8 @@ gesture_pinch_end (void *data,
int32_t cancelled)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
GdkTouchpadGesturePhase phase;
_gdk_wayland_display_update_serial (display, serial);
phase = (cancelled) ?
GDK_TOUCHPAD_GESTURE_PHASE_CANCEL :
GDK_TOUCHPAD_GESTURE_PHASE_END;
@ -2901,9 +2871,6 @@ gesture_hold_begin (void *data,
uint32_t fingers)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
_gdk_wayland_display_update_serial (display, serial);
emit_gesture_hold_event (seat,
GDK_TOUCHPAD_GESTURE_PHASE_BEGIN,
@ -2919,11 +2886,8 @@ gesture_hold_end (void *data,
int32_t cancelled)
{
GdkWaylandSeat *seat = data;
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
GdkTouchpadGesturePhase phase;
_gdk_wayland_display_update_serial (display, serial);
phase = (cancelled) ?
GDK_TOUCHPAD_GESTURE_PHASE_CANCEL :
GDK_TOUCHPAD_GESTURE_PHASE_END;
@ -3630,8 +3594,6 @@ tablet_tool_handle_proximity_in (void *data,
{
GdkWaylandTabletToolData *tool = data;
GdkWaylandTabletData *tablet = zwp_tablet_v2_get_user_data (wp_tablet);
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
GdkSurface *surface;
GdkEvent *event;
@ -3648,7 +3610,6 @@ tablet_tool_handle_proximity_in (void *data,
tool->current_tablet = tablet;
tablet->current_tool = tool;
_gdk_wayland_display_update_serial (display_wayland, serial);
tablet->pointer_info.enter_serial = serial;
tablet->pointer_info.focus = g_object_ref (surface);
@ -3669,9 +3630,9 @@ tablet_tool_handle_proximity_in (void *data,
gdk_wayland_surface_get_wl_output (surface));
pointer_surface_update_scale (tablet->logical_device);
GDK_SEAT_NOTE (seat, EVENTS,
GDK_SEAT_NOTE (tablet->seat, EVENTS,
g_message ("proximity in, seat %p surface %p tool %d",
seat, tablet->pointer_info.focus,
tablet->seat, tablet->pointer_info.focus,
gdk_device_tool_get_tool_type (tool->tool)));
}
@ -3748,13 +3709,10 @@ tablet_tool_handle_down (void *data,
{
GdkWaylandTabletToolData *tool = data;
GdkWaylandTabletData *tablet = tool->current_tablet;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tool->seat);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
if (!tablet || !tablet->pointer_info.focus)
return;
_gdk_wayland_display_update_serial (display_wayland, serial);
tablet->pointer_info.press_serial = serial;
tablet_create_button_event_frame (tablet, GDK_BUTTON_PRESS, GDK_BUTTON_PRIMARY);
@ -5305,15 +5263,13 @@ gdk_wayland_device_set_selection (GdkDevice *gdk_device,
struct wl_data_source *source)
{
GdkWaylandSeat *seat;
GdkWaylandDisplay *display_wayland;
guint32 serial;
g_return_if_fail (GDK_IS_WAYLAND_DEVICE (gdk_device));
seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (gdk_device));
display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
wl_data_device_set_selection (seat->data_device, source,
_gdk_wayland_display_get_serial (display_wayland));
serial = _gdk_wayland_seat_get_implicit_grab_serial (GDK_SEAT (seat), NULL);
wl_data_device_set_selection (seat->data_device, source, serial);
}
/**

View File

@ -145,10 +145,6 @@ zxdg_shell_v6_ping (void *data,
struct zxdg_shell_v6 *xdg_shell,
uint32_t serial)
{
GdkWaylandDisplay *display_wayland = data;
_gdk_wayland_display_update_serial (display_wayland, serial);
GDK_DISPLAY_NOTE (GDK_DISPLAY (data), EVENTS,
g_message ("ping, shell %p, serial %u\n", xdg_shell, serial));
@ -1124,19 +1120,6 @@ _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland)
}
guint32
_gdk_wayland_display_get_serial (GdkWaylandDisplay *display_wayland)
{
return display_wayland->serial;
}
void
_gdk_wayland_display_update_serial (GdkWaylandDisplay *display_wayland,
guint32 serial)
{
display_wayland->serial = serial;
}
/**
* gdk_wayland_display_get_wl_display: (skip)
* @display: (type GdkWaylandDisplay): a `GdkDisplay`

View File

@ -84,9 +84,6 @@ struct _GdkWaylandDisplay
/* Startup notification */
char *startup_notification_id;
/* Most recent serial */
guint32 serial;
uint32_t xdg_wm_base_id;
int xdg_wm_base_version;
uint32_t zxdg_shell_v6_id;

View File

@ -393,8 +393,8 @@ _gdk_wayland_surface_drag_begin (GdkSurface *surface,
wl_data_device_start_drag (gdk_wayland_device_get_data_device (device),
drag_wayland->data_source,
gdk_wayland_surface_get_wl_surface (surface),
drag_wayland->dnd_wl_surface,
_gdk_wayland_display_get_serial (display_wayland));
drag_wayland->dnd_wl_surface,
_gdk_wayland_seat_get_implicit_grab_serial (seat, NULL));
cursor = gdk_drag_get_cursor (drag, gdk_drag_get_selected_action (drag));
gdk_drag_set_cursor (drag, cursor);

View File

@ -263,6 +263,8 @@ gdk_wayland_primary_claim (GdkClipboard *clipboard,
GdkWaylandDisplay *wdisplay = GDK_WAYLAND_DISPLAY (gdk_clipboard_get_display (clipboard));
const char * const *mime_types;
gsize i, n_mime_types;
GdkSeat *seat;
guint32 serial;
gdk_wayland_primary_discard_offer (cb);
gdk_wayland_primary_discard_source (cb);
@ -276,9 +278,11 @@ gdk_wayland_primary_claim (GdkClipboard *clipboard,
zwp_primary_selection_source_v1_offer (cb->source, mime_types[i]);
}
seat = gdk_display_get_default_seat (GDK_DISPLAY (wdisplay));
serial = _gdk_wayland_seat_get_implicit_grab_serial (seat, NULL);
zwp_primary_selection_device_v1_set_selection (cb->primary_data_device,
cb->source,
_gdk_wayland_display_get_serial (wdisplay));
serial);
}
return GDK_CLIPBOARD_CLASS (gdk_wayland_primary_parent_class)->claim (clipboard, formats, local, content);

View File

@ -170,10 +170,6 @@ GdkMonitor *gdk_wayland_display_get_monitor_for_output (GdkDisplay *displa
void _gdk_wayland_surface_set_grab_seat (GdkSurface *surface,
GdkSeat *seat);
guint32 _gdk_wayland_display_get_serial (GdkWaylandDisplay *display_wayland);
void _gdk_wayland_display_update_serial (GdkWaylandDisplay *display_wayland,
guint32 serial);
cairo_surface_t * _gdk_wayland_display_create_shm_surface (GdkWaylandDisplay *display,
int width,
int height,