Merge branch 'wip/carlosg/tablet-cursors-hidpi' into 'gtk-3-24'

gdk/wayland: Listen to wl_surface events on tablet cursors

See merge request GNOME/gtk!759
This commit is contained in:
Matthias Clasen
2019-04-18 16:55:54 +00:00

View File

@@ -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,14 +5076,8 @@ _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_devices (seat);
init_pointer_data (&seat->pointer_info, display, seat->master_pointer);
if (display_wayland->tablet_manager)
{