aboutsummaryrefslogtreecommitdiff
path: root/rootston/wl_shell.c
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-11-17 12:45:07 +0100
committeremersion <contact@emersion.fr>2017-11-17 12:45:07 +0100
commitbb6d34e7a5e270c6998f95f45c1e518d9c053714 (patch)
tree4c3a34eb809203e76c63ac90239f6d07312cc0f5 /rootston/wl_shell.c
parent10f3be73843250c400531873b4dd27dba44919fd (diff)
rootston: add per-seat views
Diffstat (limited to 'rootston/wl_shell.c')
-rw-r--r--rootston/wl_shell.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c
index 96f461fe..7359c878 100644
--- a/rootston/wl_shell.c
+++ b/rootston/wl_shell.c
@@ -77,7 +77,6 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
static void handle_destroy(struct wl_listener *listener, void *data) {
struct roots_wl_shell_surface *roots_surface =
wl_container_of(listener, roots_surface, destroy);
- view_teardown(roots_surface->view);
wl_list_remove(&roots_surface->destroy.link);
wl_list_remove(&roots_surface->request_move.link);
wl_list_remove(&roots_surface->request_resize.link);
@@ -88,14 +87,6 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
free(roots_surface);
}
-static int shell_surface_compare_equals(const void *item, const void *cmp_to) {
- const struct roots_view *view = item;
- if (view->type == ROOTS_WL_SHELL_VIEW && view->wl_shell_surface == cmp_to) {
- return 0;
- }
- return -1;
-}
-
void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
struct roots_desktop *desktop =
wl_container_of(listener, desktop, wl_shell_surface);
@@ -138,17 +129,23 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
view->wlr_surface = surface->surface;
view->resize = resize;
view->close = close;
- view->desktop = desktop;
roots_surface->view = view;
- wlr_list_add(desktop->views, view);
+ view_init(view, desktop);
+
view_setup(view);
if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TRANSIENT) {
- // we need to map it relative to the parent
- int i = wlr_list_seq_find(desktop->views, shell_surface_compare_equals,
- surface->parent);
- if (i != -1) {
- struct roots_view *parent = desktop->views->items[i];
+ // We need to map it relative to the parent
+ bool found = false;
+ struct roots_view *parent;
+ wl_list_for_each(parent, &desktop->views, link) {
+ if (parent->type == ROOTS_WL_SHELL_VIEW &&
+ parent->wl_shell_surface == surface->parent) {
+ found = true;
+ break;
+ }
+ }
+ if (found) {
view_move(view,
parent->x + surface->transient_state->x,
parent->y + surface->transient_state->y);