[gtk/wip/carlosg/tablet-cursors-hidpi] gdk/wayland: Listen to wl_surface events on tablet cursors
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/carlosg/tablet-cursors-hidpi] gdk/wayland: Listen to wl_surface events on tablet cursors
- Date: Thu, 18 Apr 2019 15:47:10 +0000 (UTC)
commit bf4bca715e484a991d506830f196a2939280cae8
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Apr 18 19:31:55 2019 +0200
gdk/wayland: Listen to wl_surface events on tablet cursors
And update the surface accordingly (eg. scale on hidpi). The mechanism
that did that for wl_pointer has been made generic so it can be shared
with tablets too.
Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1675
gdk/wayland/gdkdevice-wayland.c | 76 +++++++++++++++++++++++++++++++----------
1 file changed, 58 insertions(+), 18 deletions(-)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index fb3cfcb505..e886c6557a 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -310,9 +310,14 @@ struct _GdkWaylandDeviceManagerClass
GdkDeviceManagerClass parent_class;
};
+static void init_pointer_data (GdkWaylandPointerData *pointer_data,
+ GdkDisplay *display_wayland,
+ GdkDevice *master);
+
static void
pointer_surface_update_scale (GdkDevice *device);
+
static void deliver_key_event (GdkWaylandSeat *seat,
uint32_t time_,
uint32_t key,
@@ -2971,6 +2976,8 @@ tablet_handle_done (void *data,
g_list_prepend (device_manager->devices, tablet->master);
g_signal_emit_by_name (device_manager, "device-added", master);
+ init_pointer_data (&tablet->pointer_info, display, tablet->master);
+
tablet->stylus_device = stylus_device;
device_manager->devices =
g_list_prepend (device_manager->devices, tablet->stylus_device);
@@ -4446,14 +4453,11 @@ tablet_seat_handle_tablet_added (void *data,
struct zwp_tablet_v2 *wp_tablet)
{
GdkWaylandSeat *seat = data;
- GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (seat->display);
GdkWaylandTabletData *tablet;
tablet = g_new0 (GdkWaylandTabletData, 1);
tablet->seat = GDK_SEAT (seat);
- tablet->pointer_info.current_output_scale = 1;
- tablet->pointer_info.pointer_surface =
- wl_compositor_create_surface (display_wayland->compositor);
+
tablet->wp_tablet = wp_tablet;
seat->tablets = g_list_prepend (seat->tablets, tablet);
@@ -4598,16 +4602,28 @@ pointer_surface_enter (void *data,
struct wl_output *output)
{
- GdkWaylandSeat *seat = data;
+ GdkDevice *device = data;
+ GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
+ GdkWaylandTabletData *tablet;
GDK_NOTE (EVENTS,
g_message ("pointer surface of seat %p entered output %p",
seat, output));
- seat->pointer_info.pointer_surface_outputs =
- g_slist_append (seat->pointer_info.pointer_surface_outputs, output);
+ tablet = gdk_wayland_device_manager_find_tablet (seat, device);
- pointer_surface_update_scale (seat->master_pointer);
+ if (tablet)
+ {
+ tablet->pointer_info.pointer_surface_outputs =
+ g_slist_append (seat->pointer_info.pointer_surface_outputs, output);
+ }
+ else
+ {
+ seat->pointer_info.pointer_surface_outputs =
+ g_slist_append (seat->pointer_info.pointer_surface_outputs, output);
+ }
+
+ pointer_surface_update_scale (device);
}
static void
@@ -4615,16 +4631,28 @@ pointer_surface_leave (void *data,
struct wl_surface *wl_surface,
struct wl_output *output)
{
- GdkWaylandSeat *seat = data;
+ GdkDevice *device = data;
+ GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
+ GdkWaylandTabletData *tablet;
GDK_NOTE (EVENTS,
g_message ("pointer surface of seat %p left output %p",
seat, output));
- seat->pointer_info.pointer_surface_outputs =
- g_slist_remove (seat->pointer_info.pointer_surface_outputs, output);
+ tablet = gdk_wayland_device_manager_find_tablet (seat, device);
- pointer_surface_update_scale (seat->master_pointer);
+ if (tablet)
+ {
+ tablet->pointer_info.pointer_surface_outputs =
+ g_slist_remove (seat->pointer_info.pointer_surface_outputs, output);
+ }
+ else
+ {
+ seat->pointer_info.pointer_surface_outputs =
+ g_slist_remove (seat->pointer_info.pointer_surface_outputs, output);
+ }
+
+ pointer_surface_update_scale (device);
}
static const struct wl_surface_listener pointer_surface_listener = {
@@ -4985,6 +5013,23 @@ gdk_wayland_seat_init (GdkWaylandSeat *seat)
{
}
+static void
+init_pointer_data (GdkWaylandPointerData *pointer_data,
+ GdkDisplay *display,
+ GdkDevice *master)
+{
+ 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,
+ master);
+}
+
void
_gdk_wayland_device_manager_add_seat (GdkDeviceManager *device_manager,
guint32 id,
@@ -5031,12 +5076,7 @@ _gdk_wayland_device_manager_add_seat (GdkDeviceManager *device_manager,
wl_data_device_add_listener (seat->data_device,
&data_device_listener, seat);
- seat->pointer_info.current_output_scale = 1;
- seat->pointer_info.pointer_surface =
- wl_compositor_create_surface (display_wayland->compositor);
- wl_surface_add_listener (seat->pointer_info.pointer_surface,
- &pointer_surface_listener,
- seat);
+ init_pointer_data (&seat->pointer_info, display, seat->master_pointer);
init_devices (seat);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]