DRY up focus and implement z ordering

This commit is contained in:
Drew DeVault 2017-09-28 19:48:55 -04:00
parent 033036712a
commit ada7fde6fb
9 changed files with 56 additions and 43 deletions

View file

@ -30,24 +30,11 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
struct roots_view *view = roots_xdg_surface->view;
struct roots_input *input = view->desktop->server->input;
struct wlr_xdg_toplevel_v6_move_event *e = data;
// TODO: Some of this might want to live in cursor.c I guess
struct roots_input_event *event = NULL;
size_t len = sizeof(input->input_events) / sizeof(*input->input_events);
for (size_t i = 0; i < len; ++i) {
if (input->input_events[i].cursor
&& input->input_events[i].serial == e->serial) {
event = &input->input_events[i];
break;
}
}
const struct roots_input_event *event = get_input_event(input, e->serial);
if (!event || input->mode != ROOTS_CURSOR_PASSTHROUGH) {
return;
}
input->mode = ROOTS_CURSOR_MOVE;
input->offs_x = input->cursor->x - view->x;
input->offs_y = input->cursor->y - view->y;
wlr_seat_pointer_clear_focus(input->wl_seat);
view_begin_move(input, event->cursor, view);
}
static void handle_destroy(struct wl_listener *listener, void *data) {
@ -96,5 +83,5 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
view->activate = activate;
view->desktop = desktop;
roots_surface->view = view;
wl_list_insert(&desktop->views, &view->link);
list_add(desktop->views, view);
}