Wayland: Translate wl_tablet.down/up into button events

These are sent with button=GDK_BUTTON_PRIMARY, axes must be also
included in these events, in addition to motion ones.
This commit is contained in:
Stephen Chandler Paul 2015-06-22 18:16:27 +02:00 committed by Carlos Garnacho
parent 0f6be24e28
commit 4f6bc82052

View File

@ -3133,6 +3133,66 @@ tablet_tool_handle_proximity_out (void *data,
gdk_device_update_tool (tablet->current_device, NULL); gdk_device_update_tool (tablet->current_device, NULL);
} }
static void
tablet_create_button_event_frame (GdkWaylandTabletData *tablet,
GdkEventType evtype,
guint button)
{
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tablet->seat);
GdkWaylandDisplay *wayland_display = GDK_WAYLAND_DISPLAY (seat->display);
GdkEvent *event;
event = gdk_wayland_tablet_get_frame_event (tablet, evtype);
event->button.window = g_object_ref (tablet->pointer_info.focus);
gdk_event_set_device (event, tablet->master);
gdk_event_set_source_device (event, tablet->current_device);
gdk_event_set_device_tool (event, tablet->current_tool->tool);
event->button.time = tablet->pointer_info.time;
event->button.state = device_get_modifiers (tablet->master);
event->button.button = button;
gdk_event_set_screen (event, wayland_display->screen);
get_coordinates (tablet->master,
&event->button.x,
&event->button.y,
&event->button.x_root,
&event->button.y_root);
}
static void
tablet_tool_handle_down (void *data,
struct zwp_tablet_tool_v1 *wp_tablet_tool,
uint32_t serial)
{
GdkWaylandTabletToolData *tool = data;
GdkWaylandTabletData *tablet = tool->current_tablet;
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (tool->seat);
GdkWaylandDisplay *wayland_display = GDK_WAYLAND_DISPLAY (seat->display);
if (!tablet->pointer_info.focus)
return;
_gdk_wayland_display_update_serial (wayland_display, serial);
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,
struct zwp_tablet_tool_v1 *wp_tablet_tool)
{
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;
}
static void static void
tablet_tool_handle_motion (void *data, tablet_tool_handle_motion (void *data,
struct zwp_tablet_tool_v1 *wp_tablet_tool, struct zwp_tablet_tool_v1 *wp_tablet_tool,
@ -3307,8 +3367,8 @@ static const struct zwp_tablet_tool_v1_listener tablet_tool_listener = {
tablet_tool_handle_removed, tablet_tool_handle_removed,
tablet_tool_handle_proximity_in, tablet_tool_handle_proximity_in,
tablet_tool_handle_proximity_out, tablet_tool_handle_proximity_out,
tablet_handler_placeholder, /* down */ tablet_tool_handle_down,
tablet_handler_placeholder, /* up */ tablet_tool_handle_up,
tablet_tool_handle_motion, tablet_tool_handle_motion,
tablet_tool_handle_pressure, tablet_tool_handle_pressure,
tablet_tool_handle_distance, tablet_tool_handle_distance,