2010-12-18 20:38:49 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2010-12-18 20:38:49 +00:00
|
|
|
*/
|
|
|
|
|
2014-08-21 17:19:26 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2011-12-14 14:09:52 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2011-02-09 20:27:08 +00:00
|
|
|
#include <string.h>
|
2019-04-22 01:14:46 +00:00
|
|
|
#include "gdksurfaceprivate.h"
|
|
|
|
#include "gdktypes.h"
|
2017-12-02 20:54:36 +00:00
|
|
|
#include "gdkclipboard-wayland.h"
|
|
|
|
#include "gdkclipboardprivate.h"
|
2010-12-18 20:38:49 +00:00
|
|
|
#include "gdkprivate-wayland.h"
|
2015-11-26 18:40:56 +00:00
|
|
|
#include "gdkseat-wayland.h"
|
2010-12-18 20:38:49 +00:00
|
|
|
#include "gdkwayland.h"
|
2011-02-09 20:27:08 +00:00
|
|
|
#include "gdkkeysyms.h"
|
2020-04-05 15:29:12 +00:00
|
|
|
#include "gdkkeysprivate.h"
|
2017-11-15 18:05:48 +00:00
|
|
|
#include "gdkcursorprivate.h"
|
2011-02-09 20:27:08 +00:00
|
|
|
#include "gdkdeviceprivate.h"
|
2016-08-04 17:40:14 +00:00
|
|
|
#include "gdkdevicepadprivate.h"
|
2016-04-09 19:20:07 +00:00
|
|
|
#include "gdkdevicetoolprivate.h"
|
2018-06-14 02:58:50 +00:00
|
|
|
#include "gdkdropprivate.h"
|
2017-12-03 04:39:08 +00:00
|
|
|
#include "gdkprimary-wayland.h"
|
2015-11-26 18:40:56 +00:00
|
|
|
#include "gdkseatprivate.h"
|
2015-11-18 03:38:28 +00:00
|
|
|
#include "pointer-gestures-unstable-v1-client-protocol.h"
|
2016-05-13 13:19:04 +00:00
|
|
|
#include "tablet-unstable-v2-client-protocol.h"
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2012-06-18 15:02:37 +00:00
|
|
|
#include <xkbcommon/xkbcommon.h>
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2011-12-14 14:09:52 +00:00
|
|
|
#include <sys/time.h>
|
2012-07-16 11:33:35 +00:00
|
|
|
#include <sys/mman.h>
|
2018-05-01 14:28:57 +00:00
|
|
|
#if defined(HAVE_DEV_EVDEV_INPUT_H)
|
|
|
|
#include <dev/evdev/input.h>
|
|
|
|
#elif defined(HAVE_LINUX_INPUT_H)
|
2015-06-22 16:28:46 +00:00
|
|
|
#include <linux/input.h>
|
2018-05-01 14:28:57 +00:00
|
|
|
#endif
|
2011-12-14 14:09:52 +00:00
|
|
|
|
2015-11-16 11:51:42 +00:00
|
|
|
#define BUTTON_BASE (BTN_LEFT - 1) /* Used to translate to 1-indexed buttons */
|
|
|
|
|
2017-10-10 16:17:43 +00:00
|
|
|
#ifndef BTN_STYLUS3
|
|
|
|
#define BTN_STYLUS3 0x149 /* Linux 4.15 */
|
|
|
|
#endif
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
#define GDK_SEAT_NOTE(seat,type,action) GDK_DISPLAY_NOTE(gdk_seat_get_display (GDK_SEAT (seat)),type,action)
|
|
|
|
|
2016-08-04 17:40:14 +00:00
|
|
|
typedef struct _GdkWaylandDevicePad GdkWaylandDevicePad;
|
|
|
|
typedef struct _GdkWaylandDevicePadClass GdkWaylandDevicePadClass;
|
|
|
|
|
2014-04-17 12:19:39 +00:00
|
|
|
typedef struct _GdkWaylandTouchData GdkWaylandTouchData;
|
2015-10-20 03:21:54 +00:00
|
|
|
typedef struct _GdkWaylandPointerFrameData GdkWaylandPointerFrameData;
|
2015-06-19 15:25:54 +00:00
|
|
|
typedef struct _GdkWaylandPointerData GdkWaylandPointerData;
|
2015-01-19 00:32:24 +00:00
|
|
|
typedef struct _GdkWaylandTabletData GdkWaylandTabletData;
|
|
|
|
typedef struct _GdkWaylandTabletToolData GdkWaylandTabletToolData;
|
2016-08-04 17:36:32 +00:00
|
|
|
typedef struct _GdkWaylandTabletPadGroupData GdkWaylandTabletPadGroupData;
|
|
|
|
typedef struct _GdkWaylandTabletPadData GdkWaylandTabletPadData;
|
2014-04-17 12:19:39 +00:00
|
|
|
|
|
|
|
struct _GdkWaylandTouchData
|
|
|
|
{
|
|
|
|
uint32_t id;
|
2020-07-24 20:32:16 +00:00
|
|
|
double x;
|
|
|
|
double y;
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface;
|
2014-08-13 19:05:12 +00:00
|
|
|
uint32_t touch_down_serial;
|
2014-04-17 12:19:39 +00:00
|
|
|
guint initial_touch : 1;
|
|
|
|
};
|
|
|
|
|
2015-10-20 03:21:54 +00:00
|
|
|
struct _GdkWaylandPointerFrameData
|
|
|
|
{
|
|
|
|
GdkEvent *event;
|
|
|
|
|
|
|
|
/* Specific to the scroll event */
|
2020-07-24 20:32:16 +00:00
|
|
|
double delta_x, delta_y;
|
2015-10-20 03:21:54 +00:00
|
|
|
int32_t discrete_x, discrete_y;
|
2015-10-21 00:14:40 +00:00
|
|
|
gint8 is_scroll_stop;
|
2016-06-01 03:14:30 +00:00
|
|
|
enum wl_pointer_axis_source source;
|
2015-10-20 03:21:54 +00:00
|
|
|
};
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
struct _GdkWaylandPointerData {
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *focus;
|
2015-06-19 15:25:54 +00:00
|
|
|
|
|
|
|
double surface_x, surface_y;
|
|
|
|
|
|
|
|
GdkModifierType button_modifiers;
|
|
|
|
|
|
|
|
uint32_t time;
|
|
|
|
uint32_t enter_serial;
|
|
|
|
uint32_t press_serial;
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *grab_surface;
|
2015-06-19 15:25:54 +00:00
|
|
|
uint32_t grab_time;
|
|
|
|
|
|
|
|
struct wl_surface *pointer_surface;
|
2019-04-22 09:31:12 +00:00
|
|
|
guint cursor_is_default: 1;
|
2015-06-19 15:25:54 +00:00
|
|
|
GdkCursor *cursor;
|
|
|
|
guint cursor_timeout_id;
|
|
|
|
guint cursor_image_index;
|
|
|
|
guint cursor_image_delay;
|
|
|
|
|
|
|
|
guint current_output_scale;
|
|
|
|
GSList *pointer_surface_outputs;
|
|
|
|
|
|
|
|
/* Accumulated event data for a pointer frame */
|
|
|
|
GdkWaylandPointerFrameData frame;
|
|
|
|
};
|
|
|
|
|
2015-01-19 00:32:24 +00:00
|
|
|
struct _GdkWaylandTabletToolData
|
|
|
|
{
|
|
|
|
GdkSeat *seat;
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool;
|
2015-01-19 00:32:24 +00:00
|
|
|
GdkAxisFlags axes;
|
|
|
|
GdkDeviceToolType type;
|
|
|
|
guint64 hardware_serial;
|
|
|
|
guint64 hardware_id_wacom;
|
|
|
|
|
|
|
|
GdkDeviceTool *tool;
|
|
|
|
GdkWaylandTabletData *current_tablet;
|
|
|
|
};
|
|
|
|
|
2016-08-04 17:36:32 +00:00
|
|
|
struct _GdkWaylandTabletPadGroupData
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadData *pad;
|
|
|
|
struct zwp_tablet_pad_group_v2 *wp_tablet_pad_group;
|
|
|
|
GList *rings;
|
|
|
|
GList *strips;
|
|
|
|
GList *buttons;
|
|
|
|
|
|
|
|
guint mode_switch_serial;
|
|
|
|
guint n_modes;
|
|
|
|
guint current_mode;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
guint source;
|
|
|
|
gboolean is_stop;
|
2020-07-24 20:32:16 +00:00
|
|
|
double value;
|
2016-08-04 17:36:32 +00:00
|
|
|
} axis_tmp_info;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GdkWaylandTabletPadData
|
|
|
|
{
|
|
|
|
GdkSeat *seat;
|
|
|
|
struct zwp_tablet_pad_v2 *wp_tablet_pad;
|
|
|
|
GdkDevice *device;
|
|
|
|
|
|
|
|
GdkWaylandTabletData *current_tablet;
|
|
|
|
|
|
|
|
guint enter_serial;
|
|
|
|
uint32_t n_buttons;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *path;
|
2016-08-04 17:36:32 +00:00
|
|
|
|
|
|
|
GList *rings;
|
|
|
|
GList *strips;
|
|
|
|
GList *mode_groups;
|
|
|
|
};
|
|
|
|
|
2015-01-19 00:32:24 +00:00
|
|
|
struct _GdkWaylandTabletData
|
|
|
|
{
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_v2 *wp_tablet;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *name;
|
|
|
|
char *path;
|
2015-01-19 00:32:24 +00:00
|
|
|
uint32_t vid;
|
|
|
|
uint32_t pid;
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
GdkDevice *logical_device;
|
2015-01-19 00:32:24 +00:00
|
|
|
GdkDevice *stylus_device;
|
|
|
|
GdkSeat *seat;
|
|
|
|
GdkWaylandPointerData pointer_info;
|
|
|
|
|
2016-08-04 17:36:32 +00:00
|
|
|
GList *pads;
|
|
|
|
|
2015-01-19 00:32:24 +00:00
|
|
|
GdkWaylandTabletToolData *current_tool;
|
2015-06-22 16:02:50 +00:00
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
int axis_indices[GDK_AXIS_LAST];
|
2020-07-24 20:32:16 +00:00
|
|
|
double *axes;
|
2015-01-19 00:32:24 +00:00
|
|
|
};
|
|
|
|
|
2015-11-26 18:40:56 +00:00
|
|
|
struct _GdkWaylandSeat
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2015-11-26 18:40:56 +00:00
|
|
|
GdkSeat parent_instance;
|
|
|
|
|
2013-03-27 02:57:46 +00:00
|
|
|
guint32 id;
|
2012-07-11 13:29:43 +00:00
|
|
|
struct wl_seat *wl_seat;
|
|
|
|
struct wl_pointer *wl_pointer;
|
|
|
|
struct wl_keyboard *wl_keyboard;
|
2014-04-17 12:19:39 +00:00
|
|
|
struct wl_touch *wl_touch;
|
2015-11-18 03:38:28 +00:00
|
|
|
struct zwp_pointer_gesture_swipe_v1 *wp_pointer_gesture_swipe;
|
|
|
|
struct zwp_pointer_gesture_pinch_v1 *wp_pointer_gesture_pinch;
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_seat_v2 *wp_tablet_seat;
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2011-02-09 20:27:08 +00:00
|
|
|
GdkDisplay *display;
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
GdkDevice *logical_pointer;
|
|
|
|
GdkDevice *logical_keyboard;
|
2011-02-09 20:27:08 +00:00
|
|
|
GdkDevice *pointer;
|
2016-06-01 03:14:30 +00:00
|
|
|
GdkDevice *wheel_scrolling;
|
|
|
|
GdkDevice *finger_scrolling;
|
|
|
|
GdkDevice *continuous_scrolling;
|
2011-02-09 20:27:08 +00:00
|
|
|
GdkDevice *keyboard;
|
2020-06-18 18:22:20 +00:00
|
|
|
GdkDevice *logical_touch;
|
2014-04-17 12:19:39 +00:00
|
|
|
GdkDevice *touch;
|
2013-03-21 02:42:44 +00:00
|
|
|
GdkCursor *cursor;
|
2012-07-16 18:02:41 +00:00
|
|
|
GdkKeymap *keymap;
|
|
|
|
|
2014-04-17 12:19:39 +00:00
|
|
|
GHashTable *touches;
|
2015-01-19 00:32:24 +00:00
|
|
|
GList *tablets;
|
|
|
|
GList *tablet_tools;
|
2016-08-04 17:36:32 +00:00
|
|
|
GList *tablet_pads;
|
2014-04-17 12:19:39 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
GdkWaylandPointerData pointer_info;
|
|
|
|
GdkWaylandPointerData touch_info;
|
|
|
|
|
2015-06-01 13:53:11 +00:00
|
|
|
GdkModifierType key_modifiers;
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *keyboard_focus;
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *grab_surface;
|
2015-06-19 15:25:54 +00:00
|
|
|
uint32_t grab_time;
|
2014-07-25 13:37:06 +00:00
|
|
|
gboolean have_server_repeat;
|
|
|
|
uint32_t server_repeat_rate;
|
|
|
|
uint32_t server_repeat_delay;
|
2016-02-25 18:58:42 +00:00
|
|
|
|
2018-05-06 00:06:53 +00:00
|
|
|
struct wl_data_offer *pending_offer;
|
|
|
|
GdkContentFormatsBuilder *pending_builder;
|
|
|
|
GdkDragAction pending_source_actions;
|
|
|
|
GdkDragAction pending_action;
|
|
|
|
|
2016-02-25 18:58:42 +00:00
|
|
|
struct wl_callback *repeat_callback;
|
2012-01-15 04:48:51 +00:00
|
|
|
guint32 repeat_timer;
|
|
|
|
guint32 repeat_key;
|
|
|
|
guint32 repeat_count;
|
2016-04-26 01:10:09 +00:00
|
|
|
gint64 repeat_deadline;
|
2015-06-19 15:25:54 +00:00
|
|
|
uint32_t keyboard_time;
|
2016-06-30 10:56:21 +00:00
|
|
|
uint32_t keyboard_key_serial;
|
2013-03-28 12:08:43 +00:00
|
|
|
|
2017-12-02 20:54:36 +00:00
|
|
|
GdkClipboard *clipboard;
|
|
|
|
GdkClipboard *primary_clipboard;
|
2016-02-04 16:33:51 +00:00
|
|
|
struct wl_data_device *data_device;
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *drag;
|
2018-05-30 02:04:51 +00:00
|
|
|
GdkDrop *drop;
|
2012-07-11 13:43:16 +00:00
|
|
|
|
2015-07-09 17:36:30 +00:00
|
|
|
/* Some tracking on gesture events */
|
|
|
|
guint gesture_n_fingers;
|
2020-07-24 20:32:16 +00:00
|
|
|
double gesture_scale;
|
2016-01-08 20:45:03 +00:00
|
|
|
|
|
|
|
GdkCursor *grab_cursor;
|
2011-02-09 20:27:08 +00:00
|
|
|
};
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2015-11-26 18:40:56 +00:00
|
|
|
G_DEFINE_TYPE (GdkWaylandSeat, gdk_wayland_seat, GDK_TYPE_SEAT)
|
|
|
|
|
2013-01-27 13:28:43 +00:00
|
|
|
struct _GdkWaylandDevice
|
2011-02-09 20:27:08 +00:00
|
|
|
{
|
|
|
|
GdkDevice parent_instance;
|
2020-06-18 18:22:20 +00:00
|
|
|
GdkWaylandTouchData *emulating_touch; /* Only used on wd->logical_touch */
|
2015-06-19 15:25:54 +00:00
|
|
|
GdkWaylandPointerData *pointer;
|
2011-02-09 20:27:08 +00:00
|
|
|
};
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2013-01-27 13:28:43 +00:00
|
|
|
struct _GdkWaylandDeviceClass
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2011-02-09 20:27:08 +00:00
|
|
|
GdkDeviceClass parent_class;
|
|
|
|
};
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2013-01-27 13:28:43 +00:00
|
|
|
G_DEFINE_TYPE (GdkWaylandDevice, gdk_wayland_device, GDK_TYPE_DEVICE)
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2016-08-04 17:40:14 +00:00
|
|
|
struct _GdkWaylandDevicePad
|
|
|
|
{
|
|
|
|
GdkWaylandDevice parent_instance;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GdkWaylandDevicePadClass
|
|
|
|
{
|
|
|
|
GdkWaylandDeviceClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void gdk_wayland_device_pad_iface_init (GdkDevicePadInterface *iface);
|
2019-04-18 17:31:55 +00:00
|
|
|
static void init_pointer_data (GdkWaylandPointerData *pointer_data,
|
|
|
|
GdkDisplay *display_wayland,
|
2020-06-18 18:22:20 +00:00
|
|
|
GdkDevice *logical_device);
|
2019-02-15 01:42:23 +00:00
|
|
|
static void pointer_surface_update_scale (GdkDevice *device);
|
2016-08-04 17:40:14 +00:00
|
|
|
|
2017-04-28 21:56:29 +00:00
|
|
|
#define GDK_TYPE_WAYLAND_DEVICE_PAD (gdk_wayland_device_pad_get_type ())
|
|
|
|
GType gdk_wayland_device_pad_get_type (void);
|
|
|
|
|
2016-08-04 17:40:14 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GdkWaylandDevicePad, gdk_wayland_device_pad,
|
|
|
|
GDK_TYPE_WAYLAND_DEVICE,
|
|
|
|
G_IMPLEMENT_INTERFACE (GDK_TYPE_DEVICE_PAD,
|
|
|
|
gdk_wayland_device_pad_iface_init))
|
|
|
|
|
2014-08-22 11:33:14 +00:00
|
|
|
#define GDK_SLOT_TO_EVENT_SEQUENCE(s) ((GdkEventSequence *) GUINT_TO_POINTER((s) + 1))
|
|
|
|
#define GDK_EVENT_SEQUENCE_TO_SLOT(s) (GPOINTER_TO_UINT(s) - 1)
|
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
static void deliver_key_event (GdkWaylandSeat *seat,
|
2016-02-25 18:58:42 +00:00
|
|
|
uint32_t time_,
|
|
|
|
uint32_t key,
|
2017-02-02 09:43:45 +00:00
|
|
|
uint32_t state,
|
|
|
|
gboolean from_key_repeat);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
|
|
static void
|
2013-01-27 13:28:43 +00:00
|
|
|
gdk_wayland_device_get_state (GdkDevice *device,
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface,
|
2020-07-24 20:32:16 +00:00
|
|
|
double *axes,
|
2013-01-27 13:28:43 +00:00
|
|
|
GdkModifierType *mask)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
double x, y;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2019-03-25 14:12:01 +00:00
|
|
|
gdk_surface_get_device_position (surface, device, &x, &y, mask);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
|
|
|
if (axes)
|
|
|
|
{
|
2013-07-03 09:52:58 +00:00
|
|
|
axes[0] = x;
|
|
|
|
axes[1] = y;
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-28 12:08:43 +00:00
|
|
|
static void
|
2015-06-19 15:25:54 +00:00
|
|
|
gdk_wayland_pointer_stop_cursor_animation (GdkWaylandPointerData *pointer)
|
2013-03-28 12:08:43 +00:00
|
|
|
{
|
2015-06-19 15:25:54 +00:00
|
|
|
if (pointer->cursor_timeout_id > 0)
|
2013-03-28 12:08:43 +00:00
|
|
|
{
|
2015-06-19 15:25:54 +00:00
|
|
|
g_source_remove (pointer->cursor_timeout_id);
|
|
|
|
pointer->cursor_timeout_id = 0;
|
2017-11-05 16:20:42 +00:00
|
|
|
pointer->cursor_image_delay = 0;
|
2013-03-28 12:08:43 +00:00
|
|
|
}
|
2015-06-19 15:25:54 +00:00
|
|
|
|
|
|
|
pointer->cursor_image_index = 0;
|
2013-03-28 12:08:43 +00:00
|
|
|
}
|
|
|
|
|
2015-01-19 00:32:24 +00:00
|
|
|
static GdkWaylandTabletData *
|
2017-11-25 04:00:40 +00:00
|
|
|
gdk_wayland_seat_find_tablet (GdkWaylandSeat *seat,
|
|
|
|
GdkDevice *device)
|
2015-01-19 00:32:24 +00:00
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = seat->tablets; l; l = l->next)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletData *tablet = l->data;
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (tablet->logical_device == device ||
|
2020-06-22 21:19:35 +00:00
|
|
|
tablet->stylus_device == device)
|
2015-01-19 00:32:24 +00:00
|
|
|
return tablet;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-08-04 17:40:14 +00:00
|
|
|
static GdkWaylandTabletPadData *
|
2017-11-25 04:00:40 +00:00
|
|
|
gdk_wayland_seat_find_pad (GdkWaylandSeat *seat,
|
|
|
|
GdkDevice *device)
|
2016-08-04 17:40:14 +00:00
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = seat->tablet_pads; l; l = l->next)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadData *pad = l->data;
|
|
|
|
|
|
|
|
if (pad->device == device)
|
|
|
|
return pad;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-28 12:08:43 +00:00
|
|
|
static gboolean
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_wayland_device_update_surface_cursor (GdkDevice *device)
|
2013-03-28 12:08:43 +00:00
|
|
|
{
|
2015-06-19 15:25:54 +00:00
|
|
|
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
|
|
|
|
GdkWaylandPointerData *pointer = GDK_WAYLAND_DEVICE (device)->pointer;
|
2013-03-28 12:08:43 +00:00
|
|
|
struct wl_buffer *buffer;
|
2013-08-07 10:18:38 +00:00
|
|
|
int x, y, w, h, scale;
|
2013-03-28 12:08:43 +00:00
|
|
|
guint next_image_index, next_image_delay;
|
2015-09-16 10:21:36 +00:00
|
|
|
gboolean retval = G_SOURCE_REMOVE;
|
2015-01-19 00:32:24 +00:00
|
|
|
GdkWaylandTabletData *tablet;
|
|
|
|
|
2017-11-25 04:00:40 +00:00
|
|
|
tablet = gdk_wayland_seat_find_tablet (seat, device);
|
2013-03-28 12:08:43 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
if (pointer->cursor)
|
2014-09-01 17:11:02 +00:00
|
|
|
{
|
2017-11-03 21:41:31 +00:00
|
|
|
buffer = _gdk_wayland_cursor_get_buffer (GDK_WAYLAND_DISPLAY (seat->display),
|
|
|
|
pointer->cursor,
|
|
|
|
pointer->current_output_scale,
|
2015-06-19 15:25:54 +00:00
|
|
|
pointer->cursor_image_index,
|
2014-09-01 17:11:02 +00:00
|
|
|
&x, &y, &w, &h, &scale);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-19 15:25:54 +00:00
|
|
|
pointer->cursor_timeout_id = 0;
|
2018-05-09 20:13:10 +00:00
|
|
|
return G_SOURCE_REMOVE;
|
2014-09-01 17:11:02 +00:00
|
|
|
}
|
2014-06-23 16:21:08 +00:00
|
|
|
|
2015-01-19 00:32:24 +00:00
|
|
|
if (tablet)
|
|
|
|
{
|
|
|
|
if (!tablet->current_tool)
|
2018-05-09 20:13:10 +00:00
|
|
|
{
|
|
|
|
pointer->cursor_timeout_id = 0;
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
}
|
2015-01-19 00:32:24 +00:00
|
|
|
|
2016-05-13 13:19:04 +00:00
|
|
|
zwp_tablet_tool_v2_set_cursor (tablet->current_tool->wp_tablet_tool,
|
2015-01-19 00:32:24 +00:00
|
|
|
pointer->enter_serial,
|
|
|
|
pointer->pointer_surface,
|
|
|
|
x, y);
|
|
|
|
}
|
|
|
|
else if (seat->wl_pointer)
|
|
|
|
{
|
|
|
|
wl_pointer_set_cursor (seat->wl_pointer,
|
|
|
|
pointer->enter_serial,
|
|
|
|
pointer->pointer_surface,
|
|
|
|
x, y);
|
|
|
|
}
|
|
|
|
else
|
2018-05-09 20:13:10 +00:00
|
|
|
{
|
|
|
|
pointer->cursor_timeout_id = 0;
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
}
|
2014-06-23 16:21:08 +00:00
|
|
|
|
2015-04-30 08:26:52 +00:00
|
|
|
if (buffer)
|
|
|
|
{
|
2015-06-19 15:25:54 +00:00
|
|
|
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);
|
2015-11-20 08:49:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-06-19 15:25:54 +00:00
|
|
|
wl_surface_attach (pointer->pointer_surface, NULL, 0, 0);
|
|
|
|
wl_surface_commit (pointer->pointer_surface);
|
2015-04-30 08:26:52 +00:00
|
|
|
}
|
2013-03-28 12:08:43 +00:00
|
|
|
|
|
|
|
next_image_index =
|
2017-11-03 21:41:31 +00:00
|
|
|
_gdk_wayland_cursor_get_next_image_index (GDK_WAYLAND_DISPLAY (seat->display),
|
|
|
|
pointer->cursor,
|
|
|
|
pointer->current_output_scale,
|
2015-06-19 15:25:54 +00:00
|
|
|
pointer->cursor_image_index,
|
2013-03-28 12:08:43 +00:00
|
|
|
&next_image_delay);
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
if (next_image_index != pointer->cursor_image_index)
|
2013-03-28 12:08:43 +00:00
|
|
|
{
|
2018-05-09 20:13:10 +00:00
|
|
|
if (next_image_delay != pointer->cursor_image_delay ||
|
|
|
|
pointer->cursor_timeout_id == 0)
|
2015-09-16 10:21:36 +00:00
|
|
|
{
|
|
|
|
guint id;
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
gdk_wayland_pointer_stop_cursor_animation (pointer);
|
2015-09-16 10:21:36 +00:00
|
|
|
|
|
|
|
/* Queue timeout for next frame */
|
|
|
|
id = g_timeout_add (next_image_delay,
|
2018-03-20 11:05:26 +00:00
|
|
|
(GSourceFunc) gdk_wayland_device_update_surface_cursor,
|
2015-06-19 15:25:54 +00:00
|
|
|
device);
|
2019-02-06 09:37:24 +00:00
|
|
|
g_source_set_name_by_id (id, "[gtk] gdk_wayland_device_update_surface_cursor");
|
2015-06-19 15:25:54 +00:00
|
|
|
pointer->cursor_timeout_id = id;
|
2015-09-16 10:21:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
retval = G_SOURCE_CONTINUE;
|
2013-03-28 12:08:43 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
pointer->cursor_image_index = next_image_index;
|
|
|
|
pointer->cursor_image_delay = next_image_delay;
|
2013-03-28 12:08:43 +00:00
|
|
|
}
|
|
|
|
else
|
2015-06-19 15:25:54 +00:00
|
|
|
gdk_wayland_pointer_stop_cursor_animation (pointer);
|
2013-03-28 12:08:43 +00:00
|
|
|
|
2015-09-16 10:21:36 +00:00
|
|
|
return retval;
|
2013-03-28 12:08:43 +00:00
|
|
|
}
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
static void
|
2019-04-22 09:31:12 +00:00
|
|
|
gdk_wayland_device_set_surface_cursor (GdkDevice *device,
|
|
|
|
GdkSurface *surface,
|
|
|
|
GdkCursor *cursor)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
|
2015-06-19 15:25:54 +00:00
|
|
|
GdkWaylandPointerData *pointer = GDK_WAYLAND_DEVICE (device)->pointer;
|
2011-02-09 19:48:29 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (device == seat->logical_touch)
|
2015-11-19 19:06:07 +00:00
|
|
|
return;
|
|
|
|
|
2016-03-17 17:03:26 +00:00
|
|
|
if (seat->grab_cursor)
|
|
|
|
cursor = seat->grab_cursor;
|
2016-01-08 20:45:03 +00:00
|
|
|
|
2017-11-15 18:05:48 +00:00
|
|
|
if (pointer->cursor != NULL &&
|
2019-04-22 09:31:12 +00:00
|
|
|
cursor != NULL &&
|
2017-11-15 18:05:48 +00:00
|
|
|
gdk_cursor_equal (cursor, pointer->cursor))
|
2019-04-22 09:31:12 +00:00
|
|
|
return;
|
2013-03-28 12:08:43 +00:00
|
|
|
|
2019-04-22 09:31:12 +00:00
|
|
|
if (cursor == NULL)
|
|
|
|
{
|
|
|
|
if (!pointer->cursor_is_default)
|
|
|
|
{
|
|
|
|
g_clear_object (&pointer->cursor);
|
|
|
|
pointer->cursor = gdk_cursor_new_from_name ("default", NULL);
|
|
|
|
pointer->cursor_is_default = TRUE;
|
2013-03-21 02:42:44 +00:00
|
|
|
|
2019-04-22 09:31:12 +00:00
|
|
|
gdk_wayland_pointer_stop_cursor_animation (pointer);
|
|
|
|
gdk_wayland_device_update_surface_cursor (device);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Nothing to do, we'already using the default cursor */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_set_object (&pointer->cursor, cursor);
|
|
|
|
pointer->cursor_is_default = FALSE;
|
2013-03-21 02:42:44 +00:00
|
|
|
|
2019-04-22 09:31:12 +00:00
|
|
|
gdk_wayland_pointer_stop_cursor_animation (pointer);
|
|
|
|
gdk_wayland_device_update_surface_cursor (device);
|
|
|
|
}
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
static GdkModifierType
|
|
|
|
device_get_modifiers (GdkDevice *device)
|
|
|
|
{
|
|
|
|
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
|
|
|
|
GdkWaylandPointerData *pointer = GDK_WAYLAND_DEVICE (device)->pointer;
|
|
|
|
GdkModifierType mask;
|
|
|
|
|
|
|
|
mask = seat->key_modifiers;
|
|
|
|
|
|
|
|
if (pointer)
|
|
|
|
mask |= pointer->button_modifiers;
|
|
|
|
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
2012-03-09 12:20:41 +00:00
|
|
|
static void
|
2013-01-27 13:28:43 +00:00
|
|
|
gdk_wayland_device_query_state (GdkDevice *device,
|
2020-02-14 22:46:56 +00:00
|
|
|
GdkSurface *surface,
|
|
|
|
GdkSurface **child_surface,
|
2020-07-24 20:32:16 +00:00
|
|
|
double *win_x,
|
|
|
|
double *win_y,
|
2013-01-27 13:28:43 +00:00
|
|
|
GdkModifierType *mask)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2015-06-19 15:25:54 +00:00
|
|
|
GdkWaylandPointerData *pointer;
|
2019-03-23 13:28:11 +00:00
|
|
|
GList *children = NULL;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (surface == NULL)
|
|
|
|
children = gdk_wayland_display_get_toplevel_surfaces (gdk_device_get_display (device));
|
2017-08-08 23:45:09 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
pointer = GDK_WAYLAND_DEVICE (device)->pointer;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (child_surface)
|
|
|
|
/* Set child only if actually a child of the given surface, as XIQueryPointer() does */
|
|
|
|
*child_surface = g_list_find (children, pointer->focus) ? pointer->focus : NULL;
|
2010-12-18 20:38:49 +00:00
|
|
|
if (mask)
|
2015-06-19 15:25:54 +00:00
|
|
|
*mask = device_get_modifiers (device);
|
2014-03-17 18:58:37 +00:00
|
|
|
|
2020-02-14 22:46:56 +00:00
|
|
|
if (win_x)
|
|
|
|
*win_x = pointer->surface_x;
|
|
|
|
if (win_y)
|
|
|
|
*win_y = pointer->surface_y;
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2015-06-24 15:48:18 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
emulate_crossing (GdkSurface *surface,
|
|
|
|
GdkSurface *child_surface,
|
2015-06-24 15:48:18 +00:00
|
|
|
GdkDevice *device,
|
|
|
|
GdkEventType type,
|
|
|
|
GdkCrossingMode mode,
|
|
|
|
guint32 time_)
|
|
|
|
{
|
|
|
|
GdkEvent *event;
|
2020-02-14 13:10:21 +00:00
|
|
|
GdkModifierType state;
|
|
|
|
double x, y;
|
|
|
|
|
|
|
|
gdk_surface_get_device_position (surface, device, &x, &y, &state);
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_crossing_event_new (type,
|
2020-02-14 13:10:21 +00:00
|
|
|
surface,
|
|
|
|
device,
|
|
|
|
device,
|
|
|
|
time_,
|
|
|
|
state,
|
|
|
|
x, y,
|
|
|
|
mode,
|
|
|
|
GDK_NOTIFY_NONLINEAR);
|
2015-06-24 15:48:18 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
_gdk_wayland_display_deliver_event (gdk_surface_get_display (surface), event);
|
2015-06-24 15:48:18 +00:00
|
|
|
}
|
|
|
|
|
2015-10-08 14:41:35 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
emulate_touch_crossing (GdkSurface *surface,
|
|
|
|
GdkSurface *child_surface,
|
2015-10-08 14:41:35 +00:00
|
|
|
GdkDevice *device,
|
|
|
|
GdkDevice *source,
|
|
|
|
GdkWaylandTouchData *touch,
|
|
|
|
GdkEventType type,
|
|
|
|
GdkCrossingMode mode,
|
|
|
|
guint32 time_)
|
|
|
|
{
|
|
|
|
GdkEvent *event;
|
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_crossing_event_new (type,
|
2020-02-14 13:10:21 +00:00
|
|
|
surface,
|
|
|
|
device,
|
|
|
|
source,
|
|
|
|
time_,
|
|
|
|
0,
|
|
|
|
touch->x, touch->y,
|
|
|
|
mode,
|
|
|
|
GDK_NOTIFY_NONLINEAR);
|
2015-10-08 14:41:35 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
_gdk_wayland_display_deliver_event (gdk_surface_get_display (surface), event);
|
2015-10-08 14:41:35 +00:00
|
|
|
}
|
|
|
|
|
2015-06-24 15:48:18 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
emulate_focus (GdkSurface *surface,
|
2015-06-24 15:48:18 +00:00
|
|
|
GdkDevice *device,
|
|
|
|
gboolean focus_in,
|
|
|
|
guint32 time_)
|
|
|
|
{
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
GdkEvent *event = gdk_focus_event_new (surface, device, device, focus_in);
|
2015-06-24 15:48:18 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
_gdk_wayland_display_deliver_event (gdk_surface_get_display (surface), event);
|
2015-06-24 15:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
device_emit_grab_crossing (GdkDevice *device,
|
2018-03-20 10:40:08 +00:00
|
|
|
GdkSurface *from,
|
|
|
|
GdkSurface *to,
|
2015-06-24 15:48:18 +00:00
|
|
|
GdkCrossingMode mode,
|
|
|
|
guint32 time_)
|
|
|
|
{
|
|
|
|
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
|
|
|
|
{
|
|
|
|
if (from)
|
|
|
|
emulate_focus (from, device, FALSE, time_);
|
|
|
|
if (to)
|
|
|
|
emulate_focus (to, device, TRUE, time_);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (from)
|
|
|
|
emulate_crossing (from, to, device, GDK_LEAVE_NOTIFY, mode, time_);
|
|
|
|
if (to)
|
|
|
|
emulate_crossing (to, from, device, GDK_ENTER_NOTIFY, mode, time_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
static GdkSurface *
|
2015-06-24 15:48:18 +00:00
|
|
|
gdk_wayland_device_get_focus (GdkDevice *device)
|
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
|
2015-06-19 15:25:54 +00:00
|
|
|
GdkWaylandPointerData *pointer;
|
2015-12-09 11:42:33 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (device == wayland_seat->logical_keyboard)
|
2015-12-09 11:42:33 +00:00
|
|
|
return wayland_seat->keyboard_focus;
|
2015-06-24 15:48:18 +00:00
|
|
|
else
|
2015-06-19 15:25:54 +00:00
|
|
|
{
|
|
|
|
pointer = GDK_WAYLAND_DEVICE (device)->pointer;
|
|
|
|
|
|
|
|
if (pointer)
|
|
|
|
return pointer->focus;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
2015-06-24 15:48:18 +00:00
|
|
|
}
|
|
|
|
|
2018-04-19 12:22:04 +00:00
|
|
|
static void
|
|
|
|
device_maybe_emit_grab_crossing (GdkDevice *device,
|
|
|
|
GdkSurface *window,
|
|
|
|
guint32 time)
|
|
|
|
{
|
2019-04-19 23:08:24 +00:00
|
|
|
GdkSurface *surface = gdk_wayland_device_get_focus (device);
|
2019-03-23 04:14:46 +00:00
|
|
|
GdkSurface *focus = window;
|
2018-04-19 12:22:04 +00:00
|
|
|
|
2019-04-19 23:08:24 +00:00
|
|
|
if (focus != surface)
|
2018-04-19 12:22:04 +00:00
|
|
|
device_emit_grab_crossing (device, focus, window, GDK_CROSSING_GRAB, time);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkSurface*
|
2019-04-19 23:08:24 +00:00
|
|
|
device_maybe_emit_ungrab_crossing (GdkDevice *device,
|
|
|
|
guint32 time_)
|
2018-04-19 12:22:04 +00:00
|
|
|
{
|
|
|
|
GdkDeviceGrabInfo *grab;
|
|
|
|
GdkSurface *focus = NULL;
|
2019-04-19 23:08:24 +00:00
|
|
|
GdkSurface *surface = NULL;
|
2018-04-19 12:22:04 +00:00
|
|
|
GdkSurface *prev_focus = NULL;
|
|
|
|
|
|
|
|
focus = gdk_wayland_device_get_focus (device);
|
|
|
|
grab = _gdk_display_get_last_device_grab (gdk_device_get_display (device), device);
|
|
|
|
|
|
|
|
if (grab)
|
|
|
|
{
|
|
|
|
prev_focus = grab->surface;
|
2019-04-19 23:08:24 +00:00
|
|
|
surface = grab->surface;
|
2018-04-19 12:22:04 +00:00
|
|
|
}
|
|
|
|
|
2019-04-19 23:08:24 +00:00
|
|
|
if (focus != surface)
|
|
|
|
device_emit_grab_crossing (device, prev_focus, focus, GDK_CROSSING_UNGRAB, time_);
|
2018-04-19 12:22:04 +00:00
|
|
|
|
|
|
|
return prev_focus;
|
|
|
|
}
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
static GdkGrabStatus
|
2013-01-27 13:28:43 +00:00
|
|
|
gdk_wayland_device_grab (GdkDevice *device,
|
2019-04-19 23:08:24 +00:00
|
|
|
GdkSurface *surface,
|
2013-01-27 13:28:43 +00:00
|
|
|
gboolean owner_events,
|
|
|
|
GdkEventMask event_mask,
|
2019-04-19 23:08:24 +00:00
|
|
|
GdkSurface *confine_to,
|
2013-01-27 13:28:43 +00:00
|
|
|
GdkCursor *cursor,
|
|
|
|
guint32 time_)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
|
2015-06-19 15:25:54 +00:00
|
|
|
GdkWaylandPointerData *pointer = GDK_WAYLAND_DEVICE (device)->pointer;
|
2015-06-24 15:48:18 +00:00
|
|
|
|
2020-03-08 20:37:13 +00:00
|
|
|
if (GDK_IS_DRAG_SURFACE (surface) &&
|
2020-02-25 00:02:34 +00:00
|
|
|
gdk_surface_get_mapped (surface))
|
2016-10-18 17:18:14 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
g_warning ("Surface %p is already mapped at the time of grabbing. "
|
2016-10-18 17:18:14 +00:00
|
|
|
"gdk_seat_grab() should be used to simultanously grab input "
|
|
|
|
"and show this popup. You may find oddities ahead.",
|
2018-03-20 14:14:10 +00:00
|
|
|
surface);
|
2016-10-18 17:18:14 +00:00
|
|
|
}
|
|
|
|
|
2018-04-19 12:22:04 +00:00
|
|
|
device_maybe_emit_grab_crossing (device, surface, time_);
|
2012-01-09 15:49:57 +00:00
|
|
|
|
|
|
|
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
|
|
|
|
{
|
|
|
|
/* Device is a keyboard */
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_inhibit_shortcuts (surface,
|
2019-04-19 23:08:24 +00:00
|
|
|
gdk_device_get_seat (device));
|
2012-01-09 15:49:57 +00:00
|
|
|
return GDK_GRAB_SUCCESS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Device is a pointer */
|
2018-03-20 14:14:10 +00:00
|
|
|
if (pointer->grab_surface != NULL &&
|
2015-06-19 15:25:54 +00:00
|
|
|
time_ != 0 && pointer->grab_time > time_)
|
2012-01-09 15:49:57 +00:00
|
|
|
{
|
|
|
|
return GDK_GRAB_ALREADY_GRABBED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (time_ == 0)
|
2015-06-19 15:25:54 +00:00
|
|
|
time_ = pointer->time;
|
2012-01-09 15:49:57 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
pointer->grab_surface = surface;
|
2015-06-19 15:25:54 +00:00
|
|
|
pointer->grab_time = time_;
|
2018-03-20 14:14:10 +00:00
|
|
|
_gdk_wayland_surface_set_grab_seat (surface, GDK_SEAT (wayland_seat));
|
2014-09-01 17:11:02 +00:00
|
|
|
|
2016-03-17 17:03:26 +00:00
|
|
|
g_clear_object (&wayland_seat->cursor);
|
2014-09-01 17:11:02 +00:00
|
|
|
|
|
|
|
if (cursor)
|
2016-03-17 17:03:26 +00:00
|
|
|
wayland_seat->cursor = g_object_ref (cursor);
|
2014-09-01 17:11:02 +00:00
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_wayland_device_update_surface_cursor (device);
|
2012-01-09 15:49:57 +00:00
|
|
|
}
|
|
|
|
|
2010-12-18 20:38:49 +00:00
|
|
|
return GDK_GRAB_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-27 13:28:43 +00:00
|
|
|
gdk_wayland_device_ungrab (GdkDevice *device,
|
|
|
|
guint32 time_)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2015-06-19 15:25:54 +00:00
|
|
|
GdkWaylandPointerData *pointer = GDK_WAYLAND_DEVICE (device)->pointer;
|
2018-04-19 12:22:04 +00:00
|
|
|
GdkSurface *prev_focus;
|
2015-06-24 13:41:23 +00:00
|
|
|
|
2018-04-19 12:22:04 +00:00
|
|
|
prev_focus = device_maybe_emit_ungrab_crossing (device, time_);
|
2015-06-24 13:41:23 +00:00
|
|
|
|
2012-01-09 15:49:57 +00:00
|
|
|
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
|
|
|
|
{
|
|
|
|
/* Device is a keyboard */
|
2017-03-22 09:21:02 +00:00
|
|
|
if (prev_focus)
|
2018-03-20 10:40:08 +00:00
|
|
|
gdk_wayland_surface_restore_shortcuts (prev_focus,
|
2017-03-22 09:21:02 +00:00
|
|
|
gdk_device_get_seat (device));
|
2012-01-09 15:49:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Device is a pointer */
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_wayland_device_update_surface_cursor (device);
|
2014-09-01 17:11:02 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (pointer->grab_surface)
|
|
|
|
_gdk_wayland_surface_set_grab_seat (pointer->grab_surface,
|
2015-12-09 11:56:26 +00:00
|
|
|
NULL);
|
2012-01-09 15:49:57 +00:00
|
|
|
}
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
static GdkSurface *
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_wayland_device_surface_at_position (GdkDevice *device,
|
2020-07-24 20:32:16 +00:00
|
|
|
double *win_x,
|
|
|
|
double *win_y,
|
2020-05-19 19:00:32 +00:00
|
|
|
GdkModifierType *mask)
|
2010-12-18 20:38:49 +00:00
|
|
|
{
|
2015-06-19 15:25:54 +00:00
|
|
|
GdkWaylandPointerData *pointer;
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
pointer = GDK_WAYLAND_DEVICE(device)->pointer;
|
2015-11-19 19:23:44 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
if (!pointer)
|
|
|
|
return NULL;
|
2015-11-19 19:23:44 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
if (win_x)
|
|
|
|
*win_x = pointer->surface_x;
|
|
|
|
if (win_y)
|
|
|
|
*win_y = pointer->surface_y;
|
2011-02-11 22:07:19 +00:00
|
|
|
if (mask)
|
2015-06-19 15:25:54 +00:00
|
|
|
*mask = device_get_modifiers (device);
|
2010-12-18 20:38:49 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
return pointer->focus;
|
2010-12-18 20:38:49 +00:00
|
|
|
}
|
|
|
|
|
2011-02-09 20:27:08 +00:00
|
|
|
static void
|
2013-01-27 13:28:43 +00:00
|
|
|
gdk_wayland_device_class_init (GdkWaylandDeviceClass *klass)
|
2011-02-09 20:27:08 +00:00
|
|
|
{
|
|
|
|
GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
|
|
|
|
|
2013-01-27 13:28:43 +00:00
|
|
|
device_class->get_state = gdk_wayland_device_get_state;
|
2018-03-20 11:05:26 +00:00
|
|
|
device_class->set_surface_cursor = gdk_wayland_device_set_surface_cursor;
|
2013-01-27 13:28:43 +00:00
|
|
|
device_class->query_state = gdk_wayland_device_query_state;
|
|
|
|
device_class->grab = gdk_wayland_device_grab;
|
|
|
|
device_class->ungrab = gdk_wayland_device_ungrab;
|
2018-03-20 11:05:26 +00:00
|
|
|
device_class->surface_at_position = gdk_wayland_device_surface_at_position;
|
2011-02-09 20:27:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-27 13:28:43 +00:00
|
|
|
gdk_wayland_device_init (GdkWaylandDevice *device_core)
|
2011-02-09 20:27:08 +00:00
|
|
|
{
|
|
|
|
GdkDevice *device;
|
|
|
|
|
|
|
|
device = GDK_DEVICE (device_core);
|
|
|
|
|
2020-06-09 19:26:04 +00:00
|
|
|
_gdk_device_add_axis (device, GDK_AXIS_X, 0, 0, 1);
|
|
|
|
_gdk_device_add_axis (device, GDK_AXIS_Y, 0, 0, 1);
|
2011-02-09 20:27:08 +00:00
|
|
|
}
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
static int
|
2016-08-04 17:40:14 +00:00
|
|
|
gdk_wayland_device_pad_get_n_groups (GdkDevicePad *pad)
|
|
|
|
{
|
|
|
|
GdkSeat *seat = gdk_device_get_seat (GDK_DEVICE (pad));
|
|
|
|
GdkWaylandTabletPadData *data;
|
|
|
|
|
2017-11-25 04:00:40 +00:00
|
|
|
data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
|
|
|
|
GDK_DEVICE (pad));
|
2016-08-04 17:40:14 +00:00
|
|
|
g_assert (data != NULL);
|
|
|
|
|
|
|
|
return g_list_length (data->mode_groups);
|
|
|
|
}
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
static int
|
2016-08-04 17:40:14 +00:00
|
|
|
gdk_wayland_device_pad_get_group_n_modes (GdkDevicePad *pad,
|
2020-07-24 13:54:49 +00:00
|
|
|
int n_group)
|
2016-08-04 17:40:14 +00:00
|
|
|
{
|
|
|
|
GdkSeat *seat = gdk_device_get_seat (GDK_DEVICE (pad));
|
|
|
|
GdkWaylandTabletPadGroupData *group;
|
|
|
|
GdkWaylandTabletPadData *data;
|
|
|
|
|
2017-11-25 04:00:40 +00:00
|
|
|
data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
|
|
|
|
GDK_DEVICE (pad));
|
2016-08-04 17:40:14 +00:00
|
|
|
g_assert (data != NULL);
|
|
|
|
|
|
|
|
group = g_list_nth_data (data->mode_groups, n_group);
|
|
|
|
if (!group)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return group->n_modes;
|
|
|
|
}
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
static int
|
2016-08-04 17:40:14 +00:00
|
|
|
gdk_wayland_device_pad_get_n_features (GdkDevicePad *pad,
|
|
|
|
GdkDevicePadFeature feature)
|
|
|
|
{
|
|
|
|
GdkSeat *seat = gdk_device_get_seat (GDK_DEVICE (pad));
|
|
|
|
GdkWaylandTabletPadData *data;
|
|
|
|
|
2017-11-25 04:00:40 +00:00
|
|
|
data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
|
|
|
|
GDK_DEVICE (pad));
|
2016-08-04 17:40:14 +00:00
|
|
|
g_assert (data != NULL);
|
|
|
|
|
|
|
|
switch (feature)
|
|
|
|
{
|
|
|
|
case GDK_DEVICE_PAD_FEATURE_BUTTON:
|
|
|
|
return data->n_buttons;
|
|
|
|
case GDK_DEVICE_PAD_FEATURE_RING:
|
|
|
|
return g_list_length (data->rings);
|
|
|
|
case GDK_DEVICE_PAD_FEATURE_STRIP:
|
|
|
|
return g_list_length (data->strips);
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
static int
|
2016-08-04 17:40:14 +00:00
|
|
|
gdk_wayland_device_pad_get_feature_group (GdkDevicePad *pad,
|
|
|
|
GdkDevicePadFeature feature,
|
2020-07-24 13:54:49 +00:00
|
|
|
int idx)
|
2016-08-04 17:40:14 +00:00
|
|
|
{
|
|
|
|
GdkSeat *seat = gdk_device_get_seat (GDK_DEVICE (pad));
|
|
|
|
GdkWaylandTabletPadGroupData *group;
|
|
|
|
GdkWaylandTabletPadData *data;
|
|
|
|
GList *l;
|
2020-07-24 13:54:49 +00:00
|
|
|
int i;
|
2016-08-04 17:40:14 +00:00
|
|
|
|
2017-11-25 04:00:40 +00:00
|
|
|
data = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat),
|
|
|
|
GDK_DEVICE (pad));
|
2016-08-04 17:40:14 +00:00
|
|
|
g_assert (data != NULL);
|
|
|
|
|
|
|
|
for (l = data->mode_groups, i = 0; l; l = l->next, i++)
|
|
|
|
{
|
|
|
|
group = l->data;
|
|
|
|
|
|
|
|
switch (feature)
|
|
|
|
{
|
|
|
|
case GDK_DEVICE_PAD_FEATURE_BUTTON:
|
|
|
|
if (g_list_find (group->buttons, GINT_TO_POINTER (idx)))
|
|
|
|
return i;
|
|
|
|
break;
|
|
|
|
case GDK_DEVICE_PAD_FEATURE_RING:
|
|
|
|
{
|
|
|
|
gpointer ring;
|
|
|
|
|
|
|
|
ring = g_list_nth_data (data->rings, idx);
|
|
|
|
if (ring && g_list_find (group->rings, ring))
|
|
|
|
return i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GDK_DEVICE_PAD_FEATURE_STRIP:
|
|
|
|
{
|
|
|
|
gpointer strip;
|
|
|
|
strip = g_list_nth_data (data->strips, idx);
|
|
|
|
if (strip && g_list_find (group->strips, strip))
|
|
|
|
return i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_device_pad_iface_init (GdkDevicePadInterface *iface)
|
|
|
|
{
|
|
|
|
iface->get_n_groups = gdk_wayland_device_pad_get_n_groups;
|
|
|
|
iface->get_group_n_modes = gdk_wayland_device_pad_get_group_n_modes;
|
|
|
|
iface->get_n_features = gdk_wayland_device_pad_get_n_features;
|
|
|
|
iface->get_feature_group = gdk_wayland_device_pad_get_feature_group;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_device_pad_class_init (GdkWaylandDevicePadClass *klass)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_device_pad_init (GdkWaylandDevicePad *pad)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-09-17 05:16:13 +00:00
|
|
|
/**
|
|
|
|
* gdk_wayland_device_get_wl_seat:
|
|
|
|
* @device: (type GdkWaylandDevice): a #GdkDevice
|
|
|
|
*
|
2015-02-28 03:28:28 +00:00
|
|
|
* Returns the Wayland wl_seat of a #GdkDevice.
|
2013-09-17 05:16:13 +00:00
|
|
|
*
|
|
|
|
* Returns: (transfer none): a Wayland wl_seat
|
|
|
|
*/
|
2012-07-11 13:29:43 +00:00
|
|
|
struct wl_seat *
|
2013-01-27 13:28:43 +00:00
|
|
|
gdk_wayland_device_get_wl_seat (GdkDevice *device)
|
2012-07-11 13:29:43 +00:00
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
GdkWaylandSeat *seat;
|
|
|
|
|
2015-02-28 03:28:28 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_DEVICE (device), NULL);
|
2013-01-27 13:28:43 +00:00
|
|
|
|
2016-03-17 17:03:26 +00:00
|
|
|
seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
|
|
|
|
return seat->wl_seat;
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
2013-09-17 05:16:13 +00:00
|
|
|
/**
|
|
|
|
* gdk_wayland_device_get_wl_pointer:
|
|
|
|
* @device: (type GdkWaylandDevice): a #GdkDevice
|
|
|
|
*
|
2015-02-28 03:28:28 +00:00
|
|
|
* Returns the Wayland wl_pointer of a #GdkDevice.
|
2013-09-17 05:16:13 +00:00
|
|
|
*
|
|
|
|
* Returns: (transfer none): a Wayland wl_pointer
|
|
|
|
*/
|
2012-07-11 13:29:43 +00:00
|
|
|
struct wl_pointer *
|
2013-01-27 13:28:43 +00:00
|
|
|
gdk_wayland_device_get_wl_pointer (GdkDevice *device)
|
2011-02-09 20:27:08 +00:00
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
GdkWaylandSeat *seat;
|
|
|
|
|
2015-02-28 03:28:28 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_DEVICE (device), NULL);
|
2013-01-27 13:28:43 +00:00
|
|
|
|
2016-03-17 17:03:26 +00:00
|
|
|
seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
|
|
|
|
return seat->wl_pointer;
|
2011-02-09 20:27:08 +00:00
|
|
|
}
|
|
|
|
|
2013-09-17 05:16:13 +00:00
|
|
|
/**
|
|
|
|
* gdk_wayland_device_get_wl_keyboard:
|
|
|
|
* @device: (type GdkWaylandDevice): a #GdkDevice
|
|
|
|
*
|
2015-02-28 03:28:28 +00:00
|
|
|
* Returns the Wayland wl_keyboard of a #GdkDevice.
|
2013-09-17 05:16:13 +00:00
|
|
|
*
|
|
|
|
* Returns: (transfer none): a Wayland wl_keyboard
|
|
|
|
*/
|
2012-07-11 13:29:43 +00:00
|
|
|
struct wl_keyboard *
|
2013-01-27 13:28:43 +00:00
|
|
|
gdk_wayland_device_get_wl_keyboard (GdkDevice *device)
|
2012-07-11 13:29:43 +00:00
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
GdkWaylandSeat *seat;
|
|
|
|
|
2015-02-28 03:28:28 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_DEVICE (device), NULL);
|
2013-01-27 13:28:43 +00:00
|
|
|
|
2016-03-17 17:03:26 +00:00
|
|
|
seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
|
|
|
|
return seat->wl_keyboard;
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
2012-07-16 18:02:41 +00:00
|
|
|
GdkKeymap *
|
|
|
|
_gdk_wayland_device_get_keymap (GdkDevice *device)
|
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
|
|
|
|
return seat->keymap;
|
2012-07-16 18:02:41 +00:00
|
|
|
}
|
|
|
|
|
2018-05-06 00:06:53 +00:00
|
|
|
static void
|
|
|
|
gdk_wayland_seat_discard_pending_offer (GdkWaylandSeat *seat)
|
|
|
|
{
|
|
|
|
if (seat->pending_builder)
|
|
|
|
{
|
|
|
|
GdkContentFormats *ignore = gdk_content_formats_builder_free_to_formats (seat->pending_builder);
|
|
|
|
gdk_content_formats_unref (ignore);
|
|
|
|
seat->pending_builder = NULL;
|
|
|
|
}
|
2018-07-25 07:00:09 +00:00
|
|
|
g_clear_pointer (&seat->pending_offer, wl_data_offer_destroy);
|
2018-05-06 00:06:53 +00:00
|
|
|
seat->pending_source_actions = 0;
|
|
|
|
seat->pending_action = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline GdkDragAction
|
|
|
|
gdk_wayland_actions_to_gdk_actions (uint32_t dnd_actions)
|
|
|
|
{
|
|
|
|
GdkDragAction actions = 0;
|
|
|
|
|
|
|
|
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY)
|
|
|
|
actions |= GDK_ACTION_COPY;
|
|
|
|
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE)
|
|
|
|
actions |= GDK_ACTION_MOVE;
|
|
|
|
if (dnd_actions & WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK)
|
|
|
|
actions |= GDK_ACTION_ASK;
|
|
|
|
|
|
|
|
return actions;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_offer_offer (void *data,
|
|
|
|
struct wl_data_offer *offer,
|
|
|
|
const char *type)
|
|
|
|
{
|
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
|
|
|
|
if (seat->pending_offer != offer)
|
|
|
|
{
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2018-05-06 00:06:53 +00:00
|
|
|
g_message ("%p: offer for unknown offer %p of %s",
|
|
|
|
seat, offer, type));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-15 20:04:57 +00:00
|
|
|
/* skip magic mime types */
|
|
|
|
if (g_str_equal (type, GDK_WAYLAND_LOCAL_DND_MIME_TYPE))
|
|
|
|
return;
|
|
|
|
|
2018-05-06 00:06:53 +00:00
|
|
|
gdk_content_formats_builder_add_mime_type (seat->pending_builder, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_offer_source_actions (void *data,
|
|
|
|
struct wl_data_offer *offer,
|
|
|
|
uint32_t source_actions)
|
|
|
|
{
|
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
|
|
|
|
if (offer == seat->pending_offer)
|
|
|
|
{
|
|
|
|
seat->pending_source_actions = gdk_wayland_actions_to_gdk_actions (source_actions);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-30 02:04:51 +00:00
|
|
|
if (seat->drop == NULL)
|
2018-05-06 00:06:53 +00:00
|
|
|
return;
|
|
|
|
|
2018-05-30 02:04:51 +00:00
|
|
|
gdk_wayland_drop_set_source_actions (seat->drop, source_actions);
|
2018-05-06 00:06:53 +00:00
|
|
|
|
2018-05-30 02:04:51 +00:00
|
|
|
gdk_drop_emit_motion_event (seat->drop,
|
2018-05-23 18:11:28 +00:00
|
|
|
FALSE,
|
|
|
|
seat->pointer_info.surface_x,
|
|
|
|
seat->pointer_info.surface_y,
|
|
|
|
GDK_CURRENT_TIME);
|
2018-05-06 00:06:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_offer_action (void *data,
|
|
|
|
struct wl_data_offer *offer,
|
|
|
|
uint32_t action)
|
|
|
|
{
|
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
|
|
|
|
if (offer == seat->pending_offer)
|
|
|
|
{
|
|
|
|
seat->pending_action = gdk_wayland_actions_to_gdk_actions (action);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-30 02:04:51 +00:00
|
|
|
if (seat->drop == NULL)
|
2018-05-06 00:06:53 +00:00
|
|
|
return;
|
|
|
|
|
2018-05-30 02:04:51 +00:00
|
|
|
gdk_wayland_drop_set_action (seat->drop, action);
|
2018-05-06 00:06:53 +00:00
|
|
|
|
2018-05-30 02:04:51 +00:00
|
|
|
gdk_drop_emit_motion_event (seat->drop,
|
2018-05-23 18:11:28 +00:00
|
|
|
FALSE,
|
|
|
|
seat->pointer_info.surface_x,
|
|
|
|
seat->pointer_info.surface_y,
|
|
|
|
GDK_CURRENT_TIME);
|
2018-05-06 00:06:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_data_offer_listener data_offer_listener = {
|
|
|
|
data_offer_offer,
|
|
|
|
data_offer_source_actions,
|
|
|
|
data_offer_action
|
|
|
|
};
|
|
|
|
|
2011-12-14 13:11:18 +00:00
|
|
|
static void
|
|
|
|
data_device_data_offer (void *data,
|
|
|
|
struct wl_data_device *data_device,
|
2015-02-28 05:15:13 +00:00
|
|
|
struct wl_data_offer *offer)
|
2011-12-14 13:11:18 +00:00
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2014-10-29 16:31:15 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2015-02-28 05:15:13 +00:00
|
|
|
g_message ("data device data offer, data device %p, offer %p",
|
|
|
|
data_device, offer));
|
|
|
|
|
2018-05-06 00:06:53 +00:00
|
|
|
gdk_wayland_seat_discard_pending_offer (seat);
|
|
|
|
|
|
|
|
seat->pending_offer = offer;
|
|
|
|
wl_data_offer_add_listener (offer,
|
|
|
|
&data_offer_listener,
|
|
|
|
seat);
|
|
|
|
|
|
|
|
seat->pending_builder = gdk_content_formats_builder_new ();
|
|
|
|
seat->pending_source_actions = 0;
|
|
|
|
seat->pending_action = 0;
|
2011-12-14 13:11:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_device_enter (void *data,
|
|
|
|
struct wl_data_device *data_device,
|
2013-08-24 06:04:43 +00:00
|
|
|
uint32_t serial,
|
2011-12-14 13:11:18 +00:00
|
|
|
struct wl_surface *surface,
|
2014-08-21 17:01:32 +00:00
|
|
|
wl_fixed_t x,
|
|
|
|
wl_fixed_t y,
|
2011-12-14 13:11:18 +00:00
|
|
|
struct wl_data_offer *offer)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2018-05-30 02:04:51 +00:00
|
|
|
GdkSurface *dest_surface;
|
2018-05-06 00:06:53 +00:00
|
|
|
GdkContentFormats *formats;
|
2020-02-19 02:37:23 +00:00
|
|
|
int origin_x, origin_y;
|
2018-04-27 10:32:17 +00:00
|
|
|
GdkDevice *device;
|
2014-08-21 18:20:37 +00:00
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
dest_surface = wl_surface_get_user_data (surface);
|
2014-08-21 18:20:37 +00:00
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
if (!GDK_IS_SURFACE (dest_surface))
|
2014-08-21 18:20:37 +00:00
|
|
|
return;
|
2011-12-14 13:11:18 +00:00
|
|
|
|
2018-05-06 00:06:53 +00:00
|
|
|
if (offer != seat->pending_offer)
|
|
|
|
{
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2018-05-06 00:06:53 +00:00
|
|
|
g_message ("%p: enter event for unknown offer %p, expected %p",
|
|
|
|
seat, offer, seat->pending_offer));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2015-07-06 16:21:41 +00:00
|
|
|
g_message ("data device enter, data device %p serial %u, surface %p, x %f y %f, offer %p",
|
|
|
|
data_device, serial, surface, wl_fixed_to_double (x), wl_fixed_to_double (y), offer));
|
2011-12-14 13:11:18 +00:00
|
|
|
|
2014-08-21 18:20:37 +00:00
|
|
|
/* Update pointer state, so device state queries work during DnD */
|
2018-03-20 11:05:26 +00:00
|
|
|
seat->pointer_info.focus = g_object_ref (dest_surface);
|
2015-06-19 15:25:54 +00:00
|
|
|
seat->pointer_info.surface_x = wl_fixed_to_double (x);
|
|
|
|
seat->pointer_info.surface_y = wl_fixed_to_double (y);
|
2014-08-21 18:20:37 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (seat->logical_pointer)
|
|
|
|
device = seat->logical_pointer;
|
|
|
|
else if (seat->logical_touch)
|
|
|
|
device = seat->logical_touch;
|
2018-04-27 10:32:17 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("No device for DND enter, ignoring.");
|
|
|
|
return;
|
|
|
|
}
|
2018-04-27 10:25:59 +00:00
|
|
|
|
2018-05-06 00:06:53 +00:00
|
|
|
formats = gdk_content_formats_builder_free_to_formats (seat->pending_builder);
|
|
|
|
seat->pending_builder = NULL;
|
|
|
|
seat->pending_offer = NULL;
|
|
|
|
|
2018-05-31 19:15:59 +00:00
|
|
|
seat->drop = gdk_wayland_drop_new (device, seat->drag, formats, dest_surface, offer, serial);
|
2020-01-04 14:14:33 +00:00
|
|
|
gdk_wayland_drop_set_source_actions (seat->drop, seat->pending_source_actions);
|
|
|
|
gdk_wayland_drop_set_action (seat->drop, seat->pending_action);
|
2014-08-21 19:30:22 +00:00
|
|
|
|
2018-05-06 00:06:53 +00:00
|
|
|
gdk_wayland_seat_discard_pending_offer (seat);
|
|
|
|
|
2020-02-19 02:37:23 +00:00
|
|
|
gdk_surface_get_origin (gdk_drop_get_surface (seat->drop), &origin_x, &origin_y);
|
|
|
|
|
2018-05-30 02:04:51 +00:00
|
|
|
gdk_drop_emit_enter_event (seat->drop,
|
2018-05-23 18:11:28 +00:00
|
|
|
FALSE,
|
2020-02-19 02:37:23 +00:00
|
|
|
origin_x + seat->pointer_info.surface_x,
|
|
|
|
origin_y + seat->pointer_info.surface_y,
|
2018-05-23 18:11:28 +00:00
|
|
|
GDK_CURRENT_TIME);
|
2011-12-14 13:11:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_device_leave (void *data,
|
|
|
|
struct wl_data_device *data_device)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2011-12-14 13:11:18 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2015-02-28 05:15:13 +00:00
|
|
|
g_message ("data device leave, data device %p", data_device));
|
2011-12-14 13:11:18 +00:00
|
|
|
|
2018-05-30 02:04:51 +00:00
|
|
|
if (seat->drop == NULL)
|
2014-08-21 18:20:37 +00:00
|
|
|
return;
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
g_object_unref (seat->pointer_info.focus);
|
|
|
|
seat->pointer_info.focus = NULL;
|
2014-08-21 18:20:37 +00:00
|
|
|
|
2018-05-30 02:04:51 +00:00
|
|
|
gdk_drop_emit_leave_event (seat->drop,
|
2018-05-23 18:11:28 +00:00
|
|
|
FALSE,
|
|
|
|
GDK_CURRENT_TIME);
|
2018-04-27 10:25:59 +00:00
|
|
|
|
2018-05-30 02:04:51 +00:00
|
|
|
g_clear_object (&seat->drop);
|
2011-12-14 13:11:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_device_motion (void *data,
|
|
|
|
struct wl_data_device *data_device,
|
|
|
|
uint32_t time,
|
2014-08-21 17:01:32 +00:00
|
|
|
wl_fixed_t x,
|
|
|
|
wl_fixed_t y)
|
2011-12-14 13:11:18 +00:00
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2019-12-30 17:00:53 +00:00
|
|
|
int origin_x, origin_y;
|
2014-08-21 18:20:37 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("data device motion, data_device = %p, time = %d, x = %f, y = %f",
|
|
|
|
data_device, time, wl_fixed_to_double (x), wl_fixed_to_double (y)));
|
2014-08-21 18:20:37 +00:00
|
|
|
|
2018-05-30 02:04:51 +00:00
|
|
|
if (seat->drop == NULL)
|
2014-08-21 18:20:37 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Update pointer state, so device state queries work during DnD */
|
2015-06-19 15:25:54 +00:00
|
|
|
seat->pointer_info.surface_x = wl_fixed_to_double (x);
|
|
|
|
seat->pointer_info.surface_y = wl_fixed_to_double (y);
|
2014-08-21 18:20:37 +00:00
|
|
|
|
2019-12-30 17:00:53 +00:00
|
|
|
gdk_surface_get_origin (gdk_drop_get_surface (seat->drop), &origin_x, &origin_y);
|
|
|
|
|
2018-05-30 02:04:51 +00:00
|
|
|
gdk_drop_emit_motion_event (seat->drop,
|
2018-05-23 18:11:28 +00:00
|
|
|
FALSE,
|
2019-12-30 17:00:53 +00:00
|
|
|
origin_x + seat->pointer_info.surface_x,
|
|
|
|
origin_y + seat->pointer_info.surface_y,
|
2018-05-23 18:11:28 +00:00
|
|
|
time);
|
2011-12-14 13:11:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_device_drop (void *data,
|
|
|
|
struct wl_data_device *data_device)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2019-12-30 17:00:53 +00:00
|
|
|
int origin_x, origin_y;
|
2014-08-21 18:20:37 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2015-02-28 05:15:13 +00:00
|
|
|
g_message ("data device drop, data device %p", data_device));
|
2014-08-21 18:20:37 +00:00
|
|
|
|
2019-12-30 17:00:53 +00:00
|
|
|
gdk_surface_get_origin (gdk_drop_get_surface (seat->drop), &origin_x, &origin_y);
|
|
|
|
|
2018-05-30 02:04:51 +00:00
|
|
|
gdk_drop_emit_drop_event (seat->drop,
|
2018-05-23 18:11:28 +00:00
|
|
|
FALSE,
|
2019-12-30 17:00:53 +00:00
|
|
|
origin_x + seat->pointer_info.surface_x,
|
|
|
|
origin_y + seat->pointer_info.surface_y,
|
2018-05-23 18:11:28 +00:00
|
|
|
GDK_CURRENT_TIME);
|
2011-12-14 13:11:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
data_device_selection (void *data,
|
|
|
|
struct wl_data_device *wl_data_device,
|
|
|
|
struct wl_data_offer *offer)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2017-12-03 01:48:17 +00:00
|
|
|
GdkContentFormats *formats;
|
2011-12-14 13:11:18 +00:00
|
|
|
|
2017-12-03 01:48:17 +00:00
|
|
|
if (offer)
|
2018-05-06 00:06:53 +00:00
|
|
|
{
|
|
|
|
if (offer == seat->pending_offer)
|
|
|
|
{
|
|
|
|
formats = gdk_content_formats_builder_free_to_formats (seat->pending_builder);
|
|
|
|
seat->pending_builder = NULL;
|
|
|
|
seat->pending_offer = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
formats = gdk_content_formats_new (NULL, 0);
|
|
|
|
offer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_wayland_seat_discard_pending_offer (seat);
|
|
|
|
}
|
2015-08-27 06:59:45 +00:00
|
|
|
else
|
2018-05-06 00:06:53 +00:00
|
|
|
{
|
|
|
|
formats = gdk_content_formats_new (NULL, 0);
|
|
|
|
}
|
2017-12-03 01:48:17 +00:00
|
|
|
|
|
|
|
gdk_wayland_clipboard_claim_remote (GDK_WAYLAND_CLIPBOARD (seat->clipboard),
|
|
|
|
offer,
|
|
|
|
formats);
|
2011-12-14 13:11:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_data_device_listener data_device_listener = {
|
|
|
|
data_device_data_offer,
|
|
|
|
data_device_enter,
|
|
|
|
data_device_leave,
|
|
|
|
data_device_motion,
|
|
|
|
data_device_drop,
|
|
|
|
data_device_selection
|
|
|
|
};
|
|
|
|
|
2016-06-01 03:14:30 +00:00
|
|
|
static GdkDevice * get_scroll_device (GdkWaylandSeat *seat,
|
|
|
|
enum wl_pointer_axis_source source);
|
|
|
|
|
2015-10-20 03:21:54 +00:00
|
|
|
static void
|
|
|
|
flush_discrete_scroll_event (GdkWaylandSeat *seat,
|
|
|
|
GdkScrollDirection direction)
|
|
|
|
{
|
|
|
|
GdkEvent *event;
|
2017-07-20 11:26:00 +00:00
|
|
|
GdkDevice *source;
|
2015-10-20 03:21:54 +00:00
|
|
|
|
2017-07-20 11:26:00 +00:00
|
|
|
source = get_scroll_device (seat, seat->pointer_info.frame.source);
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_scroll_event_new_discrete (seat->pointer_info.focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_pointer,
|
2020-02-14 13:10:21 +00:00
|
|
|
source,
|
|
|
|
NULL,
|
|
|
|
seat->pointer_info.time,
|
2020-06-18 18:22:20 +00:00
|
|
|
device_get_modifiers (seat->logical_pointer),
|
2020-02-14 13:10:21 +00:00
|
|
|
direction,
|
|
|
|
TRUE);
|
2015-10-20 03:21:54 +00:00
|
|
|
|
|
|
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
flush_smooth_scroll_event (GdkWaylandSeat *seat,
|
2020-07-24 20:32:16 +00:00
|
|
|
double delta_x,
|
|
|
|
double delta_y,
|
2015-10-21 00:14:40 +00:00
|
|
|
gboolean is_stop)
|
2015-10-20 03:21:54 +00:00
|
|
|
{
|
|
|
|
GdkEvent *event;
|
2017-07-20 11:26:00 +00:00
|
|
|
GdkDevice *source;
|
2015-10-20 03:21:54 +00:00
|
|
|
|
2017-07-20 11:26:00 +00:00
|
|
|
source = get_scroll_device (seat, seat->pointer_info.frame.source);
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_scroll_event_new (seat->pointer_info.focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_pointer,
|
2020-02-14 13:10:21 +00:00
|
|
|
source,
|
|
|
|
NULL,
|
|
|
|
seat->pointer_info.time,
|
2020-06-18 18:22:20 +00:00
|
|
|
device_get_modifiers (seat->logical_pointer),
|
2020-02-14 13:10:21 +00:00
|
|
|
delta_x, delta_y,
|
|
|
|
is_stop);
|
2015-10-20 03:21:54 +00:00
|
|
|
|
|
|
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
flush_scroll_event (GdkWaylandSeat *seat,
|
|
|
|
GdkWaylandPointerFrameData *pointer_frame)
|
|
|
|
{
|
2015-10-21 00:14:40 +00:00
|
|
|
gboolean is_stop = FALSE;
|
|
|
|
|
2015-10-20 03:21:54 +00:00
|
|
|
if (pointer_frame->discrete_x || pointer_frame->discrete_y)
|
|
|
|
{
|
|
|
|
GdkScrollDirection direction;
|
|
|
|
|
|
|
|
if (pointer_frame->discrete_x > 0)
|
|
|
|
direction = GDK_SCROLL_LEFT;
|
|
|
|
else if (pointer_frame->discrete_x < 0)
|
|
|
|
direction = GDK_SCROLL_RIGHT;
|
|
|
|
else if (pointer_frame->discrete_y > 0)
|
|
|
|
direction = GDK_SCROLL_DOWN;
|
2016-05-03 08:44:16 +00:00
|
|
|
else
|
|
|
|
direction = GDK_SCROLL_UP;
|
2015-10-20 03:21:54 +00:00
|
|
|
|
|
|
|
flush_discrete_scroll_event (seat, direction);
|
2016-04-18 13:10:49 +00:00
|
|
|
pointer_frame->discrete_x = 0;
|
|
|
|
pointer_frame->discrete_y = 0;
|
2015-10-20 03:21:54 +00:00
|
|
|
}
|
2017-09-15 11:20:16 +00:00
|
|
|
else if (pointer_frame->is_scroll_stop ||
|
|
|
|
pointer_frame->delta_x != 0 ||
|
|
|
|
pointer_frame->delta_y != 0)
|
2016-04-18 13:10:49 +00:00
|
|
|
{
|
|
|
|
/* Axes can stop independently, if we stop on one axis but have a
|
|
|
|
* delta on the other, we don't count it as a stop event.
|
|
|
|
*/
|
|
|
|
if (pointer_frame->is_scroll_stop &&
|
|
|
|
pointer_frame->delta_x == 0 &&
|
|
|
|
pointer_frame->delta_y == 0)
|
|
|
|
is_stop = TRUE;
|
|
|
|
|
|
|
|
flush_smooth_scroll_event (seat,
|
|
|
|
pointer_frame->delta_x,
|
|
|
|
pointer_frame->delta_y,
|
|
|
|
is_stop);
|
|
|
|
}
|
2017-09-15 11:20:16 +00:00
|
|
|
|
|
|
|
pointer_frame->discrete_x = 0;
|
|
|
|
pointer_frame->discrete_y = 0;
|
|
|
|
pointer_frame->delta_x = 0;
|
|
|
|
pointer_frame->delta_y = 0;
|
|
|
|
pointer_frame->is_scroll_stop = FALSE;
|
2015-10-20 03:21:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_seat_flush_frame_event (GdkWaylandSeat *seat)
|
|
|
|
{
|
2015-06-19 15:25:54 +00:00
|
|
|
if (seat->pointer_info.frame.event)
|
2015-10-20 03:21:54 +00:00
|
|
|
{
|
|
|
|
_gdk_wayland_display_deliver_event (gdk_seat_get_display (GDK_SEAT (seat)),
|
2015-06-19 15:25:54 +00:00
|
|
|
seat->pointer_info.frame.event);
|
|
|
|
seat->pointer_info.frame.event = NULL;
|
2015-10-20 03:21:54 +00:00
|
|
|
}
|
|
|
|
else
|
2016-06-01 03:14:30 +00:00
|
|
|
{
|
|
|
|
flush_scroll_event (seat, &seat->pointer_info.frame);
|
|
|
|
seat->pointer_info.frame.source = 0;
|
|
|
|
}
|
2015-10-20 03:21:54 +00:00
|
|
|
}
|
|
|
|
|
2020-02-14 13:10:21 +00:00
|
|
|
static void
|
|
|
|
gdk_wayland_seat_set_frame_event (GdkWaylandSeat *seat,
|
|
|
|
GdkEvent *event)
|
2015-10-20 03:21:54 +00:00
|
|
|
{
|
2015-06-19 15:25:54 +00:00
|
|
|
if (seat->pointer_info.frame.event &&
|
2020-02-18 03:11:56 +00:00
|
|
|
gdk_event_get_event_type (seat->pointer_info.frame.event) != gdk_event_get_event_type (event))
|
2015-10-20 03:21:54 +00:00
|
|
|
gdk_wayland_seat_flush_frame_event (seat);
|
|
|
|
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->pointer_info.frame.event = event;
|
2015-10-20 03:21:54 +00:00
|
|
|
}
|
|
|
|
|
2012-07-11 13:29:43 +00:00
|
|
|
static void
|
|
|
|
pointer_handle_enter (void *data,
|
|
|
|
struct wl_pointer *pointer,
|
|
|
|
uint32_t serial,
|
|
|
|
struct wl_surface *surface,
|
|
|
|
wl_fixed_t sx,
|
|
|
|
wl_fixed_t sy)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2012-07-11 13:29:43 +00:00
|
|
|
GdkEvent *event;
|
2020-02-14 13:10:21 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
|
2012-07-11 16:08:39 +00:00
|
|
|
|
2013-02-07 15:38:40 +00:00
|
|
|
if (!surface)
|
|
|
|
return;
|
2015-02-28 03:28:28 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (!GDK_IS_SURFACE (wl_surface_get_user_data (surface)))
|
2013-08-04 12:32:41 +00:00
|
|
|
return;
|
2013-02-07 15:38:40 +00:00
|
|
|
|
2016-04-26 03:16:56 +00:00
|
|
|
_gdk_wayland_display_update_serial (display_wayland, serial);
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2016-05-04 02:36:20 +00:00
|
|
|
seat->pointer_info.focus = wl_surface_get_user_data (surface);
|
|
|
|
g_object_ref (seat->pointer_info.focus);
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
seat->pointer_info.button_modifiers = 0;
|
2016-01-18 12:31:35 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
seat->pointer_info.surface_x = wl_fixed_to_double (sx);
|
|
|
|
seat->pointer_info.surface_y = wl_fixed_to_double (sy);
|
|
|
|
seat->pointer_info.enter_serial = serial;
|
2014-03-17 18:58:37 +00:00
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_crossing_event_new (GDK_ENTER_NOTIFY,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->pointer_info.focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_pointer,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->pointer,
|
|
|
|
0,
|
|
|
|
0,
|
2020-02-14 22:46:56 +00:00
|
|
|
seat->pointer_info.surface_x,
|
|
|
|
seat->pointer_info.surface_y,
|
2020-02-14 13:10:21 +00:00
|
|
|
GDK_CROSSING_NORMAL,
|
|
|
|
GDK_NOTIFY_NONLINEAR);
|
|
|
|
gdk_wayland_seat_set_frame_event (seat, event);
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_wayland_device_update_surface_cursor (seat->logical_pointer);
|
2014-09-01 16:53:00 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2016-03-17 17:32:03 +00:00
|
|
|
g_message ("enter, seat %p surface %p",
|
2015-06-19 15:25:54 +00:00
|
|
|
seat, seat->pointer_info.focus));
|
2015-10-20 03:21:54 +00:00
|
|
|
|
2016-04-26 03:16:56 +00:00
|
|
|
if (display_wayland->seat_version < WL_POINTER_HAS_FRAME)
|
2016-03-17 17:32:03 +00:00
|
|
|
gdk_wayland_seat_flush_frame_event (seat);
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pointer_handle_leave (void *data,
|
|
|
|
struct wl_pointer *pointer,
|
|
|
|
uint32_t serial,
|
|
|
|
struct wl_surface *surface)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2012-07-11 13:29:43 +00:00
|
|
|
GdkEvent *event;
|
2016-04-26 03:16:56 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
|
2012-07-11 16:08:39 +00:00
|
|
|
|
2013-02-07 15:38:40 +00:00
|
|
|
if (!surface)
|
|
|
|
return;
|
2015-02-28 03:28:28 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (!GDK_IS_SURFACE (wl_surface_get_user_data (surface)))
|
2013-08-04 12:32:41 +00:00
|
|
|
return;
|
2015-02-28 03:28:28 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
if (!seat->pointer_info.focus)
|
2013-08-04 13:01:10 +00:00
|
|
|
return;
|
2013-02-07 15:38:40 +00:00
|
|
|
|
2016-04-26 03:16:56 +00:00
|
|
|
_gdk_wayland_display_update_serial (display_wayland, serial);
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2020-05-12 08:21:35 +00:00
|
|
|
if (seat->pointer_info.button_modifiers != 0)
|
|
|
|
{
|
|
|
|
gulong display_serial;
|
|
|
|
|
|
|
|
display_serial = _gdk_display_get_next_serial (seat->display);
|
2020-06-18 18:22:20 +00:00
|
|
|
_gdk_display_end_device_grab (seat->display, seat->logical_pointer,
|
2020-05-12 08:21:35 +00:00
|
|
|
display_serial, NULL, TRUE);
|
|
|
|
_gdk_display_device_grab_update (seat->display,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_pointer,
|
2020-05-12 08:21:35 +00:00
|
|
|
seat->pointer,
|
|
|
|
display_serial);
|
|
|
|
}
|
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_crossing_event_new (GDK_LEAVE_NOTIFY,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->pointer_info.focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_pointer,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->pointer,
|
|
|
|
0,
|
|
|
|
0,
|
2020-02-14 22:46:56 +00:00
|
|
|
seat->pointer_info.surface_x,
|
|
|
|
seat->pointer_info.surface_y,
|
2020-02-14 13:10:21 +00:00
|
|
|
GDK_CROSSING_NORMAL,
|
|
|
|
GDK_NOTIFY_NONLINEAR);
|
|
|
|
gdk_wayland_seat_set_frame_event (seat, event);
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_wayland_device_update_surface_cursor (seat->logical_pointer);
|
2014-09-01 16:53:00 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2016-03-17 17:32:03 +00:00
|
|
|
g_message ("leave, seat %p surface %p",
|
2015-06-19 15:25:54 +00:00
|
|
|
seat, seat->pointer_info.focus));
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
g_object_unref (seat->pointer_info.focus);
|
|
|
|
seat->pointer_info.focus = NULL;
|
2016-03-17 17:32:03 +00:00
|
|
|
if (seat->cursor)
|
2015-06-19 15:25:54 +00:00
|
|
|
gdk_wayland_pointer_stop_cursor_animation (&seat->pointer_info);
|
2013-03-21 12:51:35 +00:00
|
|
|
|
2016-04-26 03:16:56 +00:00
|
|
|
if (display_wayland->seat_version < WL_POINTER_HAS_FRAME)
|
2016-03-17 17:32:03 +00:00
|
|
|
gdk_wayland_seat_flush_frame_event (seat);
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pointer_handle_motion (void *data,
|
|
|
|
struct wl_pointer *pointer,
|
|
|
|
uint32_t time,
|
|
|
|
wl_fixed_t sx,
|
|
|
|
wl_fixed_t sy)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
|
2012-07-11 13:29:43 +00:00
|
|
|
GdkEvent *event;
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
if (!seat->pointer_info.focus)
|
2013-08-04 13:01:10 +00:00
|
|
|
return;
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
seat->pointer_info.time = time;
|
|
|
|
seat->pointer_info.surface_x = wl_fixed_to_double (sx);
|
|
|
|
seat->pointer_info.surface_y = wl_fixed_to_double (sy);
|
2012-07-11 13:29:43 +00:00
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_motion_event_new (seat->pointer_info.focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_pointer,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->pointer,
|
|
|
|
NULL,
|
|
|
|
time,
|
2020-06-18 18:22:20 +00:00
|
|
|
device_get_modifiers (seat->logical_pointer),
|
2020-02-14 22:46:56 +00:00
|
|
|
seat->pointer_info.surface_x,
|
|
|
|
seat->pointer_info.surface_y,
|
2020-02-14 13:10:21 +00:00
|
|
|
NULL);
|
|
|
|
gdk_wayland_seat_set_frame_event (seat, event);
|
2014-03-17 18:58:37 +00:00
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
if (GDK_DISPLAY_DEBUG_CHECK (gdk_seat_get_display (GDK_SEAT (seat)), EVENTS))
|
|
|
|
{
|
|
|
|
double x, y;
|
|
|
|
gdk_event_get_position (event, &x, &y);
|
|
|
|
g_message ("motion %f %f, seat %p state %d",
|
|
|
|
x, y, seat, gdk_event_get_modifier_state (event));
|
|
|
|
}
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2015-10-20 03:21:54 +00:00
|
|
|
if (display->seat_version < WL_POINTER_HAS_FRAME)
|
2016-03-17 17:32:03 +00:00
|
|
|
gdk_wayland_seat_flush_frame_event (seat);
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pointer_handle_button (void *data,
|
|
|
|
struct wl_pointer *pointer,
|
|
|
|
uint32_t serial,
|
|
|
|
uint32_t time,
|
|
|
|
uint32_t button,
|
|
|
|
uint32_t state)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
|
2012-07-11 13:29:43 +00:00
|
|
|
GdkEvent *event;
|
|
|
|
uint32_t modifier;
|
|
|
|
int gdk_button;
|
2012-07-11 16:08:39 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
if (!seat->pointer_info.focus)
|
2013-08-04 13:01:10 +00:00
|
|
|
return;
|
|
|
|
|
2015-02-28 03:28:28 +00:00
|
|
|
_gdk_wayland_display_update_serial (display, serial);
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2015-02-28 03:28:28 +00:00
|
|
|
switch (button)
|
|
|
|
{
|
2015-11-16 11:51:42 +00:00
|
|
|
case BTN_LEFT:
|
|
|
|
gdk_button = GDK_BUTTON_PRIMARY;
|
|
|
|
break;
|
|
|
|
case BTN_MIDDLE:
|
|
|
|
gdk_button = GDK_BUTTON_MIDDLE;
|
2015-02-28 03:28:28 +00:00
|
|
|
break;
|
2015-11-16 11:51:42 +00:00
|
|
|
case BTN_RIGHT:
|
|
|
|
gdk_button = GDK_BUTTON_SECONDARY;
|
2015-02-28 03:28:28 +00:00
|
|
|
break;
|
|
|
|
default:
|
2015-11-16 11:51:42 +00:00
|
|
|
/* For compatibility reasons, all additional buttons go after the old 4-7 scroll ones */
|
|
|
|
gdk_button = button - BUTTON_BASE + 4;
|
2015-02-28 03:28:28 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
seat->pointer_info.time = time;
|
2013-03-27 17:21:54 +00:00
|
|
|
if (state)
|
2015-06-19 15:25:54 +00:00
|
|
|
seat->pointer_info.press_serial = serial;
|
2012-07-11 13:29:43 +00:00
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_button_event_new (state ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->pointer_info.focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_pointer,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->pointer,
|
|
|
|
NULL,
|
|
|
|
time,
|
2020-06-18 18:22:20 +00:00
|
|
|
device_get_modifiers (seat->logical_pointer),
|
2020-02-14 13:10:21 +00:00
|
|
|
gdk_button,
|
2020-02-14 22:46:56 +00:00
|
|
|
seat->pointer_info.surface_x,
|
|
|
|
seat->pointer_info.surface_y,
|
2020-02-14 13:10:21 +00:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
gdk_wayland_seat_set_frame_event (seat, event);
|
2014-03-17 18:58:37 +00:00
|
|
|
|
2012-07-11 13:29:43 +00:00
|
|
|
modifier = 1 << (8 + gdk_button - 1);
|
|
|
|
if (state)
|
2015-06-19 15:25:54 +00:00
|
|
|
seat->pointer_info.button_modifiers |= modifier;
|
2012-07-11 13:29:43 +00:00
|
|
|
else
|
2015-06-19 15:25:54 +00:00
|
|
|
seat->pointer_info.button_modifiers &= ~modifier;
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2016-03-17 17:32:03 +00:00
|
|
|
g_message ("button %d %s, seat %p state %d",
|
2020-02-18 03:11:56 +00:00
|
|
|
gdk_button_event_get_button (event),
|
2015-02-28 05:15:13 +00:00
|
|
|
state ? "press" : "release",
|
2016-03-17 17:32:03 +00:00
|
|
|
seat,
|
2020-02-18 03:11:56 +00:00
|
|
|
gdk_event_get_modifier_state (event)));
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2015-10-20 03:21:54 +00:00
|
|
|
if (display->seat_version < WL_POINTER_HAS_FRAME)
|
2016-03-17 17:32:03 +00:00
|
|
|
gdk_wayland_seat_flush_frame_event (seat);
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
2016-06-01 02:05:58 +00:00
|
|
|
#ifdef G_ENABLE_DEBUG
|
|
|
|
|
2017-04-28 21:47:29 +00:00
|
|
|
static const char *
|
2016-06-01 02:05:58 +00:00
|
|
|
get_axis_name (uint32_t axis)
|
|
|
|
{
|
|
|
|
switch (axis)
|
|
|
|
{
|
|
|
|
case WL_POINTER_AXIS_VERTICAL_SCROLL:
|
|
|
|
return "horizontal";
|
|
|
|
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
|
|
|
|
return "vertical";
|
|
|
|
default:
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2012-07-11 13:29:43 +00:00
|
|
|
static void
|
|
|
|
pointer_handle_axis (void *data,
|
|
|
|
struct wl_pointer *pointer,
|
|
|
|
uint32_t time,
|
|
|
|
uint32_t axis,
|
|
|
|
wl_fixed_t value)
|
|
|
|
{
|
2015-10-20 03:21:54 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2015-06-19 15:25:54 +00:00
|
|
|
GdkWaylandPointerFrameData *pointer_frame = &seat->pointer_info.frame;
|
2015-10-20 03:21:54 +00:00
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
|
2012-07-13 14:29:25 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
if (!seat->pointer_info.focus)
|
2013-08-04 13:01:10 +00:00
|
|
|
return;
|
|
|
|
|
2013-02-05 17:00:10 +00:00
|
|
|
/* get the delta and convert it into the expected range */
|
2015-02-28 03:28:28 +00:00
|
|
|
switch (axis)
|
|
|
|
{
|
|
|
|
case WL_POINTER_AXIS_VERTICAL_SCROLL:
|
2015-10-20 03:21:54 +00:00
|
|
|
pointer_frame->delta_y = wl_fixed_to_double (value) / 10.0;
|
2015-02-28 03:28:28 +00:00
|
|
|
break;
|
|
|
|
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
|
2015-10-20 03:21:54 +00:00
|
|
|
pointer_frame->delta_x = wl_fixed_to_double (value) / 10.0;
|
2015-02-28 03:28:28 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_return_if_reached ();
|
|
|
|
}
|
2012-07-13 14:29:25 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
seat->pointer_info.time = time;
|
2012-07-13 14:29:25 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2016-06-01 02:05:58 +00:00
|
|
|
g_message ("scroll, axis %s, value %f, seat %p",
|
|
|
|
get_axis_name (axis), wl_fixed_to_double (value) / 10.0,
|
2015-10-20 03:21:54 +00:00
|
|
|
seat));
|
|
|
|
|
|
|
|
if (display->seat_version < WL_POINTER_HAS_FRAME)
|
|
|
|
gdk_wayland_seat_flush_frame_event (seat);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pointer_handle_frame (void *data,
|
|
|
|
struct wl_pointer *pointer)
|
|
|
|
{
|
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2015-10-20 03:21:54 +00:00
|
|
|
g_message ("frame, seat %p", seat));
|
2012-07-13 14:29:25 +00:00
|
|
|
|
2015-10-20 03:21:54 +00:00
|
|
|
gdk_wayland_seat_flush_frame_event (seat);
|
|
|
|
}
|
|
|
|
|
2016-06-01 02:05:58 +00:00
|
|
|
#ifdef G_ENABLE_DEBUG
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
get_axis_source_name (enum wl_pointer_axis_source source)
|
|
|
|
{
|
|
|
|
switch (source)
|
|
|
|
{
|
|
|
|
case WL_POINTER_AXIS_SOURCE_WHEEL:
|
|
|
|
return "wheel";
|
|
|
|
case WL_POINTER_AXIS_SOURCE_FINGER:
|
|
|
|
return "finger";
|
|
|
|
case WL_POINTER_AXIS_SOURCE_CONTINUOUS:
|
|
|
|
return "continuous";
|
2017-10-06 19:19:42 +00:00
|
|
|
case WL_POINTER_AXIS_SOURCE_WHEEL_TILT:
|
|
|
|
return "wheel-tilt";
|
2016-06-01 02:05:58 +00:00
|
|
|
default:
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2015-10-20 03:21:54 +00:00
|
|
|
static void
|
|
|
|
pointer_handle_axis_source (void *data,
|
|
|
|
struct wl_pointer *pointer,
|
|
|
|
enum wl_pointer_axis_source source)
|
|
|
|
{
|
|
|
|
GdkWaylandSeat *seat = data;
|
2016-06-01 03:14:30 +00:00
|
|
|
GdkWaylandPointerFrameData *pointer_frame = &seat->pointer_info.frame;
|
2015-10-20 03:21:54 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
if (!seat->pointer_info.focus)
|
2015-10-20 03:21:54 +00:00
|
|
|
return;
|
|
|
|
|
2016-06-01 03:14:30 +00:00
|
|
|
pointer_frame->source = source;
|
2015-10-20 03:21:54 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2016-06-01 02:05:58 +00:00
|
|
|
g_message ("axis source %s, seat %p", get_axis_source_name (source), seat));
|
2015-10-20 03:21:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pointer_handle_axis_stop (void *data,
|
|
|
|
struct wl_pointer *pointer,
|
|
|
|
uint32_t time,
|
|
|
|
uint32_t axis)
|
|
|
|
{
|
|
|
|
GdkWaylandSeat *seat = data;
|
2015-06-19 15:25:54 +00:00
|
|
|
GdkWaylandPointerFrameData *pointer_frame = &seat->pointer_info.frame;
|
2015-10-20 03:21:54 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
if (!seat->pointer_info.focus)
|
2015-10-20 03:21:54 +00:00
|
|
|
return;
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
seat->pointer_info.time = time;
|
2015-10-20 03:21:54 +00:00
|
|
|
|
|
|
|
switch (axis)
|
|
|
|
{
|
|
|
|
case WL_POINTER_AXIS_VERTICAL_SCROLL:
|
|
|
|
pointer_frame->delta_y = 0;
|
|
|
|
break;
|
|
|
|
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
|
|
|
|
pointer_frame->delta_x = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_return_if_reached ();
|
|
|
|
}
|
|
|
|
|
2015-10-21 00:14:40 +00:00
|
|
|
pointer_frame->is_scroll_stop = TRUE;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2016-06-01 02:05:58 +00:00
|
|
|
g_message ("axis %s stop, seat %p", get_axis_name (axis), seat));
|
2015-10-20 03:21:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pointer_handle_axis_discrete (void *data,
|
|
|
|
struct wl_pointer *pointer,
|
|
|
|
uint32_t axis,
|
|
|
|
int32_t value)
|
|
|
|
{
|
|
|
|
GdkWaylandSeat *seat = data;
|
2015-06-19 15:25:54 +00:00
|
|
|
GdkWaylandPointerFrameData *pointer_frame = &seat->pointer_info.frame;
|
2015-10-20 03:21:54 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
if (!seat->pointer_info.focus)
|
2015-10-20 03:21:54 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
switch (axis)
|
|
|
|
{
|
|
|
|
case WL_POINTER_AXIS_VERTICAL_SCROLL:
|
|
|
|
pointer_frame->discrete_y = value;
|
|
|
|
break;
|
|
|
|
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
|
|
|
|
pointer_frame->discrete_x = value;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_return_if_reached ();
|
|
|
|
}
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2016-06-01 02:05:58 +00:00
|
|
|
g_message ("discrete scroll, axis %s, value %d, seat %p",
|
|
|
|
get_axis_name (axis), value, seat));
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
keyboard_handle_keymap (void *data,
|
2014-07-25 13:27:22 +00:00
|
|
|
struct wl_keyboard *keyboard,
|
|
|
|
uint32_t format,
|
|
|
|
int fd,
|
|
|
|
uint32_t size)
|
2012-07-11 13:29:43 +00:00
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2016-05-04 02:52:38 +00:00
|
|
|
PangoDirection direction;
|
2020-04-05 04:37:51 +00:00
|
|
|
gboolean bidi;
|
|
|
|
gboolean caps_lock;
|
|
|
|
gboolean num_lock;
|
|
|
|
gboolean scroll_lock;
|
|
|
|
GdkModifierType modifiers;
|
2016-05-04 02:52:38 +00:00
|
|
|
|
|
|
|
direction = gdk_keymap_get_direction (seat->keymap);
|
2020-04-05 04:37:51 +00:00
|
|
|
bidi = gdk_keymap_have_bidi_layouts (seat->keymap);
|
|
|
|
caps_lock = gdk_keymap_get_caps_lock_state (seat->keymap);
|
|
|
|
num_lock = gdk_keymap_get_num_lock_state (seat->keymap);
|
|
|
|
scroll_lock = gdk_keymap_get_scroll_lock_state (seat->keymap);
|
|
|
|
modifiers = gdk_keymap_get_modifier_state (seat->keymap);
|
2012-07-16 11:33:35 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
_gdk_wayland_keymap_update_from_fd (seat->keymap, format, fd, size);
|
2013-03-23 22:02:28 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
g_signal_emit_by_name (seat->keymap, "keys-changed");
|
|
|
|
g_signal_emit_by_name (seat->keymap, "state-changed");
|
2016-05-04 02:52:38 +00:00
|
|
|
if (direction != gdk_keymap_get_direction (seat->keymap))
|
|
|
|
g_signal_emit_by_name (seat->keymap, "direction-changed");
|
2020-04-05 04:37:51 +00:00
|
|
|
|
|
|
|
if (direction != gdk_keymap_get_direction (seat->keymap))
|
2020-06-18 18:22:20 +00:00
|
|
|
g_object_notify (G_OBJECT (seat->logical_keyboard), "direction");
|
2020-04-05 04:37:51 +00:00
|
|
|
if (bidi != gdk_keymap_have_bidi_layouts (seat->keymap))
|
2020-06-18 18:22:20 +00:00
|
|
|
g_object_notify (G_OBJECT (seat->logical_keyboard), "has-bidi-layouts");
|
2020-04-05 04:37:51 +00:00
|
|
|
if (caps_lock != gdk_keymap_get_caps_lock_state (seat->keymap))
|
2020-06-18 18:22:20 +00:00
|
|
|
g_object_notify (G_OBJECT (seat->logical_keyboard), "caps-lock-state");
|
2020-04-05 04:37:51 +00:00
|
|
|
if (num_lock != gdk_keymap_get_num_lock_state (seat->keymap))
|
2020-06-18 18:22:20 +00:00
|
|
|
g_object_notify (G_OBJECT (seat->logical_keyboard), "num-lock-state");
|
2020-04-05 04:37:51 +00:00
|
|
|
if (scroll_lock != gdk_keymap_get_scroll_lock_state (seat->keymap))
|
2020-06-18 18:22:20 +00:00
|
|
|
g_object_notify (G_OBJECT (seat->logical_keyboard), "scroll-lock-state");
|
2020-04-05 04:37:51 +00:00
|
|
|
if (modifiers != gdk_keymap_get_modifier_state (seat->keymap))
|
2020-06-18 18:22:20 +00:00
|
|
|
g_object_notify (G_OBJECT (seat->logical_keyboard), "modifier-state");
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
keyboard_handle_enter (void *data,
|
|
|
|
struct wl_keyboard *keyboard,
|
|
|
|
uint32_t serial,
|
|
|
|
struct wl_surface *surface,
|
|
|
|
struct wl_array *keys)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2012-07-16 12:40:55 +00:00
|
|
|
GdkEvent *event;
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
|
2012-07-16 12:40:55 +00:00
|
|
|
|
2013-02-07 15:38:40 +00:00
|
|
|
if (!surface)
|
|
|
|
return;
|
2015-02-28 03:28:28 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
if (!GDK_IS_SURFACE (wl_surface_get_user_data (surface)))
|
2013-08-04 12:32:41 +00:00
|
|
|
return;
|
2013-02-07 15:38:40 +00:00
|
|
|
|
2015-02-28 03:28:28 +00:00
|
|
|
_gdk_wayland_display_update_serial (display, serial);
|
2012-07-16 12:40:55 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
seat->keyboard_focus = wl_surface_get_user_data (surface);
|
|
|
|
g_object_ref (seat->keyboard_focus);
|
2017-04-13 14:37:22 +00:00
|
|
|
seat->repeat_key = 0;
|
2012-07-16 12:40:55 +00:00
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_focus_event_new (seat->keyboard_focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_keyboard,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->keyboard,
|
|
|
|
TRUE);
|
2012-07-16 12:40:55 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2016-03-17 17:32:03 +00:00
|
|
|
g_message ("focus in, seat %p surface %p",
|
|
|
|
seat, seat->keyboard_focus));
|
2012-07-16 12:40:55 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
static void stop_key_repeat (GdkWaylandSeat *seat);
|
2015-08-31 15:31:24 +00:00
|
|
|
|
2012-07-11 13:29:43 +00:00
|
|
|
static void
|
|
|
|
keyboard_handle_leave (void *data,
|
|
|
|
struct wl_keyboard *keyboard,
|
|
|
|
uint32_t serial,
|
|
|
|
struct wl_surface *surface)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2012-07-16 12:40:55 +00:00
|
|
|
GdkEvent *event;
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
|
2012-07-16 12:40:55 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
if (!seat->keyboard_focus)
|
2013-08-04 13:01:10 +00:00
|
|
|
return;
|
2013-02-07 15:38:40 +00:00
|
|
|
|
2018-03-20 10:40:08 +00:00
|
|
|
/* gdk_surface_is_destroyed() might already return TRUE for
|
2016-03-17 17:32:03 +00:00
|
|
|
* seat->keyboard_focus here, which would happen if we destroyed the
|
2018-03-20 14:14:10 +00:00
|
|
|
* surface before loosing keyboard focus.
|
2015-10-06 06:30:28 +00:00
|
|
|
*/
|
2016-03-17 17:32:03 +00:00
|
|
|
stop_key_repeat (seat);
|
2015-08-31 15:04:10 +00:00
|
|
|
|
2015-02-28 03:28:28 +00:00
|
|
|
_gdk_wayland_display_update_serial (display, serial);
|
2012-07-16 12:40:55 +00:00
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_focus_event_new (seat->keyboard_focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_keyboard,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->keyboard,
|
|
|
|
FALSE);
|
2012-07-16 12:40:55 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
g_object_unref (seat->keyboard_focus);
|
|
|
|
seat->keyboard_focus = NULL;
|
2017-04-13 14:37:22 +00:00
|
|
|
seat->repeat_key = 0;
|
2020-04-02 17:31:22 +00:00
|
|
|
seat->key_modifiers = 0;
|
2012-07-16 12:40:55 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2016-03-17 17:32:03 +00:00
|
|
|
g_message ("focus out, seat %p surface %p",
|
2020-02-18 03:11:56 +00:00
|
|
|
seat, gdk_event_get_surface (event)));
|
2012-07-16 12:40:55 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
2015-02-28 03:28:28 +00:00
|
|
|
static gboolean keyboard_repeat (gpointer data);
|
2012-07-16 19:08:20 +00:00
|
|
|
|
2013-03-22 22:09:23 +00:00
|
|
|
static gboolean
|
2016-03-17 17:32:03 +00:00
|
|
|
get_key_repeat (GdkWaylandSeat *seat,
|
|
|
|
guint *delay,
|
|
|
|
guint *interval)
|
2013-03-22 22:09:23 +00:00
|
|
|
{
|
2013-03-22 22:26:33 +00:00
|
|
|
gboolean repeat;
|
2013-03-22 22:09:23 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
if (seat->have_server_repeat)
|
2013-03-22 22:26:33 +00:00
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
if (seat->server_repeat_rate > 0)
|
2014-07-25 13:37:06 +00:00
|
|
|
{
|
|
|
|
repeat = TRUE;
|
2016-03-17 17:32:03 +00:00
|
|
|
*delay = seat->server_repeat_delay;
|
|
|
|
*interval = (1000 / seat->server_repeat_rate);
|
2014-07-25 13:37:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
repeat = FALSE;
|
|
|
|
}
|
2013-03-22 22:26:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-30 01:55:13 +00:00
|
|
|
repeat = TRUE;
|
|
|
|
*delay = 400;
|
|
|
|
*interval = 80;
|
2013-03-22 22:26:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return repeat;
|
2013-03-22 22:09:23 +00:00
|
|
|
}
|
|
|
|
|
2015-08-31 14:54:07 +00:00
|
|
|
static void
|
2016-03-17 17:32:03 +00:00
|
|
|
stop_key_repeat (GdkWaylandSeat *seat)
|
2015-08-31 14:54:07 +00:00
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
if (seat->repeat_timer)
|
2015-08-31 14:54:07 +00:00
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
g_source_remove (seat->repeat_timer);
|
|
|
|
seat->repeat_timer = 0;
|
2015-08-31 14:54:07 +00:00
|
|
|
}
|
2016-02-25 18:58:42 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
g_clear_pointer (&seat->repeat_callback, wl_callback_destroy);
|
2015-08-31 14:54:07 +00:00
|
|
|
}
|
|
|
|
|
2016-03-01 13:29:31 +00:00
|
|
|
static void
|
2016-03-17 17:32:03 +00:00
|
|
|
deliver_key_event (GdkWaylandSeat *seat,
|
|
|
|
uint32_t time_,
|
|
|
|
uint32_t key,
|
2017-02-02 09:43:45 +00:00
|
|
|
uint32_t state,
|
|
|
|
gboolean from_key_repeat)
|
2012-07-16 19:08:20 +00:00
|
|
|
{
|
|
|
|
GdkEvent *event;
|
|
|
|
struct xkb_state *xkb_state;
|
2013-03-23 21:09:38 +00:00
|
|
|
struct xkb_keymap *xkb_keymap;
|
2012-07-16 19:08:20 +00:00
|
|
|
GdkKeymap *keymap;
|
2016-03-01 13:29:31 +00:00
|
|
|
guint delay, interval, timeout;
|
2016-04-26 01:10:09 +00:00
|
|
|
gint64 begin_time, now;
|
2020-04-05 18:40:55 +00:00
|
|
|
xkb_mod_mask_t consumed;
|
|
|
|
GdkTranslatedKey translated;
|
|
|
|
GdkTranslatedKey no_lock;
|
|
|
|
xkb_mod_mask_t modifiers;
|
|
|
|
xkb_mod_index_t caps_lock;
|
2016-04-26 01:10:09 +00:00
|
|
|
|
|
|
|
begin_time = g_get_monotonic_time ();
|
2016-03-01 13:29:31 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
stop_key_repeat (seat);
|
2012-07-16 19:08:20 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
keymap = seat->keymap;
|
2012-07-16 19:08:20 +00:00
|
|
|
xkb_state = _gdk_wayland_keymap_get_xkb_state (keymap);
|
2013-03-23 21:09:38 +00:00
|
|
|
xkb_keymap = _gdk_wayland_keymap_get_xkb_keymap (keymap);
|
2012-07-16 19:08:20 +00:00
|
|
|
|
2020-04-05 18:40:55 +00:00
|
|
|
translated.keyval = xkb_state_key_get_one_sym (xkb_state, key);
|
|
|
|
modifiers = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_EFFECTIVE);
|
|
|
|
consumed = modifiers & ~xkb_state_mod_mask_remove_consumed (xkb_state, key, modifiers);
|
|
|
|
translated.consumed = gdk_wayland_keymap_get_gdk_modifiers (keymap, consumed);
|
|
|
|
translated.layout = xkb_state_key_get_layout (xkb_state, key);
|
|
|
|
translated.level = xkb_state_key_get_level (xkb_state, key, translated.layout);
|
|
|
|
|
|
|
|
if (translated.keyval == XKB_KEY_NoSymbol)
|
2016-04-27 12:06:38 +00:00
|
|
|
return;
|
2012-07-16 19:08:20 +00:00
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
seat->pointer_info.time = time_;
|
2016-03-17 17:32:03 +00:00
|
|
|
seat->key_modifiers = gdk_keymap_get_modifier_state (keymap);
|
2012-07-16 19:08:20 +00:00
|
|
|
|
2020-04-05 18:40:55 +00:00
|
|
|
|
|
|
|
modifiers = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_EFFECTIVE);
|
|
|
|
caps_lock = xkb_keymap_mod_get_index (xkb_keymap, XKB_MOD_NAME_CAPS);
|
|
|
|
if (modifiers & (1 << caps_lock))
|
|
|
|
{
|
|
|
|
struct xkb_state *tmp_state = xkb_state_new (xkb_keymap);
|
|
|
|
xkb_layout_index_t layout;
|
|
|
|
|
|
|
|
modifiers &= ~(1 << caps_lock);
|
|
|
|
layout = xkb_state_serialize_layout (xkb_state, XKB_STATE_LAYOUT_EFFECTIVE);
|
|
|
|
xkb_state_update_mask (tmp_state, modifiers, 0, 0, layout, 0, 0);
|
|
|
|
|
|
|
|
no_lock.keyval = xkb_state_key_get_one_sym (tmp_state, key);
|
|
|
|
consumed = modifiers & ~xkb_state_mod_mask_remove_consumed (tmp_state, key, modifiers);
|
|
|
|
no_lock.consumed = gdk_wayland_keymap_get_gdk_modifiers (keymap, consumed);
|
|
|
|
no_lock.layout = xkb_state_key_get_layout (tmp_state, key);
|
|
|
|
no_lock.level = xkb_state_key_get_level (tmp_state, key, no_lock.layout);
|
|
|
|
|
|
|
|
xkb_state_unref (tmp_state);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
no_lock = translated;
|
|
|
|
}
|
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_key_event_new (state ? GDK_KEY_PRESS : GDK_KEY_RELEASE,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->keyboard_focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_keyboard,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->keyboard,
|
|
|
|
time_,
|
|
|
|
key,
|
2020-06-18 18:22:20 +00:00
|
|
|
device_get_modifiers (seat->logical_pointer),
|
2020-04-05 18:40:55 +00:00
|
|
|
_gdk_wayland_keymap_key_is_modifier (keymap, key),
|
|
|
|
&translated,
|
|
|
|
&no_lock);
|
2012-07-16 19:08:20 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
2012-07-16 19:08:20 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2019-03-20 00:04:49 +00:00
|
|
|
g_message ("keyboard %s event%s, surface %p, code %d, sym %d, "
|
2020-04-05 18:40:55 +00:00
|
|
|
"mods 0x%x, consumed 0x%x, layout %d level %d",
|
2017-04-26 13:35:42 +00:00
|
|
|
(state ? "press" : "release"),
|
|
|
|
(from_key_repeat ? " (repeat)" : ""),
|
2020-02-18 03:11:56 +00:00
|
|
|
gdk_event_get_surface (event),
|
|
|
|
gdk_key_event_get_keycode (event),
|
|
|
|
gdk_key_event_get_keyval (event),
|
2020-04-05 18:40:55 +00:00
|
|
|
gdk_event_get_modifier_state (event),
|
|
|
|
gdk_key_event_get_consumed_modifiers (event),
|
|
|
|
gdk_key_event_get_layout (event),
|
|
|
|
gdk_key_event_get_level (event)));
|
2012-07-16 19:08:20 +00:00
|
|
|
|
2013-03-23 21:09:38 +00:00
|
|
|
if (!xkb_keymap_key_repeats (xkb_keymap, key))
|
2016-03-01 13:29:31 +00:00
|
|
|
return;
|
2013-03-23 21:09:38 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
if (!get_key_repeat (seat, &delay, &interval))
|
2016-03-01 13:29:31 +00:00
|
|
|
return;
|
2013-03-22 22:09:23 +00:00
|
|
|
|
2017-02-02 09:43:45 +00:00
|
|
|
if (!from_key_repeat)
|
|
|
|
{
|
|
|
|
if (state) /* Another key is pressed */
|
|
|
|
{
|
|
|
|
seat->repeat_key = key;
|
|
|
|
}
|
2017-04-13 14:37:22 +00:00
|
|
|
else if (seat->repeat_key == key) /* Repeated key is released */
|
2017-02-02 09:43:45 +00:00
|
|
|
{
|
2017-04-13 14:37:22 +00:00
|
|
|
seat->repeat_key = 0;
|
2017-02-02 09:43:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-13 14:37:22 +00:00
|
|
|
if (!seat->repeat_key)
|
2017-02-02 09:43:45 +00:00
|
|
|
return;
|
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
seat->repeat_count++;
|
2012-07-16 19:08:20 +00:00
|
|
|
|
2016-04-26 01:10:09 +00:00
|
|
|
interval *= 1000L;
|
|
|
|
delay *= 1000L;
|
|
|
|
|
|
|
|
now = g_get_monotonic_time ();
|
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
if (seat->repeat_count == 1)
|
2016-04-26 01:10:09 +00:00
|
|
|
seat->repeat_deadline = begin_time + delay;
|
|
|
|
else if (seat->repeat_deadline + interval > now)
|
|
|
|
seat->repeat_deadline += interval;
|
2014-07-25 13:27:22 +00:00
|
|
|
else
|
2016-04-26 01:10:09 +00:00
|
|
|
/* frame delay caused us to miss repeat deadline */
|
|
|
|
seat->repeat_deadline = now;
|
|
|
|
|
|
|
|
timeout = (seat->repeat_deadline - now) / 1000L;
|
2016-03-01 13:29:31 +00:00
|
|
|
|
2018-02-02 14:51:47 +00:00
|
|
|
seat->repeat_timer = g_timeout_add (timeout, keyboard_repeat, seat);
|
2019-02-06 09:37:24 +00:00
|
|
|
g_source_set_name_by_id (seat->repeat_timer, "[gtk] keyboard_repeat");
|
2012-07-16 19:08:20 +00:00
|
|
|
}
|
|
|
|
|
2016-02-25 18:58:42 +00:00
|
|
|
static void
|
|
|
|
sync_after_repeat_callback (void *data,
|
|
|
|
struct wl_callback *callback,
|
|
|
|
uint32_t time)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2016-02-25 18:58:42 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
g_clear_pointer (&seat->repeat_callback, wl_callback_destroy);
|
2017-02-02 09:43:45 +00:00
|
|
|
deliver_key_event (seat, seat->keyboard_time, seat->repeat_key, 1, TRUE);
|
2016-02-25 18:58:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_callback_listener sync_after_repeat_callback_listener = {
|
|
|
|
sync_after_repeat_callback
|
|
|
|
};
|
|
|
|
|
2012-07-16 19:08:20 +00:00
|
|
|
static gboolean
|
|
|
|
keyboard_repeat (gpointer data)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
|
2012-07-16 19:08:20 +00:00
|
|
|
|
2016-02-25 18:58:42 +00:00
|
|
|
/* Ping the server and wait for the timeout. We won't process
|
|
|
|
* key repeat until it responds, since a hung server could lead
|
|
|
|
* to a delayed key release event. We don't want to generate
|
|
|
|
* repeat events long after the user released the key, just because
|
|
|
|
* the server is tardy in telling us the user released the key.
|
|
|
|
*/
|
2016-03-17 17:32:03 +00:00
|
|
|
seat->repeat_callback = wl_display_sync (display->wl_display);
|
2016-02-25 18:58:42 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
wl_callback_add_listener (seat->repeat_callback,
|
2016-02-25 18:58:42 +00:00
|
|
|
&sync_after_repeat_callback_listener,
|
2016-03-17 17:32:03 +00:00
|
|
|
seat);
|
2016-03-01 13:29:31 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
seat->repeat_timer = 0;
|
2016-03-01 13:29:31 +00:00
|
|
|
return G_SOURCE_REMOVE;
|
2012-07-16 19:08:20 +00:00
|
|
|
}
|
|
|
|
|
2012-07-11 13:29:43 +00:00
|
|
|
static void
|
|
|
|
keyboard_handle_key (void *data,
|
|
|
|
struct wl_keyboard *keyboard,
|
|
|
|
uint32_t serial,
|
|
|
|
uint32_t time,
|
|
|
|
uint32_t key,
|
|
|
|
uint32_t state_w)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
|
2012-07-16 19:08:20 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
if (!seat->keyboard_focus)
|
2013-08-04 13:01:10 +00:00
|
|
|
return;
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
seat->keyboard_time = time;
|
2016-06-30 10:56:21 +00:00
|
|
|
seat->keyboard_key_serial = serial;
|
2016-03-17 17:32:03 +00:00
|
|
|
seat->repeat_count = 0;
|
2015-02-28 03:28:28 +00:00
|
|
|
_gdk_wayland_display_update_serial (display, serial);
|
2017-02-02 09:43:45 +00:00
|
|
|
deliver_key_event (data, time, key + 8, state_w, FALSE);
|
|
|
|
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
keyboard_handle_modifiers (void *data,
|
|
|
|
struct wl_keyboard *keyboard,
|
|
|
|
uint32_t serial,
|
|
|
|
uint32_t mods_depressed,
|
|
|
|
uint32_t mods_latched,
|
|
|
|
uint32_t mods_locked,
|
|
|
|
uint32_t group)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2012-07-16 19:08:20 +00:00
|
|
|
GdkKeymap *keymap;
|
|
|
|
struct xkb_state *xkb_state;
|
2013-04-04 03:52:52 +00:00
|
|
|
PangoDirection direction;
|
2020-04-05 04:37:51 +00:00
|
|
|
gboolean bidi;
|
|
|
|
gboolean caps_lock;
|
|
|
|
gboolean num_lock;
|
|
|
|
gboolean scroll_lock;
|
|
|
|
GdkModifierType modifiers;
|
2012-07-16 19:08:20 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
keymap = seat->keymap;
|
2012-07-16 19:08:20 +00:00
|
|
|
xkb_state = _gdk_wayland_keymap_get_xkb_state (keymap);
|
|
|
|
|
2020-04-05 04:37:51 +00:00
|
|
|
direction = gdk_keymap_get_direction (seat->keymap);
|
|
|
|
bidi = gdk_keymap_have_bidi_layouts (seat->keymap);
|
|
|
|
caps_lock = gdk_keymap_get_caps_lock_state (seat->keymap);
|
|
|
|
num_lock = gdk_keymap_get_num_lock_state (seat->keymap);
|
|
|
|
scroll_lock = gdk_keymap_get_scroll_lock_state (seat->keymap);
|
|
|
|
modifiers = gdk_keymap_get_modifier_state (seat->keymap);
|
|
|
|
|
|
|
|
|
2020-04-02 21:40:44 +00:00
|
|
|
/* Note: the docs for xkb_state_update mask state that all parameters
|
|
|
|
* must be passed, or we may end up with an 'incoherent' state. But the
|
|
|
|
* Wayland modifiers event only includes a single group field, so we
|
|
|
|
* can't pass depressed/latched/locked groups.
|
|
|
|
*
|
|
|
|
* We assume that the compositor is sending us the 'effective' group
|
|
|
|
* (the protocol is not clear on that point), and pass it as the depressed
|
|
|
|
* group - we are basically pretending that the user holds down a key for
|
|
|
|
* this group at all times.
|
|
|
|
*
|
|
|
|
* This means that our xkb_state would answer a few questions differently
|
|
|
|
* from the compositors xkb_state - e.g. if you asked it about the latched
|
|
|
|
* group. But nobody is asking it those questions, so it does not really
|
|
|
|
* matter. We hope.
|
|
|
|
*/
|
2012-07-16 19:08:20 +00:00
|
|
|
xkb_state_update_mask (xkb_state, mods_depressed, mods_latched, mods_locked, group, 0, 0);
|
2013-03-22 22:34:44 +00:00
|
|
|
|
2017-01-11 18:12:12 +00:00
|
|
|
seat->key_modifiers = gdk_keymap_get_modifier_state (keymap);
|
|
|
|
|
2013-03-22 22:34:44 +00:00
|
|
|
g_signal_emit_by_name (keymap, "state-changed");
|
2013-04-04 03:52:52 +00:00
|
|
|
if (direction != gdk_keymap_get_direction (keymap))
|
|
|
|
g_signal_emit_by_name (keymap, "direction-changed");
|
2020-04-05 04:37:51 +00:00
|
|
|
|
|
|
|
if (direction != gdk_keymap_get_direction (seat->keymap))
|
2020-06-18 18:22:20 +00:00
|
|
|
g_object_notify (G_OBJECT (seat->logical_keyboard), "direction");
|
2020-04-05 04:37:51 +00:00
|
|
|
if (bidi != gdk_keymap_have_bidi_layouts (seat->keymap))
|
2020-06-18 18:22:20 +00:00
|
|
|
g_object_notify (G_OBJECT (seat->logical_keyboard), "has-bidi-layouts");
|
2020-04-05 04:37:51 +00:00
|
|
|
if (caps_lock != gdk_keymap_get_caps_lock_state (seat->keymap))
|
2020-06-18 18:22:20 +00:00
|
|
|
g_object_notify (G_OBJECT (seat->logical_keyboard), "caps-lock-state");
|
2020-04-05 04:37:51 +00:00
|
|
|
if (num_lock != gdk_keymap_get_num_lock_state (seat->keymap))
|
2020-06-18 18:22:20 +00:00
|
|
|
g_object_notify (G_OBJECT (seat->logical_keyboard), "num-lock-state");
|
2020-04-05 04:37:51 +00:00
|
|
|
if (scroll_lock != gdk_keymap_get_scroll_lock_state (seat->keymap))
|
2020-06-18 18:22:20 +00:00
|
|
|
g_object_notify (G_OBJECT (seat->logical_keyboard), "scroll-lock-state");
|
2020-04-05 04:37:51 +00:00
|
|
|
if (modifiers != gdk_keymap_get_modifier_state (seat->keymap))
|
2020-06-18 18:22:20 +00:00
|
|
|
g_object_notify (G_OBJECT (seat->logical_keyboard), "modifier-state");
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
2014-07-25 13:37:06 +00:00
|
|
|
static void
|
|
|
|
keyboard_handle_repeat_info (void *data,
|
|
|
|
struct wl_keyboard *keyboard,
|
2014-07-26 13:46:56 +00:00
|
|
|
int32_t rate,
|
|
|
|
int32_t delay)
|
2014-07-25 13:37:06 +00:00
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2014-07-25 13:37:06 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
seat->have_server_repeat = TRUE;
|
|
|
|
seat->server_repeat_rate = rate;
|
|
|
|
seat->server_repeat_delay = delay;
|
2014-07-25 13:37:06 +00:00
|
|
|
}
|
|
|
|
|
2014-04-17 12:19:39 +00:00
|
|
|
static GdkWaylandTouchData *
|
2016-03-17 17:38:40 +00:00
|
|
|
gdk_wayland_seat_add_touch (GdkWaylandSeat *seat,
|
|
|
|
uint32_t id,
|
|
|
|
struct wl_surface *surface)
|
2014-04-17 12:19:39 +00:00
|
|
|
{
|
|
|
|
GdkWaylandTouchData *touch;
|
|
|
|
|
|
|
|
touch = g_new0 (GdkWaylandTouchData, 1);
|
|
|
|
touch->id = id;
|
2018-03-20 14:14:10 +00:00
|
|
|
touch->surface = wl_surface_get_user_data (surface);
|
2016-03-17 17:32:03 +00:00
|
|
|
touch->initial_touch = (g_hash_table_size (seat->touches) == 0);
|
2014-04-17 12:19:39 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
g_hash_table_insert (seat->touches, GUINT_TO_POINTER (id), touch);
|
2014-04-17 12:19:39 +00:00
|
|
|
|
|
|
|
return touch;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkWaylandTouchData *
|
2016-03-17 17:38:40 +00:00
|
|
|
gdk_wayland_seat_get_touch (GdkWaylandSeat *seat,
|
|
|
|
uint32_t id)
|
2014-04-17 12:19:39 +00:00
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
return g_hash_table_lookup (seat->touches, GUINT_TO_POINTER (id));
|
2014-04-17 12:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-03-17 17:38:40 +00:00
|
|
|
gdk_wayland_seat_remove_touch (GdkWaylandSeat *seat,
|
|
|
|
uint32_t id)
|
2014-04-17 12:19:39 +00:00
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
g_hash_table_remove (seat->touches, GUINT_TO_POINTER (id));
|
2014-04-17 12:19:39 +00:00
|
|
|
}
|
|
|
|
|
2020-04-24 21:11:00 +00:00
|
|
|
void
|
|
|
|
gdk_wayland_seat_clear_touchpoints (GdkWaylandSeat *seat,
|
|
|
|
GdkSurface *surface)
|
|
|
|
{
|
|
|
|
GHashTableIter iter;
|
|
|
|
GdkWaylandTouchData *touch;
|
|
|
|
|
|
|
|
g_hash_table_iter_init (&iter, seat->touches);
|
|
|
|
|
|
|
|
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &touch))
|
|
|
|
{
|
|
|
|
if (touch->surface == surface)
|
|
|
|
g_hash_table_iter_remove (&iter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
static void
|
|
|
|
mimic_pointer_emulating_touch_info (GdkDevice *device,
|
|
|
|
GdkWaylandTouchData *touch)
|
|
|
|
{
|
|
|
|
GdkWaylandPointerData *pointer;
|
|
|
|
|
|
|
|
pointer = GDK_WAYLAND_DEVICE (device)->pointer;
|
2018-03-20 14:14:10 +00:00
|
|
|
g_set_object (&pointer->focus, touch->surface);
|
2015-06-19 15:25:54 +00:00
|
|
|
pointer->press_serial = pointer->enter_serial = touch->touch_down_serial;
|
|
|
|
pointer->surface_x = touch->x;
|
|
|
|
pointer->surface_y = touch->y;
|
|
|
|
}
|
|
|
|
|
2016-05-12 11:34:42 +00:00
|
|
|
static void
|
2020-06-18 18:22:20 +00:00
|
|
|
touch_handle_logical_pointer_crossing (GdkWaylandSeat *seat,
|
|
|
|
GdkWaylandTouchData *touch,
|
|
|
|
uint32_t time)
|
2016-05-12 11:34:42 +00:00
|
|
|
{
|
|
|
|
GdkWaylandPointerData *pointer;
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
pointer = GDK_WAYLAND_DEVICE (seat->logical_touch)->pointer;
|
2016-05-12 11:34:42 +00:00
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (pointer->focus == touch->surface)
|
2016-05-12 11:34:42 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (pointer->focus)
|
|
|
|
{
|
|
|
|
emulate_touch_crossing (pointer->focus, NULL,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_touch, seat->touch, touch,
|
2016-05-12 11:34:42 +00:00
|
|
|
GDK_LEAVE_NOTIFY, GDK_CROSSING_NORMAL, time);
|
|
|
|
}
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (touch->surface)
|
2016-05-12 11:34:42 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
emulate_touch_crossing (touch->surface, NULL,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_touch, seat->touch, touch,
|
2016-05-12 11:34:42 +00:00
|
|
|
GDK_ENTER_NOTIFY, GDK_CROSSING_NORMAL, time);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-17 12:19:39 +00:00
|
|
|
static void
|
|
|
|
touch_handle_down (void *data,
|
|
|
|
struct wl_touch *wl_touch,
|
|
|
|
uint32_t serial,
|
|
|
|
uint32_t time,
|
|
|
|
struct wl_surface *wl_surface,
|
|
|
|
int32_t id,
|
|
|
|
wl_fixed_t x,
|
|
|
|
wl_fixed_t y)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
|
2014-04-17 12:19:39 +00:00
|
|
|
GdkWaylandTouchData *touch;
|
|
|
|
GdkEvent *event;
|
|
|
|
|
2015-02-28 03:28:28 +00:00
|
|
|
_gdk_wayland_display_update_serial (display, serial);
|
2014-08-20 18:52:39 +00:00
|
|
|
|
2016-03-17 17:38:40 +00:00
|
|
|
touch = gdk_wayland_seat_add_touch (seat, id, wl_surface);
|
2014-04-17 12:19:39 +00:00
|
|
|
touch->x = wl_fixed_to_double (x);
|
|
|
|
touch->y = wl_fixed_to_double (y);
|
2014-08-13 19:05:12 +00:00
|
|
|
touch->touch_down_serial = serial;
|
2014-04-17 12:19:39 +00:00
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_touch_event_new (GDK_TOUCH_BEGIN,
|
2020-02-14 13:10:21 +00:00
|
|
|
GDK_SLOT_TO_EVENT_SEQUENCE (touch->id),
|
|
|
|
touch->surface,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_touch,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->touch,
|
|
|
|
time,
|
2020-06-18 18:22:20 +00:00
|
|
|
device_get_modifiers (seat->logical_touch),
|
2020-02-14 13:10:21 +00:00
|
|
|
touch->x, touch->y,
|
|
|
|
NULL,
|
|
|
|
touch->initial_touch);
|
2014-04-17 12:19:39 +00:00
|
|
|
|
2015-10-08 14:41:35 +00:00
|
|
|
if (touch->initial_touch)
|
|
|
|
{
|
2020-06-18 18:22:20 +00:00
|
|
|
touch_handle_logical_pointer_crossing (seat, touch, time);
|
|
|
|
GDK_WAYLAND_DEVICE(seat->logical_touch)->emulating_touch = touch;
|
|
|
|
mimic_pointer_emulating_touch_info (seat->logical_touch, touch);
|
2015-10-08 14:41:35 +00:00
|
|
|
}
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
if (GDK_DISPLAY_DEBUG_CHECK (gdk_seat_get_display (GDK_SEAT (seat)), EVENTS))
|
|
|
|
{
|
|
|
|
double xx, yy;
|
|
|
|
gdk_event_get_position (event, &xx, &yy);
|
|
|
|
g_message ("touch begin %f %f", xx, yy);
|
|
|
|
}
|
2014-04-17 12:19:39 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
2014-04-17 12:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
touch_handle_up (void *data,
|
|
|
|
struct wl_touch *wl_touch,
|
|
|
|
uint32_t serial,
|
|
|
|
uint32_t time,
|
|
|
|
int32_t id)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
|
2014-04-17 12:19:39 +00:00
|
|
|
GdkWaylandTouchData *touch;
|
|
|
|
GdkEvent *event;
|
|
|
|
|
2015-02-28 03:28:28 +00:00
|
|
|
_gdk_wayland_display_update_serial (display, serial);
|
2014-08-20 18:52:39 +00:00
|
|
|
|
2016-03-17 17:38:40 +00:00
|
|
|
touch = gdk_wayland_seat_get_touch (seat, id);
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_touch_event_new (GDK_TOUCH_END,
|
2020-02-14 13:10:21 +00:00
|
|
|
GDK_SLOT_TO_EVENT_SEQUENCE (touch->id),
|
|
|
|
touch->surface,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_touch,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->touch,
|
|
|
|
time,
|
2020-06-18 18:22:20 +00:00
|
|
|
device_get_modifiers (seat->logical_touch),
|
2020-02-14 13:10:21 +00:00
|
|
|
touch->x, touch->y,
|
|
|
|
NULL,
|
|
|
|
touch->initial_touch);
|
2014-04-17 12:19:39 +00:00
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
if (GDK_DISPLAY_DEBUG_CHECK (gdk_seat_get_display (GDK_SEAT (seat)), EVENTS))
|
|
|
|
{
|
|
|
|
double x, y;
|
|
|
|
gdk_event_get_position (event, &x, &y);
|
|
|
|
g_message ("touch end %f %f", x, y);
|
|
|
|
}
|
2014-04-17 12:19:39 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
2015-10-08 14:41:35 +00:00
|
|
|
|
|
|
|
if (touch->initial_touch)
|
2020-06-18 18:22:20 +00:00
|
|
|
GDK_WAYLAND_DEVICE(seat->logical_touch)->emulating_touch = NULL;
|
2015-10-08 14:41:35 +00:00
|
|
|
|
2016-03-17 17:38:40 +00:00
|
|
|
gdk_wayland_seat_remove_touch (seat, id);
|
2014-04-17 12:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
touch_handle_motion (void *data,
|
|
|
|
struct wl_touch *wl_touch,
|
|
|
|
uint32_t time,
|
|
|
|
int32_t id,
|
|
|
|
wl_fixed_t x,
|
|
|
|
wl_fixed_t y)
|
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2014-04-17 12:19:39 +00:00
|
|
|
GdkWaylandTouchData *touch;
|
|
|
|
GdkEvent *event;
|
|
|
|
|
2016-03-17 17:38:40 +00:00
|
|
|
touch = gdk_wayland_seat_get_touch (seat, id);
|
2014-04-17 12:19:39 +00:00
|
|
|
touch->x = wl_fixed_to_double (x);
|
|
|
|
touch->y = wl_fixed_to_double (y);
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
if (touch->initial_touch)
|
2020-06-18 18:22:20 +00:00
|
|
|
mimic_pointer_emulating_touch_info (seat->logical_touch, touch);
|
2015-06-19 15:25:54 +00:00
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_touch_event_new (GDK_TOUCH_UPDATE,
|
2020-02-14 13:10:21 +00:00
|
|
|
GDK_SLOT_TO_EVENT_SEQUENCE (touch->id),
|
|
|
|
touch->surface,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_touch,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->touch,
|
|
|
|
time,
|
2020-06-18 18:22:20 +00:00
|
|
|
device_get_modifiers (seat->logical_touch),
|
2020-02-14 13:10:21 +00:00
|
|
|
touch->x, touch->y,
|
|
|
|
NULL,
|
|
|
|
touch->initial_touch);
|
2014-04-17 12:19:39 +00:00
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
if (GDK_DISPLAY_DEBUG_CHECK (gdk_seat_get_display (GDK_SEAT (seat)), EVENTS))
|
|
|
|
{
|
|
|
|
double xx, yy;
|
|
|
|
gdk_event_get_position (event, &xx, &yy);
|
|
|
|
g_message ("touch update %f %f", xx, yy);
|
|
|
|
}
|
2014-04-17 12:19:39 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
2014-04-17 12:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
touch_handle_frame (void *data,
|
|
|
|
struct wl_touch *wl_touch)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
touch_handle_cancel (void *data,
|
|
|
|
struct wl_touch *wl_touch)
|
|
|
|
{
|
2020-02-14 13:10:21 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2014-04-17 12:19:39 +00:00
|
|
|
GdkWaylandTouchData *touch;
|
|
|
|
GHashTableIter iter;
|
|
|
|
GdkEvent *event;
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (GDK_WAYLAND_DEVICE (seat->logical_touch)->emulating_touch)
|
2015-12-09 11:46:08 +00:00
|
|
|
{
|
2020-06-18 18:22:20 +00:00
|
|
|
touch = GDK_WAYLAND_DEVICE (seat->logical_touch)->emulating_touch;
|
|
|
|
GDK_WAYLAND_DEVICE (seat->logical_touch)->emulating_touch = NULL;
|
2015-12-09 11:46:08 +00:00
|
|
|
}
|
|
|
|
|
2020-02-14 13:10:21 +00:00
|
|
|
g_hash_table_iter_init (&iter, seat->touches);
|
2014-04-17 12:19:39 +00:00
|
|
|
|
|
|
|
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &touch))
|
|
|
|
{
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_touch_event_new (GDK_TOUCH_CANCEL,
|
2020-02-14 13:10:21 +00:00
|
|
|
GDK_SLOT_TO_EVENT_SEQUENCE (touch->id),
|
|
|
|
touch->surface,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_touch,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->touch,
|
|
|
|
GDK_CURRENT_TIME,
|
2020-06-18 18:22:20 +00:00
|
|
|
device_get_modifiers (seat->logical_touch),
|
2020-02-14 13:10:21 +00:00
|
|
|
touch->x, touch->y,
|
|
|
|
NULL,
|
|
|
|
touch->initial_touch);
|
|
|
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
2014-04-17 12:19:39 +00:00
|
|
|
g_hash_table_iter_remove (&iter);
|
|
|
|
}
|
|
|
|
|
2020-02-14 13:10:21 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS, g_message ("touch cancel"));
|
2014-04-17 12:19:39 +00:00
|
|
|
}
|
|
|
|
|
2015-07-09 17:36:30 +00:00
|
|
|
static void
|
2016-03-17 17:32:03 +00:00
|
|
|
emit_gesture_swipe_event (GdkWaylandSeat *seat,
|
2015-07-09 17:36:30 +00:00
|
|
|
GdkTouchpadGesturePhase phase,
|
|
|
|
guint32 _time,
|
|
|
|
guint32 n_fingers,
|
2020-07-24 20:32:16 +00:00
|
|
|
double dx,
|
|
|
|
double dy)
|
2015-07-09 17:36:30 +00:00
|
|
|
{
|
|
|
|
GdkEvent *event;
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
if (!seat->pointer_info.focus)
|
2015-07-09 17:36:30 +00:00
|
|
|
return;
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
seat->pointer_info.time = _time;
|
2015-07-09 17:36:30 +00:00
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_touchpad_event_new_swipe (seat->pointer_info.focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_pointer,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->pointer,
|
|
|
|
_time,
|
2020-06-18 18:22:20 +00:00
|
|
|
device_get_modifiers (seat->logical_pointer),
|
2020-02-14 13:10:21 +00:00
|
|
|
phase,
|
2020-02-14 22:46:56 +00:00
|
|
|
seat->pointer_info.surface_x,
|
|
|
|
seat->pointer_info.surface_y,
|
2020-02-14 13:10:21 +00:00
|
|
|
n_fingers,
|
|
|
|
dx, dy);
|
2015-07-09 17:36:30 +00:00
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
if (GDK_DISPLAY_DEBUG_CHECK (gdk_seat_get_display (GDK_SEAT (seat)), EVENTS))
|
|
|
|
{
|
|
|
|
double x, y;
|
|
|
|
gdk_event_get_position (event, &x, &y);
|
|
|
|
g_message ("swipe event %d, coords: %f %f, seat %p state %d",
|
|
|
|
gdk_event_get_event_type (event), x, y, seat,
|
|
|
|
gdk_event_get_modifier_state (event));
|
|
|
|
}
|
2015-07-09 17:36:30 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
2015-07-09 17:36:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-11-18 03:38:28 +00:00
|
|
|
gesture_swipe_begin (void *data,
|
|
|
|
struct zwp_pointer_gesture_swipe_v1 *swipe,
|
|
|
|
uint32_t serial,
|
|
|
|
uint32_t time,
|
|
|
|
struct wl_surface *surface,
|
|
|
|
uint32_t fingers)
|
2015-07-09 17:36:30 +00:00
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
|
2015-07-09 17:36:30 +00:00
|
|
|
|
|
|
|
_gdk_wayland_display_update_serial (display, serial);
|
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
emit_gesture_swipe_event (seat,
|
2015-07-09 17:36:30 +00:00
|
|
|
GDK_TOUCHPAD_GESTURE_PHASE_BEGIN,
|
|
|
|
time, fingers, 0, 0);
|
2016-03-17 17:32:03 +00:00
|
|
|
seat->gesture_n_fingers = fingers;
|
2015-07-09 17:36:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-11-18 03:38:28 +00:00
|
|
|
gesture_swipe_update (void *data,
|
|
|
|
struct zwp_pointer_gesture_swipe_v1 *swipe,
|
|
|
|
uint32_t time,
|
|
|
|
wl_fixed_t dx,
|
|
|
|
wl_fixed_t dy)
|
2015-07-09 17:36:30 +00:00
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2015-07-09 17:36:30 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
emit_gesture_swipe_event (seat,
|
2015-07-09 17:36:30 +00:00
|
|
|
GDK_TOUCHPAD_GESTURE_PHASE_UPDATE,
|
|
|
|
time,
|
2016-03-17 17:32:03 +00:00
|
|
|
seat->gesture_n_fingers,
|
2015-07-09 17:36:30 +00:00
|
|
|
wl_fixed_to_double (dx),
|
|
|
|
wl_fixed_to_double (dy));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-11-18 03:38:28 +00:00
|
|
|
gesture_swipe_end (void *data,
|
|
|
|
struct zwp_pointer_gesture_swipe_v1 *swipe,
|
|
|
|
uint32_t serial,
|
|
|
|
uint32_t time,
|
|
|
|
int32_t cancelled)
|
2015-07-09 17:36:30 +00:00
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
|
2015-07-09 17:36:30 +00:00
|
|
|
GdkTouchpadGesturePhase phase;
|
|
|
|
|
|
|
|
_gdk_wayland_display_update_serial (display, serial);
|
|
|
|
|
|
|
|
phase = (cancelled) ?
|
|
|
|
GDK_TOUCHPAD_GESTURE_PHASE_CANCEL :
|
|
|
|
GDK_TOUCHPAD_GESTURE_PHASE_END;
|
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
emit_gesture_swipe_event (seat, phase, time,
|
|
|
|
seat->gesture_n_fingers, 0, 0);
|
2015-07-09 17:36:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-03-17 17:32:03 +00:00
|
|
|
emit_gesture_pinch_event (GdkWaylandSeat *seat,
|
2015-07-09 17:36:30 +00:00
|
|
|
GdkTouchpadGesturePhase phase,
|
|
|
|
guint32 _time,
|
|
|
|
guint n_fingers,
|
2020-07-24 20:32:16 +00:00
|
|
|
double dx,
|
|
|
|
double dy,
|
|
|
|
double scale,
|
|
|
|
double angle_delta)
|
2015-07-09 17:36:30 +00:00
|
|
|
{
|
|
|
|
GdkEvent *event;
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
if (!seat->pointer_info.focus)
|
2015-07-09 17:36:30 +00:00
|
|
|
return;
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
seat->pointer_info.time = _time;
|
2015-07-09 17:36:30 +00:00
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_touchpad_event_new_pinch (seat->pointer_info.focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_pointer,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->pointer,
|
|
|
|
_time,
|
2020-06-18 18:22:20 +00:00
|
|
|
device_get_modifiers (seat->logical_pointer),
|
2020-02-14 13:10:21 +00:00
|
|
|
phase,
|
2020-02-14 22:46:56 +00:00
|
|
|
seat->pointer_info.surface_x,
|
|
|
|
seat->pointer_info.surface_y,
|
2020-02-14 13:10:21 +00:00
|
|
|
n_fingers,
|
|
|
|
dx, dy,
|
|
|
|
scale, angle_delta * G_PI / 180);
|
2015-07-09 17:36:30 +00:00
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
if (GDK_DISPLAY_DEBUG_CHECK (gdk_seat_get_display (GDK_SEAT (seat)), EVENTS))
|
|
|
|
{
|
|
|
|
double x, y;
|
|
|
|
gdk_event_get_position (event, &x, &y);
|
|
|
|
g_message ("pinch event %d, coords: %f %f, seat %p state %d",
|
|
|
|
gdk_event_get_event_type (event),
|
|
|
|
x, y, seat,
|
|
|
|
gdk_event_get_modifier_state (event));
|
|
|
|
}
|
2015-07-09 17:36:30 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
2015-07-09 17:36:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-11-18 03:38:28 +00:00
|
|
|
gesture_pinch_begin (void *data,
|
|
|
|
struct zwp_pointer_gesture_pinch_v1 *pinch,
|
|
|
|
uint32_t serial,
|
|
|
|
uint32_t time,
|
|
|
|
struct wl_surface *surface,
|
|
|
|
uint32_t fingers)
|
2015-07-09 17:36:30 +00:00
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
|
2015-07-09 17:36:30 +00:00
|
|
|
|
|
|
|
_gdk_wayland_display_update_serial (display, serial);
|
2016-03-17 17:32:03 +00:00
|
|
|
emit_gesture_pinch_event (seat,
|
2015-07-09 17:36:30 +00:00
|
|
|
GDK_TOUCHPAD_GESTURE_PHASE_BEGIN,
|
|
|
|
time, fingers, 0, 0, 1, 0);
|
2016-03-17 17:32:03 +00:00
|
|
|
seat->gesture_n_fingers = fingers;
|
2015-07-09 17:36:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-11-18 03:38:28 +00:00
|
|
|
gesture_pinch_update (void *data,
|
|
|
|
struct zwp_pointer_gesture_pinch_v1 *pinch,
|
|
|
|
uint32_t time,
|
|
|
|
wl_fixed_t dx,
|
|
|
|
wl_fixed_t dy,
|
|
|
|
wl_fixed_t scale,
|
|
|
|
wl_fixed_t rotation)
|
2015-07-09 17:36:30 +00:00
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2015-07-09 17:36:30 +00:00
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
emit_gesture_pinch_event (seat,
|
2015-07-09 17:36:30 +00:00
|
|
|
GDK_TOUCHPAD_GESTURE_PHASE_UPDATE, time,
|
2016-03-17 17:32:03 +00:00
|
|
|
seat->gesture_n_fingers,
|
2015-07-09 17:36:30 +00:00
|
|
|
wl_fixed_to_double (dx),
|
|
|
|
wl_fixed_to_double (dy),
|
|
|
|
wl_fixed_to_double (scale),
|
|
|
|
wl_fixed_to_double (rotation));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-11-18 03:38:28 +00:00
|
|
|
gesture_pinch_end (void *data,
|
|
|
|
struct zwp_pointer_gesture_pinch_v1 *pinch,
|
|
|
|
uint32_t serial,
|
|
|
|
uint32_t time,
|
|
|
|
int32_t cancelled)
|
2015-07-09 17:36:30 +00:00
|
|
|
{
|
2016-03-17 17:32:03 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (seat->display);
|
2015-07-09 17:36:30 +00:00
|
|
|
GdkTouchpadGesturePhase phase;
|
|
|
|
|
|
|
|
_gdk_wayland_display_update_serial (display, serial);
|
|
|
|
|
|
|
|
phase = (cancelled) ?
|
|
|
|
GDK_TOUCHPAD_GESTURE_PHASE_CANCEL :
|
|
|
|
GDK_TOUCHPAD_GESTURE_PHASE_END;
|
|
|
|
|
2016-03-17 17:32:03 +00:00
|
|
|
emit_gesture_pinch_event (seat, phase,
|
|
|
|
time, seat->gesture_n_fingers,
|
2015-07-09 17:36:30 +00:00
|
|
|
0, 0, 1, 0);
|
|
|
|
}
|
|
|
|
|
2015-01-19 00:32:24 +00:00
|
|
|
static void
|
|
|
|
_gdk_wayland_seat_remove_tool (GdkWaylandSeat *seat,
|
|
|
|
GdkWaylandTabletToolData *tool)
|
|
|
|
{
|
|
|
|
seat->tablet_tools = g_list_remove (seat->tablet_tools, tool);
|
|
|
|
|
|
|
|
gdk_seat_tool_removed (GDK_SEAT (seat), tool->tool);
|
|
|
|
|
2016-05-13 13:19:04 +00:00
|
|
|
zwp_tablet_tool_v2_destroy (tool->wp_tablet_tool);
|
2015-01-19 00:32:24 +00:00
|
|
|
g_object_unref (tool->tool);
|
|
|
|
g_free (tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gdk_wayland_seat_remove_tablet (GdkWaylandSeat *seat,
|
|
|
|
GdkWaylandTabletData *tablet)
|
|
|
|
{
|
|
|
|
seat->tablets = g_list_remove (seat->tablets, tablet);
|
|
|
|
|
2017-11-27 18:51:38 +00:00
|
|
|
gdk_seat_device_removed (GDK_SEAT (seat), tablet->stylus_device);
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_seat_device_removed (GDK_SEAT (seat), tablet->logical_device);
|
2017-11-27 18:51:38 +00:00
|
|
|
|
2020-05-15 16:39:57 +00:00
|
|
|
while (tablet->pads)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadData *pad = tablet->pads->data;
|
|
|
|
|
|
|
|
pad->current_tablet = NULL;
|
|
|
|
tablet->pads = g_list_remove (tablet->pads, pad);
|
|
|
|
}
|
|
|
|
|
2016-05-13 13:19:04 +00:00
|
|
|
zwp_tablet_v2_destroy (tablet->wp_tablet);
|
2015-01-19 00:32:24 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
_gdk_device_set_associated_device (tablet->logical_device, NULL);
|
2015-01-19 00:32:24 +00:00
|
|
|
_gdk_device_set_associated_device (tablet->stylus_device, NULL);
|
|
|
|
|
|
|
|
if (tablet->pointer_info.focus)
|
|
|
|
g_object_unref (tablet->pointer_info.focus);
|
|
|
|
|
2015-06-22 16:02:50 +00:00
|
|
|
if (tablet->axes)
|
|
|
|
g_free (tablet->axes);
|
|
|
|
|
2015-01-19 00:32:24 +00:00
|
|
|
wl_surface_destroy (tablet->pointer_info.pointer_surface);
|
2020-06-18 18:22:20 +00:00
|
|
|
g_object_unref (tablet->logical_device);
|
2015-01-19 00:32:24 +00:00
|
|
|
g_object_unref (tablet->stylus_device);
|
|
|
|
g_free (tablet);
|
|
|
|
}
|
|
|
|
|
2016-08-04 17:36:32 +00:00
|
|
|
static void
|
|
|
|
_gdk_wayland_seat_remove_tablet_pad (GdkWaylandSeat *seat,
|
|
|
|
GdkWaylandTabletPadData *pad)
|
|
|
|
{
|
|
|
|
seat->tablet_pads = g_list_remove (seat->tablet_pads, pad);
|
2016-08-04 17:42:23 +00:00
|
|
|
|
2017-11-27 18:51:38 +00:00
|
|
|
gdk_seat_device_removed (GDK_SEAT (seat), pad->device);
|
2016-08-04 17:42:23 +00:00
|
|
|
_gdk_device_set_associated_device (pad->device, NULL);
|
|
|
|
|
|
|
|
g_object_unref (pad->device);
|
2016-08-04 17:36:32 +00:00
|
|
|
g_free (pad);
|
|
|
|
}
|
|
|
|
|
2016-08-04 17:44:44 +00:00
|
|
|
static GdkWaylandTabletPadGroupData *
|
|
|
|
tablet_pad_lookup_button_group (GdkWaylandTabletPadData *pad,
|
|
|
|
uint32_t button)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadGroupData *group;
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = pad->mode_groups; l; l = l->next)
|
|
|
|
{
|
|
|
|
group = l->data;
|
|
|
|
|
|
|
|
if (g_list_find (group->buttons, GUINT_TO_POINTER (button)))
|
|
|
|
return group;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-01-19 00:32:24 +00:00
|
|
|
static void
|
|
|
|
tablet_handle_name (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_v2 *wp_tablet,
|
2015-01-19 00:32:24 +00:00
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletData *tablet = data;
|
|
|
|
|
|
|
|
tablet->name = g_strdup (name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_handle_id (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_v2 *wp_tablet,
|
2015-01-19 00:32:24 +00:00
|
|
|
uint32_t vid,
|
|
|
|
uint32_t pid)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletData *tablet = data;
|
|
|
|
|
|
|
|
tablet->vid = vid;
|
|
|
|
tablet->pid = pid;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_handle_path (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_v2 *wp_tablet,
|
2015-01-19 00:32:24 +00:00
|
|
|
const char *path)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletData *tablet = data;
|
|
|
|
|
|
|
|
tablet->path = g_strdup (path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_handle_done (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_v2 *wp_tablet)
|
2015-01-19 00:32:24 +00:00
|
|
|
{
|
|
|
|
GdkWaylandTabletData *tablet = data;
|
|
|
|
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
|
|
|
|
GdkDisplay *display = gdk_seat_get_display (GDK_SEAT (seat));
|
2020-06-22 21:19:35 +00:00
|
|
|
GdkDevice *logical_device, *stylus_device;
|
2020-07-24 18:40:36 +00:00
|
|
|
char *logical_name;
|
|
|
|
char *vid, *pid;
|
2017-06-16 16:21:34 +00:00
|
|
|
|
|
|
|
vid = g_strdup_printf ("%.4x", tablet->vid);
|
|
|
|
pid = g_strdup_printf ("%.4x", tablet->pid);
|
2015-01-19 00:32:24 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
logical_name = g_strdup_printf ("Logical pointer for %s", tablet->name);
|
|
|
|
logical_device = g_object_new (GDK_TYPE_WAYLAND_DEVICE,
|
|
|
|
"name", logical_name,
|
|
|
|
"type", GDK_DEVICE_TYPE_LOGICAL,
|
|
|
|
"source", GDK_SOURCE_MOUSE,
|
|
|
|
"has-cursor", TRUE,
|
|
|
|
"display", display,
|
|
|
|
"seat", seat,
|
|
|
|
NULL);
|
|
|
|
GDK_WAYLAND_DEVICE (logical_device)->pointer = &tablet->pointer_info;
|
2015-01-19 00:32:24 +00:00
|
|
|
|
|
|
|
stylus_device = g_object_new (GDK_TYPE_WAYLAND_DEVICE,
|
|
|
|
"name", tablet->name,
|
2020-06-18 18:22:20 +00:00
|
|
|
"type", GDK_DEVICE_TYPE_PHYSICAL,
|
2020-02-24 18:35:27 +00:00
|
|
|
"source", GDK_SOURCE_PEN,
|
2015-01-19 00:32:24 +00:00
|
|
|
"has-cursor", FALSE,
|
|
|
|
"display", display,
|
|
|
|
"seat", seat,
|
2017-06-16 16:21:34 +00:00
|
|
|
"vendor-id", vid,
|
|
|
|
"product-id", pid,
|
2015-01-19 00:32:24 +00:00
|
|
|
NULL);
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
tablet->logical_device = logical_device;
|
|
|
|
init_pointer_data (&tablet->pointer_info, display, tablet->logical_device);
|
2019-04-18 17:31:55 +00:00
|
|
|
|
2015-01-19 00:32:24 +00:00
|
|
|
tablet->stylus_device = stylus_device;
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
_gdk_device_set_associated_device (logical_device, seat->logical_keyboard);
|
|
|
|
_gdk_device_set_associated_device (stylus_device, logical_device);
|
2015-01-19 00:32:24 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_seat_device_added (GDK_SEAT (seat), logical_device);
|
2017-11-27 18:51:38 +00:00
|
|
|
gdk_seat_device_added (GDK_SEAT (seat), stylus_device);
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
g_free (logical_name);
|
2017-06-16 16:21:34 +00:00
|
|
|
g_free (vid);
|
|
|
|
g_free (pid);
|
2015-01-19 00:32:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_handle_removed (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_v2 *wp_tablet)
|
2015-01-19 00:32:24 +00:00
|
|
|
{
|
|
|
|
GdkWaylandTabletData *tablet = data;
|
|
|
|
|
|
|
|
_gdk_wayland_seat_remove_tablet (GDK_WAYLAND_SEAT (tablet->seat), tablet);
|
|
|
|
}
|
|
|
|
|
2012-07-11 13:29:43 +00:00
|
|
|
static const struct wl_pointer_listener pointer_listener = {
|
2014-07-25 13:27:22 +00:00
|
|
|
pointer_handle_enter,
|
|
|
|
pointer_handle_leave,
|
|
|
|
pointer_handle_motion,
|
|
|
|
pointer_handle_button,
|
|
|
|
pointer_handle_axis,
|
2015-10-20 03:21:54 +00:00
|
|
|
pointer_handle_frame,
|
|
|
|
pointer_handle_axis_source,
|
|
|
|
pointer_handle_axis_stop,
|
|
|
|
pointer_handle_axis_discrete,
|
2012-07-11 13:29:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct wl_keyboard_listener keyboard_listener = {
|
2014-07-25 13:27:22 +00:00
|
|
|
keyboard_handle_keymap,
|
|
|
|
keyboard_handle_enter,
|
|
|
|
keyboard_handle_leave,
|
|
|
|
keyboard_handle_key,
|
|
|
|
keyboard_handle_modifiers,
|
2014-07-25 13:37:06 +00:00
|
|
|
keyboard_handle_repeat_info,
|
2012-07-11 13:29:43 +00:00
|
|
|
};
|
|
|
|
|
2014-04-17 12:19:39 +00:00
|
|
|
static const struct wl_touch_listener touch_listener = {
|
|
|
|
touch_handle_down,
|
|
|
|
touch_handle_up,
|
|
|
|
touch_handle_motion,
|
|
|
|
touch_handle_frame,
|
|
|
|
touch_handle_cancel
|
|
|
|
};
|
|
|
|
|
2015-11-18 03:38:28 +00:00
|
|
|
static const struct zwp_pointer_gesture_swipe_v1_listener gesture_swipe_listener = {
|
2015-07-09 17:36:30 +00:00
|
|
|
gesture_swipe_begin,
|
|
|
|
gesture_swipe_update,
|
|
|
|
gesture_swipe_end
|
|
|
|
};
|
|
|
|
|
2015-11-18 03:38:28 +00:00
|
|
|
static const struct zwp_pointer_gesture_pinch_v1_listener gesture_pinch_listener = {
|
2015-07-09 17:36:30 +00:00
|
|
|
gesture_pinch_begin,
|
|
|
|
gesture_pinch_update,
|
|
|
|
gesture_pinch_end
|
|
|
|
};
|
|
|
|
|
2016-05-13 13:19:04 +00:00
|
|
|
static const struct zwp_tablet_v2_listener tablet_listener = {
|
2015-01-19 00:32:24 +00:00
|
|
|
tablet_handle_name,
|
|
|
|
tablet_handle_id,
|
|
|
|
tablet_handle_path,
|
|
|
|
tablet_handle_done,
|
|
|
|
tablet_handle_removed,
|
|
|
|
};
|
|
|
|
|
2012-07-11 13:29:43 +00:00
|
|
|
static void
|
2013-09-17 05:13:31 +00:00
|
|
|
seat_handle_capabilities (void *data,
|
2016-03-17 17:03:26 +00:00
|
|
|
struct wl_seat *wl_seat,
|
2013-09-17 05:13:31 +00:00
|
|
|
enum wl_seat_capability caps)
|
2012-07-11 13:29:43 +00:00
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
2016-04-26 03:16:56 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, MISC,
|
2016-03-17 17:03:26 +00:00
|
|
|
g_message ("seat %p with %s%s%s", wl_seat,
|
2015-02-28 05:15:13 +00:00
|
|
|
(caps & WL_SEAT_CAPABILITY_POINTER) ? " pointer, " : "",
|
|
|
|
(caps & WL_SEAT_CAPABILITY_KEYBOARD) ? " keyboard, " : "",
|
|
|
|
(caps & WL_SEAT_CAPABILITY_TOUCH) ? " touch" : ""));
|
|
|
|
|
2016-03-17 17:03:26 +00:00
|
|
|
if ((caps & WL_SEAT_CAPABILITY_POINTER) && !seat->wl_pointer)
|
2012-07-11 13:29:43 +00:00
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
seat->wl_pointer = wl_seat_get_pointer (wl_seat);
|
|
|
|
wl_pointer_set_user_data (seat->wl_pointer, seat);
|
|
|
|
wl_pointer_add_listener (seat->wl_pointer, &pointer_listener, seat);
|
|
|
|
|
|
|
|
seat->pointer = g_object_new (GDK_TYPE_WAYLAND_DEVICE,
|
|
|
|
"name", "Wayland Pointer",
|
2020-06-18 18:22:20 +00:00
|
|
|
"type", GDK_DEVICE_TYPE_PHYSICAL,
|
2020-02-24 18:35:27 +00:00
|
|
|
"source", GDK_SOURCE_MOUSE,
|
2016-03-17 17:03:26 +00:00
|
|
|
"has-cursor", TRUE,
|
|
|
|
"display", seat->display,
|
|
|
|
"seat", seat,
|
|
|
|
NULL);
|
2020-06-18 18:22:20 +00:00
|
|
|
_gdk_device_set_associated_device (seat->pointer, seat->logical_pointer);
|
2017-11-27 18:51:38 +00:00
|
|
|
gdk_seat_device_added (GDK_SEAT (seat), seat->pointer);
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2016-04-26 03:16:56 +00:00
|
|
|
if (display_wayland->pointer_gestures)
|
2015-07-09 17:36:30 +00:00
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
seat->wp_pointer_gesture_swipe =
|
2016-04-26 03:16:56 +00:00
|
|
|
zwp_pointer_gestures_v1_get_swipe_gesture (display_wayland->pointer_gestures,
|
2016-03-17 17:03:26 +00:00
|
|
|
seat->wl_pointer);
|
|
|
|
zwp_pointer_gesture_swipe_v1_set_user_data (seat->wp_pointer_gesture_swipe,
|
|
|
|
seat);
|
|
|
|
zwp_pointer_gesture_swipe_v1_add_listener (seat->wp_pointer_gesture_swipe,
|
|
|
|
&gesture_swipe_listener, seat);
|
2015-11-18 03:38:28 +00:00
|
|
|
|
2016-03-17 17:03:26 +00:00
|
|
|
seat->wp_pointer_gesture_pinch =
|
2016-04-26 03:16:56 +00:00
|
|
|
zwp_pointer_gestures_v1_get_pinch_gesture (display_wayland->pointer_gestures,
|
2016-03-17 17:03:26 +00:00
|
|
|
seat->wl_pointer);
|
|
|
|
zwp_pointer_gesture_pinch_v1_set_user_data (seat->wp_pointer_gesture_pinch,
|
|
|
|
seat);
|
|
|
|
zwp_pointer_gesture_pinch_v1_add_listener (seat->wp_pointer_gesture_pinch,
|
|
|
|
&gesture_pinch_listener, seat);
|
2015-07-09 17:36:30 +00:00
|
|
|
}
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
2016-03-17 17:03:26 +00:00
|
|
|
else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && seat->wl_pointer)
|
2012-07-11 13:29:43 +00:00
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
wl_pointer_release (seat->wl_pointer);
|
|
|
|
seat->wl_pointer = NULL;
|
2017-11-27 18:51:38 +00:00
|
|
|
gdk_seat_device_removed (GDK_SEAT (seat), seat->pointer);
|
2016-03-17 17:03:26 +00:00
|
|
|
_gdk_device_set_associated_device (seat->pointer, NULL);
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2016-06-01 03:14:30 +00:00
|
|
|
g_clear_object (&seat->pointer);
|
|
|
|
|
|
|
|
if (seat->wheel_scrolling)
|
|
|
|
{
|
2017-11-27 18:51:38 +00:00
|
|
|
gdk_seat_device_removed (GDK_SEAT (seat), seat->wheel_scrolling);
|
2016-06-01 03:14:30 +00:00
|
|
|
_gdk_device_set_associated_device (seat->wheel_scrolling, NULL);
|
|
|
|
|
|
|
|
g_clear_object (&seat->wheel_scrolling);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seat->finger_scrolling)
|
|
|
|
{
|
2017-11-27 18:51:38 +00:00
|
|
|
gdk_seat_device_removed (GDK_SEAT (seat), seat->finger_scrolling);
|
2016-06-01 03:14:30 +00:00
|
|
|
_gdk_device_set_associated_device (seat->finger_scrolling, NULL);
|
|
|
|
|
|
|
|
g_clear_object (&seat->finger_scrolling);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seat->continuous_scrolling)
|
|
|
|
{
|
2017-11-27 18:51:38 +00:00
|
|
|
gdk_seat_device_removed (GDK_SEAT (seat), seat->continuous_scrolling);
|
2016-06-01 03:14:30 +00:00
|
|
|
_gdk_device_set_associated_device (seat->continuous_scrolling, NULL);
|
|
|
|
|
|
|
|
g_clear_object (&seat->continuous_scrolling);
|
|
|
|
}
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
2016-03-17 17:03:26 +00:00
|
|
|
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !seat->wl_keyboard)
|
2012-07-11 13:29:43 +00:00
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
seat->wl_keyboard = wl_seat_get_keyboard (wl_seat);
|
|
|
|
wl_keyboard_set_user_data (seat->wl_keyboard, seat);
|
|
|
|
wl_keyboard_add_listener (seat->wl_keyboard, &keyboard_listener, seat);
|
|
|
|
|
|
|
|
seat->keyboard = g_object_new (GDK_TYPE_WAYLAND_DEVICE,
|
|
|
|
"name", "Wayland Keyboard",
|
2020-06-18 18:22:20 +00:00
|
|
|
"type", GDK_DEVICE_TYPE_PHYSICAL,
|
2020-02-24 18:35:27 +00:00
|
|
|
"source", GDK_SOURCE_KEYBOARD,
|
2016-03-17 17:03:26 +00:00
|
|
|
"has-cursor", FALSE,
|
|
|
|
"display", seat->display,
|
|
|
|
"seat", seat,
|
|
|
|
NULL);
|
2016-04-09 21:31:39 +00:00
|
|
|
_gdk_device_reset_axes (seat->keyboard);
|
2020-06-18 18:22:20 +00:00
|
|
|
_gdk_device_set_associated_device (seat->keyboard, seat->logical_keyboard);
|
2017-11-27 18:51:38 +00:00
|
|
|
gdk_seat_device_added (GDK_SEAT (seat), seat->keyboard);
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
2016-03-17 17:03:26 +00:00
|
|
|
else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && seat->wl_keyboard)
|
2012-07-11 13:29:43 +00:00
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
wl_keyboard_release (seat->wl_keyboard);
|
|
|
|
seat->wl_keyboard = NULL;
|
2017-11-27 18:51:38 +00:00
|
|
|
gdk_seat_device_removed (GDK_SEAT (seat), seat->keyboard);
|
2016-03-17 17:03:26 +00:00
|
|
|
_gdk_device_set_associated_device (seat->keyboard, NULL);
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2016-06-01 03:14:30 +00:00
|
|
|
g_clear_object (&seat->keyboard);
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
2014-04-17 12:19:39 +00:00
|
|
|
|
2016-03-17 17:03:26 +00:00
|
|
|
if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !seat->wl_touch)
|
2014-04-17 12:19:39 +00:00
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
seat->wl_touch = wl_seat_get_touch (wl_seat);
|
|
|
|
wl_touch_set_user_data (seat->wl_touch, seat);
|
|
|
|
wl_touch_add_listener (seat->wl_touch, &touch_listener, seat);
|
2015-10-08 14:41:35 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_touch = g_object_new (GDK_TYPE_WAYLAND_DEVICE,
|
|
|
|
"name", "Wayland Touch Logical Pointer",
|
|
|
|
"type", GDK_DEVICE_TYPE_LOGICAL,
|
2020-02-24 18:35:27 +00:00
|
|
|
"source", GDK_SOURCE_MOUSE,
|
2016-03-17 17:03:26 +00:00
|
|
|
"has-cursor", TRUE,
|
|
|
|
"display", seat->display,
|
|
|
|
"seat", seat,
|
|
|
|
NULL);
|
2020-06-18 18:22:20 +00:00
|
|
|
GDK_WAYLAND_DEVICE (seat->logical_touch)->pointer = &seat->touch_info;
|
|
|
|
_gdk_device_set_associated_device (seat->logical_touch, seat->logical_keyboard);
|
|
|
|
gdk_seat_device_added (GDK_SEAT (seat), seat->logical_touch);
|
2015-10-08 14:41:35 +00:00
|
|
|
|
2016-03-17 17:03:26 +00:00
|
|
|
seat->touch = g_object_new (GDK_TYPE_WAYLAND_DEVICE,
|
|
|
|
"name", "Wayland Touch",
|
2020-06-18 18:22:20 +00:00
|
|
|
"type", GDK_DEVICE_TYPE_PHYSICAL,
|
2020-02-24 18:35:27 +00:00
|
|
|
"source", GDK_SOURCE_TOUCHSCREEN,
|
2016-03-17 17:03:26 +00:00
|
|
|
"has-cursor", FALSE,
|
|
|
|
"display", seat->display,
|
|
|
|
"seat", seat,
|
|
|
|
NULL);
|
2020-06-18 18:22:20 +00:00
|
|
|
_gdk_device_set_associated_device (seat->touch, seat->logical_touch);
|
2017-11-27 18:51:38 +00:00
|
|
|
gdk_seat_device_added (GDK_SEAT (seat), seat->touch);
|
2014-04-17 12:19:39 +00:00
|
|
|
}
|
2016-03-17 17:03:26 +00:00
|
|
|
else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && seat->wl_touch)
|
2014-04-17 12:19:39 +00:00
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
wl_touch_release (seat->wl_touch);
|
|
|
|
seat->wl_touch = NULL;
|
2017-11-27 18:51:38 +00:00
|
|
|
gdk_seat_device_removed (GDK_SEAT (seat), seat->touch);
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_seat_device_removed (GDK_SEAT (seat), seat->logical_touch);
|
|
|
|
_gdk_device_set_associated_device (seat->logical_touch, NULL);
|
2016-03-17 17:03:26 +00:00
|
|
|
_gdk_device_set_associated_device (seat->touch, NULL);
|
2014-04-17 12:19:39 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
g_clear_object (&seat->logical_touch);
|
2016-06-01 03:14:30 +00:00
|
|
|
g_clear_object (&seat->touch);
|
2014-04-17 12:19:39 +00:00
|
|
|
}
|
2012-07-11 13:29:43 +00:00
|
|
|
}
|
|
|
|
|
2016-06-01 03:14:30 +00:00
|
|
|
static GdkDevice *
|
|
|
|
get_scroll_device (GdkWaylandSeat *seat,
|
|
|
|
enum wl_pointer_axis_source source)
|
|
|
|
{
|
|
|
|
if (!seat->pointer)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
switch (source)
|
|
|
|
{
|
|
|
|
case WL_POINTER_AXIS_SOURCE_WHEEL:
|
|
|
|
if (seat->wheel_scrolling == NULL)
|
|
|
|
{
|
|
|
|
seat->wheel_scrolling = g_object_new (GDK_TYPE_WAYLAND_DEVICE,
|
|
|
|
"name", "Wayland Wheel Scrolling",
|
2020-06-18 18:22:20 +00:00
|
|
|
"type", GDK_DEVICE_TYPE_PHYSICAL,
|
2020-02-24 18:35:27 +00:00
|
|
|
"source", GDK_SOURCE_MOUSE,
|
2016-06-01 03:14:30 +00:00
|
|
|
"has-cursor", TRUE,
|
|
|
|
"display", seat->display,
|
|
|
|
"seat", seat,
|
|
|
|
NULL);
|
2020-06-18 18:22:20 +00:00
|
|
|
_gdk_device_set_associated_device (seat->wheel_scrolling, seat->logical_pointer);
|
2017-11-27 18:51:38 +00:00
|
|
|
gdk_seat_device_added (GDK_SEAT (seat), seat->wheel_scrolling);
|
2016-06-01 03:14:30 +00:00
|
|
|
}
|
|
|
|
return seat->wheel_scrolling;
|
|
|
|
|
|
|
|
case WL_POINTER_AXIS_SOURCE_FINGER:
|
|
|
|
if (seat->finger_scrolling == NULL)
|
|
|
|
{
|
|
|
|
seat->finger_scrolling = g_object_new (GDK_TYPE_WAYLAND_DEVICE,
|
|
|
|
"name", "Wayland Finger Scrolling",
|
2020-06-18 18:22:20 +00:00
|
|
|
"type", GDK_DEVICE_TYPE_PHYSICAL,
|
2020-02-24 18:35:27 +00:00
|
|
|
"source", GDK_SOURCE_TOUCHPAD,
|
2016-06-01 03:14:30 +00:00
|
|
|
"has-cursor", TRUE,
|
|
|
|
"display", seat->display,
|
|
|
|
"seat", seat,
|
|
|
|
NULL);
|
2020-06-18 18:22:20 +00:00
|
|
|
_gdk_device_set_associated_device (seat->finger_scrolling, seat->logical_pointer);
|
2017-11-27 18:51:38 +00:00
|
|
|
gdk_seat_device_added (GDK_SEAT (seat), seat->finger_scrolling);
|
2016-06-01 03:14:30 +00:00
|
|
|
}
|
|
|
|
return seat->finger_scrolling;
|
|
|
|
|
|
|
|
case WL_POINTER_AXIS_SOURCE_CONTINUOUS:
|
|
|
|
if (seat->continuous_scrolling == NULL)
|
|
|
|
{
|
|
|
|
seat->continuous_scrolling = g_object_new (GDK_TYPE_WAYLAND_DEVICE,
|
|
|
|
"name", "Wayland Continuous Scrolling",
|
2020-06-18 18:22:20 +00:00
|
|
|
"type", GDK_DEVICE_TYPE_PHYSICAL,
|
2020-02-24 18:35:27 +00:00
|
|
|
"source", GDK_SOURCE_TRACKPOINT,
|
2016-06-01 03:14:30 +00:00
|
|
|
"has-cursor", TRUE,
|
|
|
|
"display", seat->display,
|
|
|
|
"seat", seat,
|
|
|
|
NULL);
|
2020-06-18 18:22:20 +00:00
|
|
|
_gdk_device_set_associated_device (seat->continuous_scrolling, seat->logical_pointer);
|
2017-11-27 18:51:38 +00:00
|
|
|
gdk_seat_device_added (GDK_SEAT (seat), seat->continuous_scrolling);
|
2016-06-01 03:14:30 +00:00
|
|
|
}
|
|
|
|
return seat->continuous_scrolling;
|
|
|
|
|
2017-10-06 19:19:42 +00:00
|
|
|
case WL_POINTER_AXIS_SOURCE_WHEEL_TILT:
|
2016-06-01 03:14:30 +00:00
|
|
|
default:
|
|
|
|
return seat->pointer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-25 13:38:22 +00:00
|
|
|
static void
|
2015-02-28 03:28:28 +00:00
|
|
|
seat_handle_name (void *data,
|
|
|
|
struct wl_seat *seat,
|
|
|
|
const char *name)
|
2014-07-25 13:38:22 +00:00
|
|
|
{
|
|
|
|
/* We don't care about the name. */
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (GDK_WAYLAND_SEAT (data), MISC,
|
2015-02-28 05:15:13 +00:00
|
|
|
g_message ("seat %p name %s", seat, name));
|
2014-07-25 13:38:22 +00:00
|
|
|
}
|
|
|
|
|
2012-07-11 13:29:43 +00:00
|
|
|
static const struct wl_seat_listener seat_listener = {
|
2014-07-25 13:27:22 +00:00
|
|
|
seat_handle_capabilities,
|
2014-07-25 13:38:22 +00:00
|
|
|
seat_handle_name,
|
2012-07-11 13:29:43 +00:00
|
|
|
};
|
|
|
|
|
2015-01-19 00:32:24 +00:00
|
|
|
static void
|
|
|
|
tablet_tool_handle_type (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool,
|
2015-01-19 00:32:24 +00:00
|
|
|
uint32_t tool_type)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
|
|
|
|
switch (tool_type)
|
|
|
|
{
|
2016-05-13 13:19:04 +00:00
|
|
|
case ZWP_TABLET_TOOL_V2_TYPE_PEN:
|
2015-01-19 00:32:24 +00:00
|
|
|
tool->type = GDK_DEVICE_TOOL_TYPE_PEN;
|
|
|
|
break;
|
2016-05-13 13:19:04 +00:00
|
|
|
case ZWP_TABLET_TOOL_V2_TYPE_BRUSH:
|
2015-01-19 00:32:24 +00:00
|
|
|
tool->type = GDK_DEVICE_TOOL_TYPE_BRUSH;
|
|
|
|
break;
|
2016-05-13 13:19:04 +00:00
|
|
|
case ZWP_TABLET_TOOL_V2_TYPE_AIRBRUSH:
|
2015-01-19 00:32:24 +00:00
|
|
|
tool->type = GDK_DEVICE_TOOL_TYPE_AIRBRUSH;
|
|
|
|
break;
|
2016-05-13 13:19:04 +00:00
|
|
|
case ZWP_TABLET_TOOL_V2_TYPE_PENCIL:
|
2015-01-19 00:32:24 +00:00
|
|
|
tool->type = GDK_DEVICE_TOOL_TYPE_PENCIL;
|
|
|
|
break;
|
2016-05-13 13:19:04 +00:00
|
|
|
case ZWP_TABLET_TOOL_V2_TYPE_ERASER:
|
2015-01-19 00:32:24 +00:00
|
|
|
tool->type = GDK_DEVICE_TOOL_TYPE_ERASER;
|
|
|
|
break;
|
2016-05-13 13:19:04 +00:00
|
|
|
case ZWP_TABLET_TOOL_V2_TYPE_MOUSE:
|
2015-01-19 00:32:24 +00:00
|
|
|
tool->type = GDK_DEVICE_TOOL_TYPE_MOUSE;
|
|
|
|
break;
|
2016-05-13 13:19:04 +00:00
|
|
|
case ZWP_TABLET_TOOL_V2_TYPE_LENS:
|
2015-01-19 00:32:24 +00:00
|
|
|
tool->type = GDK_DEVICE_TOOL_TYPE_LENS;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
tool->type = GDK_DEVICE_TOOL_TYPE_UNKNOWN;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_tool_handle_hardware_serial (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool,
|
2015-01-19 00:32:24 +00:00
|
|
|
uint32_t serial_hi,
|
|
|
|
uint32_t serial_lo)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
|
|
|
|
tool->hardware_serial = ((guint64) serial_hi) << 32 | serial_lo;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_tool_handle_hardware_id_wacom (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool,
|
2015-01-19 00:32:24 +00:00
|
|
|
uint32_t id_hi,
|
|
|
|
uint32_t id_lo)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
|
|
|
|
tool->hardware_id_wacom = ((guint64) id_hi) << 32 | id_lo;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_tool_handle_capability (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool,
|
2015-01-19 00:32:24 +00:00
|
|
|
uint32_t capability)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
|
|
|
|
switch (capability)
|
|
|
|
{
|
2016-05-13 13:19:04 +00:00
|
|
|
case ZWP_TABLET_TOOL_V2_CAPABILITY_TILT:
|
2015-01-19 00:32:24 +00:00
|
|
|
tool->axes |= GDK_AXIS_FLAG_XTILT | GDK_AXIS_FLAG_YTILT;
|
|
|
|
break;
|
2016-05-13 13:19:04 +00:00
|
|
|
case ZWP_TABLET_TOOL_V2_CAPABILITY_PRESSURE:
|
2015-01-19 00:32:24 +00:00
|
|
|
tool->axes |= GDK_AXIS_FLAG_PRESSURE;
|
|
|
|
break;
|
2016-05-13 13:19:04 +00:00
|
|
|
case ZWP_TABLET_TOOL_V2_CAPABILITY_DISTANCE:
|
2015-01-19 00:32:24 +00:00
|
|
|
tool->axes |= GDK_AXIS_FLAG_DISTANCE;
|
|
|
|
break;
|
2016-05-13 13:19:04 +00:00
|
|
|
case ZWP_TABLET_TOOL_V2_CAPABILITY_ROTATION:
|
2016-04-08 15:25:04 +00:00
|
|
|
tool->axes |= GDK_AXIS_FLAG_ROTATION;
|
|
|
|
break;
|
2016-05-13 13:19:04 +00:00
|
|
|
case ZWP_TABLET_TOOL_V2_CAPABILITY_SLIDER:
|
2016-04-08 15:25:04 +00:00
|
|
|
tool->axes |= GDK_AXIS_FLAG_SLIDER;
|
|
|
|
break;
|
2017-10-06 19:19:42 +00:00
|
|
|
default:
|
|
|
|
break;
|
2015-01-19 00:32:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_tool_handle_done (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool)
|
2015-01-19 00:32:24 +00:00
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
|
2016-08-04 16:52:51 +00:00
|
|
|
tool->tool = gdk_device_tool_new (tool->hardware_serial,
|
|
|
|
tool->hardware_id_wacom,
|
|
|
|
tool->type, tool->axes);
|
2015-01-19 00:32:24 +00:00
|
|
|
gdk_seat_tool_added (tool->seat, tool->tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_tool_handle_removed (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool)
|
2015-01-19 00:32:24 +00:00
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
|
|
|
|
_gdk_wayland_seat_remove_tool (GDK_WAYLAND_SEAT (tool->seat), tool);
|
|
|
|
}
|
|
|
|
|
2015-06-22 15:51:48 +00:00
|
|
|
static void
|
|
|
|
gdk_wayland_tablet_flush_frame_event (GdkWaylandTabletData *tablet,
|
|
|
|
guint32 time)
|
|
|
|
{
|
|
|
|
GdkEvent *event;
|
2020-02-18 03:11:56 +00:00
|
|
|
GdkEventType type;
|
2015-06-22 15:51:48 +00:00
|
|
|
|
|
|
|
event = tablet->pointer_info.frame.event;
|
|
|
|
tablet->pointer_info.frame.event = NULL;
|
|
|
|
|
|
|
|
if (!event)
|
|
|
|
return;
|
|
|
|
|
2020-02-15 20:07:24 +00:00
|
|
|
gdk_event_ref (event);
|
2019-10-08 15:56:10 +00:00
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
type = gdk_event_get_event_type (event);
|
|
|
|
|
|
|
|
if (type == GDK_PROXIMITY_OUT)
|
|
|
|
emulate_crossing (gdk_event_get_surface (event), NULL,
|
2020-06-18 18:22:20 +00:00
|
|
|
tablet->logical_device, GDK_LEAVE_NOTIFY,
|
2015-06-22 15:51:48 +00:00
|
|
|
GDK_CROSSING_NORMAL, time);
|
|
|
|
|
|
|
|
_gdk_wayland_display_deliver_event (gdk_seat_get_display (tablet->seat),
|
|
|
|
event);
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
if (type == GDK_PROXIMITY_IN)
|
|
|
|
emulate_crossing (gdk_event_get_surface (event), NULL,
|
2020-06-18 18:22:20 +00:00
|
|
|
tablet->logical_device, GDK_ENTER_NOTIFY,
|
2015-06-22 15:51:48 +00:00
|
|
|
GDK_CROSSING_NORMAL, time);
|
2019-10-08 15:56:10 +00:00
|
|
|
|
2020-02-15 20:07:24 +00:00
|
|
|
gdk_event_unref (event);
|
2015-06-22 15:51:48 +00:00
|
|
|
}
|
|
|
|
|
2020-02-14 13:10:21 +00:00
|
|
|
static void
|
|
|
|
gdk_wayland_tablet_set_frame_event (GdkWaylandTabletData *tablet,
|
|
|
|
GdkEvent *event)
|
2015-06-22 15:51:48 +00:00
|
|
|
{
|
|
|
|
if (tablet->pointer_info.frame.event &&
|
2020-02-18 03:11:56 +00:00
|
|
|
gdk_event_get_event_type (tablet->pointer_info.frame.event) != gdk_event_get_event_type (event))
|
2015-06-22 15:51:48 +00:00
|
|
|
gdk_wayland_tablet_flush_frame_event (tablet, GDK_CURRENT_TIME);
|
|
|
|
|
2020-02-14 13:10:21 +00:00
|
|
|
tablet->pointer_info.frame.event = event;
|
2015-06-22 15:51:48 +00:00
|
|
|
}
|
|
|
|
|
2015-06-22 16:02:50 +00:00
|
|
|
static void
|
|
|
|
gdk_wayland_device_tablet_clone_tool_axes (GdkWaylandTabletData *tablet,
|
|
|
|
GdkDeviceTool *tool)
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
int axis_pos;
|
2015-06-22 16:02:50 +00:00
|
|
|
|
2020-06-22 21:19:35 +00:00
|
|
|
g_object_freeze_notify (G_OBJECT (tablet->stylus_device));
|
|
|
|
_gdk_device_reset_axes (tablet->stylus_device);
|
2015-06-22 16:02:50 +00:00
|
|
|
|
2020-06-22 21:19:35 +00:00
|
|
|
_gdk_device_add_axis (tablet->stylus_device, GDK_AXIS_X, 0, 0, 0);
|
|
|
|
_gdk_device_add_axis (tablet->stylus_device, GDK_AXIS_Y, 0, 0, 0);
|
2015-06-22 16:02:50 +00:00
|
|
|
|
|
|
|
if (tool->tool_axes & (GDK_AXIS_FLAG_XTILT | GDK_AXIS_FLAG_YTILT))
|
|
|
|
{
|
2020-06-22 21:19:35 +00:00
|
|
|
axis_pos = _gdk_device_add_axis (tablet->stylus_device,
|
2016-05-13 13:25:25 +00:00
|
|
|
GDK_AXIS_XTILT, -90, 90, 0);
|
2015-06-22 16:02:50 +00:00
|
|
|
tablet->axis_indices[GDK_AXIS_XTILT] = axis_pos;
|
|
|
|
|
2020-06-22 21:19:35 +00:00
|
|
|
axis_pos = _gdk_device_add_axis (tablet->stylus_device,
|
2016-05-13 13:25:25 +00:00
|
|
|
GDK_AXIS_YTILT, -90, 90, 0);
|
2015-06-22 16:02:50 +00:00
|
|
|
tablet->axis_indices[GDK_AXIS_YTILT] = axis_pos;
|
|
|
|
}
|
|
|
|
if (tool->tool_axes & GDK_AXIS_FLAG_DISTANCE)
|
|
|
|
{
|
2020-06-22 21:19:35 +00:00
|
|
|
axis_pos = _gdk_device_add_axis (tablet->stylus_device,
|
2015-06-22 16:02:50 +00:00
|
|
|
GDK_AXIS_DISTANCE, 0, 65535, 0);
|
|
|
|
tablet->axis_indices[GDK_AXIS_DISTANCE] = axis_pos;
|
|
|
|
}
|
|
|
|
if (tool->tool_axes & GDK_AXIS_FLAG_PRESSURE)
|
|
|
|
{
|
2020-06-22 21:19:35 +00:00
|
|
|
axis_pos = _gdk_device_add_axis (tablet->stylus_device,
|
2015-06-22 16:02:50 +00:00
|
|
|
GDK_AXIS_PRESSURE, 0, 65535, 0);
|
|
|
|
tablet->axis_indices[GDK_AXIS_PRESSURE] = axis_pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tool->tool_axes & GDK_AXIS_FLAG_ROTATION)
|
|
|
|
{
|
2020-06-22 21:19:35 +00:00
|
|
|
axis_pos = _gdk_device_add_axis (tablet->stylus_device,
|
2016-05-13 13:25:25 +00:00
|
|
|
GDK_AXIS_ROTATION, 0, 360, 0);
|
2015-06-22 16:02:50 +00:00
|
|
|
tablet->axis_indices[GDK_AXIS_ROTATION] = axis_pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tool->tool_axes & GDK_AXIS_FLAG_SLIDER)
|
|
|
|
{
|
2020-06-22 21:19:35 +00:00
|
|
|
axis_pos = _gdk_device_add_axis (tablet->stylus_device,
|
2015-06-22 16:02:50 +00:00
|
|
|
GDK_AXIS_SLIDER, -65535, 65535, 0);
|
|
|
|
tablet->axis_indices[GDK_AXIS_SLIDER] = axis_pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tablet->axes)
|
2016-05-04 02:36:20 +00:00
|
|
|
g_free (tablet->axes);
|
2015-06-22 16:02:50 +00:00
|
|
|
|
|
|
|
tablet->axes =
|
2020-07-24 20:32:16 +00:00
|
|
|
g_new0 (double, gdk_device_get_n_axes (tablet->stylus_device));
|
2015-06-22 16:02:50 +00:00
|
|
|
|
2020-06-22 21:19:35 +00:00
|
|
|
g_object_thaw_notify (G_OBJECT (tablet->stylus_device));
|
2015-06-22 16:02:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_wayland_mimic_device_axes (GdkDevice *logical,
|
|
|
|
GdkDevice *physical)
|
2015-06-22 16:02:50 +00:00
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
double axis_min, axis_max, axis_resolution;
|
2015-06-22 16:02:50 +00:00
|
|
|
GdkAxisUse axis_use;
|
2020-07-24 13:54:49 +00:00
|
|
|
int axis_count;
|
|
|
|
int i;
|
2015-06-22 16:02:50 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
g_object_freeze_notify (G_OBJECT (logical));
|
|
|
|
_gdk_device_reset_axes (logical);
|
|
|
|
axis_count = gdk_device_get_n_axes (physical);
|
2015-06-22 16:02:50 +00:00
|
|
|
|
|
|
|
for (i = 0; i < axis_count; i++)
|
|
|
|
{
|
2020-06-18 18:22:20 +00:00
|
|
|
_gdk_device_get_axis_info (physical, i, &axis_use, &axis_min,
|
2015-06-22 16:02:50 +00:00
|
|
|
&axis_max, &axis_resolution);
|
2020-06-18 18:22:20 +00:00
|
|
|
_gdk_device_add_axis (logical, axis_use, axis_min,
|
2015-06-22 16:02:50 +00:00
|
|
|
axis_max, axis_resolution);
|
|
|
|
}
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
g_object_thaw_notify (G_OBJECT (logical));
|
2015-06-22 16:02:50 +00:00
|
|
|
}
|
|
|
|
|
2015-06-22 15:51:48 +00:00
|
|
|
static void
|
|
|
|
tablet_tool_handle_proximity_in (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool,
|
2015-06-22 15:51:48 +00:00
|
|
|
uint32_t serial,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_v2 *wp_tablet,
|
2018-03-20 14:14:10 +00:00
|
|
|
struct wl_surface *wsurface)
|
2015-06-22 15:51:48 +00:00
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
2016-05-13 13:19:04 +00:00
|
|
|
GdkWaylandTabletData *tablet = zwp_tablet_v2_get_user_data (wp_tablet);
|
2015-06-22 15:51:48 +00:00
|
|
|
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
|
2016-04-26 03:16:56 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
|
2018-03-20 14:14:10 +00:00
|
|
|
GdkSurface *surface = wl_surface_get_user_data (wsurface);
|
2015-06-22 15:51:48 +00:00
|
|
|
GdkEvent *event;
|
|
|
|
|
|
|
|
if (!surface)
|
|
|
|
return;
|
2018-03-20 14:14:10 +00:00
|
|
|
if (!GDK_IS_SURFACE (surface))
|
2015-06-22 15:51:48 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
tool->current_tablet = tablet;
|
|
|
|
tablet->current_tool = tool;
|
|
|
|
|
2016-04-26 03:16:56 +00:00
|
|
|
_gdk_wayland_display_update_serial (display_wayland, serial);
|
2015-06-22 15:51:48 +00:00
|
|
|
tablet->pointer_info.enter_serial = serial;
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
tablet->pointer_info.focus = g_object_ref (surface);
|
2015-06-22 15:51:48 +00:00
|
|
|
|
2020-06-22 21:19:35 +00:00
|
|
|
gdk_device_update_tool (tablet->stylus_device, tool->tool);
|
2015-06-22 16:02:50 +00:00
|
|
|
gdk_wayland_device_tablet_clone_tool_axes (tablet, tool->tool);
|
2020-06-22 21:19:35 +00:00
|
|
|
gdk_wayland_mimic_device_axes (tablet->logical_device, tablet->stylus_device);
|
2015-06-22 15:51:48 +00:00
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_proximity_event_new (GDK_PROXIMITY_IN,
|
2020-02-14 13:10:21 +00:00
|
|
|
tablet->pointer_info.focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
tablet->logical_device,
|
2020-06-22 21:19:35 +00:00
|
|
|
tablet->stylus_device,
|
2020-02-14 13:10:21 +00:00
|
|
|
tool->tool,
|
|
|
|
tablet->pointer_info.time);
|
|
|
|
gdk_wayland_tablet_set_frame_event (tablet, event);
|
2015-06-22 15:51:48 +00:00
|
|
|
|
2019-02-15 01:42:23 +00:00
|
|
|
tablet->pointer_info.pointer_surface_outputs =
|
|
|
|
g_slist_append (tablet->pointer_info.pointer_surface_outputs,
|
|
|
|
gdk_wayland_surface_get_wl_output (surface));
|
2020-06-18 18:22:20 +00:00
|
|
|
pointer_surface_update_scale (tablet->logical_device);
|
2019-02-15 01:42:23 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2015-06-22 15:51:48 +00:00
|
|
|
g_message ("proximity in, seat %p surface %p tool %d",
|
|
|
|
seat, tablet->pointer_info.focus,
|
|
|
|
gdk_device_tool_get_tool_type (tool->tool)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_tool_handle_proximity_out (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool)
|
2015-06-22 15:51:48 +00:00
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
GdkWaylandTabletData *tablet = tool->current_tablet;
|
|
|
|
GdkEvent *event;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (tool->seat, EVENTS,
|
|
|
|
g_message ("proximity out, seat %p, tool %d", tool->seat,
|
2015-06-22 15:51:48 +00:00
|
|
|
gdk_device_tool_get_tool_type (tool->tool)));
|
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_proximity_event_new (GDK_PROXIMITY_OUT,
|
2020-02-14 13:10:21 +00:00
|
|
|
tablet->pointer_info.focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
tablet->logical_device,
|
2020-06-22 21:19:35 +00:00
|
|
|
tablet->stylus_device,
|
2020-02-14 13:10:21 +00:00
|
|
|
tool->tool,
|
|
|
|
tablet->pointer_info.time);
|
|
|
|
gdk_wayland_tablet_set_frame_event (tablet, event);
|
2015-06-22 15:51:48 +00:00
|
|
|
|
|
|
|
gdk_wayland_pointer_stop_cursor_animation (&tablet->pointer_info);
|
|
|
|
|
2019-02-15 01:42:23 +00:00
|
|
|
tablet->pointer_info.pointer_surface_outputs =
|
|
|
|
g_slist_remove (tablet->pointer_info.pointer_surface_outputs,
|
|
|
|
gdk_wayland_surface_get_wl_output (tablet->pointer_info.focus));
|
2020-06-18 18:22:20 +00:00
|
|
|
pointer_surface_update_scale (tablet->logical_device);
|
2019-02-15 01:42:23 +00:00
|
|
|
|
2015-06-22 15:51:48 +00:00
|
|
|
g_object_unref (tablet->pointer_info.focus);
|
|
|
|
tablet->pointer_info.focus = NULL;
|
|
|
|
|
2020-06-22 21:19:35 +00:00
|
|
|
gdk_device_update_tool (tablet->stylus_device, NULL);
|
2017-07-25 13:44:30 +00:00
|
|
|
g_clear_object (&tablet->pointer_info.cursor);
|
2015-06-22 15:51:48 +00:00
|
|
|
}
|
|
|
|
|
2020-02-14 13:10:21 +00:00
|
|
|
static double *
|
|
|
|
tablet_copy_axes (GdkWaylandTabletData *tablet)
|
|
|
|
{
|
|
|
|
return g_memdup (tablet->axes,
|
2020-07-24 20:32:16 +00:00
|
|
|
sizeof (double) * gdk_device_get_n_axes (tablet->stylus_device));
|
2020-02-14 13:10:21 +00:00
|
|
|
}
|
|
|
|
|
2015-06-22 16:16:27 +00:00
|
|
|
static void
|
|
|
|
tablet_create_button_event_frame (GdkWaylandTabletData *tablet,
|
|
|
|
GdkEventType evtype,
|
|
|
|
guint button)
|
|
|
|
{
|
|
|
|
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
|
|
|
|
GdkEvent *event;
|
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_button_event_new (evtype,
|
2020-02-14 13:10:21 +00:00
|
|
|
tablet->pointer_info.focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
tablet->logical_device,
|
2020-06-22 21:19:35 +00:00
|
|
|
tablet->stylus_device,
|
2020-02-14 13:10:21 +00:00
|
|
|
tablet->current_tool->tool,
|
|
|
|
tablet->pointer_info.time,
|
2020-06-18 18:22:20 +00:00
|
|
|
device_get_modifiers (seat->logical_pointer),
|
2020-02-14 13:10:21 +00:00
|
|
|
button,
|
2020-02-14 22:46:56 +00:00
|
|
|
tablet->pointer_info.surface_x,
|
|
|
|
tablet->pointer_info.surface_y,
|
2020-02-14 13:10:21 +00:00
|
|
|
tablet_copy_axes (tablet));
|
|
|
|
gdk_wayland_tablet_set_frame_event (tablet, event);
|
2015-06-22 16:16:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_tool_handle_down (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool,
|
2015-06-22 16:16:27 +00:00
|
|
|
uint32_t serial)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
GdkWaylandTabletData *tablet = tool->current_tablet;
|
|
|
|
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tool->seat);
|
2016-04-26 03:16:56 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
|
2015-06-22 16:16:27 +00:00
|
|
|
|
|
|
|
if (!tablet->pointer_info.focus)
|
|
|
|
return;
|
|
|
|
|
2016-04-26 03:16:56 +00:00
|
|
|
_gdk_wayland_display_update_serial (display_wayland, serial);
|
2015-06-22 16:16:27 +00:00
|
|
|
tablet->pointer_info.press_serial = serial;
|
|
|
|
|
|
|
|
tablet_create_button_event_frame (tablet, GDK_BUTTON_PRESS, GDK_BUTTON_PRIMARY);
|
|
|
|
tablet->pointer_info.button_modifiers |= GDK_BUTTON1_MASK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_tool_handle_up (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool)
|
2015-06-22 16:16:27 +00:00
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
GdkWaylandTabletData *tablet = tool->current_tablet;
|
|
|
|
|
|
|
|
if (!tablet->pointer_info.focus)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tablet_create_button_event_frame (tablet, GDK_BUTTON_RELEASE, GDK_BUTTON_PRIMARY);
|
|
|
|
tablet->pointer_info.button_modifiers &= ~GDK_BUTTON1_MASK;
|
|
|
|
}
|
|
|
|
|
2015-06-22 15:51:48 +00:00
|
|
|
static void
|
|
|
|
tablet_tool_handle_motion (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool,
|
2015-06-22 15:51:48 +00:00
|
|
|
wl_fixed_t sx,
|
|
|
|
wl_fixed_t sy)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
GdkWaylandTabletData *tablet = tool->current_tablet;
|
|
|
|
GdkEvent *event;
|
|
|
|
|
|
|
|
tablet->pointer_info.surface_x = wl_fixed_to_double (sx);
|
|
|
|
tablet->pointer_info.surface_y = wl_fixed_to_double (sy);
|
|
|
|
|
2020-02-18 05:40:48 +00:00
|
|
|
GDK_SEAT_NOTE (tool->seat, EVENTS,
|
2015-06-22 15:51:48 +00:00
|
|
|
g_message ("tablet motion %f %f",
|
|
|
|
tablet->pointer_info.surface_x,
|
|
|
|
tablet->pointer_info.surface_y));
|
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_motion_event_new (tablet->pointer_info.focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
tablet->logical_device,
|
2020-06-22 21:19:35 +00:00
|
|
|
tablet->stylus_device,
|
2020-02-14 13:10:21 +00:00
|
|
|
tool->tool,
|
|
|
|
tablet->pointer_info.time,
|
2020-06-18 18:22:20 +00:00
|
|
|
device_get_modifiers (tablet->logical_device),
|
2020-02-14 22:46:56 +00:00
|
|
|
tablet->pointer_info.surface_x,
|
|
|
|
tablet->pointer_info.surface_y,
|
2020-02-14 13:10:21 +00:00
|
|
|
tablet_copy_axes (tablet));
|
2015-06-22 15:51:48 +00:00
|
|
|
|
2020-02-14 13:10:21 +00:00
|
|
|
gdk_wayland_tablet_set_frame_event (tablet, event);
|
2015-06-22 15:51:48 +00:00
|
|
|
}
|
|
|
|
|
2015-06-22 16:02:50 +00:00
|
|
|
static void
|
|
|
|
tablet_tool_handle_pressure (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool,
|
2015-06-22 16:02:50 +00:00
|
|
|
uint32_t pressure)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
GdkWaylandTabletData *tablet = tool->current_tablet;
|
2020-07-24 13:54:49 +00:00
|
|
|
int axis_index = tablet->axis_indices[GDK_AXIS_PRESSURE];
|
2015-06-22 16:02:50 +00:00
|
|
|
|
2020-06-22 21:19:35 +00:00
|
|
|
_gdk_device_translate_axis (tablet->stylus_device, axis_index,
|
2015-06-22 16:02:50 +00:00
|
|
|
pressure, &tablet->axes[axis_index]);
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (tool->seat, EVENTS,
|
2015-06-22 16:02:50 +00:00
|
|
|
g_message ("tablet tool %d pressure %d",
|
|
|
|
gdk_device_tool_get_tool_type (tool->tool), pressure));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_tool_handle_distance (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool,
|
2015-06-22 16:02:50 +00:00
|
|
|
uint32_t distance)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
GdkWaylandTabletData *tablet = tool->current_tablet;
|
2020-07-24 13:54:49 +00:00
|
|
|
int axis_index = tablet->axis_indices[GDK_AXIS_DISTANCE];
|
2015-06-22 16:02:50 +00:00
|
|
|
|
2020-06-22 21:19:35 +00:00
|
|
|
_gdk_device_translate_axis (tablet->stylus_device, axis_index,
|
2015-06-22 16:02:50 +00:00
|
|
|
distance, &tablet->axes[axis_index]);
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (tool->seat, EVENTS,
|
2015-06-22 16:02:50 +00:00
|
|
|
g_message ("tablet tool %d distance %d",
|
|
|
|
gdk_device_tool_get_tool_type (tool->tool), distance));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_tool_handle_tilt (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool,
|
2016-05-13 13:25:25 +00:00
|
|
|
wl_fixed_t xtilt,
|
|
|
|
wl_fixed_t ytilt)
|
2015-06-22 16:02:50 +00:00
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
GdkWaylandTabletData *tablet = tool->current_tablet;
|
2020-07-24 13:54:49 +00:00
|
|
|
int xtilt_axis_index = tablet->axis_indices[GDK_AXIS_XTILT];
|
|
|
|
int ytilt_axis_index = tablet->axis_indices[GDK_AXIS_YTILT];
|
2015-06-22 16:02:50 +00:00
|
|
|
|
2020-06-22 21:19:35 +00:00
|
|
|
_gdk_device_translate_axis (tablet->stylus_device, xtilt_axis_index,
|
2016-05-13 13:25:25 +00:00
|
|
|
wl_fixed_to_double (xtilt),
|
|
|
|
&tablet->axes[xtilt_axis_index]);
|
2020-06-22 21:19:35 +00:00
|
|
|
_gdk_device_translate_axis (tablet->stylus_device, ytilt_axis_index,
|
2016-05-13 13:25:25 +00:00
|
|
|
wl_fixed_to_double (ytilt),
|
|
|
|
&tablet->axes[ytilt_axis_index]);
|
2015-06-22 16:02:50 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (tool->seat, EVENTS,
|
2016-05-13 13:25:25 +00:00
|
|
|
g_message ("tablet tool %d tilt %f/%f",
|
2015-06-22 16:02:50 +00:00
|
|
|
gdk_device_tool_get_tool_type (tool->tool),
|
2016-05-13 13:25:25 +00:00
|
|
|
wl_fixed_to_double (xtilt), wl_fixed_to_double (ytilt)));
|
2015-06-22 16:02:50 +00:00
|
|
|
}
|
|
|
|
|
2015-06-22 16:28:46 +00:00
|
|
|
static void
|
|
|
|
tablet_tool_handle_button (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool,
|
2015-06-22 16:28:46 +00:00
|
|
|
uint32_t serial,
|
|
|
|
uint32_t button,
|
|
|
|
uint32_t state)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
GdkWaylandTabletData *tablet = tool->current_tablet;
|
|
|
|
GdkEventType evtype;
|
|
|
|
guint n_button;
|
|
|
|
|
|
|
|
if (!tablet->pointer_info.focus)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tablet->pointer_info.press_serial = serial;
|
|
|
|
|
|
|
|
if (button == BTN_STYLUS)
|
|
|
|
n_button = GDK_BUTTON_SECONDARY;
|
|
|
|
else if (button == BTN_STYLUS2)
|
|
|
|
n_button = GDK_BUTTON_MIDDLE;
|
2017-10-10 16:17:43 +00:00
|
|
|
else if (button == BTN_STYLUS3)
|
|
|
|
n_button = 8; /* Back */
|
2015-06-22 16:28:46 +00:00
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
2016-05-13 13:19:04 +00:00
|
|
|
if (state == ZWP_TABLET_TOOL_V2_BUTTON_STATE_PRESSED)
|
2015-06-22 16:28:46 +00:00
|
|
|
evtype = GDK_BUTTON_PRESS;
|
2016-05-13 13:19:04 +00:00
|
|
|
else if (state == ZWP_TABLET_TOOL_V2_BUTTON_STATE_RELEASED)
|
2015-06-22 16:28:46 +00:00
|
|
|
evtype = GDK_BUTTON_RELEASE;
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
|
|
|
tablet_create_button_event_frame (tablet, evtype, n_button);
|
|
|
|
}
|
|
|
|
|
2015-06-22 16:02:50 +00:00
|
|
|
static void
|
|
|
|
tablet_tool_handle_rotation (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool,
|
2016-05-13 13:25:25 +00:00
|
|
|
wl_fixed_t degrees)
|
2015-06-22 16:02:50 +00:00
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
GdkWaylandTabletData *tablet = tool->current_tablet;
|
2020-07-24 13:54:49 +00:00
|
|
|
int axis_index = tablet->axis_indices[GDK_AXIS_ROTATION];
|
2015-06-22 16:02:50 +00:00
|
|
|
|
2020-06-22 21:19:35 +00:00
|
|
|
_gdk_device_translate_axis (tablet->stylus_device, axis_index,
|
2016-05-13 13:25:25 +00:00
|
|
|
wl_fixed_to_double (degrees),
|
|
|
|
&tablet->axes[axis_index]);
|
2015-06-22 16:02:50 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (tool->seat, EVENTS,
|
2016-05-13 13:25:25 +00:00
|
|
|
g_message ("tablet tool %d rotation %f",
|
|
|
|
gdk_device_tool_get_tool_type (tool->tool),
|
|
|
|
wl_fixed_to_double (degrees)));
|
2015-06-22 16:02:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_tool_handle_slider (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool,
|
2015-06-22 16:02:50 +00:00
|
|
|
int32_t position)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
GdkWaylandTabletData *tablet = tool->current_tablet;
|
2020-07-24 13:54:49 +00:00
|
|
|
int axis_index = tablet->axis_indices[GDK_AXIS_SLIDER];
|
2015-06-22 16:02:50 +00:00
|
|
|
|
2020-06-22 21:19:35 +00:00
|
|
|
_gdk_device_translate_axis (tablet->stylus_device, axis_index,
|
2015-06-22 16:02:50 +00:00
|
|
|
position, &tablet->axes[axis_index]);
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (tool->seat, EVENTS,
|
2015-06-22 16:02:50 +00:00
|
|
|
g_message ("tablet tool %d slider %d",
|
|
|
|
gdk_device_tool_get_tool_type (tool->tool), position));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_tool_handle_wheel (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool,
|
2015-06-22 16:02:50 +00:00
|
|
|
int32_t degrees,
|
|
|
|
int32_t clicks)
|
|
|
|
{
|
2017-06-12 22:41:51 +00:00
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
GdkWaylandTabletData *tablet = tool->current_tablet;
|
|
|
|
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
|
|
|
|
GdkEvent *event;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2017-06-12 22:41:51 +00:00
|
|
|
g_message ("tablet tool %d wheel %d/%d",
|
|
|
|
gdk_device_tool_get_tool_type (tool->tool), degrees, clicks));
|
|
|
|
|
|
|
|
if (clicks == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Send smooth event */
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_scroll_event_new (tablet->pointer_info.focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
tablet->logical_device,
|
2020-06-22 21:19:35 +00:00
|
|
|
tablet->stylus_device,
|
2020-02-14 13:10:21 +00:00
|
|
|
tablet->current_tool->tool,
|
|
|
|
tablet->pointer_info.time,
|
2020-06-18 18:22:20 +00:00
|
|
|
device_get_modifiers (tablet->logical_device),
|
2020-02-14 13:10:21 +00:00
|
|
|
0, clicks,
|
|
|
|
FALSE);
|
|
|
|
|
2017-06-12 22:41:51 +00:00
|
|
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
|
|
|
|
|
|
|
/* Send discrete event */
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_scroll_event_new_discrete (tablet->pointer_info.focus,
|
2020-06-18 18:22:20 +00:00
|
|
|
tablet->logical_device,
|
2020-06-22 21:19:35 +00:00
|
|
|
tablet->stylus_device,
|
2020-02-14 13:10:21 +00:00
|
|
|
tablet->current_tool->tool,
|
|
|
|
tablet->pointer_info.time,
|
2020-06-18 18:22:20 +00:00
|
|
|
device_get_modifiers (tablet->logical_device),
|
2020-02-14 13:10:21 +00:00
|
|
|
clicks > 0 ? GDK_SCROLL_DOWN : GDK_SCROLL_UP,
|
|
|
|
TRUE);
|
|
|
|
|
2017-06-12 22:41:51 +00:00
|
|
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
2015-06-22 16:02:50 +00:00
|
|
|
}
|
|
|
|
|
2015-06-22 15:51:48 +00:00
|
|
|
static void
|
|
|
|
tablet_tool_handle_frame (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_tool_v2 *wl_tablet_tool,
|
2015-06-22 15:51:48 +00:00
|
|
|
uint32_t time)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletToolData *tool = data;
|
|
|
|
GdkWaylandTabletData *tablet = tool->current_tablet;
|
|
|
|
GdkEvent *frame_event;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (tablet->seat, EVENTS,
|
2015-06-22 15:51:48 +00:00
|
|
|
g_message ("tablet frame, time %d", time));
|
|
|
|
|
|
|
|
frame_event = tablet->pointer_info.frame.event;
|
|
|
|
|
2020-02-18 03:11:56 +00:00
|
|
|
if (frame_event && gdk_event_get_event_type (frame_event) == GDK_PROXIMITY_OUT)
|
2015-06-22 15:51:48 +00:00
|
|
|
{
|
|
|
|
tool->current_tablet = NULL;
|
|
|
|
tablet->current_tool = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
tablet->pointer_info.time = time;
|
|
|
|
gdk_wayland_tablet_flush_frame_event (tablet, time);
|
|
|
|
}
|
|
|
|
|
2016-05-13 13:19:04 +00:00
|
|
|
static const struct zwp_tablet_tool_v2_listener tablet_tool_listener = {
|
2015-01-19 00:32:24 +00:00
|
|
|
tablet_tool_handle_type,
|
|
|
|
tablet_tool_handle_hardware_serial,
|
|
|
|
tablet_tool_handle_hardware_id_wacom,
|
|
|
|
tablet_tool_handle_capability,
|
|
|
|
tablet_tool_handle_done,
|
|
|
|
tablet_tool_handle_removed,
|
2015-06-22 15:51:48 +00:00
|
|
|
tablet_tool_handle_proximity_in,
|
|
|
|
tablet_tool_handle_proximity_out,
|
2015-06-22 16:16:27 +00:00
|
|
|
tablet_tool_handle_down,
|
|
|
|
tablet_tool_handle_up,
|
2015-06-22 15:51:48 +00:00
|
|
|
tablet_tool_handle_motion,
|
2015-06-22 16:02:50 +00:00
|
|
|
tablet_tool_handle_pressure,
|
|
|
|
tablet_tool_handle_distance,
|
|
|
|
tablet_tool_handle_tilt,
|
|
|
|
tablet_tool_handle_rotation,
|
|
|
|
tablet_tool_handle_slider,
|
|
|
|
tablet_tool_handle_wheel,
|
2015-06-22 16:28:46 +00:00
|
|
|
tablet_tool_handle_button,
|
2015-06-22 15:51:48 +00:00
|
|
|
tablet_tool_handle_frame,
|
2015-01-19 00:32:24 +00:00
|
|
|
};
|
|
|
|
|
2016-08-04 17:36:32 +00:00
|
|
|
static void
|
|
|
|
tablet_pad_ring_handle_source (void *data,
|
|
|
|
struct zwp_tablet_pad_ring_v2 *wp_tablet_pad_ring,
|
|
|
|
uint32_t source)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadGroupData *group = data;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad ring handle source, ring = %p source = %d",
|
|
|
|
wp_tablet_pad_ring, source));
|
2016-08-04 17:36:32 +00:00
|
|
|
|
|
|
|
group->axis_tmp_info.source = source;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_ring_handle_angle (void *data,
|
|
|
|
struct zwp_tablet_pad_ring_v2 *wp_tablet_pad_ring,
|
|
|
|
wl_fixed_t angle)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadGroupData *group = data;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
2018-02-04 14:48:47 +00:00
|
|
|
g_message ("tablet pad ring handle angle, ring = %p angle = %f",
|
2016-08-25 03:59:46 +00:00
|
|
|
wp_tablet_pad_ring, wl_fixed_to_double (angle)));
|
2016-08-04 17:36:32 +00:00
|
|
|
|
|
|
|
group->axis_tmp_info.value = wl_fixed_to_double (angle);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_ring_handle_stop (void *data,
|
|
|
|
struct zwp_tablet_pad_ring_v2 *wp_tablet_pad_ring)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadGroupData *group = data;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad ring handle stop, ring = %p", wp_tablet_pad_ring));
|
2016-08-04 17:36:32 +00:00
|
|
|
|
|
|
|
group->axis_tmp_info.is_stop = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_ring_handle_frame (void *data,
|
|
|
|
struct zwp_tablet_pad_ring_v2 *wp_tablet_pad_ring,
|
|
|
|
uint32_t time)
|
|
|
|
{
|
2016-08-04 17:44:44 +00:00
|
|
|
GdkWaylandTabletPadGroupData *group = data;
|
|
|
|
GdkWaylandTabletPadData *pad = group->pad;
|
|
|
|
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
|
|
|
GdkEvent *event;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad ring handle frame, ring = %p", wp_tablet_pad_ring));
|
2016-08-04 17:44:44 +00:00
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_pad_event_new_ring (seat->keyboard_focus,
|
2020-02-14 13:10:21 +00:00
|
|
|
pad->device,
|
|
|
|
pad->device,
|
|
|
|
time,
|
|
|
|
g_list_index (pad->mode_groups, group),
|
|
|
|
g_list_index (pad->rings, wp_tablet_pad_ring),
|
|
|
|
group->current_mode,
|
|
|
|
group->axis_tmp_info.value);
|
2016-08-04 17:44:44 +00:00
|
|
|
|
|
|
|
_gdk_wayland_display_deliver_event (gdk_seat_get_display (pad->seat),
|
|
|
|
event);
|
2016-08-04 17:36:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct zwp_tablet_pad_ring_v2_listener tablet_pad_ring_listener = {
|
|
|
|
tablet_pad_ring_handle_source,
|
|
|
|
tablet_pad_ring_handle_angle,
|
|
|
|
tablet_pad_ring_handle_stop,
|
|
|
|
tablet_pad_ring_handle_frame,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_strip_handle_source (void *data,
|
|
|
|
struct zwp_tablet_pad_strip_v2 *wp_tablet_pad_strip,
|
|
|
|
uint32_t source)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadGroupData *group = data;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad strip handle source, strip = %p source = %d",
|
|
|
|
wp_tablet_pad_strip, source));
|
2016-08-04 17:36:32 +00:00
|
|
|
|
|
|
|
group->axis_tmp_info.source = source;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_strip_handle_position (void *data,
|
|
|
|
struct zwp_tablet_pad_strip_v2 *wp_tablet_pad_strip,
|
|
|
|
uint32_t position)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadGroupData *group = data;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad strip handle position, strip = %p position = %d",
|
|
|
|
wp_tablet_pad_strip, position));
|
2016-08-04 17:36:32 +00:00
|
|
|
|
2020-07-24 20:32:16 +00:00
|
|
|
group->axis_tmp_info.value = (double) position / 65535;
|
2016-08-04 17:36:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_strip_handle_stop (void *data,
|
|
|
|
struct zwp_tablet_pad_strip_v2 *wp_tablet_pad_strip)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadGroupData *group = data;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad strip handle stop, strip = %p",
|
|
|
|
wp_tablet_pad_strip));
|
2016-08-04 17:36:32 +00:00
|
|
|
|
|
|
|
group->axis_tmp_info.is_stop = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_strip_handle_frame (void *data,
|
|
|
|
struct zwp_tablet_pad_strip_v2 *wp_tablet_pad_strip,
|
|
|
|
uint32_t time)
|
|
|
|
{
|
2016-08-04 17:44:44 +00:00
|
|
|
GdkWaylandTabletPadGroupData *group = data;
|
|
|
|
GdkWaylandTabletPadData *pad = group->pad;
|
|
|
|
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
|
|
|
GdkEvent *event;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad strip handle frame, strip = %p",
|
|
|
|
wp_tablet_pad_strip));
|
2016-08-04 17:44:44 +00:00
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_pad_event_new_strip (seat->keyboard_focus,
|
2020-02-14 13:10:21 +00:00
|
|
|
pad->device,
|
|
|
|
pad->device,
|
|
|
|
time,
|
|
|
|
g_list_index (pad->mode_groups, group),
|
|
|
|
g_list_index (pad->strips, wp_tablet_pad_strip),
|
|
|
|
group->current_mode,
|
|
|
|
group->axis_tmp_info.value);
|
2016-08-04 17:44:44 +00:00
|
|
|
|
|
|
|
_gdk_wayland_display_deliver_event (gdk_seat_get_display (pad->seat),
|
|
|
|
event);
|
2016-08-04 17:36:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct zwp_tablet_pad_strip_v2_listener tablet_pad_strip_listener = {
|
|
|
|
tablet_pad_strip_handle_source,
|
|
|
|
tablet_pad_strip_handle_position,
|
|
|
|
tablet_pad_strip_handle_stop,
|
|
|
|
tablet_pad_strip_handle_frame,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_group_handle_buttons (void *data,
|
|
|
|
struct zwp_tablet_pad_group_v2 *wp_tablet_pad_group,
|
|
|
|
struct wl_array *buttons)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadGroupData *group = data;
|
|
|
|
uint32_t *p;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
2018-06-11 15:14:23 +00:00
|
|
|
g_message ("tablet pad group handle buttons, pad group = %p, n_buttons = %" G_GSIZE_FORMAT,
|
2016-08-25 03:59:46 +00:00
|
|
|
wp_tablet_pad_group, buttons->size));
|
2016-08-04 17:36:32 +00:00
|
|
|
|
|
|
|
wl_array_for_each (p, buttons)
|
|
|
|
{
|
|
|
|
group->buttons = g_list_prepend (group->buttons, GUINT_TO_POINTER (*p));
|
|
|
|
}
|
|
|
|
|
|
|
|
group->buttons = g_list_reverse (group->buttons);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_group_handle_ring (void *data,
|
|
|
|
struct zwp_tablet_pad_group_v2 *wp_tablet_pad_group,
|
|
|
|
struct zwp_tablet_pad_ring_v2 *wp_tablet_pad_ring)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadGroupData *group = data;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad group handle ring, pad group = %p, ring = %p",
|
|
|
|
wp_tablet_pad_group, wp_tablet_pad_ring));
|
2016-08-04 17:36:32 +00:00
|
|
|
|
|
|
|
zwp_tablet_pad_ring_v2_add_listener (wp_tablet_pad_ring,
|
|
|
|
&tablet_pad_ring_listener, group);
|
|
|
|
zwp_tablet_pad_ring_v2_set_user_data (wp_tablet_pad_ring, group);
|
|
|
|
|
|
|
|
group->rings = g_list_append (group->rings, wp_tablet_pad_ring);
|
|
|
|
group->pad->rings = g_list_append (group->pad->rings, wp_tablet_pad_ring);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_group_handle_strip (void *data,
|
|
|
|
struct zwp_tablet_pad_group_v2 *wp_tablet_pad_group,
|
|
|
|
struct zwp_tablet_pad_strip_v2 *wp_tablet_pad_strip)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadGroupData *group = data;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad group handle strip, pad group = %p, strip = %p",
|
|
|
|
wp_tablet_pad_group, wp_tablet_pad_strip));
|
2016-08-04 17:36:32 +00:00
|
|
|
|
|
|
|
zwp_tablet_pad_strip_v2_add_listener (wp_tablet_pad_strip,
|
|
|
|
&tablet_pad_strip_listener, group);
|
|
|
|
zwp_tablet_pad_strip_v2_set_user_data (wp_tablet_pad_strip, group);
|
|
|
|
|
|
|
|
group->strips = g_list_append (group->strips, wp_tablet_pad_strip);
|
|
|
|
group->pad->strips = g_list_append (group->pad->strips, wp_tablet_pad_strip);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_group_handle_modes (void *data,
|
|
|
|
struct zwp_tablet_pad_group_v2 *wp_tablet_pad_group,
|
|
|
|
uint32_t modes)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadGroupData *group = data;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad group handle modes, pad group = %p, n_modes = %d",
|
|
|
|
wp_tablet_pad_group, modes));
|
2016-08-04 17:36:32 +00:00
|
|
|
|
|
|
|
group->n_modes = modes;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_group_handle_done (void *data,
|
|
|
|
struct zwp_tablet_pad_group_v2 *wp_tablet_pad_group)
|
|
|
|
{
|
2020-01-18 07:34:56 +00:00
|
|
|
#ifdef G_ENABLE_DEBUG
|
2018-01-12 00:48:27 +00:00
|
|
|
GdkWaylandTabletPadGroupData *group = data;
|
2020-01-18 07:34:56 +00:00
|
|
|
#endif
|
2018-01-12 00:48:27 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (group->pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad group handle done, pad group = %p",
|
|
|
|
wp_tablet_pad_group));
|
2016-08-04 17:36:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_group_handle_mode (void *data,
|
|
|
|
struct zwp_tablet_pad_group_v2 *wp_tablet_pad_group,
|
|
|
|
uint32_t time,
|
|
|
|
uint32_t serial,
|
|
|
|
uint32_t mode)
|
|
|
|
{
|
2016-08-04 17:44:44 +00:00
|
|
|
GdkWaylandTabletPadGroupData *group = data;
|
|
|
|
GdkWaylandTabletPadData *pad = group->pad;
|
|
|
|
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (pad->seat);
|
|
|
|
GdkEvent *event;
|
|
|
|
guint n_group;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad group handle mode, pad group = %p, mode = %d",
|
|
|
|
wp_tablet_pad_group, mode));
|
2016-08-04 17:44:44 +00:00
|
|
|
|
|
|
|
group->mode_switch_serial = serial;
|
|
|
|
group->current_mode = mode;
|
|
|
|
n_group = g_list_index (pad->mode_groups, group);
|
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_pad_event_new_group_mode (seat->keyboard_focus,
|
2020-02-14 13:10:21 +00:00
|
|
|
pad->device,
|
|
|
|
pad->device,
|
|
|
|
time,
|
|
|
|
n_group,
|
|
|
|
mode);
|
2016-08-04 17:44:44 +00:00
|
|
|
|
|
|
|
_gdk_wayland_display_deliver_event (gdk_seat_get_display (pad->seat),
|
|
|
|
event);
|
2016-08-04 17:36:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct zwp_tablet_pad_group_v2_listener tablet_pad_group_listener = {
|
|
|
|
tablet_pad_group_handle_buttons,
|
|
|
|
tablet_pad_group_handle_ring,
|
|
|
|
tablet_pad_group_handle_strip,
|
|
|
|
tablet_pad_group_handle_modes,
|
|
|
|
tablet_pad_group_handle_done,
|
|
|
|
tablet_pad_group_handle_mode,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_handle_group (void *data,
|
|
|
|
struct zwp_tablet_pad_v2 *wp_tablet_pad,
|
|
|
|
struct zwp_tablet_pad_group_v2 *wp_tablet_pad_group)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadData *pad = data;
|
|
|
|
GdkWaylandTabletPadGroupData *group;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad handle group, pad group = %p, group = %p",
|
|
|
|
wp_tablet_pad_group, wp_tablet_pad_group));
|
2016-08-04 17:36:32 +00:00
|
|
|
|
|
|
|
group = g_new0 (GdkWaylandTabletPadGroupData, 1);
|
|
|
|
group->wp_tablet_pad_group = wp_tablet_pad_group;
|
|
|
|
group->pad = pad;
|
|
|
|
|
|
|
|
zwp_tablet_pad_group_v2_add_listener (wp_tablet_pad_group,
|
|
|
|
&tablet_pad_group_listener, group);
|
|
|
|
zwp_tablet_pad_group_v2_set_user_data (wp_tablet_pad_group, group);
|
|
|
|
pad->mode_groups = g_list_append (pad->mode_groups, group);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_handle_path (void *data,
|
|
|
|
struct zwp_tablet_pad_v2 *wp_tablet_pad,
|
|
|
|
const char *path)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadData *pad = data;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad handle path, pad = %p, path = %s",
|
|
|
|
wp_tablet_pad, path));
|
2016-08-04 17:36:32 +00:00
|
|
|
|
|
|
|
pad->path = g_strdup (path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_handle_buttons (void *data,
|
|
|
|
struct zwp_tablet_pad_v2 *wp_tablet_pad,
|
|
|
|
uint32_t buttons)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadData *pad = data;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad handle buttons, pad = %p, n_buttons = %d",
|
|
|
|
wp_tablet_pad, buttons));
|
2016-08-04 17:36:32 +00:00
|
|
|
|
|
|
|
pad->n_buttons = buttons;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_handle_done (void *data,
|
|
|
|
struct zwp_tablet_pad_v2 *wp_tablet_pad)
|
|
|
|
{
|
2016-08-04 17:42:23 +00:00
|
|
|
GdkWaylandTabletPadData *pad = data;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad handle done, pad = %p", wp_tablet_pad));
|
2016-08-04 17:42:23 +00:00
|
|
|
|
|
|
|
pad->device =
|
|
|
|
g_object_new (GDK_TYPE_WAYLAND_DEVICE_PAD,
|
|
|
|
"name", "Pad device",
|
2020-06-18 18:22:20 +00:00
|
|
|
"type", GDK_DEVICE_TYPE_PHYSICAL,
|
2020-02-24 18:35:27 +00:00
|
|
|
"source", GDK_SOURCE_TABLET_PAD,
|
2016-08-04 17:42:23 +00:00
|
|
|
"display", gdk_seat_get_display (pad->seat),
|
2020-01-18 07:34:56 +00:00
|
|
|
"seat", pad->seat,
|
2016-08-04 17:42:23 +00:00
|
|
|
NULL);
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
_gdk_device_set_associated_device (pad->device, GDK_WAYLAND_SEAT (pad->seat)->logical_keyboard);
|
2020-01-18 07:34:56 +00:00
|
|
|
gdk_seat_device_added (GDK_SEAT (pad->seat), pad->device);
|
2016-08-04 17:36:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_handle_button (void *data,
|
|
|
|
struct zwp_tablet_pad_v2 *wp_tablet_pad,
|
|
|
|
uint32_t time,
|
|
|
|
uint32_t button,
|
|
|
|
uint32_t state)
|
|
|
|
{
|
2016-08-04 17:44:44 +00:00
|
|
|
GdkWaylandTabletPadData *pad = data;
|
|
|
|
GdkWaylandTabletPadGroupData *group;
|
|
|
|
GdkEvent *event;
|
2020-07-24 13:54:49 +00:00
|
|
|
int n_group;
|
2016-08-04 17:44:44 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad handle button, pad = %p, button = %d, state = %d",
|
|
|
|
wp_tablet_pad, button, state));
|
2016-08-04 17:44:44 +00:00
|
|
|
|
|
|
|
group = tablet_pad_lookup_button_group (pad, button);
|
2020-03-05 06:02:24 +00:00
|
|
|
g_assert (group != NULL);
|
2016-08-04 17:44:44 +00:00
|
|
|
n_group = g_list_index (pad->mode_groups, group);
|
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_pad_event_new_button (state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED
|
2020-02-14 13:10:21 +00:00
|
|
|
? GDK_PAD_BUTTON_PRESS
|
|
|
|
: GDK_PAD_BUTTON_RELEASE,
|
|
|
|
GDK_WAYLAND_SEAT (pad->seat)->keyboard_focus,
|
|
|
|
pad->device,
|
|
|
|
pad->device,
|
|
|
|
time,
|
|
|
|
n_group,
|
|
|
|
button,
|
|
|
|
group->current_mode);
|
2016-08-04 17:44:44 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
_gdk_wayland_display_deliver_event (gdk_seat_get_display (pad->seat), event);
|
2016-08-04 17:36:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_handle_enter (void *data,
|
|
|
|
struct zwp_tablet_pad_v2 *wp_tablet_pad,
|
|
|
|
uint32_t serial,
|
|
|
|
struct zwp_tablet_v2 *wp_tablet,
|
|
|
|
struct wl_surface *surface)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadData *pad = data;
|
|
|
|
GdkWaylandTabletData *tablet = zwp_tablet_v2_get_user_data (wp_tablet);
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad handle enter, pad = %p, tablet = %p surface = %p",
|
|
|
|
wp_tablet_pad, wp_tablet, surface));
|
2016-08-04 17:36:32 +00:00
|
|
|
|
|
|
|
/* Relate pad and tablet */
|
|
|
|
tablet->pads = g_list_prepend (tablet->pads, pad);
|
|
|
|
pad->current_tablet = tablet;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_handle_leave (void *data,
|
|
|
|
struct zwp_tablet_pad_v2 *wp_tablet_pad,
|
|
|
|
uint32_t serial,
|
|
|
|
struct wl_surface *surface)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadData *pad = data;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad handle leave, pad = %p, surface = %p",
|
|
|
|
wp_tablet_pad, surface));
|
2016-08-04 17:36:32 +00:00
|
|
|
|
|
|
|
if (pad->current_tablet)
|
|
|
|
{
|
|
|
|
pad->current_tablet->pads = g_list_remove (pad->current_tablet->pads, pad);
|
|
|
|
pad->current_tablet = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_pad_handle_removed (void *data,
|
|
|
|
struct zwp_tablet_pad_v2 *wp_tablet_pad)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadData *pad = data;
|
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (pad->seat, EVENTS,
|
2016-08-25 03:59:46 +00:00
|
|
|
g_message ("tablet pad handle removed, pad = %p", wp_tablet_pad));
|
2016-08-04 17:36:32 +00:00
|
|
|
|
|
|
|
/* Remove from the current tablet */
|
|
|
|
if (pad->current_tablet)
|
|
|
|
{
|
|
|
|
pad->current_tablet->pads = g_list_remove (pad->current_tablet->pads, pad);
|
|
|
|
pad->current_tablet = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
_gdk_wayland_seat_remove_tablet_pad (GDK_WAYLAND_SEAT (pad->seat), pad);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct zwp_tablet_pad_v2_listener tablet_pad_listener = {
|
|
|
|
tablet_pad_handle_group,
|
|
|
|
tablet_pad_handle_path,
|
|
|
|
tablet_pad_handle_buttons,
|
|
|
|
tablet_pad_handle_done,
|
|
|
|
tablet_pad_handle_button,
|
|
|
|
tablet_pad_handle_enter,
|
|
|
|
tablet_pad_handle_leave,
|
|
|
|
tablet_pad_handle_removed,
|
|
|
|
};
|
|
|
|
|
2015-01-19 00:32:24 +00:00
|
|
|
static void
|
|
|
|
tablet_seat_handle_tablet_added (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_seat_v2 *wp_tablet_seat,
|
|
|
|
struct zwp_tablet_v2 *wp_tablet)
|
2015-01-19 00:32:24 +00:00
|
|
|
{
|
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
GdkWaylandTabletData *tablet;
|
|
|
|
|
|
|
|
tablet = g_new0 (GdkWaylandTabletData, 1);
|
|
|
|
tablet->seat = GDK_SEAT (seat);
|
2019-04-18 17:31:55 +00:00
|
|
|
|
2015-01-19 00:32:24 +00:00
|
|
|
tablet->wp_tablet = wp_tablet;
|
|
|
|
|
|
|
|
seat->tablets = g_list_prepend (seat->tablets, tablet);
|
|
|
|
|
2016-05-13 13:19:04 +00:00
|
|
|
zwp_tablet_v2_add_listener (wp_tablet, &tablet_listener, tablet);
|
|
|
|
zwp_tablet_v2_set_user_data (wp_tablet, tablet);
|
2015-01-19 00:32:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tablet_seat_handle_tool_added (void *data,
|
2016-05-13 13:19:04 +00:00
|
|
|
struct zwp_tablet_seat_v2 *wp_tablet_seat,
|
|
|
|
struct zwp_tablet_tool_v2 *wp_tablet_tool)
|
2015-01-19 00:32:24 +00:00
|
|
|
{
|
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
GdkWaylandTabletToolData *tool;
|
|
|
|
|
|
|
|
tool = g_new0 (GdkWaylandTabletToolData, 1);
|
|
|
|
tool->wp_tablet_tool = wp_tablet_tool;
|
|
|
|
tool->seat = GDK_SEAT (seat);
|
|
|
|
|
2016-05-13 13:19:04 +00:00
|
|
|
zwp_tablet_tool_v2_add_listener (wp_tablet_tool, &tablet_tool_listener, tool);
|
|
|
|
zwp_tablet_tool_v2_set_user_data (wp_tablet_tool, tool);
|
2015-01-19 00:32:24 +00:00
|
|
|
|
|
|
|
seat->tablet_tools = g_list_prepend (seat->tablet_tools, tool);
|
|
|
|
}
|
|
|
|
|
2016-05-13 13:19:04 +00:00
|
|
|
static void
|
|
|
|
tablet_seat_handle_pad_added (void *data,
|
|
|
|
struct zwp_tablet_seat_v2 *wp_tablet_seat,
|
|
|
|
struct zwp_tablet_pad_v2 *wp_tablet_pad)
|
|
|
|
{
|
2016-08-04 17:36:32 +00:00
|
|
|
GdkWaylandSeat *seat = data;
|
|
|
|
GdkWaylandTabletPadData *pad;
|
|
|
|
|
|
|
|
pad = g_new0 (GdkWaylandTabletPadData, 1);
|
|
|
|
pad->wp_tablet_pad = wp_tablet_pad;
|
|
|
|
pad->seat = GDK_SEAT (seat);
|
|
|
|
|
|
|
|
zwp_tablet_pad_v2_add_listener (wp_tablet_pad, &tablet_pad_listener, pad);
|
|
|
|
zwp_tablet_pad_v2_set_user_data (wp_tablet_pad, pad);
|
|
|
|
|
|
|
|
seat->tablet_pads = g_list_prepend (seat->tablet_pads, pad);
|
2016-05-13 13:19:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct zwp_tablet_seat_v2_listener tablet_seat_listener = {
|
2015-01-19 00:32:24 +00:00
|
|
|
tablet_seat_handle_tablet_added,
|
|
|
|
tablet_seat_handle_tool_added,
|
2016-05-13 13:19:04 +00:00
|
|
|
tablet_seat_handle_pad_added,
|
2015-01-19 00:32:24 +00:00
|
|
|
};
|
|
|
|
|
2014-04-17 11:15:08 +00:00
|
|
|
static void
|
2016-03-17 17:03:26 +00:00
|
|
|
init_devices (GdkWaylandSeat *seat)
|
2014-04-17 11:15:08 +00:00
|
|
|
{
|
|
|
|
/* pointer */
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_pointer = g_object_new (GDK_TYPE_WAYLAND_DEVICE,
|
2016-03-17 17:03:26 +00:00
|
|
|
"name", "Core Pointer",
|
2020-06-18 18:22:20 +00:00
|
|
|
"type", GDK_DEVICE_TYPE_LOGICAL,
|
2020-02-24 18:35:27 +00:00
|
|
|
"source", GDK_SOURCE_MOUSE,
|
2016-03-17 17:03:26 +00:00
|
|
|
"has-cursor", TRUE,
|
|
|
|
"display", seat->display,
|
|
|
|
"seat", seat,
|
|
|
|
NULL);
|
2016-04-09 21:31:39 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
GDK_WAYLAND_DEVICE (seat->logical_pointer)->pointer = &seat->pointer_info;
|
2014-04-17 11:15:08 +00:00
|
|
|
|
|
|
|
/* keyboard */
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_keyboard = g_object_new (GDK_TYPE_WAYLAND_DEVICE,
|
2016-03-17 17:03:26 +00:00
|
|
|
"name", "Core Keyboard",
|
2020-06-18 18:22:20 +00:00
|
|
|
"type", GDK_DEVICE_TYPE_LOGICAL,
|
2020-02-24 18:35:27 +00:00
|
|
|
"source", GDK_SOURCE_KEYBOARD,
|
2016-03-17 17:03:26 +00:00
|
|
|
"has-cursor", FALSE,
|
|
|
|
"display", seat->display,
|
|
|
|
"seat", seat,
|
|
|
|
NULL);
|
2020-06-18 18:22:20 +00:00
|
|
|
_gdk_device_reset_axes (seat->logical_keyboard);
|
2014-04-17 11:15:08 +00:00
|
|
|
|
|
|
|
/* link both */
|
2020-06-18 18:22:20 +00:00
|
|
|
_gdk_device_set_associated_device (seat->logical_pointer, seat->logical_keyboard);
|
|
|
|
_gdk_device_set_associated_device (seat->logical_keyboard, seat->logical_pointer);
|
2017-11-27 18:51:38 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_seat_device_added (GDK_SEAT (seat), seat->logical_pointer);
|
|
|
|
gdk_seat_device_added (GDK_SEAT (seat), seat->logical_keyboard);
|
2014-04-17 11:15:08 +00:00
|
|
|
}
|
|
|
|
|
2015-03-13 07:40:18 +00:00
|
|
|
static void
|
2015-06-19 15:25:54 +00:00
|
|
|
pointer_surface_update_scale (GdkDevice *device)
|
2015-03-13 07:40:18 +00:00
|
|
|
{
|
2015-06-19 15:25:54 +00:00
|
|
|
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
|
|
|
|
GdkWaylandPointerData *pointer = GDK_WAYLAND_DEVICE (device)->pointer;
|
2016-04-26 03:16:56 +00:00
|
|
|
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
|
2015-03-13 07:40:18 +00:00
|
|
|
guint32 scale;
|
|
|
|
GSList *l;
|
|
|
|
|
2016-04-26 03:16:56 +00:00
|
|
|
if (display_wayland->compositor_version < WL_SURFACE_HAS_BUFFER_SCALE)
|
2015-03-13 07:40:18 +00:00
|
|
|
{
|
|
|
|
/* We can't set the scale on this surface */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
scale = 1;
|
2015-06-19 15:25:54 +00:00
|
|
|
for (l = pointer->pointer_surface_outputs; l != NULL; l = l->next)
|
2015-03-13 07:40:18 +00:00
|
|
|
{
|
2017-11-01 23:25:45 +00:00
|
|
|
guint32 output_scale = gdk_wayland_display_get_output_scale (display_wayland, l->data);
|
2015-03-13 07:40:18 +00:00
|
|
|
scale = MAX (scale, output_scale);
|
|
|
|
}
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
pointer->current_output_scale = scale;
|
2015-03-13 07:40:18 +00:00
|
|
|
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_wayland_device_update_surface_cursor (device);
|
2015-03-13 07:40:18 +00:00
|
|
|
}
|
|
|
|
|
2018-06-28 10:44:22 +00:00
|
|
|
void
|
|
|
|
gdk_wayland_seat_update_cursor_scale (GdkWaylandSeat *seat)
|
|
|
|
{
|
2019-02-15 01:42:23 +00:00
|
|
|
GList *l;
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
pointer_surface_update_scale (seat->logical_pointer);
|
2019-02-15 01:42:23 +00:00
|
|
|
|
|
|
|
for (l = seat->tablets; l; l = l->next)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletData *tablet = l->data;
|
2020-06-18 18:22:20 +00:00
|
|
|
pointer_surface_update_scale (tablet->logical_device);
|
2019-02-15 01:42:23 +00:00
|
|
|
}
|
2018-06-28 10:44:22 +00:00
|
|
|
}
|
|
|
|
|
2015-03-13 07:40:18 +00:00
|
|
|
static void
|
|
|
|
pointer_surface_enter (void *data,
|
|
|
|
struct wl_surface *wl_surface,
|
|
|
|
struct wl_output *output)
|
|
|
|
|
|
|
|
{
|
2019-04-18 17:31:55 +00:00
|
|
|
GdkDevice *device = data;
|
|
|
|
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
|
|
|
|
GdkWaylandTabletData *tablet;
|
2015-03-13 07:40:18 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2016-03-17 17:32:03 +00:00
|
|
|
g_message ("pointer surface of seat %p entered output %p",
|
|
|
|
seat, output));
|
2015-03-13 07:40:18 +00:00
|
|
|
|
2019-04-18 17:31:55 +00:00
|
|
|
tablet = gdk_wayland_seat_find_tablet (seat, device);
|
2015-03-13 07:40:18 +00:00
|
|
|
|
2019-04-18 17:31:55 +00:00
|
|
|
if (tablet)
|
|
|
|
{
|
|
|
|
tablet->pointer_info.pointer_surface_outputs =
|
2019-10-08 15:46:38 +00:00
|
|
|
g_slist_append (tablet->pointer_info.pointer_surface_outputs, output);
|
2019-04-18 17:31:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
seat->pointer_info.pointer_surface_outputs =
|
|
|
|
g_slist_append (seat->pointer_info.pointer_surface_outputs, output);
|
|
|
|
}
|
|
|
|
|
|
|
|
pointer_surface_update_scale (device);
|
2015-03-13 07:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pointer_surface_leave (void *data,
|
|
|
|
struct wl_surface *wl_surface,
|
|
|
|
struct wl_output *output)
|
|
|
|
{
|
2019-04-18 17:31:55 +00:00
|
|
|
GdkDevice *device = data;
|
|
|
|
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
|
|
|
|
GdkWaylandTabletData *tablet;
|
2015-03-13 07:40:18 +00:00
|
|
|
|
2020-01-18 07:34:56 +00:00
|
|
|
GDK_SEAT_NOTE (seat, EVENTS,
|
2016-03-17 17:32:03 +00:00
|
|
|
g_message ("pointer surface of seat %p left output %p",
|
|
|
|
seat, output));
|
2015-03-13 07:40:18 +00:00
|
|
|
|
2019-04-18 17:31:55 +00:00
|
|
|
tablet = gdk_wayland_seat_find_tablet (seat, device);
|
2015-03-13 07:40:18 +00:00
|
|
|
|
2019-04-18 17:31:55 +00:00
|
|
|
if (tablet)
|
|
|
|
{
|
|
|
|
tablet->pointer_info.pointer_surface_outputs =
|
2019-10-08 15:46:38 +00:00
|
|
|
g_slist_remove (tablet->pointer_info.pointer_surface_outputs, output);
|
2019-04-18 17:31:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
seat->pointer_info.pointer_surface_outputs =
|
|
|
|
g_slist_remove (seat->pointer_info.pointer_surface_outputs, output);
|
|
|
|
}
|
|
|
|
|
|
|
|
pointer_surface_update_scale (device);
|
2015-03-13 07:40:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_surface_listener pointer_surface_listener = {
|
|
|
|
pointer_surface_enter,
|
|
|
|
pointer_surface_leave
|
|
|
|
};
|
|
|
|
|
2015-06-19 15:25:54 +00:00
|
|
|
static void
|
|
|
|
gdk_wayland_pointer_data_finalize (GdkWaylandPointerData *pointer)
|
|
|
|
{
|
|
|
|
g_clear_object (&pointer->focus);
|
|
|
|
g_clear_object (&pointer->cursor);
|
|
|
|
wl_surface_destroy (pointer->pointer_surface);
|
|
|
|
g_slist_free (pointer->pointer_surface_outputs);
|
|
|
|
}
|
|
|
|
|
2015-11-26 18:40:56 +00:00
|
|
|
static void
|
|
|
|
gdk_wayland_seat_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (object);
|
2015-01-19 00:32:24 +00:00
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = seat->tablet_tools; l != NULL; l = l->next)
|
|
|
|
_gdk_wayland_seat_remove_tool (seat, l->data);
|
|
|
|
|
2016-08-04 17:36:32 +00:00
|
|
|
for (l = seat->tablet_pads; l != NULL; l = l->next)
|
|
|
|
_gdk_wayland_seat_remove_tablet_pad (seat, l->data);
|
|
|
|
|
2015-01-19 00:32:24 +00:00
|
|
|
for (l = seat->tablets; l != NULL; l = l->next)
|
|
|
|
_gdk_wayland_seat_remove_tablet (seat, l->data);
|
2015-11-26 18:40:56 +00:00
|
|
|
|
|
|
|
seat_handle_capabilities (seat, seat->wl_seat, 0);
|
|
|
|
g_object_unref (seat->keymap);
|
2015-06-19 15:25:54 +00:00
|
|
|
gdk_wayland_pointer_data_finalize (&seat->pointer_info);
|
2015-11-26 18:40:56 +00:00
|
|
|
/* FIXME: destroy data_device */
|
2018-05-31 19:15:59 +00:00
|
|
|
g_clear_object (&seat->drag);
|
2018-05-30 02:04:51 +00:00
|
|
|
g_clear_object (&seat->drop);
|
2017-12-02 20:54:36 +00:00
|
|
|
g_clear_object (&seat->clipboard);
|
|
|
|
g_clear_object (&seat->primary_clipboard);
|
2015-11-26 18:40:56 +00:00
|
|
|
g_hash_table_destroy (seat->touches);
|
2016-05-13 13:19:04 +00:00
|
|
|
zwp_tablet_seat_v2_destroy (seat->wp_tablet_seat);
|
2015-11-26 18:40:56 +00:00
|
|
|
stop_key_repeat (seat);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gdk_wayland_seat_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkSeatCapabilities
|
|
|
|
gdk_wayland_seat_get_capabilities (GdkSeat *seat)
|
|
|
|
{
|
|
|
|
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
|
|
|
|
GdkSeatCapabilities caps = 0;
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (wayland_seat->logical_pointer)
|
2015-11-26 18:40:56 +00:00
|
|
|
caps |= GDK_SEAT_CAPABILITY_POINTER;
|
2020-06-18 18:22:20 +00:00
|
|
|
if (wayland_seat->logical_keyboard)
|
2015-11-26 18:40:56 +00:00
|
|
|
caps |= GDK_SEAT_CAPABILITY_KEYBOARD;
|
2020-06-18 18:22:20 +00:00
|
|
|
if (wayland_seat->logical_touch)
|
2015-11-26 18:40:56 +00:00
|
|
|
caps |= GDK_SEAT_CAPABILITY_TOUCH;
|
|
|
|
|
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
2016-01-18 13:05:00 +00:00
|
|
|
static void
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_seat_set_grab_surface (GdkWaylandSeat *seat,
|
|
|
|
GdkSurface *surface)
|
2016-01-18 13:05:00 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
if (seat->grab_surface)
|
2016-01-18 13:05:00 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
_gdk_wayland_surface_set_grab_seat (seat->grab_surface, NULL);
|
|
|
|
g_object_remove_weak_pointer (G_OBJECT (seat->grab_surface),
|
|
|
|
(gpointer *) &seat->grab_surface);
|
|
|
|
seat->grab_surface = NULL;
|
2016-01-18 13:05:00 +00:00
|
|
|
}
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
if (surface)
|
2016-01-18 13:05:00 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
seat->grab_surface = surface;
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (surface),
|
|
|
|
(gpointer *) &seat->grab_surface);
|
|
|
|
_gdk_wayland_surface_set_grab_seat (surface, GDK_SEAT (seat));
|
2016-01-18 13:05:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-26 18:40:56 +00:00
|
|
|
static GdkGrabStatus
|
|
|
|
gdk_wayland_seat_grab (GdkSeat *seat,
|
2019-04-19 23:08:24 +00:00
|
|
|
GdkSurface *surface,
|
2015-11-26 18:40:56 +00:00
|
|
|
GdkSeatCapabilities capabilities,
|
|
|
|
gboolean owner_events,
|
|
|
|
GdkCursor *cursor,
|
2020-02-16 16:09:02 +00:00
|
|
|
GdkEvent *event,
|
2015-11-26 18:40:56 +00:00
|
|
|
GdkSeatGrabPrepareFunc prepare_func,
|
|
|
|
gpointer prepare_func_data)
|
|
|
|
{
|
|
|
|
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
|
|
|
|
guint32 evtime = event ? gdk_event_get_time (event) : GDK_CURRENT_TIME;
|
|
|
|
GdkDisplay *display = gdk_seat_get_display (seat);
|
2016-01-26 18:25:19 +00:00
|
|
|
GList *l;
|
2015-11-26 18:40:56 +00:00
|
|
|
|
2019-04-19 23:08:24 +00:00
|
|
|
if (surface == NULL || GDK_SURFACE_DESTROYED (surface))
|
2015-11-26 18:40:56 +00:00
|
|
|
return GDK_GRAB_NOT_VIEWABLE;
|
|
|
|
|
2019-04-19 23:08:24 +00:00
|
|
|
gdk_wayland_seat_set_grab_surface (wayland_seat, surface);
|
2015-06-19 15:25:54 +00:00
|
|
|
wayland_seat->grab_time = evtime;
|
2015-11-26 18:40:56 +00:00
|
|
|
|
|
|
|
if (prepare_func)
|
2018-03-20 14:14:10 +00:00
|
|
|
(prepare_func) (seat, surface, prepare_func_data);
|
2015-11-26 18:40:56 +00:00
|
|
|
|
2020-02-25 00:02:34 +00:00
|
|
|
if (!gdk_surface_get_mapped (surface))
|
2015-11-26 18:40:56 +00:00
|
|
|
{
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_seat_set_grab_surface (wayland_seat, NULL);
|
2015-11-26 18:40:56 +00:00
|
|
|
return GDK_GRAB_NOT_VIEWABLE;
|
|
|
|
}
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (wayland_seat->logical_pointer &&
|
2015-12-21 18:13:41 +00:00
|
|
|
capabilities & GDK_SEAT_CAPABILITY_POINTER)
|
2015-11-26 18:40:56 +00:00
|
|
|
{
|
2020-06-18 18:22:20 +00:00
|
|
|
device_maybe_emit_grab_crossing (wayland_seat->logical_pointer,
|
2019-04-19 23:08:24 +00:00
|
|
|
surface, evtime);
|
2015-11-26 18:40:56 +00:00
|
|
|
|
|
|
|
_gdk_display_add_device_grab (display,
|
2020-06-18 18:22:20 +00:00
|
|
|
wayland_seat->logical_pointer,
|
2018-03-20 14:14:10 +00:00
|
|
|
surface,
|
2015-11-26 18:40:56 +00:00
|
|
|
owner_events,
|
|
|
|
GDK_ALL_EVENTS_MASK,
|
|
|
|
_gdk_display_get_next_serial (display),
|
|
|
|
evtime,
|
|
|
|
FALSE);
|
|
|
|
|
2016-01-13 19:57:47 +00:00
|
|
|
gdk_wayland_seat_set_global_cursor (seat, cursor);
|
2015-11-26 18:40:56 +00:00
|
|
|
g_set_object (&wayland_seat->cursor, cursor);
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_wayland_device_update_surface_cursor (wayland_seat->logical_pointer);
|
2015-11-26 18:40:56 +00:00
|
|
|
}
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (wayland_seat->logical_touch &&
|
2015-12-21 18:13:41 +00:00
|
|
|
capabilities & GDK_SEAT_CAPABILITY_TOUCH)
|
2015-11-26 18:40:56 +00:00
|
|
|
{
|
2020-06-18 18:22:20 +00:00
|
|
|
device_maybe_emit_grab_crossing (wayland_seat->logical_touch,
|
2019-04-19 23:08:24 +00:00
|
|
|
surface, evtime);
|
2015-11-26 18:40:56 +00:00
|
|
|
|
|
|
|
_gdk_display_add_device_grab (display,
|
2020-06-18 18:22:20 +00:00
|
|
|
wayland_seat->logical_touch,
|
2018-03-20 14:14:10 +00:00
|
|
|
surface,
|
2015-11-26 18:40:56 +00:00
|
|
|
owner_events,
|
|
|
|
GDK_ALL_EVENTS_MASK,
|
|
|
|
_gdk_display_get_next_serial (display),
|
|
|
|
evtime,
|
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (wayland_seat->logical_keyboard &&
|
2015-12-21 18:13:41 +00:00
|
|
|
capabilities & GDK_SEAT_CAPABILITY_KEYBOARD)
|
2015-11-26 18:40:56 +00:00
|
|
|
{
|
2020-06-18 18:22:20 +00:00
|
|
|
device_maybe_emit_grab_crossing (wayland_seat->logical_keyboard,
|
2019-04-19 23:08:24 +00:00
|
|
|
surface, evtime);
|
2015-11-26 18:40:56 +00:00
|
|
|
|
|
|
|
_gdk_display_add_device_grab (display,
|
2020-06-18 18:22:20 +00:00
|
|
|
wayland_seat->logical_keyboard,
|
2018-03-20 14:14:10 +00:00
|
|
|
surface,
|
2015-11-26 18:40:56 +00:00
|
|
|
owner_events,
|
|
|
|
GDK_ALL_EVENTS_MASK,
|
|
|
|
_gdk_display_get_next_serial (display),
|
|
|
|
evtime,
|
|
|
|
FALSE);
|
2017-03-22 09:21:02 +00:00
|
|
|
|
|
|
|
/* Inhibit shortcuts if the seat grab is for the keyboard only */
|
|
|
|
if (capabilities == GDK_SEAT_CAPABILITY_KEYBOARD)
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_surface_inhibit_shortcuts (surface, seat);
|
2015-11-26 18:40:56 +00:00
|
|
|
}
|
|
|
|
|
2016-01-26 18:25:19 +00:00
|
|
|
if (wayland_seat->tablets &&
|
|
|
|
capabilities & GDK_SEAT_CAPABILITY_TABLET_STYLUS)
|
|
|
|
{
|
|
|
|
for (l = wayland_seat->tablets; l; l = l->next)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletData *tablet = l->data;
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
device_maybe_emit_grab_crossing (tablet->logical_device,
|
|
|
|
surface,
|
|
|
|
evtime);
|
2016-01-26 18:25:19 +00:00
|
|
|
|
|
|
|
_gdk_display_add_device_grab (display,
|
2020-06-18 18:22:20 +00:00
|
|
|
tablet->logical_device,
|
2018-03-20 14:14:10 +00:00
|
|
|
surface,
|
2016-01-26 18:25:19 +00:00
|
|
|
owner_events,
|
|
|
|
GDK_ALL_EVENTS_MASK,
|
|
|
|
_gdk_display_get_next_serial (display),
|
|
|
|
evtime,
|
|
|
|
FALSE);
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_wayland_device_update_surface_cursor (tablet->logical_device);
|
2016-01-26 18:25:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-26 18:40:56 +00:00
|
|
|
return GDK_GRAB_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_seat_ungrab (GdkSeat *seat)
|
|
|
|
{
|
|
|
|
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
|
2016-01-12 08:32:04 +00:00
|
|
|
GdkDisplay *display = gdk_seat_get_display (seat);
|
2015-11-26 18:40:56 +00:00
|
|
|
GdkDeviceGrabInfo *grab;
|
2016-01-26 18:25:19 +00:00
|
|
|
GList *l;
|
2015-11-26 18:40:56 +00:00
|
|
|
|
2016-01-08 20:45:03 +00:00
|
|
|
g_clear_object (&wayland_seat->grab_cursor);
|
|
|
|
|
2018-03-20 14:14:10 +00:00
|
|
|
gdk_wayland_seat_set_grab_surface (wayland_seat, NULL);
|
2016-01-08 20:45:03 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (wayland_seat->logical_pointer)
|
2015-11-26 18:40:56 +00:00
|
|
|
{
|
2020-06-18 18:22:20 +00:00
|
|
|
device_maybe_emit_ungrab_crossing (wayland_seat->logical_pointer,
|
2018-04-19 12:22:04 +00:00
|
|
|
GDK_CURRENT_TIME);
|
2015-11-26 18:40:56 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_wayland_device_update_surface_cursor (wayland_seat->logical_pointer);
|
2015-11-26 18:40:56 +00:00
|
|
|
}
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (wayland_seat->logical_keyboard)
|
2015-11-26 18:40:56 +00:00
|
|
|
{
|
2018-04-19 12:22:04 +00:00
|
|
|
GdkSurface *prev_focus;
|
2015-11-26 18:40:56 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
prev_focus = device_maybe_emit_ungrab_crossing (wayland_seat->logical_keyboard,
|
2018-04-19 12:22:04 +00:00
|
|
|
GDK_CURRENT_TIME);
|
|
|
|
if (prev_focus)
|
|
|
|
gdk_wayland_surface_restore_shortcuts (prev_focus, seat);
|
2015-11-26 18:40:56 +00:00
|
|
|
}
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (wayland_seat->logical_touch)
|
2015-11-26 18:40:56 +00:00
|
|
|
{
|
2020-06-18 18:22:20 +00:00
|
|
|
grab = _gdk_display_get_last_device_grab (display, wayland_seat->logical_touch);
|
2015-11-26 18:40:56 +00:00
|
|
|
|
2016-01-26 18:25:19 +00:00
|
|
|
if (grab)
|
|
|
|
grab->serial_end = grab->serial_start;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (l = wayland_seat->tablets; l; l = l->next)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletData *tablet = l->data;
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
grab = _gdk_display_get_last_device_grab (display, tablet->logical_device);
|
2016-01-26 18:25:19 +00:00
|
|
|
|
2015-11-26 18:40:56 +00:00
|
|
|
if (grab)
|
|
|
|
grab->serial_end = grab->serial_start;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkDevice *
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_wayland_seat_get_logical_device (GdkSeat *seat,
|
|
|
|
GdkSeatCapabilities capabilities)
|
2015-11-26 18:40:56 +00:00
|
|
|
{
|
|
|
|
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
|
|
|
|
|
|
|
|
if (capabilities == GDK_SEAT_CAPABILITY_POINTER)
|
2020-06-18 18:22:20 +00:00
|
|
|
return wayland_seat->logical_pointer;
|
2015-11-26 18:40:56 +00:00
|
|
|
else if (capabilities == GDK_SEAT_CAPABILITY_KEYBOARD)
|
2020-06-18 18:22:20 +00:00
|
|
|
return wayland_seat->logical_keyboard;
|
2015-11-26 18:40:56 +00:00
|
|
|
else if (capabilities == GDK_SEAT_CAPABILITY_TOUCH)
|
2020-06-18 18:22:20 +00:00
|
|
|
return wayland_seat->logical_touch;
|
2015-11-26 18:40:56 +00:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GList *
|
2020-06-18 18:22:20 +00:00
|
|
|
gdk_wayland_seat_get_physical_devices (GdkSeat *seat,
|
|
|
|
GdkSeatCapabilities capabilities)
|
2015-11-26 18:40:56 +00:00
|
|
|
{
|
|
|
|
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
|
2020-06-18 18:22:20 +00:00
|
|
|
GList *physical_devices = NULL;
|
2015-11-26 18:40:56 +00:00
|
|
|
|
2016-06-01 03:14:30 +00:00
|
|
|
if (wayland_seat->finger_scrolling && (capabilities & GDK_SEAT_CAPABILITY_POINTER))
|
2020-06-18 18:22:20 +00:00
|
|
|
physical_devices = g_list_prepend (physical_devices, wayland_seat->finger_scrolling);
|
2016-06-01 03:14:30 +00:00
|
|
|
if (wayland_seat->continuous_scrolling && (capabilities & GDK_SEAT_CAPABILITY_POINTER))
|
2020-06-18 18:22:20 +00:00
|
|
|
physical_devices = g_list_prepend (physical_devices, wayland_seat->continuous_scrolling);
|
2016-06-01 03:14:30 +00:00
|
|
|
if (wayland_seat->wheel_scrolling && (capabilities & GDK_SEAT_CAPABILITY_POINTER))
|
2020-06-18 18:22:20 +00:00
|
|
|
physical_devices = g_list_prepend (physical_devices, wayland_seat->wheel_scrolling);
|
2016-04-01 17:09:03 +00:00
|
|
|
if (wayland_seat->pointer && (capabilities & GDK_SEAT_CAPABILITY_POINTER))
|
2020-06-18 18:22:20 +00:00
|
|
|
physical_devices = g_list_prepend (physical_devices, wayland_seat->pointer);
|
2016-04-01 17:09:03 +00:00
|
|
|
if (wayland_seat->keyboard && (capabilities & GDK_SEAT_CAPABILITY_KEYBOARD))
|
2020-06-18 18:22:20 +00:00
|
|
|
physical_devices = g_list_prepend (physical_devices, wayland_seat->keyboard);
|
2016-04-01 17:09:03 +00:00
|
|
|
if (wayland_seat->touch && (capabilities & GDK_SEAT_CAPABILITY_TOUCH))
|
2020-06-18 18:22:20 +00:00
|
|
|
physical_devices = g_list_prepend (physical_devices, wayland_seat->touch);
|
2015-11-26 18:40:56 +00:00
|
|
|
|
2017-07-25 13:35:41 +00:00
|
|
|
if (wayland_seat->tablets && (capabilities & GDK_SEAT_CAPABILITY_TABLET_STYLUS))
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = wayland_seat->tablets; l; l = l->next)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletData *tablet = l->data;
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
physical_devices = g_list_prepend (physical_devices, tablet->stylus_device);
|
2017-07-25 13:35:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-27 20:39:05 +00:00
|
|
|
if (wayland_seat->tablet_pads && (capabilities & GDK_SEAT_CAPABILITY_TABLET_PAD))
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = wayland_seat->tablet_pads; l; l = l->next)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletPadData *data = l->data;
|
2020-06-18 18:22:20 +00:00
|
|
|
physical_devices = g_list_prepend (physical_devices, data->device);
|
2017-11-27 20:39:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
return physical_devices;
|
2015-11-26 18:40:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_seat_class_init (GdkWaylandSeatClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GdkSeatClass *seat_class = GDK_SEAT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->finalize = gdk_wayland_seat_finalize;
|
|
|
|
|
|
|
|
seat_class->get_capabilities = gdk_wayland_seat_get_capabilities;
|
|
|
|
seat_class->grab = gdk_wayland_seat_grab;
|
|
|
|
seat_class->ungrab = gdk_wayland_seat_ungrab;
|
2020-06-18 18:22:20 +00:00
|
|
|
seat_class->get_logical_device = gdk_wayland_seat_get_logical_device;
|
|
|
|
seat_class->get_physical_devices = gdk_wayland_seat_get_physical_devices;
|
2015-11-26 18:40:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gdk_wayland_seat_init (GdkWaylandSeat *seat)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-04-18 17:31:55 +00:00
|
|
|
static void
|
|
|
|
init_pointer_data (GdkWaylandPointerData *pointer_data,
|
|
|
|
GdkDisplay *display,
|
2020-06-18 18:22:20 +00:00
|
|
|
GdkDevice *logical_device)
|
2019-04-18 17:31:55 +00:00
|
|
|
{
|
|
|
|
GdkWaylandDisplay *display_wayland;
|
|
|
|
|
|
|
|
display_wayland = GDK_WAYLAND_DISPLAY (display);
|
|
|
|
|
|
|
|
pointer_data->current_output_scale = 1;
|
|
|
|
pointer_data->pointer_surface =
|
|
|
|
wl_compositor_create_surface (display_wayland->compositor);
|
|
|
|
wl_surface_add_listener (pointer_data->pointer_surface,
|
|
|
|
&pointer_surface_listener,
|
2020-06-18 18:22:20 +00:00
|
|
|
logical_device);
|
2019-04-18 17:31:55 +00:00
|
|
|
}
|
|
|
|
|
2011-02-09 20:27:08 +00:00
|
|
|
void
|
2017-11-25 13:12:48 +00:00
|
|
|
_gdk_wayland_display_create_seat (GdkWaylandDisplay *display_wayland,
|
|
|
|
guint32 id,
|
|
|
|
struct wl_seat *wl_seat)
|
2011-02-09 20:27:08 +00:00
|
|
|
{
|
2017-11-25 13:12:48 +00:00
|
|
|
GdkDisplay *display = GDK_DISPLAY (display_wayland);
|
2015-11-26 18:40:56 +00:00
|
|
|
GdkWaylandSeat *seat;
|
2011-02-09 20:27:08 +00:00
|
|
|
|
2015-11-26 18:40:56 +00:00
|
|
|
seat = g_object_new (GDK_TYPE_WAYLAND_SEAT,
|
2017-11-25 13:12:48 +00:00
|
|
|
"display", display_wayland,
|
2015-11-26 18:40:56 +00:00
|
|
|
NULL);
|
|
|
|
seat->id = id;
|
2018-01-12 02:44:49 +00:00
|
|
|
seat->keymap = _gdk_wayland_keymap_new (display);
|
2015-11-26 18:40:56 +00:00
|
|
|
seat->display = display;
|
2017-11-25 13:22:12 +00:00
|
|
|
seat->touches = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify) g_free);
|
2015-11-26 18:40:56 +00:00
|
|
|
seat->wl_seat = wl_seat;
|
2012-07-11 13:29:43 +00:00
|
|
|
|
2015-11-26 18:40:56 +00:00
|
|
|
wl_seat_add_listener (seat->wl_seat, &seat_listener, seat);
|
|
|
|
wl_seat_set_user_data (seat->wl_seat, seat);
|
2011-02-09 20:27:08 +00:00
|
|
|
|
2016-02-27 00:41:25 +00:00
|
|
|
if (display_wayland->primary_selection_manager)
|
|
|
|
{
|
2017-12-03 04:39:08 +00:00
|
|
|
seat->primary_clipboard = gdk_wayland_primary_new (seat);
|
2017-12-02 20:54:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* If the compositor doesn't support primary clipboard,
|
|
|
|
* just do it local-only */
|
|
|
|
seat->primary_clipboard = gdk_clipboard_new (display);
|
2016-02-27 00:41:25 +00:00
|
|
|
}
|
2016-02-04 16:33:51 +00:00
|
|
|
|
2015-11-26 18:40:56 +00:00
|
|
|
seat->data_device =
|
2011-12-12 14:26:27 +00:00
|
|
|
wl_data_device_manager_get_data_device (display_wayland->data_device_manager,
|
2015-11-26 18:40:56 +00:00
|
|
|
seat->wl_seat);
|
2017-12-02 20:54:36 +00:00
|
|
|
seat->clipboard = gdk_wayland_clipboard_new (display);
|
2015-11-26 18:40:56 +00:00
|
|
|
wl_data_device_add_listener (seat->data_device,
|
|
|
|
&data_device_listener, seat);
|
2011-12-12 14:26:27 +00:00
|
|
|
|
2015-11-26 18:40:56 +00:00
|
|
|
init_devices (seat);
|
2020-06-18 18:22:20 +00:00
|
|
|
init_pointer_data (&seat->pointer_info, display, seat->logical_pointer);
|
2013-03-22 22:26:33 +00:00
|
|
|
|
2016-04-06 15:29:11 +00:00
|
|
|
if (display_wayland->tablet_manager)
|
|
|
|
{
|
|
|
|
seat->wp_tablet_seat =
|
2016-05-13 13:19:04 +00:00
|
|
|
zwp_tablet_manager_v2_get_tablet_seat (display_wayland->tablet_manager,
|
2016-04-06 15:29:11 +00:00
|
|
|
wl_seat);
|
2016-05-13 13:19:04 +00:00
|
|
|
zwp_tablet_seat_v2_add_listener (seat->wp_tablet_seat, &tablet_seat_listener,
|
2016-04-06 15:29:11 +00:00
|
|
|
seat);
|
|
|
|
}
|
2015-01-19 00:32:24 +00:00
|
|
|
|
2017-12-02 20:54:36 +00:00
|
|
|
if (display->clipboard == NULL)
|
|
|
|
display->clipboard = g_object_ref (seat->clipboard);
|
|
|
|
if (display->primary_clipboard == NULL)
|
|
|
|
display->primary_clipboard = g_object_ref (seat->primary_clipboard);
|
|
|
|
|
2015-11-26 18:40:56 +00:00
|
|
|
gdk_display_add_seat (display, GDK_SEAT (seat));
|
2011-02-09 20:27:08 +00:00
|
|
|
}
|
|
|
|
|
2013-03-27 02:57:46 +00:00
|
|
|
void
|
2017-11-25 13:12:48 +00:00
|
|
|
_gdk_wayland_display_remove_seat (GdkWaylandDisplay *display_wayland,
|
|
|
|
guint32 id)
|
2013-03-27 02:57:46 +00:00
|
|
|
{
|
2017-11-25 13:12:48 +00:00
|
|
|
GdkDisplay *display = GDK_DISPLAY (display_wayland);
|
2016-01-15 17:35:25 +00:00
|
|
|
GList *l, *seats;
|
2013-03-27 02:57:46 +00:00
|
|
|
|
2016-01-15 17:35:25 +00:00
|
|
|
seats = gdk_display_list_seats (display);
|
2015-11-26 18:40:56 +00:00
|
|
|
|
2016-01-15 17:35:25 +00:00
|
|
|
for (l = seats; l != NULL; l = l->next)
|
2013-03-27 02:57:46 +00:00
|
|
|
{
|
2015-11-26 18:40:56 +00:00
|
|
|
GdkWaylandSeat *seat = l->data;
|
2013-03-27 02:57:46 +00:00
|
|
|
|
2015-11-26 18:40:56 +00:00
|
|
|
if (seat->id != id)
|
|
|
|
continue;
|
2013-03-27 02:57:46 +00:00
|
|
|
|
2015-11-26 18:40:56 +00:00
|
|
|
gdk_display_remove_seat (display, GDK_SEAT (seat));
|
|
|
|
break;
|
2013-03-27 02:57:46 +00:00
|
|
|
}
|
2016-01-15 17:35:25 +00:00
|
|
|
|
|
|
|
g_list_free (seats);
|
2013-03-27 02:57:46 +00:00
|
|
|
}
|
|
|
|
|
2013-03-27 17:21:54 +00:00
|
|
|
uint32_t
|
2020-06-23 09:00:46 +00:00
|
|
|
_gdk_wayland_seat_get_implicit_grab_serial (GdkSeat *seat,
|
|
|
|
GdkEvent *event)
|
2013-03-27 17:21:54 +00:00
|
|
|
{
|
2014-08-13 19:05:58 +00:00
|
|
|
GdkEventSequence *sequence = NULL;
|
|
|
|
GdkWaylandTouchData *touch = NULL;
|
|
|
|
|
|
|
|
if (event)
|
|
|
|
sequence = gdk_event_get_event_sequence (event);
|
|
|
|
|
|
|
|
if (sequence)
|
2016-03-17 17:38:40 +00:00
|
|
|
touch = gdk_wayland_seat_get_touch (GDK_WAYLAND_SEAT (seat),
|
|
|
|
GDK_EVENT_SEQUENCE_TO_SLOT (sequence));
|
2017-06-23 18:17:53 +00:00
|
|
|
|
2014-08-13 19:05:58 +00:00
|
|
|
if (touch)
|
|
|
|
return touch->touch_down_serial;
|
2017-06-23 18:17:53 +00:00
|
|
|
|
|
|
|
if (event)
|
|
|
|
{
|
|
|
|
GdkDevice *source = gdk_event_get_source_device (event);
|
|
|
|
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = wayland_seat->tablets; l; l = l->next)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletData *tablet = l->data;
|
|
|
|
|
2020-06-22 21:19:35 +00:00
|
|
|
if (tablet->stylus_device == source)
|
2017-06-23 18:17:53 +00:00
|
|
|
return tablet->pointer_info.press_serial;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-20 00:08:14 +00:00
|
|
|
return GDK_WAYLAND_SEAT (seat)->pointer_info.press_serial;
|
2014-08-13 19:05:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
2019-04-20 00:08:14 +00:00
|
|
|
_gdk_wayland_seat_get_last_implicit_grab_serial (GdkWaylandSeat *seat,
|
2016-02-23 19:32:31 +00:00
|
|
|
GdkEventSequence **sequence)
|
2014-08-13 19:05:58 +00:00
|
|
|
{
|
|
|
|
GdkWaylandTouchData *touch;
|
|
|
|
GHashTableIter iter;
|
2017-06-23 18:17:53 +00:00
|
|
|
GList *l;
|
2016-06-30 10:56:21 +00:00
|
|
|
uint32_t serial;
|
2014-08-13 19:05:58 +00:00
|
|
|
|
2019-04-20 00:08:14 +00:00
|
|
|
g_hash_table_iter_init (&iter, seat->touches);
|
2014-08-13 19:05:58 +00:00
|
|
|
|
|
|
|
if (sequence)
|
|
|
|
*sequence = NULL;
|
|
|
|
|
2019-04-20 00:08:14 +00:00
|
|
|
serial = seat->keyboard_key_serial;
|
2016-06-30 10:56:21 +00:00
|
|
|
|
2019-04-20 00:08:14 +00:00
|
|
|
if (seat->pointer_info.press_serial > serial)
|
|
|
|
serial = seat->pointer_info.press_serial;
|
2014-08-13 19:05:58 +00:00
|
|
|
|
2019-04-20 00:08:14 +00:00
|
|
|
for (l = seat->tablets; l; l = l->next)
|
2017-06-23 18:17:53 +00:00
|
|
|
{
|
|
|
|
GdkWaylandTabletData *tablet = l->data;
|
|
|
|
|
|
|
|
if (tablet->pointer_info.press_serial > serial)
|
|
|
|
serial = tablet->pointer_info.press_serial;
|
|
|
|
}
|
|
|
|
|
2014-08-13 19:05:58 +00:00
|
|
|
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;
|
2013-03-27 17:21:54 +00:00
|
|
|
}
|
|
|
|
|
2014-08-20 18:22:42 +00:00
|
|
|
void
|
|
|
|
gdk_wayland_device_unset_touch_grab (GdkDevice *gdk_device,
|
|
|
|
GdkEventSequence *sequence)
|
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
GdkWaylandSeat *seat;
|
2015-12-09 11:49:43 +00:00
|
|
|
GdkWaylandTouchData *touch;
|
|
|
|
GdkEvent *event;
|
2014-08-20 18:22:42 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_WAYLAND_DEVICE (gdk_device));
|
2015-02-28 03:28:28 +00:00
|
|
|
|
2016-03-17 17:03:26 +00:00
|
|
|
seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (gdk_device));
|
2016-03-17 17:38:40 +00:00
|
|
|
touch = gdk_wayland_seat_get_touch (seat,
|
|
|
|
GDK_EVENT_SEQUENCE_TO_SLOT (sequence));
|
2014-08-20 18:22:42 +00:00
|
|
|
|
2020-06-18 18:22:20 +00:00
|
|
|
if (GDK_WAYLAND_DEVICE (seat->logical_touch)->emulating_touch == touch)
|
2015-12-09 11:49:43 +00:00
|
|
|
{
|
2020-06-18 18:22:20 +00:00
|
|
|
GDK_WAYLAND_DEVICE (seat->logical_touch)->emulating_touch = NULL;
|
2018-03-20 14:14:10 +00:00
|
|
|
emulate_touch_crossing (touch->surface, NULL,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_touch, seat->touch,
|
2015-12-09 11:49:43 +00:00
|
|
|
touch, GDK_LEAVE_NOTIFY, GDK_CROSSING_NORMAL,
|
|
|
|
GDK_CURRENT_TIME);
|
|
|
|
}
|
|
|
|
|
Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.
The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.
The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 16:23:36 +00:00
|
|
|
event = gdk_touch_event_new (GDK_TOUCH_CANCEL,
|
2020-02-14 13:10:21 +00:00
|
|
|
GDK_SLOT_TO_EVENT_SEQUENCE (touch->id),
|
|
|
|
touch->surface,
|
2020-06-18 18:22:20 +00:00
|
|
|
seat->logical_touch,
|
2020-02-14 13:10:21 +00:00
|
|
|
seat->touch,
|
|
|
|
GDK_CURRENT_TIME,
|
2020-06-18 18:22:20 +00:00
|
|
|
device_get_modifiers (seat->logical_touch),
|
2020-02-14 13:10:21 +00:00
|
|
|
touch->x, touch->y,
|
|
|
|
NULL,
|
|
|
|
touch->initial_touch);
|
2016-03-17 17:03:26 +00:00
|
|
|
_gdk_wayland_display_deliver_event (seat->display, event);
|
2014-08-20 18:22:42 +00:00
|
|
|
}
|
2014-08-21 16:49:44 +00:00
|
|
|
|
2016-01-13 19:57:47 +00:00
|
|
|
void
|
|
|
|
gdk_wayland_seat_set_global_cursor (GdkSeat *seat,
|
|
|
|
GdkCursor *cursor)
|
|
|
|
{
|
|
|
|
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
|
|
|
|
GdkDevice *pointer;
|
|
|
|
|
|
|
|
pointer = gdk_seat_get_pointer (seat);
|
|
|
|
|
|
|
|
g_set_object (&wayland_seat->grab_cursor, cursor);
|
2018-03-20 11:05:26 +00:00
|
|
|
gdk_wayland_device_set_surface_cursor (pointer,
|
2016-01-13 19:57:47 +00:00
|
|
|
gdk_wayland_device_get_focus (pointer),
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2018-05-31 19:15:59 +00:00
|
|
|
void
|
2018-06-29 17:34:14 +00:00
|
|
|
gdk_wayland_seat_set_drag (GdkSeat *seat,
|
|
|
|
GdkDrag *drag)
|
2018-05-31 19:15:59 +00:00
|
|
|
{
|
|
|
|
GdkWaylandSeat *wayland_seat = GDK_WAYLAND_SEAT (seat);
|
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
g_set_object (&wayland_seat->drag, drag);
|
2018-05-31 19:15:59 +00:00
|
|
|
}
|
|
|
|
|
2014-08-21 16:49:44 +00:00
|
|
|
struct wl_data_device *
|
|
|
|
gdk_wayland_device_get_data_device (GdkDevice *gdk_device)
|
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
GdkWaylandSeat *seat;
|
|
|
|
|
2014-08-21 16:49:44 +00:00
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_DEVICE (gdk_device), NULL);
|
|
|
|
|
2016-03-17 17:03:26 +00:00
|
|
|
seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (gdk_device));
|
|
|
|
return seat->data_device;
|
2014-08-21 16:49:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gdk_wayland_device_set_selection (GdkDevice *gdk_device,
|
|
|
|
struct wl_data_source *source)
|
|
|
|
{
|
2016-03-17 17:03:26 +00:00
|
|
|
GdkWaylandSeat *seat;
|
2014-08-21 16:49:44 +00:00
|
|
|
GdkWaylandDisplay *display_wayland;
|
|
|
|
|
|
|
|
g_return_if_fail (GDK_IS_WAYLAND_DEVICE (gdk_device));
|
2015-02-28 03:28:28 +00:00
|
|
|
|
2016-03-17 17:03:26 +00:00
|
|
|
seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (gdk_device));
|
|
|
|
display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
|
2014-08-21 16:49:44 +00:00
|
|
|
|
2016-03-17 17:03:26 +00:00
|
|
|
wl_data_device_set_selection (seat->data_device, source,
|
2014-08-21 16:49:44 +00:00
|
|
|
_gdk_wayland_display_get_serial (display_wayland));
|
|
|
|
}
|
2015-06-01 13:55:20 +00:00
|
|
|
|
2016-03-21 02:49:33 +00:00
|
|
|
/**
|
|
|
|
* gdk_wayland_seat_get_wl_seat:
|
2017-12-05 07:52:48 +00:00
|
|
|
* @seat: (type GdkWaylandSeat): a #GdkSeat
|
2016-03-21 02:49:33 +00:00
|
|
|
*
|
|
|
|
* Returns the Wayland wl_seat of a #GdkSeat.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): a Wayland wl_seat
|
|
|
|
*/
|
2015-11-26 18:40:56 +00:00
|
|
|
struct wl_seat *
|
|
|
|
gdk_wayland_seat_get_wl_seat (GdkSeat *seat)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GDK_IS_WAYLAND_SEAT (seat), NULL);
|
|
|
|
|
|
|
|
return GDK_WAYLAND_SEAT (seat)->wl_seat;
|
|
|
|
}
|
2016-01-13 20:00:34 +00:00
|
|
|
|
2016-08-04 16:59:09 +00:00
|
|
|
/**
|
|
|
|
* gdk_wayland_device_get_node_path:
|
|
|
|
* @device: a #GdkDevice
|
|
|
|
*
|
|
|
|
* Returns the /dev/input/event* path of this device.
|
|
|
|
* For #GdkDevices that possibly coalesce multiple hardware
|
|
|
|
* devices (eg. mouse, keyboard, touch,...), this function
|
|
|
|
* will return %NULL.
|
|
|
|
*
|
|
|
|
* This is most notably implemented for devices of type
|
2020-06-22 21:19:35 +00:00
|
|
|
* %GDK_SOURCE_PEN, %GDK_SOURCE_TABLET_PAD.
|
2016-08-04 16:59:09 +00:00
|
|
|
*
|
|
|
|
* Returns: the /dev/input/event* path of this device
|
|
|
|
**/
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *
|
2016-08-04 16:59:09 +00:00
|
|
|
gdk_wayland_device_get_node_path (GdkDevice *device)
|
|
|
|
{
|
|
|
|
GdkWaylandTabletData *tablet;
|
2016-08-04 17:46:04 +00:00
|
|
|
GdkWaylandTabletPadData *pad;
|
2016-08-04 16:59:09 +00:00
|
|
|
|
|
|
|
GdkSeat *seat;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
|
|
|
|
|
|
|
|
seat = gdk_device_get_seat (device);
|
2017-11-25 04:00:40 +00:00
|
|
|
tablet = gdk_wayland_seat_find_tablet (GDK_WAYLAND_SEAT (seat), device);
|
2016-08-04 16:59:09 +00:00
|
|
|
if (tablet)
|
|
|
|
return tablet->path;
|
|
|
|
|
2017-11-25 04:00:40 +00:00
|
|
|
pad = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat), device);
|
2016-08-04 17:46:04 +00:00
|
|
|
if (pad)
|
|
|
|
return pad->path;
|
|
|
|
|
2016-08-04 16:59:09 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2016-08-04 17:47:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gdk_wayland_device_pad_set_feedback:
|
|
|
|
* @device: a %GDK_SOURCE_TABLET_PAD device
|
|
|
|
* @feature: Feature to set the feedback label for
|
|
|
|
* @feature_idx: 0-indexed index of the feature to set the feedback label for
|
|
|
|
* @label: Feedback label
|
|
|
|
*
|
|
|
|
* Sets the feedback label for the given feature/index. This may be used by the
|
|
|
|
* compositor to provide user feedback of the actions available/performed.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gdk_wayland_device_pad_set_feedback (GdkDevice *device,
|
|
|
|
GdkDevicePadFeature feature,
|
|
|
|
guint feature_idx,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *label)
|
2016-08-04 17:47:13 +00:00
|
|
|
{
|
|
|
|
GdkWaylandTabletPadData *pad;
|
|
|
|
GdkWaylandTabletPadGroupData *group;
|
|
|
|
GdkSeat *seat;
|
|
|
|
|
|
|
|
seat = gdk_device_get_seat (device);
|
2017-11-25 04:00:40 +00:00
|
|
|
pad = gdk_wayland_seat_find_pad (GDK_WAYLAND_SEAT (seat), device);
|
2016-08-04 17:47:13 +00:00
|
|
|
if (!pad)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (feature == GDK_DEVICE_PAD_FEATURE_BUTTON)
|
|
|
|
{
|
|
|
|
group = tablet_pad_lookup_button_group (pad, feature_idx);
|
|
|
|
if (!group)
|
|
|
|
return;
|
|
|
|
|
|
|
|
zwp_tablet_pad_v2_set_feedback (pad->wp_tablet_pad, feature_idx, label,
|
|
|
|
group->mode_switch_serial);
|
|
|
|
}
|
|
|
|
else if (feature == GDK_DEVICE_PAD_FEATURE_RING)
|
|
|
|
{
|
|
|
|
struct zwp_tablet_pad_ring_v2 *wp_pad_ring;
|
|
|
|
|
|
|
|
wp_pad_ring = g_list_nth_data (pad->rings, feature_idx);
|
|
|
|
if (!wp_pad_ring)
|
|
|
|
return;
|
|
|
|
|
|
|
|
group = zwp_tablet_pad_ring_v2_get_user_data (wp_pad_ring);
|
|
|
|
zwp_tablet_pad_ring_v2_set_feedback (wp_pad_ring, label,
|
|
|
|
group->mode_switch_serial);
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (feature == GDK_DEVICE_PAD_FEATURE_STRIP)
|
|
|
|
{
|
|
|
|
struct zwp_tablet_pad_strip_v2 *wp_pad_strip;
|
|
|
|
|
|
|
|
wp_pad_strip = g_list_nth_data (pad->strips, feature_idx);
|
|
|
|
if (!wp_pad_strip)
|
|
|
|
return;
|
|
|
|
|
|
|
|
group = zwp_tablet_pad_strip_v2_get_user_data (wp_pad_strip);
|
|
|
|
zwp_tablet_pad_strip_v2_set_feedback (wp_pad_strip, label,
|
|
|
|
group->mode_switch_serial);
|
|
|
|
}
|
|
|
|
}
|