summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2014-08-13 21:05:58 +0200
committerCarlos Garnacho <carlosg@gnome.org>2014-08-26 13:32:46 +0200
commit537ff9fcad30cbd838f7edcf4cd943bd32d0a218 (patch)
tree11aa9a7f08d240ff1b590abe93e056faca192828 /gdk
parent5b8641740bf43ca621d15ce15c0660eb2534221d (diff)
downloadgtk+-537ff9fcad30cbd838f7edcf4cd943bd32d0a218.tar.gz
wayland: Improve implicit grab serial retrieval
_gdk_wayland_device_get_button_press_serial() has been replaced by _gdk_wayland_device_get_implicit_grab_serial(), which takes a touch/pointer event and figures out the relevant serial, and _gdk_wayland_device_get_last_implicit_grab_serial() which returns the most recent serial. The button press serial was currently used when operating popping up xdg_shell/surface popups and window menus, so this is now touch aware, of some sort. https://bugzilla.gnome.org/show_bug.cgi?id=734374
Diffstat (limited to 'gdk')
-rw-r--r--gdk/wayland/gdkdevice-wayland.c46
-rw-r--r--gdk/wayland/gdkprivate-wayland.h5
-rw-r--r--gdk/wayland/gdkwindow-wayland.c20
3 files changed, 59 insertions, 12 deletions
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 9dda3d7bb2..cc2be21e0e 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -1820,9 +1820,51 @@ _gdk_wayland_device_manager_new (GdkDisplay *display)
}
uint32_t
-_gdk_wayland_device_get_button_press_serial (GdkWaylandDeviceData *device)
+_gdk_wayland_device_get_implicit_grab_serial (GdkWaylandDevice *device,
+ const GdkEvent *event)
{
- return device->button_press_serial;
+ GdkEventSequence *sequence = NULL;
+ GdkWaylandTouchData *touch = NULL;
+
+ if (event)
+ sequence = gdk_event_get_event_sequence (event);
+
+ if (sequence)
+ touch = gdk_wayland_device_get_touch (device->device,
+ GDK_EVENT_SEQUENCE_TO_SLOT (sequence));
+ if (touch)
+ return touch->touch_down_serial;
+ else
+ return device->device->button_press_serial;
+}
+
+uint32_t
+_gdk_wayland_device_get_last_implicit_grab_serial (GdkWaylandDevice *device,
+ GdkEventSequence **sequence)
+{
+ GdkWaylandTouchData *touch;
+ GHashTableIter iter;
+ uint32_t serial = 0;
+
+ g_hash_table_iter_init (&iter, device->device->touches);
+
+ if (sequence)
+ *sequence = NULL;
+
+ if (device->device->button_press_serial > serial)
+ serial = device->device->button_press_serial;
+
+ while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &touch))
+ {
+ if (touch->touch_down_serial > serial)
+ {
+ if (sequence)
+ *sequence = GDK_SLOT_TO_EVENT_SEQUENCE (touch->id);
+ serial = touch->touch_down_serial;
+ }
+ }
+
+ return serial;
}
static GdkAtom
diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h
index aaaa8d700d..e1867f6f98 100644
--- a/gdk/wayland/gdkprivate-wayland.h
+++ b/gdk/wayland/gdkprivate-wayland.h
@@ -143,7 +143,10 @@ void _gdk_wayland_device_manager_remove_seat (GdkDeviceManager *dev
typedef struct _GdkWaylandDeviceData GdkWaylandDeviceData;
GdkKeymap *_gdk_wayland_device_get_keymap (GdkDevice *device);
-uint32_t _gdk_wayland_device_get_button_press_serial(GdkWaylandDeviceData *device);
+uint32_t _gdk_wayland_device_get_implicit_grab_serial(GdkWaylandDevice *device,
+ const GdkEvent *event);
+uint32_t _gdk_wayland_device_get_last_implicit_grab_serial (GdkWaylandDevice *device,
+ GdkEventSequence **seqence);
void _gdk_wayland_display_deliver_event (GdkDisplay *display, GdkEvent *event);
GSource *_gdk_wayland_display_event_source_new (GdkDisplay *display);
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index 9c29b96a2c..35062f3fd3 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -999,7 +999,8 @@ gdk_wayland_window_create_xdg_popup (GdkWindow *window,
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
GdkWindowImplWayland *parent_impl = GDK_WINDOW_IMPL_WAYLAND (parent->impl);
- GdkWaylandDeviceData *device;
+ GdkDeviceManager *device_manager;
+ GdkWaylandDevice *device;
int x, y;
int parent_x, parent_y;
@@ -1009,7 +1010,8 @@ gdk_wayland_window_create_xdg_popup (GdkWindow *window,
if (!parent_impl->surface)
return;
- device = wl_seat_get_user_data (seat);
+ device_manager = gdk_display_get_device_manager (GDK_DISPLAY (display_wayland));
+ device = GDK_WAYLAND_DEVICE (gdk_device_manager_get_client_pointer (device_manager));
gdk_wayland_window_get_fake_root_coords (parent, &parent_x, &parent_y);
@@ -1020,7 +1022,7 @@ gdk_wayland_window_create_xdg_popup (GdkWindow *window,
impl->surface,
parent_impl->surface,
seat,
- _gdk_wayland_device_get_button_press_serial (device),
+ _gdk_wayland_device_get_last_implicit_grab_serial (device, NULL),
x, y, flags);
xdg_popup_add_listener (impl->xdg_popup, &xdg_popup_listener, window);
@@ -1987,15 +1989,16 @@ gdk_wayland_window_show_window_menu (GdkWindow *window,
GdkEvent *event)
{
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
- GdkEventButton *event_button = (GdkEventButton *) event;
struct wl_seat *seat;
+ GdkWaylandDevice *device;
double x, y;
- GdkWaylandDeviceData *device;
switch (event->type)
{
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
+ case GDK_TOUCH_BEGIN:
+ case GDK_TOUCH_END:
break;
default:
return FALSE;
@@ -2004,14 +2007,13 @@ gdk_wayland_window_show_window_menu (GdkWindow *window,
if (!impl->xdg_surface)
return FALSE;
- seat = gdk_wayland_device_get_wl_seat (event_button->device);
- device = wl_seat_get_user_data (seat);
-
+ device = GDK_WAYLAND_DEVICE (gdk_event_get_device (event));
+ seat = gdk_wayland_device_get_wl_seat (GDK_DEVICE (device));
gdk_event_get_coords (event, &x, &y);
xdg_surface_show_window_menu (impl->xdg_surface,
seat,
- _gdk_wayland_device_get_button_press_serial (device),
+ _gdk_wayland_device_get_implicit_grab_serial (device, event),
x, y);
return TRUE;
}