mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-30 00:15:58 +01:00
basic touch dnd
This commit is contained in:
parent
94e7dc8a3e
commit
6a516f7c41
9 changed files with 210 additions and 78 deletions
|
@ -56,6 +56,9 @@ struct roots_cursor {
|
||||||
struct wl_listener pointer_grab_begin;
|
struct wl_listener pointer_grab_begin;
|
||||||
struct wl_listener pointer_grab_end;
|
struct wl_listener pointer_grab_end;
|
||||||
|
|
||||||
|
struct wl_listener touch_grab_begin;
|
||||||
|
struct wl_listener touch_grab_end;
|
||||||
|
|
||||||
struct wl_listener request_set_cursor;
|
struct wl_listener request_set_cursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -99,4 +102,10 @@ void roots_cursor_handle_pointer_grab_begin(struct roots_cursor *cursor,
|
||||||
void roots_cursor_handle_pointer_grab_end(struct roots_cursor *cursor,
|
void roots_cursor_handle_pointer_grab_end(struct roots_cursor *cursor,
|
||||||
struct wlr_seat_pointer_grab *grab);
|
struct wlr_seat_pointer_grab *grab);
|
||||||
|
|
||||||
|
void roots_cursor_handle_touch_grab_begin(struct roots_cursor *cursor,
|
||||||
|
struct wlr_seat_touch_grab *grab);
|
||||||
|
|
||||||
|
void roots_cursor_handle_touch_grab_end(struct roots_cursor *cursor,
|
||||||
|
struct wlr_seat_touch_grab *grab);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,6 +9,9 @@ struct roots_drag_icon {
|
||||||
struct wl_list link; // roots_seat::drag_icons
|
struct wl_list link; // roots_seat::drag_icons
|
||||||
bool mapped;
|
bool mapped;
|
||||||
|
|
||||||
|
bool is_pointer;
|
||||||
|
bool touch_id;
|
||||||
|
|
||||||
int32_t sx;
|
int32_t sx;
|
||||||
int32_t sy;
|
int32_t sy;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@ wlr_pointer_grab_interface wlr_data_device_pointer_drag_interface;
|
||||||
extern const struct
|
extern const struct
|
||||||
wlr_keyboard_grab_interface wlr_data_device_keyboard_drag_interface;
|
wlr_keyboard_grab_interface wlr_data_device_keyboard_drag_interface;
|
||||||
|
|
||||||
|
extern const struct
|
||||||
|
wlr_touch_grab_interface wlr_data_device_touch_drag_interface;
|
||||||
|
|
||||||
struct wlr_data_device_manager {
|
struct wlr_data_device_manager {
|
||||||
struct wl_global *global;
|
struct wl_global *global;
|
||||||
};
|
};
|
||||||
|
@ -55,14 +58,18 @@ struct wlr_drag {
|
||||||
struct wlr_seat_keyboard_grab keyboard_grab;
|
struct wlr_seat_keyboard_grab keyboard_grab;
|
||||||
struct wlr_seat_touch_grab touch_grab;
|
struct wlr_seat_touch_grab touch_grab;
|
||||||
|
|
||||||
|
struct wlr_seat *seat;
|
||||||
struct wlr_seat_client *seat_client;
|
struct wlr_seat_client *seat_client;
|
||||||
struct wlr_seat_client *focus_client;
|
struct wlr_seat_client *focus_client;
|
||||||
|
|
||||||
|
bool is_pointer_grab;
|
||||||
|
|
||||||
struct wlr_surface *icon;
|
struct wlr_surface *icon;
|
||||||
struct wlr_surface *focus;
|
struct wlr_surface *focus;
|
||||||
struct wlr_data_source *source;
|
struct wlr_data_source *source;
|
||||||
|
|
||||||
bool cancelling;
|
bool cancelling;
|
||||||
|
int32_t grab_touch_id;
|
||||||
|
|
||||||
struct wl_listener icon_destroy;
|
struct wl_listener icon_destroy;
|
||||||
struct wl_listener source_destroy;
|
struct wl_listener source_destroy;
|
||||||
|
|
|
@ -144,6 +144,7 @@ struct wlr_seat_touch_state {
|
||||||
struct wl_list touch_points; // wlr_touch_point::link
|
struct wl_list touch_points; // wlr_touch_point::link
|
||||||
|
|
||||||
uint32_t grab_serial;
|
uint32_t grab_serial;
|
||||||
|
uint32_t grab_id;
|
||||||
|
|
||||||
struct wlr_seat_touch_grab *grab;
|
struct wlr_seat_touch_grab *grab;
|
||||||
struct wlr_seat_touch_grab *default_grab;
|
struct wlr_seat_touch_grab *default_grab;
|
||||||
|
|
|
@ -328,33 +328,59 @@ static void handle_drag_icon_destroy(struct wl_listener *listener, void *data) {
|
||||||
free(drag_icon);
|
free(drag_icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct roots_drag_icon *seat_add_drag_icon(struct roots_seat *seat,
|
||||||
|
struct wlr_surface *icon_surface) {
|
||||||
|
if (!icon_surface) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct roots_drag_icon *iter_icon;
|
||||||
|
wl_list_for_each(iter_icon, &seat->drag_icons, link) {
|
||||||
|
if (iter_icon->surface == icon_surface) {
|
||||||
|
// already in the list
|
||||||
|
return iter_icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct roots_drag_icon *drag_icon =
|
||||||
|
calloc(1, sizeof(struct roots_drag_icon));
|
||||||
|
drag_icon->mapped = true;
|
||||||
|
drag_icon->surface = icon_surface;
|
||||||
|
wl_list_insert(&seat->drag_icons, &drag_icon->link);
|
||||||
|
|
||||||
|
wl_signal_add(&icon_surface->events.destroy,
|
||||||
|
&drag_icon->surface_destroy);
|
||||||
|
drag_icon->surface_destroy.notify = handle_drag_icon_destroy;
|
||||||
|
|
||||||
|
wl_signal_add(&icon_surface->events.commit,
|
||||||
|
&drag_icon->surface_commit);
|
||||||
|
drag_icon->surface_commit.notify = handle_drag_icon_commit;
|
||||||
|
|
||||||
|
return drag_icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void seat_unmap_drag_icon(struct roots_seat *seat,
|
||||||
|
struct wlr_surface *icon_surface) {
|
||||||
|
if (!icon_surface) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct roots_drag_icon *icon;
|
||||||
|
wl_list_for_each(icon, &seat->drag_icons, link) {
|
||||||
|
if (icon->surface == icon_surface) {
|
||||||
|
icon->mapped = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void roots_cursor_handle_pointer_grab_begin(struct roots_cursor *cursor,
|
void roots_cursor_handle_pointer_grab_begin(struct roots_cursor *cursor,
|
||||||
struct wlr_seat_pointer_grab *grab) {
|
struct wlr_seat_pointer_grab *grab) {
|
||||||
struct roots_seat *seat = cursor->seat;
|
|
||||||
if (grab->interface == &wlr_data_device_pointer_drag_interface) {
|
if (grab->interface == &wlr_data_device_pointer_drag_interface) {
|
||||||
struct wlr_drag *drag = grab->data;
|
struct wlr_drag *drag = grab->data;
|
||||||
if (drag->icon) {
|
struct roots_drag_icon *icon =
|
||||||
struct roots_drag_icon *iter_icon;
|
seat_add_drag_icon(cursor->seat, drag->icon);
|
||||||
wl_list_for_each(iter_icon, &seat->drag_icons, link) {
|
if (icon) {
|
||||||
if (iter_icon->surface == drag->icon) {
|
icon->is_pointer = true;
|
||||||
// already in the list
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct roots_drag_icon *drag_icon =
|
|
||||||
calloc(1, sizeof(struct roots_drag_icon));
|
|
||||||
drag_icon->mapped = true;
|
|
||||||
drag_icon->surface = drag->icon;
|
|
||||||
wl_list_insert(&seat->drag_icons, &drag_icon->link);
|
|
||||||
|
|
||||||
wl_signal_add(&drag->icon->events.destroy,
|
|
||||||
&drag_icon->surface_destroy);
|
|
||||||
drag_icon->surface_destroy.notify = handle_drag_icon_destroy;
|
|
||||||
|
|
||||||
wl_signal_add(&drag->icon->events.commit,
|
|
||||||
&drag_icon->surface_commit);
|
|
||||||
drag_icon->surface_commit.notify = handle_drag_icon_commit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -363,13 +389,27 @@ void roots_cursor_handle_pointer_grab_end(struct roots_cursor *cursor,
|
||||||
struct wlr_seat_pointer_grab *grab) {
|
struct wlr_seat_pointer_grab *grab) {
|
||||||
if (grab->interface == &wlr_data_device_pointer_drag_interface) {
|
if (grab->interface == &wlr_data_device_pointer_drag_interface) {
|
||||||
struct wlr_drag *drag = grab->data;
|
struct wlr_drag *drag = grab->data;
|
||||||
struct roots_drag_icon *icon;
|
seat_unmap_drag_icon(cursor->seat, drag->icon);
|
||||||
wl_list_for_each(icon, &cursor->seat->drag_icons, link) {
|
}
|
||||||
if (icon->surface == drag->icon) {
|
}
|
||||||
icon->mapped = false;
|
|
||||||
}
|
void roots_cursor_handle_touch_grab_begin(struct roots_cursor *cursor,
|
||||||
|
struct wlr_seat_touch_grab *grab) {
|
||||||
|
if (grab->interface == &wlr_data_device_touch_drag_interface) {
|
||||||
|
struct wlr_drag *drag = grab->data;
|
||||||
|
struct roots_drag_icon *icon =
|
||||||
|
seat_add_drag_icon(cursor->seat, drag->icon);
|
||||||
|
if (icon) {
|
||||||
|
icon->is_pointer = false;
|
||||||
|
icon->touch_id = drag->grab_touch_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
roots_cursor_update_position(cursor, 0);
|
|
||||||
|
void roots_cursor_handle_touch_grab_end(struct roots_cursor *cursor,
|
||||||
|
struct wlr_seat_touch_grab *grab) {
|
||||||
|
if (grab->interface == &wlr_data_device_touch_drag_interface) {
|
||||||
|
struct wlr_drag *drag = grab->data;
|
||||||
|
seat_unmap_drag_icon(cursor->seat, drag->icon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,9 +200,20 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
struct wlr_surface *icon = drag_icon->surface;
|
struct wlr_surface *icon = drag_icon->surface;
|
||||||
struct wlr_cursor *cursor = seat->cursor->cursor;
|
struct wlr_cursor *cursor = seat->cursor->cursor;
|
||||||
double icon_x = cursor->x + drag_icon->sx;
|
double icon_x = 0, icon_y = 0;
|
||||||
double icon_y = cursor->y + drag_icon->sy;
|
if (drag_icon->is_pointer) {
|
||||||
render_surface(icon, desktop, wlr_output, &now, icon_x, icon_y, 0);
|
icon_x = cursor->x + drag_icon->sx;
|
||||||
|
icon_y = cursor->y + drag_icon->sy;
|
||||||
|
render_surface(icon, desktop, wlr_output, &now, icon_x, icon_y, 0);
|
||||||
|
} else {
|
||||||
|
struct wlr_touch_point *point =
|
||||||
|
wlr_seat_touch_get_point(seat->seat, drag_icon->touch_id);
|
||||||
|
if (point) {
|
||||||
|
icon_x = point->sx + drag_icon->sx; // TODO plus view x
|
||||||
|
icon_y = point->sy + drag_icon->sy; // TODO plus view y
|
||||||
|
render_surface(icon, desktop, wlr_output, &now, icon_x, icon_y, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,22 @@ static void handle_pointer_grab_end(struct wl_listener *listener,
|
||||||
roots_cursor_handle_pointer_grab_end(cursor, grab);
|
roots_cursor_handle_pointer_grab_end(cursor, grab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_touch_grab_begin(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct roots_cursor *cursor =
|
||||||
|
wl_container_of(listener, cursor, touch_grab_begin);
|
||||||
|
struct wlr_seat_touch_grab *grab = data;
|
||||||
|
roots_cursor_handle_touch_grab_begin(cursor, grab);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_touch_grab_end(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct roots_cursor *cursor =
|
||||||
|
wl_container_of(listener, cursor, touch_grab_end);
|
||||||
|
struct wlr_seat_touch_grab *grab = data;
|
||||||
|
roots_cursor_handle_touch_grab_end(cursor, grab);
|
||||||
|
}
|
||||||
|
|
||||||
static void seat_reset_device_mappings(struct roots_seat *seat, struct wlr_input_device *device) {
|
static void seat_reset_device_mappings(struct roots_seat *seat, struct wlr_input_device *device) {
|
||||||
struct wlr_cursor *cursor = seat->cursor->cursor;
|
struct wlr_cursor *cursor = seat->cursor->cursor;
|
||||||
struct roots_config *config = seat->input->config;
|
struct roots_config *config = seat->input->config;
|
||||||
|
@ -231,6 +247,14 @@ static void roots_seat_init_cursor(struct roots_seat *seat) {
|
||||||
wl_signal_add(&seat->seat->events.pointer_grab_end,
|
wl_signal_add(&seat->seat->events.pointer_grab_end,
|
||||||
&seat->cursor->pointer_grab_end);
|
&seat->cursor->pointer_grab_end);
|
||||||
seat->cursor->pointer_grab_end.notify = handle_pointer_grab_end;
|
seat->cursor->pointer_grab_end.notify = handle_pointer_grab_end;
|
||||||
|
|
||||||
|
wl_signal_add(&seat->seat->events.touch_grab_begin,
|
||||||
|
&seat->cursor->touch_grab_begin);
|
||||||
|
seat->cursor->touch_grab_begin.notify = handle_touch_grab_begin;
|
||||||
|
|
||||||
|
wl_signal_add(&seat->seat->events.touch_grab_end,
|
||||||
|
&seat->cursor->touch_grab_end);
|
||||||
|
seat->cursor->touch_grab_end.notify = handle_touch_grab_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
|
struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
|
||||||
|
|
|
@ -437,8 +437,12 @@ static void wlr_drag_set_focus(struct wlr_drag *drag,
|
||||||
static void wlr_drag_end(struct wlr_drag *drag) {
|
static void wlr_drag_end(struct wlr_drag *drag) {
|
||||||
if (!drag->cancelling) {
|
if (!drag->cancelling) {
|
||||||
drag->cancelling = true;
|
drag->cancelling = true;
|
||||||
wlr_seat_pointer_end_grab(drag->pointer_grab.seat);
|
if (drag->is_pointer_grab) {
|
||||||
wlr_seat_keyboard_end_grab(drag->keyboard_grab.seat);
|
wlr_seat_pointer_end_grab(drag->seat);
|
||||||
|
} else {
|
||||||
|
wlr_seat_touch_end_grab(drag->seat);
|
||||||
|
}
|
||||||
|
wlr_seat_keyboard_end_grab(drag->seat);
|
||||||
|
|
||||||
if (drag->source) {
|
if (drag->source) {
|
||||||
wl_list_remove(&drag->source_destroy.link);
|
wl_list_remove(&drag->source_destroy.link);
|
||||||
|
@ -523,20 +527,34 @@ wlr_pointer_grab_interface wlr_data_device_pointer_drag_interface = {
|
||||||
|
|
||||||
static void touch_drag_down(struct wlr_seat_touch_grab *grab, struct wlr_surface *surface,
|
static void touch_drag_down(struct wlr_seat_touch_grab *grab, struct wlr_surface *surface,
|
||||||
uint32_t time, int32_t touch_id, double sx, double sy) {
|
uint32_t time, int32_t touch_id, double sx, double sy) {
|
||||||
// TODO
|
// eat the event
|
||||||
}
|
}
|
||||||
|
|
||||||
static void touch_drag_up(struct wlr_seat_touch_grab *grab, uint32_t time, int32_t touch_id) {
|
static void touch_drag_up(struct wlr_seat_touch_grab *grab, uint32_t time, int32_t touch_id) {
|
||||||
// TODO
|
struct wlr_drag *drag = grab->data;
|
||||||
|
if (drag->grab_touch_id != touch_id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drag->focus_client && drag->focus_client->data_device) {
|
||||||
|
wl_data_device_send_drop(drag->focus_client->data_device);
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_drag_end(drag);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void touch_drag_motion(struct wlr_seat_touch_grab *grab, uint32_t time, int32_t
|
static void touch_drag_motion(struct wlr_seat_touch_grab *grab, uint32_t time, int32_t
|
||||||
touch_id, double sx, double sy) {
|
touch_id, double sx, double sy) {
|
||||||
// TODO
|
struct wlr_drag *drag = grab->data;
|
||||||
|
if (drag->focus && drag->focus_client && drag->focus_client->data_device) {
|
||||||
|
wl_data_device_send_motion(drag->focus_client->data_device, time,
|
||||||
|
wl_fixed_from_double(sx), wl_fixed_from_double(sy));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void touch_drag_cancel(struct wlr_seat_touch_grab *grab) {
|
static void touch_drag_cancel(struct wlr_seat_touch_grab *grab) {
|
||||||
// TODO
|
struct wlr_drag *drag = grab->data;
|
||||||
|
wlr_drag_end(drag);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct wlr_touch_grab_interface wlr_data_device_touch_drag_interface = {
|
const struct wlr_touch_grab_interface wlr_data_device_touch_drag_interface = {
|
||||||
|
@ -594,24 +612,31 @@ static bool seat_client_start_drag(struct wlr_seat_client *client,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_seat_pointer_state pointer_state = client->seat->pointer_state;
|
drag->seat = client->seat;
|
||||||
struct wlr_seat_touch_state touch_state = client->seat->touch_state;
|
|
||||||
|
|
||||||
bool is_pointer_grab = client->pointer &&
|
drag->is_pointer_grab = client->pointer != NULL &&
|
||||||
pointer_state.button_count == 1 &&
|
client->seat->pointer_state.button_count == 1 &&
|
||||||
pointer_state.grab_serial == serial &&
|
client->seat->pointer_state.grab_serial == serial &&
|
||||||
pointer_state.focused_surface &&
|
client->seat->pointer_state.focused_surface &&
|
||||||
pointer_state.focused_surface == origin;
|
client->seat->pointer_state.focused_surface == origin;
|
||||||
|
|
||||||
bool is_touch_grab = client->touch &&
|
bool is_touch_grab = client->touch &&
|
||||||
wl_list_length(&touch_state.touch_points) == 1 &&
|
wl_list_length(&client->seat->touch_state.touch_points) == 1 &&
|
||||||
touch_state.grab_serial == serial;
|
client->seat->touch_state.grab_serial == serial;
|
||||||
|
|
||||||
if (!is_pointer_grab || !is_touch_grab) {
|
struct wlr_touch_point *point = NULL;
|
||||||
return true;
|
if (is_touch_grab) {
|
||||||
|
wl_list_for_each(point, &client->seat->touch_state.touch_points, link) {
|
||||||
|
if (point->surface && point->surface == origin) {
|
||||||
|
is_touch_grab = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_seat *seat = client->seat;
|
if (!drag->is_pointer_grab && !is_touch_grab) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (icon) {
|
if (icon) {
|
||||||
drag->icon = icon;
|
drag->icon = icon;
|
||||||
|
@ -632,17 +657,19 @@ static bool seat_client_start_drag(struct wlr_seat_client *client,
|
||||||
|
|
||||||
drag->touch_grab.data = drag;
|
drag->touch_grab.data = drag;
|
||||||
drag->touch_grab.interface = &wlr_data_device_touch_drag_interface;
|
drag->touch_grab.interface = &wlr_data_device_touch_drag_interface;
|
||||||
|
drag->grab_touch_id = drag->seat->touch_state.grab_id;
|
||||||
|
|
||||||
drag->keyboard_grab.data = drag;
|
drag->keyboard_grab.data = drag;
|
||||||
drag->keyboard_grab.interface = &wlr_data_device_keyboard_drag_interface;
|
drag->keyboard_grab.interface = &wlr_data_device_keyboard_drag_interface;
|
||||||
|
|
||||||
wlr_seat_keyboard_start_grab(seat, &drag->keyboard_grab);
|
wlr_seat_keyboard_start_grab(drag->seat, &drag->keyboard_grab);
|
||||||
|
|
||||||
if (is_pointer_grab) {
|
if (drag->is_pointer_grab) {
|
||||||
wlr_seat_pointer_clear_focus(seat);
|
wlr_seat_pointer_clear_focus(drag->seat);
|
||||||
wlr_seat_pointer_start_grab(seat, &drag->pointer_grab);
|
wlr_seat_pointer_start_grab(drag->seat, &drag->pointer_grab);
|
||||||
} else {
|
} else {
|
||||||
wlr_seat_touch_start_grab(seat, &drag->touch_grab);
|
wlr_seat_touch_start_grab(drag->seat, &drag->touch_grab);
|
||||||
|
wlr_drag_set_focus(drag, point->surface, point->sx, point->sy);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -654,20 +681,10 @@ static void data_device_start_drag(struct wl_client *client,
|
||||||
struct wl_resource *origin_resource, struct wl_resource *icon_resource,
|
struct wl_resource *origin_resource, struct wl_resource *icon_resource,
|
||||||
uint32_t serial) {
|
uint32_t serial) {
|
||||||
struct wlr_seat_client *seat_client = wl_resource_get_user_data(device_resource);
|
struct wlr_seat_client *seat_client = wl_resource_get_user_data(device_resource);
|
||||||
struct wlr_seat *seat = seat_client->seat;
|
|
||||||
struct wlr_surface *origin = wl_resource_get_user_data(origin_resource);
|
struct wlr_surface *origin = wl_resource_get_user_data(origin_resource);
|
||||||
struct wlr_data_source *source = NULL;
|
struct wlr_data_source *source = NULL;
|
||||||
struct wlr_surface *icon = NULL;
|
struct wlr_surface *icon = NULL;
|
||||||
|
|
||||||
bool is_pointer_grab = seat->pointer_state.button_count == 1 &&
|
|
||||||
seat->pointer_state.grab_serial == serial &&
|
|
||||||
seat->pointer_state.focused_surface &&
|
|
||||||
seat->pointer_state.focused_surface == origin;
|
|
||||||
|
|
||||||
if (!is_pointer_grab) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (source_resource) {
|
if (source_resource) {
|
||||||
source = wl_resource_get_user_data(source_resource);
|
source = wl_resource_get_user_data(source_resource);
|
||||||
}
|
}
|
||||||
|
|
|
@ -378,6 +378,7 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
touch_grab->interface = &default_touch_grab_impl;
|
touch_grab->interface = &default_touch_grab_impl;
|
||||||
|
touch_grab->seat = wlr_seat;
|
||||||
wlr_seat->touch_state.default_grab = touch_grab;
|
wlr_seat->touch_state.default_grab = touch_grab;
|
||||||
wlr_seat->touch_state.grab = touch_grab;
|
wlr_seat->touch_state.grab = touch_grab;
|
||||||
|
|
||||||
|
@ -600,7 +601,9 @@ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time,
|
||||||
|
|
||||||
void wlr_seat_pointer_start_grab(struct wlr_seat *wlr_seat,
|
void wlr_seat_pointer_start_grab(struct wlr_seat *wlr_seat,
|
||||||
struct wlr_seat_pointer_grab *grab) {
|
struct wlr_seat_pointer_grab *grab) {
|
||||||
|
assert(wlr_seat);
|
||||||
grab->seat = wlr_seat;
|
grab->seat = wlr_seat;
|
||||||
|
assert(grab->seat);
|
||||||
wlr_seat->pointer_state.grab = grab;
|
wlr_seat->pointer_state.grab = grab;
|
||||||
|
|
||||||
wl_signal_emit(&wlr_seat->events.pointer_grab_begin, grab);
|
wl_signal_emit(&wlr_seat->events.pointer_grab_begin, grab);
|
||||||
|
@ -959,37 +962,58 @@ struct wlr_touch_point *wlr_seat_touch_get_point(
|
||||||
void wlr_seat_touch_notify_down(struct wlr_seat *seat,
|
void wlr_seat_touch_notify_down(struct wlr_seat *seat,
|
||||||
struct wlr_surface *surface, uint32_t time, int32_t touch_id, double sx,
|
struct wlr_surface *surface, uint32_t time, int32_t touch_id, double sx,
|
||||||
double sy) {
|
double sy) {
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &seat->last_event);
|
||||||
struct wlr_seat_touch_grab *grab = seat->touch_state.grab;
|
struct wlr_seat_touch_grab *grab = seat->touch_state.grab;
|
||||||
|
struct wlr_touch_point *point =
|
||||||
|
touch_point_create(seat, touch_id, surface, sx, sy);
|
||||||
|
if (!point) {
|
||||||
|
wlr_log(L_ERROR, "could not create touch point");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
grab->interface->down(grab, surface, time, touch_id, sx, sy);
|
grab->interface->down(grab, surface, time, touch_id, sx, sy);
|
||||||
if (wl_list_length(&seat->touch_state.touch_points) == 1) {
|
if (wl_list_length(&seat->touch_state.touch_points) == 1) {
|
||||||
seat->touch_state.grab_serial = wl_display_get_serial(seat->display);
|
seat->touch_state.grab_serial = wl_display_get_serial(seat->display);
|
||||||
|
seat->touch_state.grab_id = touch_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_seat_touch_notify_up(struct wlr_seat *seat, uint32_t time,
|
void wlr_seat_touch_notify_up(struct wlr_seat *seat, uint32_t time,
|
||||||
int32_t touch_id) {
|
int32_t touch_id) {
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &seat->last_event);
|
||||||
struct wlr_seat_touch_grab *grab = seat->touch_state.grab;
|
struct wlr_seat_touch_grab *grab = seat->touch_state.grab;
|
||||||
|
struct wlr_touch_point *point = wlr_seat_touch_get_point(seat, touch_id);
|
||||||
|
if (!point) {
|
||||||
|
wlr_log(L_ERROR, "got touch up for unknown touch point");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
grab->interface->up(grab, time, touch_id);
|
grab->interface->up(grab, time, touch_id);
|
||||||
|
touch_point_destroy(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_seat_touch_notify_motion(struct wlr_seat *seat, uint32_t time,
|
void wlr_seat_touch_notify_motion(struct wlr_seat *seat, uint32_t time,
|
||||||
int32_t touch_id, double sx, double sy) {
|
int32_t touch_id, double sx, double sy) {
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &seat->last_event);
|
||||||
struct wlr_seat_touch_grab *grab = seat->touch_state.grab;
|
struct wlr_seat_touch_grab *grab = seat->touch_state.grab;
|
||||||
|
struct wlr_touch_point *point = wlr_seat_touch_get_point(seat, touch_id);
|
||||||
|
if (!point) {
|
||||||
|
wlr_log(L_ERROR, "got touch motion for unknown touch point");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
point->sx = sx;
|
||||||
|
point->sy = sy;
|
||||||
|
|
||||||
grab->interface->motion(grab, time, touch_id, sx, sy);
|
grab->interface->motion(grab, time, touch_id, sx, sy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_seat_touch_send_down(struct wlr_seat *seat,
|
void wlr_seat_touch_send_down(struct wlr_seat *seat,
|
||||||
struct wlr_surface *surface, uint32_t time, int32_t touch_id, double sx,
|
struct wlr_surface *surface, uint32_t time, int32_t touch_id, double sx,
|
||||||
double sy) {
|
double sy) {
|
||||||
if (wlr_seat_touch_get_point(seat, touch_id)) {
|
struct wlr_touch_point *point = wlr_seat_touch_get_point(seat, touch_id);
|
||||||
wlr_log(L_ERROR, "got touch down for a touch point that's already down");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wlr_touch_point *point =
|
|
||||||
touch_point_create(seat, touch_id, surface, sx, sy);
|
|
||||||
if (!point) {
|
if (!point) {
|
||||||
wlr_log(L_ERROR, "could not create touch point");
|
wlr_log(L_ERROR, "got touch down for unknown touch point");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1009,7 +1033,6 @@ void wlr_seat_touch_send_up(struct wlr_seat *seat, uint32_t time, int32_t touch_
|
||||||
uint32_t serial = wl_display_next_serial(seat->display);
|
uint32_t serial = wl_display_next_serial(seat->display);
|
||||||
wl_touch_send_up(point->client->touch, serial, time, touch_id);
|
wl_touch_send_up(point->client->touch, serial, time, touch_id);
|
||||||
wl_touch_send_frame(point->client->touch);
|
wl_touch_send_frame(point->client->touch);
|
||||||
touch_point_destroy(point);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_seat_touch_send_motion(struct wlr_seat *seat, uint32_t time, int32_t touch_id,
|
void wlr_seat_touch_send_motion(struct wlr_seat *seat, uint32_t time, int32_t touch_id,
|
||||||
|
@ -1020,9 +1043,6 @@ void wlr_seat_touch_send_motion(struct wlr_seat *seat, uint32_t time, int32_t to
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
point->sx = sx;
|
|
||||||
point->sy = sy;
|
|
||||||
|
|
||||||
wl_touch_send_motion(point->client->touch, time, touch_id,
|
wl_touch_send_motion(point->client->touch, time, touch_id,
|
||||||
wl_fixed_from_double(sx), wl_fixed_from_double(sy));
|
wl_fixed_from_double(sx), wl_fixed_from_double(sy));
|
||||||
wl_touch_send_frame(point->client->touch);
|
wl_touch_send_frame(point->client->touch);
|
||||||
|
|
Loading…
Reference in a new issue