[gtk+/wip/wayland-tablet: 11/23] wayland: Refactor master pointer data into a separate struct
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/wayland-tablet: 11/23] wayland: Refactor master pointer data into a separate struct
- Date: Mon, 22 Jun 2015 17:15:48 +0000 (UTC)
commit bcd9551ec706d0e13495cfdb61ae40452204484f
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Jun 19 17:25:54 2015 +0200
wayland: Refactor master pointer data into a separate struct
This will enable multiple "pointers" to have separate data here.
Will come out useful when adding support for tablets, as they
will have a separate cursor for all purposes.
gdk/wayland/gdkdevice-wayland.c | 347 ++++++++++++++++++++++-----------------
1 files changed, 196 insertions(+), 151 deletions(-)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 15cae7f..8234b45 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -36,6 +36,7 @@
#include <sys/mman.h>
typedef struct _GdkWaylandTouchData GdkWaylandTouchData;
+typedef struct _GdkWaylandPointerData GdkWaylandPointerData;
struct _GdkWaylandTouchData
{
@@ -47,6 +48,30 @@ struct _GdkWaylandTouchData
guint initial_touch : 1;
};
+struct _GdkWaylandPointerData {
+ GdkDevice *device;
+ GdkWindow *focus;
+
+ double surface_x, surface_y;
+
+ GdkModifierType button_modifiers;
+
+ uint32_t time;
+ uint32_t enter_serial;
+ uint32_t press_serial;
+
+ GdkWindow *grab_window;
+ uint32_t grab_time;
+
+ struct wl_surface *pointer_surface;
+ GdkCursor *cursor;
+ guint cursor_timeout_id;
+ guint cursor_image_index;
+
+ guint current_output_scale;
+ GSList *pointer_surface_outputs;
+};
+
struct _GdkWaylandDeviceData
{
guint32 id;
@@ -68,17 +93,11 @@ struct _GdkWaylandDeviceData
GHashTable *touches;
+ GdkWaylandPointerData pointer_info;
+
GdkModifierType key_modifiers;
- GdkModifierType button_modifiers;
- GdkWindow *pointer_focus;
GdkWindow *keyboard_focus;
- struct wl_data_device *data_device;
- double surface_x, surface_y;
- uint32_t time;
- uint32_t enter_serial;
- uint32_t button_press_serial;
- GdkWindow *pointer_grab_window;
- uint32_t pointer_grab_time;
+
gboolean have_server_repeat;
uint32_t server_repeat_rate;
uint32_t server_repeat_delay;
@@ -87,15 +106,9 @@ struct _GdkWaylandDeviceData
guint32 repeat_count;
GSettings *keyboard_settings;
- guint cursor_timeout_id;
- guint cursor_image_index;
-
+ struct wl_data_device *data_device;
GdkDragContext *drop_context;
- struct wl_surface *pointer_surface;
- guint current_output_scale;
- GSList *pointer_surface_outputs;
-
/* Source/dest for non-local dnd */
GdkWindow *foreign_dnd_window;
};
@@ -104,6 +117,7 @@ struct _GdkWaylandDevice
{
GdkDevice parent_instance;
GdkWaylandDeviceData *device;
+ GdkWaylandPointerData *pointer;
};
struct _GdkWaylandDeviceClass
@@ -171,31 +185,35 @@ gdk_wayland_device_get_state (GdkDevice *device,
}
static void
-gdk_wayland_device_stop_window_cursor_animation (GdkWaylandDeviceData *wd)
+gdk_wayland_pointer_stop_cursor_animation (GdkWaylandPointerData *pointer)
{
- if (wd->cursor_timeout_id > 0)
+ if (pointer->cursor_timeout_id > 0)
{
- g_source_remove (wd->cursor_timeout_id);
- wd->cursor_timeout_id = 0;
+ g_source_remove (pointer->cursor_timeout_id);
+ pointer->cursor_timeout_id = 0;
}
- wd->cursor_image_index = 0;
+
+ pointer->cursor_image_index = 0;
}
static gboolean
-gdk_wayland_device_update_window_cursor (GdkWaylandDeviceData *wd)
+gdk_wayland_device_update_window_cursor (GdkDevice *device)
{
+ GdkWaylandDeviceData *wd = GDK_WAYLAND_DEVICE (device)->device;
+ GdkWaylandPointerData *pointer = GDK_WAYLAND_DEVICE (device)->pointer;
struct wl_buffer *buffer;
int x, y, w, h, scale;
guint next_image_index, next_image_delay;
- if (wd->cursor)
+ if (pointer->cursor)
{
- buffer = _gdk_wayland_cursor_get_buffer (wd->cursor, wd->cursor_image_index,
+ buffer = _gdk_wayland_cursor_get_buffer (pointer->cursor,
+ pointer->cursor_image_index,
&x, &y, &w, &h, &scale);
}
else
{
- wd->cursor_timeout_id = 0;
+ pointer->cursor_timeout_id = 0;
return TRUE;
}
@@ -203,37 +221,37 @@ gdk_wayland_device_update_window_cursor (GdkWaylandDeviceData *wd)
return FALSE;
wl_pointer_set_cursor (wd->wl_pointer,
- wd->enter_serial,
- wd->pointer_surface,
+ pointer->enter_serial,
+ pointer->pointer_surface,
x, y);
if (buffer)
{
- wl_surface_attach (wd->pointer_surface, buffer, 0, 0);
- wl_surface_set_buffer_scale (wd->pointer_surface, scale);
- wl_surface_damage (wd->pointer_surface, 0, 0, w, h);
- wl_surface_commit (wd->pointer_surface);
+ wl_surface_attach (pointer->pointer_surface, buffer, 0, 0);
+ wl_surface_set_buffer_scale (pointer->pointer_surface, scale);
+ wl_surface_damage (pointer->pointer_surface, 0, 0, w, h);
+ wl_surface_commit (pointer->pointer_surface);
}
next_image_index =
- _gdk_wayland_cursor_get_next_image_index (wd->cursor,
- wd->cursor_image_index,
+ _gdk_wayland_cursor_get_next_image_index (pointer->cursor,
+ pointer->cursor_image_index,
&next_image_delay);
- if (next_image_index != wd->cursor_image_index)
+ if (next_image_index != pointer->cursor_image_index)
{
guint id;
/* Queue timeout for next frame */
id = g_timeout_add (next_image_delay,
(GSourceFunc)gdk_wayland_device_update_window_cursor,
- wd);
+ device);
g_source_set_name_by_id (id, "[gtk+] gdk_wayland_device_update_window_cursor");
- wd->cursor_timeout_id = id;
- wd->cursor_image_index = next_image_index;
+ pointer->cursor_timeout_id = id;
+ pointer->cursor_image_index = next_image_index;
}
else
- wd->cursor_timeout_id = 0;
+ pointer->cursor_timeout_id = 0;
return FALSE;
}
@@ -244,32 +262,33 @@ gdk_wayland_device_set_window_cursor (GdkDevice *device,
GdkCursor *cursor)
{
GdkWaylandDeviceData *wd = GDK_WAYLAND_DEVICE (device)->device;
+ GdkWaylandPointerData *pointer = GDK_WAYLAND_DEVICE (device)->pointer;
/* Setting the cursor to NULL means that we should use
* the default cursor
*/
if (!cursor)
{
- guint scale = wd->current_output_scale;
+ guint scale = pointer->current_output_scale;
cursor =
_gdk_wayland_display_get_cursor_for_type_with_scale (wd->display,
GDK_LEFT_PTR,
scale);
}
else
- _gdk_wayland_cursor_set_scale (cursor, wd->current_output_scale);
+ _gdk_wayland_cursor_set_scale (cursor, pointer->current_output_scale);
- if (cursor == wd->cursor)
+ if (cursor == pointer->cursor)
return;
- gdk_wayland_device_stop_window_cursor_animation (wd);
+ gdk_wayland_pointer_stop_cursor_animation (pointer);
- if (wd->cursor)
- g_object_unref (wd->cursor);
+ if (pointer->cursor)
+ g_object_unref (pointer->cursor);
- wd->cursor = g_object_ref (cursor);
+ pointer->cursor = g_object_ref (cursor);
- gdk_wayland_device_update_window_cursor (wd);
+ gdk_wayland_device_update_window_cursor (device);
}
static void
@@ -281,30 +300,31 @@ gdk_wayland_device_warp (GdkDevice *device,
}
static void
-get_coordinates (GdkWaylandDeviceData *data,
- double *x,
- double *y,
- double *x_root,
- double *y_root)
+get_coordinates (GdkDevice *device,
+ double *x,
+ double *y,
+ double *x_root,
+ double *y_root)
{
+ GdkWaylandPointerData *pointer = GDK_WAYLAND_DEVICE (device)->pointer;
int root_x, root_y;
if (x)
- *x = data->surface_x;
+ *x = pointer->surface_x;
if (y)
- *y = data->surface_y;
+ *y = pointer->surface_y;
- if (data->pointer_focus)
+ if (pointer->focus)
{
- gdk_window_get_root_coords (data->pointer_focus,
- data->surface_x,
- data->surface_y,
+ gdk_window_get_root_coords (pointer->focus,
+ pointer->surface_x,
+ pointer->surface_y,
&root_x, &root_y);
}
else
{
- root_x = data->surface_x;
- root_y = data->surface_y;
+ root_x = pointer->surface_x;
+ root_y = pointer->surface_y;
}
if (x_root)
@@ -313,6 +333,21 @@ get_coordinates (GdkWaylandDeviceData *data,
*y_root = root_y;
}
+static GdkModifierType
+device_get_modifiers (GdkDevice *device)
+{
+ GdkWaylandDeviceData *wd = GDK_WAYLAND_DEVICE (device)->device;
+ GdkWaylandPointerData *pointer = GDK_WAYLAND_DEVICE (device)->pointer;
+ GdkModifierType mask;
+
+ mask = wd->key_modifiers;
+
+ if (pointer)
+ mask |= pointer->button_modifiers;
+
+ return mask;
+}
+
static void
gdk_wayland_device_query_state (GdkDevice *device,
GdkWindow *window,
@@ -325,19 +360,21 @@ gdk_wayland_device_query_state (GdkDevice *device,
GdkModifierType *mask)
{
GdkWaylandDeviceData *wd;
+ GdkWaylandPointerData *pointer;
GdkScreen *default_screen;
wd = GDK_WAYLAND_DEVICE (device)->device;
+ pointer = GDK_WAYLAND_DEVICE (device)->pointer;
default_screen = gdk_display_get_default_screen (wd->display);
if (root_window)
*root_window = gdk_screen_get_root_window (default_screen);
if (child_window)
- *child_window = wd->pointer_focus;
+ *child_window = pointer->focus;
if (mask)
- *mask = wd->button_modifiers | wd->key_modifiers;
+ *mask = device_get_modifiers (device);
- get_coordinates (wd, win_x, win_y, root_x, root_y);
+ get_coordinates (device, win_x, win_y, root_x, root_y);
}
static GdkGrabStatus
@@ -350,6 +387,7 @@ gdk_wayland_device_grab (GdkDevice *device,
guint32 time_)
{
GdkWaylandDeviceData *wayland_device = GDK_WAYLAND_DEVICE (device)->device;
+ GdkWaylandPointerData *pointer = GDK_WAYLAND_DEVICE (device)->pointer;
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
{
@@ -359,17 +397,17 @@ gdk_wayland_device_grab (GdkDevice *device,
else
{
/* Device is a pointer */
- if (wayland_device->pointer_grab_window != NULL &&
- time_ != 0 && wayland_device->pointer_grab_time > time_)
+ if (pointer->grab_window != NULL &&
+ time_ != 0 && pointer->grab_time > time_)
{
return GDK_GRAB_ALREADY_GRABBED;
}
if (time_ == 0)
- time_ = wayland_device->time;
+ time_ = pointer->time;
- wayland_device->pointer_grab_window = window;
- wayland_device->pointer_grab_time = time_;
+ pointer->grab_window = window;
+ pointer->grab_time = time_;
/* FIXME: This probably breaks if you end up with multiple grabs
* on the same window - but we need to know the input device for
@@ -386,7 +424,7 @@ gdk_wayland_device_grab (GdkDevice *device,
if (cursor)
wayland_device->cursor = g_object_ref (cursor);
- gdk_wayland_device_update_window_cursor (wayland_device);
+ gdk_wayland_device_update_window_cursor (device);
}
return GDK_GRAB_SUCCESS;
@@ -396,7 +434,7 @@ static void
gdk_wayland_device_ungrab (GdkDevice *device,
guint32 time_)
{
- GdkWaylandDeviceData *wayland_device = GDK_WAYLAND_DEVICE (device)->device;
+ GdkWaylandPointerData *pointer = GDK_WAYLAND_DEVICE (device)->pointer;
GdkDisplay *display;
GdkDeviceGrabInfo *grab;
@@ -414,10 +452,10 @@ gdk_wayland_device_ungrab (GdkDevice *device,
if (grab)
grab->serial_end = grab->serial_start;
- gdk_wayland_device_update_window_cursor (wayland_device);
+ gdk_wayland_device_update_window_cursor (device);
- if (wayland_device->pointer_grab_window)
- _gdk_wayland_window_set_device_grabbed (wayland_device->pointer_grab_window,
+ if (pointer->grab_window)
+ _gdk_wayland_window_set_device_grabbed (pointer->grab_window,
NULL,
NULL,
0);
@@ -431,17 +469,18 @@ gdk_wayland_device_window_at_position (GdkDevice *device,
GdkModifierType *mask,
gboolean get_toplevel)
{
- GdkWaylandDeviceData *wd;
+ GdkWaylandPointerData *pointer;
+
+ pointer = GDK_WAYLAND_DEVICE(device)->pointer;
- wd = GDK_WAYLAND_DEVICE(device)->device;
if (win_x)
- *win_x = wd->surface_x;
+ *win_x = pointer->surface_x;
if (win_y)
- *win_y = wd->surface_y;
+ *win_y = pointer->surface_y;
if (mask)
- *mask = wd->button_modifiers | wd->key_modifiers;
+ *mask = device_get_modifiers (device);
- return wd->pointer_focus;
+ return pointer->focus;
}
static void
@@ -608,9 +647,9 @@ data_device_enter (void *data,
data_device, serial, surface, x, y, offer));
/* Update pointer state, so device state queries work during DnD */
- device->pointer_focus = g_object_ref (dest_window);
- device->surface_x = wl_fixed_to_double (x);
- device->surface_y = wl_fixed_to_double (y);
+ device->pointer_info.focus = g_object_ref (dest_window);
+ device->pointer_info.surface_x = wl_fixed_to_double (x);
+ device->pointer_info.surface_y = wl_fixed_to_double (y);
gdk_wayland_drop_context_update_targets (device->drop_context);
@@ -645,7 +684,8 @@ data_device_leave (void *data,
if (!gdk_drag_context_get_dest_window (device->drop_context))
return;
- device->pointer_focus = NULL;
+ g_object_unref (device->pointer_info.focus);
+ device->pointer_info.focus = NULL;
_gdk_wayland_drag_context_set_coords (device->drop_context, -1, -1);
_gdk_wayland_drag_context_emit_event (device->drop_context, GDK_DRAG_LEAVE,
@@ -669,8 +709,8 @@ data_device_motion (void *data,
return;
/* Update pointer state, so device state queries work during DnD */
- device->surface_x = wl_fixed_to_double (x);
- device->surface_y = wl_fixed_to_double (y);
+ device->pointer_info.surface_x = wl_fixed_to_double (x);
+ device->pointer_info.surface_y = wl_fixed_to_double (y);
gdk_wayland_drop_context_update_targets (device->drop_context);
_gdk_wayland_drag_context_set_coords (device->drop_context,
@@ -744,15 +784,15 @@ pointer_handle_enter (void *data,
_gdk_wayland_display_update_serial (wayland_display, serial);
- device->pointer_focus = wl_surface_get_user_data(surface);
- g_object_ref(device->pointer_focus);
+ device->pointer_info.focus = wl_surface_get_user_data(surface);
+ g_object_ref(device->pointer_info.focus);
- device->surface_x = wl_fixed_to_double (sx);
- device->surface_y = wl_fixed_to_double (sy);
- device->enter_serial = serial;
+ device->pointer_info.surface_x = wl_fixed_to_double (sx);
+ device->pointer_info.surface_y = wl_fixed_to_double (sy);
+ device->pointer_info.enter_serial = serial;
event = gdk_event_new (GDK_ENTER_NOTIFY);
- event->crossing.window = g_object_ref (device->pointer_focus);
+ event->crossing.window = g_object_ref (device->pointer_info.focus);
gdk_event_set_device (event, device->master_pointer);
gdk_event_set_source_device (event, device->pointer);
event->crossing.subwindow = NULL;
@@ -762,9 +802,9 @@ pointer_handle_enter (void *data,
event->crossing.focus = TRUE;
event->crossing.state = 0;
- gdk_wayland_device_update_window_cursor (device);
+ gdk_wayland_device_update_window_cursor (device->master_pointer);
- get_coordinates (device,
+ get_coordinates (device->master_pointer,
&event->crossing.x,
&event->crossing.y,
&event->crossing.x_root,
@@ -774,7 +814,7 @@ pointer_handle_enter (void *data,
GDK_NOTE (EVENTS,
g_message ("enter, device %p surface %p",
- device, device->pointer_focus));
+ device, device->pointer_info.focus));
}
static void
@@ -793,13 +833,13 @@ pointer_handle_leave (void *data,
if (!GDK_IS_WINDOW (wl_surface_get_user_data (surface)))
return;
- if (!device->pointer_focus)
+ if (!device->pointer_info.focus)
return;
_gdk_wayland_display_update_serial (wayland_display, serial);
event = gdk_event_new (GDK_LEAVE_NOTIFY);
- event->crossing.window = g_object_ref (device->pointer_focus);
+ event->crossing.window = g_object_ref (device->pointer_info.focus);
gdk_event_set_device (event, device->master_pointer);
gdk_event_set_source_device (event, device->pointer);
event->crossing.subwindow = NULL;
@@ -809,9 +849,9 @@ pointer_handle_leave (void *data,
event->crossing.focus = TRUE;
event->crossing.state = 0;
- gdk_wayland_device_update_window_cursor (device);
+ gdk_wayland_device_update_window_cursor (device->master_pointer);
- get_coordinates (device,
+ get_coordinates (device->master_pointer,
&event->crossing.x,
&event->crossing.y,
&event->crossing.x_root,
@@ -821,13 +861,12 @@ pointer_handle_leave (void *data,
GDK_NOTE (EVENTS,
g_message ("leave, device %p surface %p",
- device, device->pointer_focus));
+ device, device->pointer_info.focus));
- g_object_unref (device->pointer_focus);
+ g_object_unref (device->pointer_info.focus);
+ device->pointer_info.focus = NULL;
if (device->cursor)
- gdk_wayland_device_stop_window_cursor_animation (device);
-
- device->pointer_focus = NULL;
+ gdk_wayland_pointer_stop_cursor_animation (&device->pointer_info);
}
static void
@@ -841,26 +880,26 @@ pointer_handle_motion (void *data,
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (device->display);
GdkEvent *event;
- if (!device->pointer_focus)
+ if (!device->pointer_info.focus)
return;
event = gdk_event_new (GDK_NOTHING);
- device->time = time;
- device->surface_x = wl_fixed_to_double (sx);
- device->surface_y = wl_fixed_to_double (sy);
+ device->pointer_info.time = time;
+ device->pointer_info.surface_x = wl_fixed_to_double (sx);
+ device->pointer_info.surface_y = wl_fixed_to_double (sy);
event->motion.type = GDK_MOTION_NOTIFY;
- event->motion.window = g_object_ref (device->pointer_focus);
+ event->motion.window = g_object_ref (device->pointer_info.focus);
gdk_event_set_device (event, device->master_pointer);
gdk_event_set_source_device (event, device->pointer);
event->motion.time = time;
event->motion.axes = NULL;
- event->motion.state = device->button_modifiers | device->key_modifiers;
+ event->motion.state = device_get_modifiers (device->master_pointer);
event->motion.is_hint = 0;
gdk_event_set_screen (event, display->screen);
- get_coordinates (device,
+ get_coordinates (device->master_pointer,
&event->motion.x,
&event->motion.y,
&event->motion.x_root,
@@ -887,7 +926,7 @@ pointer_handle_button (void *data,
uint32_t modifier;
int gdk_button;
- if (!device->pointer_focus)
+ if (!device->pointer_info.focus)
return;
_gdk_wayland_display_update_serial (display, serial);
@@ -905,21 +944,21 @@ pointer_handle_button (void *data,
break;
}
- device->time = time;
+ device->pointer_info.time = time;
if (state)
- device->button_press_serial = serial;
+ device->pointer_info.press_serial = serial;
event = gdk_event_new (state ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE);
- event->button.window = g_object_ref (device->pointer_focus);
+ event->button.window = g_object_ref (device->pointer_info.focus);
gdk_event_set_device (event, device->master_pointer);
gdk_event_set_source_device (event, device->pointer);
event->button.time = time;
event->button.axes = NULL;
- event->button.state = device->button_modifiers | device->key_modifiers;
+ event->button.state = device_get_modifiers (device->master_pointer);
event->button.button = gdk_button;
gdk_event_set_screen (event, display->screen);
- get_coordinates (device,
+ get_coordinates (device->master_pointer,
&event->button.x,
&event->button.y,
&event->button.x_root,
@@ -927,9 +966,9 @@ pointer_handle_button (void *data,
modifier = 1 << (8 + gdk_button - 1);
if (state)
- device->button_modifiers |= modifier;
+ device->pointer_info.button_modifiers |= modifier;
else
- device->button_modifiers &= ~modifier;
+ device->pointer_info.button_modifiers &= ~modifier;
GDK_NOTE (EVENTS,
g_message ("button %d %s, device %p state %d",
@@ -953,7 +992,7 @@ pointer_handle_axis (void *data,
GdkEvent *event;
gdouble delta_x, delta_y;
- if (!device->pointer_focus)
+ if (!device->pointer_info.focus)
return;
/* get the delta and convert it into the expected range */
@@ -971,19 +1010,19 @@ pointer_handle_axis (void *data,
g_return_if_reached ();
}
- device->time = time;
+ device->pointer_info.time = time;
event = gdk_event_new (GDK_SCROLL);
- event->scroll.window = g_object_ref (device->pointer_focus);
+ event->scroll.window = g_object_ref (device->pointer_info.focus);
gdk_event_set_device (event, device->master_pointer);
gdk_event_set_source_device (event, device->pointer);
event->scroll.time = time;
event->scroll.direction = GDK_SCROLL_SMOOTH;
event->scroll.delta_x = delta_x;
event->scroll.delta_y = delta_y;
- event->scroll.state = device->button_modifiers | device->key_modifiers;
+ event->scroll.state = device_get_modifiers (device->master_pointer);
gdk_event_set_screen (event, display->screen);
- get_coordinates (device,
+ get_coordinates (device->master_pointer,
&event->scroll.x,
&event->scroll.y,
&event->scroll.x_root,
@@ -1235,7 +1274,7 @@ deliver_key_event (GdkWaylandDeviceData *device,
sym = xkb_state_key_get_one_sym (xkb_state, key);
- device->time = time_;
+ device->pointer_info.time = time_;
device->key_modifiers = gdk_keymap_get_modifier_state (keymap);
event = gdk_event_new (state ? GDK_KEY_PRESS : GDK_KEY_RELEASE);
@@ -1243,7 +1282,7 @@ deliver_key_event (GdkWaylandDeviceData *device,
gdk_event_set_device (event, device->master_keyboard);
gdk_event_set_source_device (event, device->keyboard);
event->key.time = time_;
- event->key.state = device->button_modifiers | device->key_modifiers;
+ event->key.state = device_get_modifiers (device->master_pointer);
event->key.group = 0;
event->key.hardware_keycode = key;
event->key.keyval = sym;
@@ -1307,7 +1346,7 @@ keyboard_repeat (gpointer data)
{
GdkWaylandDeviceData *device = data;
- return deliver_key_event (device, device->time, device->repeat_key, 1);
+ return deliver_key_event (device, device->pointer_info.time, device->repeat_key, 1);
}
static void
@@ -1414,9 +1453,12 @@ _create_touch_event (GdkWaylandDeviceData *device,
gdk_event_set_device (event, device->master_pointer);
gdk_event_set_source_device (event, device->touch);
event->touch.time = time;
- event->touch.state = device->button_modifiers | device->key_modifiers;
gdk_event_set_screen (event, display->screen);
event->touch.sequence = GDK_SLOT_TO_EVENT_SEQUENCE (touch->id);
+ event->touch.state = device->key_modifiers;
+
+ if (evtype != GDK_TOUCH_BEGIN)
+ event->touch.state |= GDK_BUTTON1_MASK;
if (touch->initial_touch)
{
@@ -1730,6 +1772,7 @@ init_devices (GdkWaylandDeviceData *device)
"device-manager", device_manager,
NULL);
GDK_WAYLAND_DEVICE (device->master_pointer)->device = device;
+ GDK_WAYLAND_DEVICE (device->master_pointer)->pointer = &device->pointer_info;
device_manager->devices =
g_list_prepend (device_manager->devices, device->master_pointer);
@@ -1757,9 +1800,11 @@ init_devices (GdkWaylandDeviceData *device)
}
static void
-pointer_surface_update_scale (GdkWaylandDeviceData *device)
+pointer_surface_update_scale (GdkDevice *device)
{
- GdkWaylandDisplay *wayland_display = GDK_WAYLAND_DISPLAY (device->display);
+ GdkWaylandDeviceData *wd = GDK_WAYLAND_DEVICE (device)->device;
+ GdkWaylandPointerData *pointer = GDK_WAYLAND_DEVICE (device)->pointer;
+ GdkWaylandDisplay *wayland_display = GDK_WAYLAND_DISPLAY (wd->display);
guint32 scale;
GSList *l;
@@ -1770,7 +1815,7 @@ pointer_surface_update_scale (GdkWaylandDeviceData *device)
}
scale = 1;
- for (l = device->pointer_surface_outputs; l != NULL; l = l->next)
+ for (l = pointer->pointer_surface_outputs; l != NULL; l = l->next)
{
guint32 output_scale =
_gdk_wayland_screen_get_output_scale (wayland_display->screen,
@@ -1778,10 +1823,10 @@ pointer_surface_update_scale (GdkWaylandDeviceData *device)
scale = MAX (scale, output_scale);
}
- device->current_output_scale = scale;
+ pointer->current_output_scale = scale;
- if (device->cursor)
- _gdk_wayland_cursor_set_scale (device->cursor, scale);
+ if (pointer->cursor)
+ _gdk_wayland_cursor_set_scale (pointer->cursor, scale);
gdk_wayland_device_update_window_cursor (device);
}
@@ -1798,10 +1843,10 @@ pointer_surface_enter (void *data,
g_message ("pointer surface of device %p entered output %p",
device, output));
- device->pointer_surface_outputs =
- g_slist_append (device->pointer_surface_outputs, output);
+ device->pointer_info.pointer_surface_outputs =
+ g_slist_append (device->pointer_info.pointer_surface_outputs, output);
- pointer_surface_update_scale (device);
+ pointer_surface_update_scale (device->master_pointer);
}
static void
@@ -1815,10 +1860,10 @@ pointer_surface_leave (void *data,
g_message ("pointer surface of device %p left output %p",
device, output));
- device->pointer_surface_outputs =
- g_slist_remove (device->pointer_surface_outputs, output);
+ device->pointer_info.pointer_surface_outputs =
+ g_slist_remove (device->pointer_info.pointer_surface_outputs, output);
- pointer_surface_update_scale (device);
+ pointer_surface_update_scale (device->master_pointer);
}
static const struct wl_surface_listener pointer_surface_listener = {
@@ -1877,10 +1922,10 @@ _gdk_wayland_device_manager_add_seat (GdkDeviceManager *device_manager,
wl_data_device_add_listener (device->data_device,
&data_device_listener, device);
- device->current_output_scale = 1;
- device->pointer_surface =
+ device->pointer_info.current_output_scale = 1;
+ device->pointer_info.pointer_surface =
wl_compositor_create_surface (display_wayland->compositor);
- wl_surface_add_listener (device->pointer_surface,
+ wl_surface_add_listener (device->pointer_info.pointer_surface,
&pointer_surface_listener,
device);
@@ -1903,7 +1948,7 @@ _gdk_wayland_device_manager_remove_seat (GdkDeviceManager *manager,
{
seat_handle_capabilities (device, device->wl_seat, 0);
g_object_unref (device->keymap);
- wl_surface_destroy (device->pointer_surface);
+ wl_surface_destroy (device->pointer_info.pointer_surface);
/* FIXME: destroy data_device */
g_clear_object (&device->keyboard_settings);
g_hash_table_destroy (device->touches);
@@ -2012,7 +2057,7 @@ _gdk_wayland_device_get_implicit_grab_serial (GdkWaylandDevice *device,
if (touch)
return touch->touch_down_serial;
else
- return device->device->button_press_serial;
+ return device->pointer->press_serial;
}
uint32_t
@@ -2028,8 +2073,8 @@ _gdk_wayland_device_get_last_implicit_grab_serial (GdkWaylandDevice *device,
if (sequence)
*sequence = NULL;
- if (device->device->button_press_serial > serial)
- serial = device->device->button_press_serial;
+ if (device->pointer->press_serial > serial)
+ serial = device->pointer->press_serial;
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &touch))
{
@@ -2086,22 +2131,22 @@ gdk_wayland_device_set_selection (GdkDevice *gdk_device,
void
gdk_wayland_device_unset_grab (GdkDevice *gdk_device)
{
- GdkWaylandDeviceData *device;
+ GdkWaylandPointerData *pointer;
GdkEventSequence *sequence;
GdkModifierType state;
GdkEvent *event;
guint button;
gdouble x, y;
- device = GDK_WAYLAND_DEVICE (gdk_device)->device;
+ pointer = GDK_WAYLAND_DEVICE (gdk_device)->pointer;
_gdk_wayland_device_get_last_implicit_grab_serial (GDK_WAYLAND_DEVICE (gdk_device), &sequence);
- gdk_window_get_device_position_double (device->pointer_grab_window,
+ gdk_window_get_device_position_double (pointer->grab_window,
gdk_device, &x, &y, &state);
if (sequence)
{
event = gdk_event_new (GDK_TOUCH_END);
- event->touch.window = g_object_ref (device->pointer_grab_window);
+ event->touch.window = g_object_ref (pointer->grab_window);
event->touch.send_event = TRUE;
event->touch.sequence = sequence;
event->touch.time = GDK_CURRENT_TIME;
@@ -2120,7 +2165,7 @@ gdk_wayland_device_unset_grab (GdkDevice *gdk_device)
return;
event = gdk_event_new (GDK_BUTTON_RELEASE);
- event->button.window = g_object_ref (device->pointer_grab_window);
+ event->button.window = g_object_ref (pointer->grab_window);
event->button.send_event = TRUE;
event->button.button = button;
event->button.time = GDK_CURRENT_TIME;
@@ -2130,7 +2175,7 @@ gdk_wayland_device_unset_grab (GdkDevice *gdk_device)
else
return;
- device->button_modifiers = 0;
+ pointer->button_modifiers = 0;
gdk_event_set_device (event, gdk_device);
gdk_event_set_source_device (event, gdk_device);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]