Merge branch 'master' into seat-views
This commit is contained in:
commit
76e8e1a6ad
|
@ -53,12 +53,6 @@ struct roots_cursor {
|
||||||
struct wl_listener tool_axis;
|
struct wl_listener tool_axis;
|
||||||
struct wl_listener tool_tip;
|
struct wl_listener tool_tip;
|
||||||
|
|
||||||
struct wl_listener pointer_grab_begin;
|
|
||||||
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -96,16 +90,4 @@ void roots_cursor_handle_tool_tip(struct roots_cursor *cursor,
|
||||||
void roots_cursor_handle_request_set_cursor(struct roots_cursor *cursor,
|
void roots_cursor_handle_request_set_cursor(struct roots_cursor *cursor,
|
||||||
struct wlr_seat_pointer_request_set_cursor_event *event);
|
struct wlr_seat_pointer_request_set_cursor_event *event);
|
||||||
|
|
||||||
void roots_cursor_handle_pointer_grab_begin(struct roots_cursor *cursor,
|
|
||||||
struct wlr_seat_pointer_grab *grab);
|
|
||||||
|
|
||||||
void roots_cursor_handle_pointer_grab_end(struct roots_cursor *cursor,
|
|
||||||
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
|
||||||
|
|
|
@ -50,6 +50,7 @@ struct roots_desktop {
|
||||||
#ifdef HAS_XWAYLAND
|
#ifdef HAS_XWAYLAND
|
||||||
struct wlr_xwayland *xwayland;
|
struct wlr_xwayland *xwayland;
|
||||||
struct wl_listener xwayland_surface;
|
struct wl_listener xwayland_surface;
|
||||||
|
struct wl_listener xwayland_ready;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,25 +4,10 @@
|
||||||
#include "rootston/input.h"
|
#include "rootston/input.h"
|
||||||
#include "rootston/keyboard.h"
|
#include "rootston/keyboard.h"
|
||||||
|
|
||||||
struct roots_drag_icon {
|
|
||||||
struct wlr_surface *surface;
|
|
||||||
struct wl_list link; // roots_seat::drag_icons
|
|
||||||
bool mapped;
|
|
||||||
|
|
||||||
bool is_pointer;
|
|
||||||
int32_t touch_id;
|
|
||||||
|
|
||||||
int32_t sx, sy;
|
|
||||||
|
|
||||||
struct wl_listener surface_destroy;
|
|
||||||
struct wl_listener surface_commit;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct roots_seat {
|
struct roots_seat {
|
||||||
struct roots_input *input;
|
struct roots_input *input;
|
||||||
struct wlr_seat *seat;
|
struct wlr_seat *seat;
|
||||||
struct roots_cursor *cursor;
|
struct roots_cursor *cursor;
|
||||||
struct wl_list drag_icons;
|
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
|
|
||||||
// coordinates of the first touch point if it exists
|
// coordinates of the first touch point if it exists
|
||||||
|
|
|
@ -53,6 +53,27 @@ struct wlr_data_source {
|
||||||
} events;
|
} events;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct wlr_drag_icon {
|
||||||
|
struct wlr_surface *surface;
|
||||||
|
struct wlr_seat_client *client;
|
||||||
|
struct wl_list link; // wlr_seat::drag_icons
|
||||||
|
bool mapped;
|
||||||
|
|
||||||
|
bool is_pointer;
|
||||||
|
int32_t touch_id;
|
||||||
|
|
||||||
|
int32_t sx;
|
||||||
|
int32_t sy;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
struct wl_signal destroy;
|
||||||
|
} events;
|
||||||
|
|
||||||
|
struct wl_listener surface_destroy;
|
||||||
|
struct wl_listener surface_commit;
|
||||||
|
struct wl_listener seat_client_destroy;
|
||||||
|
};
|
||||||
|
|
||||||
struct wlr_drag {
|
struct wlr_drag {
|
||||||
struct wlr_seat_pointer_grab pointer_grab;
|
struct wlr_seat_pointer_grab pointer_grab;
|
||||||
struct wlr_seat_keyboard_grab keyboard_grab;
|
struct wlr_seat_keyboard_grab keyboard_grab;
|
||||||
|
@ -64,7 +85,7 @@ struct wlr_drag {
|
||||||
|
|
||||||
bool is_pointer_grab;
|
bool is_pointer_grab;
|
||||||
|
|
||||||
struct wlr_surface *icon;
|
struct wlr_drag_icon *icon;
|
||||||
struct wlr_surface *focus;
|
struct wlr_surface *focus;
|
||||||
struct wlr_data_source *source;
|
struct wlr_data_source *source;
|
||||||
|
|
||||||
|
@ -72,9 +93,9 @@ struct wlr_drag {
|
||||||
int32_t grab_touch_id;
|
int32_t grab_touch_id;
|
||||||
|
|
||||||
struct wl_listener point_destroy;
|
struct wl_listener point_destroy;
|
||||||
struct wl_listener icon_destroy;
|
|
||||||
struct wl_listener source_destroy;
|
struct wl_listener source_destroy;
|
||||||
struct wl_listener seat_client_unbound;
|
struct wl_listener seat_client_destroy;
|
||||||
|
struct wl_listener icon_destroy;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,6 +21,10 @@ struct wlr_seat_client {
|
||||||
struct wl_resource *touch;
|
struct wl_resource *touch;
|
||||||
struct wl_resource *data_device;
|
struct wl_resource *data_device;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
struct wl_signal destroy;
|
||||||
|
} events;
|
||||||
|
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -165,6 +169,8 @@ struct wlr_seat {
|
||||||
struct wl_global *wl_global;
|
struct wl_global *wl_global;
|
||||||
struct wl_display *display;
|
struct wl_display *display;
|
||||||
struct wl_list clients;
|
struct wl_list clients;
|
||||||
|
struct wl_list drag_icons; // wlr_drag_icon::link
|
||||||
|
|
||||||
char *name;
|
char *name;
|
||||||
uint32_t capabilities;
|
uint32_t capabilities;
|
||||||
struct timespec last_event;
|
struct timespec last_event;
|
||||||
|
@ -180,9 +186,6 @@ struct wlr_seat {
|
||||||
struct wl_listener selection_data_source_destroy;
|
struct wl_listener selection_data_source_destroy;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct wl_signal client_bound;
|
|
||||||
struct wl_signal client_unbound;
|
|
||||||
|
|
||||||
struct wl_signal pointer_grab_begin;
|
struct wl_signal pointer_grab_begin;
|
||||||
struct wl_signal pointer_grab_end;
|
struct wl_signal pointer_grab_end;
|
||||||
|
|
||||||
|
|
|
@ -354,105 +354,3 @@ void roots_cursor_handle_request_set_cursor(struct roots_cursor *cursor,
|
||||||
event->hotspot_y);
|
event->hotspot_y);
|
||||||
cursor->cursor_client = event->seat_client->client;
|
cursor->cursor_client = event->seat_client->client;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_drag_icon_commit(struct wl_listener *listener, void *data) {
|
|
||||||
struct roots_drag_icon *drag_icon =
|
|
||||||
wl_container_of(listener, drag_icon, surface_commit);
|
|
||||||
drag_icon->sx += drag_icon->surface->current->sx;
|
|
||||||
drag_icon->sy += drag_icon->surface->current->sy;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_drag_icon_destroy(struct wl_listener *listener, void *data) {
|
|
||||||
struct roots_drag_icon *drag_icon =
|
|
||||||
wl_container_of(listener, drag_icon, surface_destroy);
|
|
||||||
wl_list_remove(&drag_icon->link);
|
|
||||||
wl_list_remove(&drag_icon->surface_destroy.link);
|
|
||||||
wl_list_remove(&drag_icon->surface_commit.link);
|
|
||||||
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,
|
|
||||||
struct wlr_seat_pointer_grab *grab) {
|
|
||||||
if (grab->interface == &wlr_data_device_pointer_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 = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void roots_cursor_handle_pointer_grab_end(struct roots_cursor *cursor,
|
|
||||||
struct wlr_seat_pointer_grab *grab) {
|
|
||||||
if (grab->interface == &wlr_data_device_pointer_drag_interface) {
|
|
||||||
struct wlr_drag *drag = grab->data;
|
|
||||||
seat_unmap_drag_icon(cursor->seat, drag->icon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -59,8 +59,9 @@ int main(int argc, char **argv) {
|
||||||
ready(NULL, NULL);
|
ready(NULL, NULL);
|
||||||
#else
|
#else
|
||||||
if (server.desktop->xwayland != NULL) {
|
if (server.desktop->xwayland != NULL) {
|
||||||
struct wl_listener xwayland_ready = { .notify = ready };
|
wl_signal_add(&server.desktop->xwayland->events.ready,
|
||||||
wl_signal_add(&server.desktop->xwayland->events.ready, &xwayland_ready);
|
&server.desktop->xwayland_ready);
|
||||||
|
server.desktop->xwayland_ready.notify = ready;
|
||||||
} else {
|
} else {
|
||||||
ready(NULL, NULL);
|
ready(NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,10 +191,10 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
|
||||||
render_view(view, desktop, wlr_output, &now);
|
render_view(view, desktop, wlr_output, &now);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct roots_drag_icon *drag_icon = NULL;
|
struct wlr_drag_icon *drag_icon = NULL;
|
||||||
struct roots_seat *seat = NULL;
|
struct roots_seat *seat = NULL;
|
||||||
wl_list_for_each(seat, &server->input->seats, link) {
|
wl_list_for_each(seat, &server->input->seats, link) {
|
||||||
wl_list_for_each(drag_icon, &seat->drag_icons, link) {
|
wl_list_for_each(drag_icon, &seat->seat->drag_icons, link) {
|
||||||
if (!drag_icon->mapped) {
|
if (!drag_icon->mapped) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,38 +96,6 @@ static void handle_request_set_cursor(struct wl_listener *listener,
|
||||||
roots_cursor_handle_request_set_cursor(cursor, event);
|
roots_cursor_handle_request_set_cursor(cursor, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_pointer_grab_begin(struct wl_listener *listener,
|
|
||||||
void *data) {
|
|
||||||
struct roots_cursor *cursor =
|
|
||||||
wl_container_of(listener, cursor, pointer_grab_begin);
|
|
||||||
struct wlr_seat_pointer_grab *grab = data;
|
|
||||||
roots_cursor_handle_pointer_grab_begin(cursor, grab);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handle_pointer_grab_end(struct wl_listener *listener,
|
|
||||||
void *data) {
|
|
||||||
struct roots_cursor *cursor =
|
|
||||||
wl_container_of(listener, cursor, pointer_grab_end);
|
|
||||||
struct wlr_seat_pointer_grab *grab = data;
|
|
||||||
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,
|
static void seat_reset_device_mappings(struct roots_seat *seat,
|
||||||
struct wlr_input_device *device) {
|
struct wlr_input_device *device) {
|
||||||
struct wlr_cursor *cursor = seat->cursor->cursor;
|
struct wlr_cursor *cursor = seat->cursor->cursor;
|
||||||
|
@ -249,22 +217,6 @@ static void roots_seat_init_cursor(struct roots_seat *seat) {
|
||||||
wl_signal_add(&seat->seat->events.request_set_cursor,
|
wl_signal_add(&seat->seat->events.request_set_cursor,
|
||||||
&seat->cursor->request_set_cursor);
|
&seat->cursor->request_set_cursor);
|
||||||
seat->cursor->request_set_cursor.notify = handle_request_set_cursor;
|
seat->cursor->request_set_cursor.notify = handle_request_set_cursor;
|
||||||
|
|
||||||
wl_signal_add(&seat->seat->events.pointer_grab_begin,
|
|
||||||
&seat->cursor->pointer_grab_begin);
|
|
||||||
seat->cursor->pointer_grab_begin.notify = handle_pointer_grab_begin;
|
|
||||||
|
|
||||||
wl_signal_add(&seat->seat->events.pointer_grab_end,
|
|
||||||
&seat->cursor->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) {
|
||||||
|
@ -277,7 +229,6 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) {
|
||||||
wl_list_init(&seat->pointers);
|
wl_list_init(&seat->pointers);
|
||||||
wl_list_init(&seat->touch);
|
wl_list_init(&seat->touch);
|
||||||
wl_list_init(&seat->tablet_tools);
|
wl_list_init(&seat->tablet_tools);
|
||||||
wl_list_init(&seat->drag_icons);
|
|
||||||
wl_list_init(&seat->views);
|
wl_list_init(&seat->views);
|
||||||
|
|
||||||
seat->input = input;
|
seat->input = input;
|
||||||
|
|
|
@ -352,15 +352,13 @@ static void data_device_release(struct wl_client *client,
|
||||||
wl_resource_destroy(resource);
|
wl_resource_destroy(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drag_client_seat_unbound(struct wl_listener *listener, void *data) {
|
static void handle_drag_seat_client_destroy(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
struct wlr_drag *drag =
|
struct wlr_drag *drag =
|
||||||
wl_container_of(listener, drag, seat_client_unbound);
|
wl_container_of(listener, drag, seat_client_destroy);
|
||||||
struct wlr_seat_client *unbound_client = data;
|
|
||||||
|
|
||||||
if (drag->focus_client == unbound_client) {
|
drag->focus_client = NULL;
|
||||||
drag->focus_client = NULL;
|
wl_list_remove(&drag->seat_client_destroy.link);
|
||||||
wl_list_remove(&drag->seat_client_unbound.link);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wlr_drag_set_focus(struct wlr_drag *drag,
|
static void wlr_drag_set_focus(struct wlr_drag *drag,
|
||||||
|
@ -370,7 +368,7 @@ static void wlr_drag_set_focus(struct wlr_drag *drag,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drag->focus_client && drag->focus_client->data_device) {
|
if (drag->focus_client && drag->focus_client->data_device) {
|
||||||
wl_list_remove(&drag->seat_client_unbound.link);
|
wl_list_remove(&drag->seat_client_destroy.link);
|
||||||
wl_data_device_send_leave(drag->focus_client->data_device);
|
wl_data_device_send_leave(drag->focus_client->data_device);
|
||||||
drag->focus_client = NULL;
|
drag->focus_client = NULL;
|
||||||
drag->focus = NULL;
|
drag->focus = NULL;
|
||||||
|
@ -430,9 +428,9 @@ static void wlr_drag_set_focus(struct wlr_drag *drag,
|
||||||
|
|
||||||
drag->focus = surface;
|
drag->focus = surface;
|
||||||
drag->focus_client = focus_client;
|
drag->focus_client = focus_client;
|
||||||
drag->seat_client_unbound.notify = drag_client_seat_unbound;
|
drag->seat_client_destroy.notify = handle_drag_seat_client_destroy;
|
||||||
wl_signal_add(&focus_client->seat->events.client_unbound,
|
wl_signal_add(&focus_client->events.destroy,
|
||||||
&drag->seat_client_unbound);
|
&drag->seat_client_destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wlr_drag_end(struct wlr_drag *drag) {
|
static void wlr_drag_end(struct wlr_drag *drag) {
|
||||||
|
@ -452,6 +450,7 @@ static void wlr_drag_end(struct wlr_drag *drag) {
|
||||||
wlr_drag_set_focus(drag, NULL, 0, 0);
|
wlr_drag_set_focus(drag, NULL, 0, 0);
|
||||||
|
|
||||||
if (drag->icon) {
|
if (drag->icon) {
|
||||||
|
drag->icon->mapped = false;
|
||||||
wl_list_remove(&drag->icon_destroy.link);
|
wl_list_remove(&drag->icon_destroy.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,8 +613,72 @@ static void drag_handle_drag_source_destroy(struct wl_listener *listener,
|
||||||
wlr_drag_end(drag);
|
wlr_drag_end(drag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void wlr_drag_icon_destroy(struct wlr_drag_icon *icon) {
|
||||||
|
if (!icon) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wl_signal_emit(&icon->events.destroy, icon);
|
||||||
|
wl_list_remove(&icon->surface_commit.link);
|
||||||
|
wl_list_remove(&icon->surface_destroy.link);
|
||||||
|
wl_list_remove(&icon->seat_client_destroy.link);
|
||||||
|
wl_list_remove(&icon->link);
|
||||||
|
free(icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_drag_icon_surface_destroy(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct wlr_drag_icon *icon =
|
||||||
|
wl_container_of(listener, icon, surface_destroy);
|
||||||
|
wlr_drag_icon_destroy(icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_drag_icon_surface_commit(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct wlr_drag_icon *icon =
|
||||||
|
wl_container_of(listener, icon, surface_commit);
|
||||||
|
icon->sx += icon->surface->current->sx;
|
||||||
|
icon->sy += icon->surface->current->sy;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_drag_icon_seat_client_destroy(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct wlr_drag_icon *icon =
|
||||||
|
wl_container_of(listener, icon, seat_client_destroy);
|
||||||
|
|
||||||
|
wlr_drag_icon_destroy(icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct wlr_drag_icon *wlr_drag_icon_create(
|
||||||
|
struct wlr_surface *icon_surface, struct wlr_seat_client *client,
|
||||||
|
bool is_pointer, int32_t touch_id) {
|
||||||
|
struct wlr_drag_icon *icon = calloc(1, sizeof(struct wlr_drag_icon));
|
||||||
|
if (!icon) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
icon->surface = icon_surface;
|
||||||
|
icon->client = client;
|
||||||
|
icon->is_pointer = is_pointer;
|
||||||
|
icon->touch_id = touch_id;
|
||||||
|
icon->mapped = true;
|
||||||
|
wl_list_insert(&client->seat->drag_icons, &icon->link);
|
||||||
|
|
||||||
|
wl_signal_init(&icon->events.destroy);
|
||||||
|
|
||||||
|
wl_signal_add(&icon->surface->events.destroy, &icon->surface_destroy);
|
||||||
|
icon->surface_destroy.notify = handle_drag_icon_surface_destroy;
|
||||||
|
|
||||||
|
wl_signal_add(&icon->surface->events.commit, &icon->surface_commit);
|
||||||
|
icon->surface_commit.notify = handle_drag_icon_surface_commit;
|
||||||
|
|
||||||
|
wl_signal_add(&client->events.destroy, &icon->seat_client_destroy);
|
||||||
|
icon->seat_client_destroy.notify = handle_drag_icon_seat_client_destroy;
|
||||||
|
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
static bool seat_client_start_drag(struct wlr_seat_client *client,
|
static bool seat_client_start_drag(struct wlr_seat_client *client,
|
||||||
struct wlr_data_source *source, struct wlr_surface *icon,
|
struct wlr_data_source *source, struct wlr_surface *icon_surface,
|
||||||
struct wlr_surface *origin, uint32_t serial) {
|
struct wlr_surface *origin, uint32_t serial) {
|
||||||
struct wlr_drag *drag = calloc(1, sizeof(struct wlr_drag));
|
struct wlr_drag *drag = calloc(1, sizeof(struct wlr_drag));
|
||||||
if (drag == NULL) {
|
if (drag == NULL) {
|
||||||
|
@ -649,11 +712,20 @@ static bool seat_client_start_drag(struct wlr_seat_client *client,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (icon) {
|
if (icon_surface) {
|
||||||
|
int32_t touch_id = (point ? point->touch_id : 0);
|
||||||
|
struct wlr_drag_icon *icon =
|
||||||
|
wlr_drag_icon_create(icon_surface, client, drag->is_pointer_grab,
|
||||||
|
touch_id);
|
||||||
|
|
||||||
|
if (!icon) {
|
||||||
|
free(drag);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
drag->icon = icon;
|
drag->icon = icon;
|
||||||
drag->icon_destroy.notify = drag_handle_icon_destroy;
|
drag->icon_destroy.notify = drag_handle_icon_destroy;
|
||||||
wl_signal_add(&icon->events.destroy, &drag->icon_destroy);
|
wl_signal_add(&icon->events.destroy, &drag->icon_destroy);
|
||||||
drag->icon = icon;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source) {
|
if (source) {
|
||||||
|
@ -712,8 +784,6 @@ static void data_device_start_drag(struct wl_client *client,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO touch grab
|
|
||||||
|
|
||||||
if (!seat_client_start_drag(seat_client, source, icon, origin, serial)) {
|
if (!seat_client_start_drag(seat_client, source, icon, origin, serial)) {
|
||||||
wl_resource_post_no_memory(device_resource);
|
wl_resource_post_no_memory(device_resource);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -181,7 +181,7 @@ static void wl_seat_get_touch(struct wl_client *client,
|
||||||
|
|
||||||
static void wlr_seat_client_resource_destroy(struct wl_resource *resource) {
|
static void wlr_seat_client_resource_destroy(struct wl_resource *resource) {
|
||||||
struct wlr_seat_client *client = wl_resource_get_user_data(resource);
|
struct wlr_seat_client *client = wl_resource_get_user_data(resource);
|
||||||
wl_signal_emit(&client->seat->events.client_unbound, client);
|
wl_signal_emit(&client->events.destroy, client);
|
||||||
|
|
||||||
if (client == client->seat->pointer_state.focused_client) {
|
if (client == client->seat->pointer_state.focused_client) {
|
||||||
client->seat->pointer_state.focused_client = NULL;
|
client->seat->pointer_state.focused_client = NULL;
|
||||||
|
@ -240,7 +240,7 @@ static void wl_seat_bind(struct wl_client *client, void *_wlr_seat,
|
||||||
wl_seat_send_name(seat_client->wl_resource, wlr_seat->name);
|
wl_seat_send_name(seat_client->wl_resource, wlr_seat->name);
|
||||||
}
|
}
|
||||||
wl_seat_send_capabilities(seat_client->wl_resource, wlr_seat->capabilities);
|
wl_seat_send_capabilities(seat_client->wl_resource, wlr_seat->capabilities);
|
||||||
wl_signal_emit(&wlr_seat->events.client_bound, seat_client);
|
wl_signal_init(&seat_client->events.destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void default_pointer_enter(struct wlr_seat_pointer_grab *grab,
|
static void default_pointer_enter(struct wlr_seat_pointer_grab *grab,
|
||||||
|
@ -404,9 +404,7 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) {
|
||||||
wlr_seat->display = display;
|
wlr_seat->display = display;
|
||||||
wlr_seat->name = strdup(name);
|
wlr_seat->name = strdup(name);
|
||||||
wl_list_init(&wlr_seat->clients);
|
wl_list_init(&wlr_seat->clients);
|
||||||
|
wl_list_init(&wlr_seat->drag_icons);
|
||||||
wl_signal_init(&wlr_seat->events.client_bound);
|
|
||||||
wl_signal_init(&wlr_seat->events.client_unbound);
|
|
||||||
|
|
||||||
wl_signal_init(&wlr_seat->events.request_set_cursor);
|
wl_signal_init(&wlr_seat->events.request_set_cursor);
|
||||||
wl_signal_init(&wlr_seat->events.selection);
|
wl_signal_init(&wlr_seat->events.selection);
|
||||||
|
|
Loading…
Reference in New Issue