rootston: add per-seat views

This commit is contained in:
emersion 2017-11-17 12:45:07 +01:00
parent 10f3be7384
commit bb6d34e7a5
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
12 changed files with 161 additions and 123 deletions

View file

@ -18,29 +18,6 @@
#include "rootston/seat.h"
#include "rootston/xcursor.h"
// TODO replace me with a signal
void view_destroy(struct roots_view *view) {
struct roots_desktop *desktop = view->desktop;
struct roots_input *input = desktop->server->input;
struct roots_seat *seat;
wl_list_for_each(seat, &input->seats, link) {
if (seat->focus == view) {
seat->focus = NULL;
seat->cursor->mode = ROOTS_CURSOR_PASSTHROUGH;
}
}
for (size_t i = 0; i < desktop->views->length; ++i) {
struct roots_view *_view = desktop->views->items[i];
if (view == _view) {
wlr_list_del(desktop->views, i);
break;
}
}
free(view);
}
void view_get_box(const struct roots_view *view, struct wlr_box *box) {
box->x = view->x;
box->y = view->y;
@ -201,6 +178,25 @@ bool view_center(struct roots_view *view) {
return true;
}
void view_destroy(struct roots_view *view) {
wl_signal_emit(&view->events.destroy, view);
wl_list_remove(&view->link);
free(view);
}
void view_init(struct roots_view *view, struct roots_desktop *desktop) {
view->desktop = desktop;
wl_signal_init(&view->events.destroy);
wl_list_insert(&desktop->views, &view->link);
struct roots_seat *seat;
wl_list_for_each(seat, &desktop->server->input->seats, link) {
roots_seat_add_view(seat, view);
}
}
void view_setup(struct roots_view *view) {
struct roots_input *input = view->desktop->server->input;
// TODO what seat gets focus? the one with the last input event?
@ -215,25 +211,11 @@ void view_setup(struct roots_view *view) {
view_update_output(view, &before);
}
void view_teardown(struct roots_view *view) {
// TODO replace me with a signal
/*
struct wlr_list *views = view->desktop->views;
if (views->length < 2 || views->items[views->length-1] != view) {
return;
}
struct roots_view *prev_view = views->items[views->length-2];
struct roots_input *input = prev_view->desktop->server->input;
set_view_focus(input, prev_view->desktop, prev_view);
*/
}
struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) {
for (ssize_t i = desktop->views->length - 1; i >= 0; --i) {
struct roots_view *view = desktop->views->items[i];
// TODO: use the seat
struct roots_view *view;
wl_list_for_each(view, &desktop->views, link) {
if (view->type == ROOTS_WL_SHELL_VIEW &&
view->wl_shell_surface->state ==
WLR_WL_SHELL_SURFACE_STATE_POPUP) {
@ -322,11 +304,7 @@ struct roots_desktop *desktop_create(struct roots_server *server,
return NULL;
}
desktop->views = wlr_list_create();
if (desktop->views == NULL) {
free(desktop);
return NULL;
}
wl_list_init(&desktop->views);
wl_list_init(&desktop->outputs);
desktop->output_add.notify = output_add_notify;
@ -342,7 +320,6 @@ struct roots_desktop *desktop_create(struct roots_server *server,
ROOTS_XCURSOR_SIZE);
if (desktop->xcursor_manager == NULL) {
wlr_log(L_ERROR, "Cannot create XCursor manager");
wlr_list_free(desktop->views);
free(desktop);
return NULL;
}