diff options
Diffstat (limited to 'gdk/wayland/gdkdevice-wayland.c')
-rw-r--r-- | gdk/wayland/gdkdevice-wayland.c | 68 |
1 files changed, 62 insertions, 6 deletions
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index b8f92fef68..34e5759eea 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -96,7 +96,6 @@ struct _GdkWaylandSeat GdkWindow *pointer_focus; GdkWindow *keyboard_focus; GdkAtom pending_selection; - struct wl_data_device *data_device; double surface_x, surface_y; uint32_t time; uint32_t enter_serial; @@ -115,6 +114,8 @@ struct _GdkWaylandSeat guint cursor_image_index; guint cursor_image_delay; + struct zwp_primary_selection_device_v1 *primary_data_device; + struct wl_data_device *data_device; GdkDragContext *drop_context; struct wl_surface *pointer_surface; @@ -926,6 +927,42 @@ static const struct wl_data_device_listener data_device_listener = { data_device_selection }; +static void +primary_selection_data_offer (void *data, + struct zwp_primary_selection_device_v1 *wp_primary_selection_device, + struct zwp_primary_selection_offer_v1 *wp_primary_offer) +{ + GdkWaylandDeviceData *device = (GdkWaylandDeviceData *) data; + + GDK_NOTE (EVENTS, + g_message ("primary selection offer, device %p, data offer %p", + wp_primary_selection_device, wp_primary_offer)); + + gdk_wayland_selection_ensure_primary_offer (device->display, wp_primary_offer); +} + +static void +primary_selection_selection (void *data, + struct zwp_primary_selection_device_v1 *wp_primary_selection_device, + struct zwp_primary_selection_offer_v1 *wp_primary_offer) +{ + GdkWaylandDeviceData *device = (GdkWaylandDeviceData *) data; + GdkAtom selection; + + GDK_NOTE (EVENTS, + g_message ("primary selection selection, device %p, data offer %p", + wp_primary_selection_device, wp_primary_offer)); + + selection = gdk_atom_intern_static_string ("PRIMARY"); + gdk_wayland_selection_set_offer (device->display, selection, wp_primary_offer); + emit_selection_owner_change (device->keyboard_focus, selection); +} + +static const struct zwp_primary_selection_device_v1_listener primary_selection_device_listener = { + primary_selection_data_offer, + primary_selection_selection, +}; + static GdkEvent * create_scroll_event (GdkWaylandSeat *seat, gboolean emulated) @@ -2883,6 +2920,12 @@ _gdk_wayland_device_manager_add_seat (GdkDeviceManager *device_manager, wl_seat_add_listener (seat->wl_seat, &seat_listener, seat); wl_seat_set_user_data (seat->wl_seat, seat); + seat->primary_data_device = + zwp_primary_selection_device_manager_v1_get_device (display_wayland->primary_selection_manager, + seat->wl_seat); + zwp_primary_selection_device_v1_add_listener (seat->primary_data_device, + &primary_selection_device_listener, seat); + seat->data_device = wl_data_device_manager_get_data_device (display_wayland->data_device_manager, seat->wl_seat); @@ -3021,20 +3064,22 @@ _gdk_wayland_device_get_implicit_grab_serial (GdkWaylandDevice *device, } uint32_t -_gdk_wayland_device_get_last_implicit_grab_serial (GdkWaylandDevice *device, - GdkEventSequence **sequence) +_gdk_wayland_seat_get_last_implicit_grab_serial (GdkSeat *seat, + GdkEventSequence **sequence) { + GdkWaylandSeat *wayland_seat; GdkWaylandTouchData *touch; GHashTableIter iter; uint32_t serial = 0; - g_hash_table_iter_init (&iter, device->device->touches); + wayland_seat = GDK_WAYLAND_SEAT (seat); + g_hash_table_iter_init (&iter, wayland_seat->touches); if (sequence) *sequence = NULL; - if (device->device->button_press_serial > serial) - serial = device->device->button_press_serial; + if (wayland_seat->button_press_serial > serial) + serial = wayland_seat->button_press_serial; while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &touch)) { @@ -3116,6 +3161,17 @@ gdk_wayland_device_set_selection (GdkDevice *gdk_device, _gdk_wayland_display_get_serial (display_wayland)); } +void +gdk_wayland_seat_set_primary (GdkSeat *seat, + struct zwp_primary_selection_source_v1 *source) +{ + GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat); + + if (source) + zwp_primary_selection_device_v1_set_selection (wayland_seat->primary_data_device, + source); +} + struct wl_seat * gdk_wayland_seat_get_wl_seat (GdkSeat *seat) { |