aboutsummaryrefslogtreecommitdiff
path: root/rootston
diff options
context:
space:
mode:
Diffstat (limited to 'rootston')
-rw-r--r--rootston/desktop.c77
-rw-r--r--rootston/output.c10
-rw-r--r--rootston/seat.c9
-rw-r--r--rootston/wl_shell.c32
-rw-r--r--rootston/xdg_shell.c88
-rw-r--r--rootston/xdg_shell_v6.c88
-rw-r--r--rootston/xwayland.c55
7 files changed, 227 insertions, 132 deletions
diff --git a/rootston/desktop.c b/rootston/desktop.c
index a130fe38..9730ca57 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -24,13 +24,16 @@
#include "rootston/view.h"
#include "rootston/xcursor.h"
-
-struct roots_view *view_create() {
+struct roots_view *view_create(struct roots_desktop *desktop) {
struct roots_view *view = calloc(1, sizeof(struct roots_view));
if (!view) {
return NULL;
}
+ view->desktop = desktop;
view->alpha = 1.0f;
+ wl_signal_init(&view->events.unmap);
+ wl_signal_init(&view->events.destroy);
+ wl_list_init(&view->children);
return view;
}
@@ -53,7 +56,8 @@ void view_get_deco_box(const struct roots_view *view, struct wlr_box *box) {
box->height += (view->border_width * 2 + view->titlebar_height);
}
-enum roots_deco_part view_get_deco_part(struct roots_view *view, double sx, double sy) {
+enum roots_deco_part view_get_deco_part(struct roots_view *view, double sx,
+ double sy) {
if (!view->decorated) {
return ROOTS_DECO_PART_NONE;
}
@@ -93,9 +97,15 @@ enum roots_deco_part view_get_deco_part(struct roots_view *view, double sx, doub
static void view_update_output(const struct roots_view *view,
const struct wlr_box *before) {
struct roots_desktop *desktop = view->desktop;
- struct roots_output *output;
+
+ if (view->wlr_surface == NULL) {
+ return;
+ }
+
struct wlr_box box;
view_get_box(view, &box);
+
+ struct roots_output *output;
wl_list_for_each(output, &desktop->outputs, link) {
bool intersected = before != NULL && wlr_output_layout_intersects(
desktop->layout, output->wlr_output, before);
@@ -403,20 +413,22 @@ struct roots_subsurface *subsurface_create(struct roots_view *view,
return subsurface;
}
-void view_finish(struct roots_view *view) {
- view_damage_whole(view);
- wl_signal_emit(&view->events.destroy, view);
+void view_destroy(struct roots_view *view) {
+ if (view == NULL) {
+ return;
+ }
- wl_list_remove(&view->new_subsurface.link);
+ wl_signal_emit(&view->events.destroy, view);
- struct roots_view_child *child, *tmp;
- wl_list_for_each_safe(child, tmp, &view->children, link) {
- child->destroy(child);
+ if (view->wlr_surface != NULL) {
+ view_unmap(view);
}
- if (view->fullscreen_output) {
- view->fullscreen_output->fullscreen_view = NULL;
+ if (view->destroy) {
+ view->destroy(view);
}
+
+ free(view);
}
static void view_handle_new_subsurface(struct wl_listener *listener,
@@ -426,12 +438,10 @@ static void view_handle_new_subsurface(struct wl_listener *listener,
subsurface_create(view, wlr_subsurface);
}
-void view_init(struct roots_view *view, struct roots_desktop *desktop) {
- assert(view->wlr_surface);
+void view_map(struct roots_view *view, struct wlr_surface *surface) {
+ assert(view->wlr_surface == NULL);
- view->desktop = desktop;
- wl_signal_init(&view->events.destroy);
- wl_list_init(&view->children);
+ view->wlr_surface = surface;
struct wlr_subsurface *subsurface;
wl_list_for_each(subsurface, &view->wlr_surface->subsurface_list,
@@ -443,9 +453,35 @@ void view_init(struct roots_view *view, struct roots_desktop *desktop) {
wl_signal_add(&view->wlr_surface->events.new_subsurface,
&view->new_subsurface);
+ wl_list_insert(&view->desktop->views, &view->link);
view_damage_whole(view);
}
+void view_unmap(struct roots_view *view) {
+ assert(view->wlr_surface != NULL);
+
+ wl_signal_emit(&view->events.unmap, view);
+
+ view_damage_whole(view);
+ wl_list_remove(&view->link);
+
+ wl_list_remove(&view->new_subsurface.link);
+
+ struct roots_view_child *child, *tmp;
+ wl_list_for_each_safe(child, tmp, &view->children, link) {
+ child->destroy(child);
+ }
+
+ if (view->fullscreen_output != NULL) {
+ output_damage_whole(view->fullscreen_output);
+ view->fullscreen_output->fullscreen_view = NULL;
+ view->fullscreen_output = NULL;
+ }
+
+ view->wlr_surface = NULL;
+ view->width = view->height = 0;
+}
+
void view_initial_focus(struct roots_view *view) {
struct roots_input *input = view->desktop->server->input;
// TODO what seat gets focus? the one with the last input event?
@@ -458,7 +494,10 @@ void view_initial_focus(struct roots_view *view) {
void view_setup(struct roots_view *view) {
view_initial_focus(view);
- view_center(view);
+ if (view->fullscreen_output == NULL && !view->maximized) {
+ view_center(view);
+ }
+
view_update_output(view, NULL);
}
diff --git a/rootston/output.c b/rootston/output.c
index 4d0a9c05..f772ea24 100644
--- a/rootston/output.c
+++ b/rootston/output.c
@@ -433,7 +433,8 @@ static void render_output(struct roots_output *output) {
float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f};
// Check if we can delegate the fullscreen surface to the output
- if (output->fullscreen_view != NULL) {
+ if (output->fullscreen_view != NULL &&
+ output->fullscreen_view->wlr_surface != NULL) {
struct roots_view *view = output->fullscreen_view;
// Make sure the view is centered on screen
@@ -501,7 +502,9 @@ static void render_output(struct roots_output *output) {
goto renderer_end;
}
- view_for_each_surface(view, render_surface, &data);
+ if (view->wlr_surface != NULL) {
+ view_for_each_surface(view, render_surface, &data);
+ }
// During normal rendering the xwayland window tree isn't traversed
// because all windows are rendered. Here we only want to render
@@ -570,6 +573,9 @@ void output_damage_whole(struct roots_output *output) {
static bool view_accept_damage(struct roots_output *output,
struct roots_view *view) {
+ if (view->wlr_surface == NULL) {
+ return false;
+ }
if (output->fullscreen_view == NULL) {
return true;
}
diff --git a/rootston/seat.c b/rootston/seat.c
index 8ac41f6c..d2d211ba 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -645,6 +645,7 @@ static void seat_view_destroy(struct roots_seat_view *seat_view) {
seat->cursor->pointer_view = NULL;
}
+ wl_list_remove(&seat_view->view_unmap.link);
wl_list_remove(&seat_view->view_destroy.link);
wl_list_remove(&seat_view->link);
free(seat_view);
@@ -657,6 +658,12 @@ static void seat_view_destroy(struct roots_seat_view *seat_view) {
}
}
+static void seat_view_handle_unmap(struct wl_listener *listener, void *data) {
+ struct roots_seat_view *seat_view =
+ wl_container_of(listener, seat_view, view_unmap);
+ seat_view_destroy(seat_view);
+}
+
static void seat_view_handle_destroy(struct wl_listener *listener, void *data) {
struct roots_seat_view *seat_view =
wl_container_of(listener, seat_view, view_destroy);
@@ -675,6 +682,8 @@ static struct roots_seat_view *seat_add_view(struct roots_seat *seat,
wl_list_insert(seat->views.prev, &seat_view->link);
+ seat_view->view_unmap.notify = seat_view_handle_unmap;
+ wl_signal_add(&view->events.unmap, &seat_view->view_unmap);
seat_view->view_destroy.notify = seat_view_handle_destroy;
wl_signal_add(&view->events.destroy, &seat_view->view_destroy);
diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c
index 899df1c6..d58f030a 100644
--- a/rootston/wl_shell.c
+++ b/rootston/wl_shell.c
@@ -78,6 +78,19 @@ static void close(struct roots_view *view) {
wl_client_destroy(surf->client);
}
+static void destroy(struct roots_view *view) {
+ assert(view->type == ROOTS_WL_SHELL_VIEW);
+ struct roots_wl_shell_surface *roots_surface = view->roots_wl_shell_surface;
+ wl_list_remove(&roots_surface->destroy.link);
+ wl_list_remove(&roots_surface->request_move.link);
+ wl_list_remove(&roots_surface->request_resize.link);
+ wl_list_remove(&roots_surface->request_maximize.link);
+ wl_list_remove(&roots_surface->request_fullscreen.link);
+ wl_list_remove(&roots_surface->set_state.link);
+ wl_list_remove(&roots_surface->surface_commit.link);
+ free(roots_surface);
+}
+
static void handle_request_move(struct wl_listener *listener, void *data) {
struct roots_wl_shell_surface *roots_surface =
wl_container_of(listener, roots_surface, request_move);
@@ -174,17 +187,7 @@ static void handle_new_popup(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);
- wl_list_remove(&roots_surface->destroy.link);
- wl_list_remove(&roots_surface->request_move.link);
- wl_list_remove(&roots_surface->request_resize.link);
- wl_list_remove(&roots_surface->request_maximize.link);
- wl_list_remove(&roots_surface->request_fullscreen.link);
- wl_list_remove(&roots_surface->set_state.link);
- wl_list_remove(&roots_surface->surface_commit.link);
- wl_list_remove(&roots_surface->view->link);
- view_finish(roots_surface->view);
- free(roots_surface->view);
- free(roots_surface);
+ view_destroy(roots_surface->view);
}
void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
@@ -227,7 +230,7 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
roots_surface->surface_commit.notify = handle_surface_commit;
wl_signal_add(&surface->surface->events.commit, &roots_surface->surface_commit);
- struct roots_view *view = view_create();
+ struct roots_view *view = view_create(desktop);
if (!view) {
free(roots_surface);
return;
@@ -238,13 +241,12 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
view->wl_shell_surface = surface;
view->roots_wl_shell_surface = roots_surface;
- view->wlr_surface = surface->surface;
view->resize = resize;
view->close = close;
+ view->destroy = destroy;
roots_surface->view = view;
- view_init(view, desktop);
- wl_list_insert(&desktop->views, &view->link);
+ view_map(view, surface->surface);
view_setup(view);
if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TRANSIENT) {
diff --git a/rootston/xdg_shell.c b/rootston/xdg_shell.c
index 9368ce0b..851c0045 100644
--- a/rootston/xdg_shell.c
+++ b/rootston/xdg_shell.c
@@ -60,12 +60,14 @@ static void get_size(const struct roots_view *view, struct wlr_box *box) {
assert(view->type == ROOTS_XDG_SHELL_VIEW);
struct wlr_xdg_surface *surface = view->xdg_surface;
- if (surface->geometry->width > 0 && surface->geometry->height > 0) {
- box->width = surface->geometry->width;
- box->height = surface->geometry->height;
- } else {
+ if (surface->geometry.width > 0 && surface->geometry.height > 0) {
+ box->width = surface->geometry.width;
+ box->height = surface->geometry.height;
+ } else if (view->wlr_surface != NULL) {
box->width = view->wlr_surface->current->width;
box->height = view->wlr_surface->current->height;
+ } else {
+ box->width = box->height = 0;
}
}
@@ -83,7 +85,7 @@ static void apply_size_constraints(struct wlr_xdg_surface *surface,
*dest_width = width;
*dest_height = height;
- struct wlr_xdg_toplevel_state *state = &surface->toplevel_state->current;
+ struct wlr_xdg_toplevel_state *state = &surface->toplevel->current;
if (width < state->min_width) {
*dest_width = state->min_width;
} else if (state->max_width > 0 &&
@@ -180,6 +182,21 @@ static void close(struct roots_view *view) {
}
}
+static void destroy(struct roots_view *view) {
+ assert(view->type == ROOTS_XDG_SHELL_VIEW);
+ struct roots_xdg_surface *roots_xdg_surface = view->roots_xdg_surface;
+ wl_list_remove(&roots_xdg_surface->surface_commit.link);
+ wl_list_remove(&roots_xdg_surface->destroy.link);
+ wl_list_remove(&roots_xdg_surface->new_popup.link);
+ wl_list_remove(&roots_xdg_surface->map.link);
+ wl_list_remove(&roots_xdg_surface->unmap.link);
+ wl_list_remove(&roots_xdg_surface->request_move.link);
+ wl_list_remove(&roots_xdg_surface->request_resize.link);
+ wl_list_remove(&roots_xdg_surface->request_maximize.link);
+ wl_list_remove(&roots_xdg_surface->request_fullscreen.link);
+ free(roots_xdg_surface);
+}
+
static void handle_request_move(struct wl_listener *listener, void *data) {
struct roots_xdg_surface *roots_xdg_surface =
wl_container_of(listener, roots_xdg_surface, request_move);
@@ -219,7 +236,7 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) {
return;
}
- view_maximize(view, surface->toplevel_state->next.maximized);
+ view_maximize(view, surface->toplevel->next.maximized);
}
static void handle_request_fullscreen(struct wl_listener *listener,
@@ -243,6 +260,10 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
struct roots_view *view = roots_surface->view;
struct wlr_xdg_surface *surface = view->xdg_surface;
+ if (!surface->mapped) {
+ return;
+ }
+
view_apply_damage(view);
struct wlr_box size;
@@ -277,20 +298,30 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
popup_create(roots_xdg_surface->view, wlr_popup);
}
+static void handle_map(struct wl_listener *listener, void *data) {
+ struct roots_xdg_surface *roots_xdg_surface =
+ wl_container_of(listener, roots_xdg_surface, map);
+ struct roots_view *view = roots_xdg_surface->view;
+
+ struct wlr_box box;
+ get_size(view, &box);
+ view->width = box.width;
+ view->height = box.height;
+
+ view_map(view, view->xdg_surface->surface);
+ view_setup(view);
+}
+
+static void handle_unmap(struct wl_listener *listener, void *data) {
+ struct roots_xdg_surface *roots_xdg_surface =
+ wl_container_of(listener, roots_xdg_surface, unmap);
+ view_unmap(roots_xdg_surface->view);
+}
+
static void handle_destroy(struct wl_listener *listener, void *data) {
struct roots_xdg_surface *roots_xdg_surface =
wl_container_of(listener, roots_xdg_surface, destroy);
- wl_list_remove(&roots_xdg_surface->surface_commit.link);
- wl_list_remove(&roots_xdg_surface->destroy.link);
- wl_list_remove(&roots_xdg_surface->new_popup.link);
- wl_list_remove(&roots_xdg_surface->request_move.link);
- wl_list_remove(&roots_xdg_surface->request_resize.link);
- wl_list_remove(&roots_xdg_surface->request_maximize.link);
- wl_list_remove(&roots_xdg_surface->request_fullscreen.link);
- wl_list_remove(&roots_xdg_surface->view->link);
- view_finish(roots_xdg_surface->view);
- free(roots_xdg_surface->view);
- free(roots_xdg_surface);
+ view_destroy(roots_xdg_surface->view);
}
void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
@@ -319,6 +350,10 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
&roots_surface->surface_commit);
roots_surface->destroy.notify = handle_destroy;
wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
+ roots_surface->map.notify = handle_map;
+ wl_signal_add(&surface->events.map, &roots_surface->map);
+ roots_surface->unmap.notify = handle_unmap;
+ wl_signal_add(&surface->events.unmap, &roots_surface->unmap);
roots_surface->request_move.notify = handle_request_move;
wl_signal_add(&surface->events.request_move, &roots_surface->request_move);
roots_surface->request_resize.notify = handle_request_resize;
@@ -333,7 +368,7 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
roots_surface->new_popup.notify = handle_new_popup;
wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup);
- struct roots_view *view = view_create();
+ struct roots_view *view = view_create(desktop);
if (!view) {
free(roots_surface);
return;
@@ -342,22 +377,19 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
view->xdg_surface = surface;
view->roots_xdg_surface = roots_surface;
- view->wlr_surface = surface->surface;
view->activate = activate;
view->resize = resize;
view->move_resize = move_resize;
view->maximize = maximize;
view->set_fullscreen = set_fullscreen;
view->close = close;
+ view->destroy = destroy;
roots_surface->view = view;
- struct wlr_box box;
- get_size(view, &box);
- view->width = box.width;
- view->height = box.height;
-
- view_init(view, desktop);
- wl_list_insert(&desktop->views, &view->link);
-
- view_setup(view);
+ if (surface->toplevel->next.maximized) {
+ view_maximize(view, true);
+ }
+ if (surface->toplevel->next.fullscreen) {
+ view_set_fullscreen(view, true, NULL);
+ }
}
diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c
index eda349cb..13d25331 100644
--- a/rootston/xdg_shell_v6.c
+++ b/rootston/xdg_shell_v6.c
@@ -60,12 +60,14 @@ static void get_size(const struct roots_view *view, struct wlr_box *box) {
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
- if (surface->geometry->width > 0 && surface->geometry->height > 0) {
- box->width = surface->geometry->width;
- box->height = surface->geometry->height;
- } else {
+ if (surface->geometry.width > 0 && surface->geometry.height > 0) {
+ box->width = surface->geometry.width;
+ box->height = surface->geometry.height;
+ } else if (view->wlr_surface != NULL) {
box->width = view->wlr_surface->current->width;
box->height = view->wlr_surface->current->height;
+ } else {
+ box->width = box->height = 0;
}
}
@@ -83,7 +85,7 @@ static void apply_size_constraints(struct wlr_xdg_surface_v6 *surface,
*dest_width = width;
*dest_height = height;
- struct wlr_xdg_toplevel_v6_state *state = &surface->toplevel_state->current;
+ struct wlr_xdg_toplevel_v6_state *state = &surface->toplevel->current;
if (width < state->min_width) {
*dest_width = state->min_width;
} else if (state->max_width > 0 &&
@@ -180,6 +182,21 @@ static void close(struct roots_view *view) {
}
}
+static void destroy(struct roots_view *view) {
+ assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
+ struct roots_xdg_surface_v6 *roots_xdg_surface = view->roots_xdg_surface_v6;
+ wl_list_remove(&roots_xdg_surface->surface_commit.link);
+ wl_list_remove(&roots_xdg_surface->destroy.link);
+ wl_list_remove(&roots_xdg_surface->new_popup.link);
+ wl_list_remove(&roots_xdg_surface->map.link);
+ wl_list_remove(&roots_xdg_surface->unmap.link);
+ wl_list_remove(&roots_xdg_surface->request_move.link);
+ wl_list_remove(&roots_xdg_surface->request_resize.link);
+ wl_list_remove(&roots_xdg_surface->request_maximize.link);
+ wl_list_remove(&roots_xdg_surface->request_fullscreen.link);
+ free(roots_xdg_surface);
+}
+
static void handle_request_move(struct wl_listener *listener, void *data) {
struct roots_xdg_surface_v6 *roots_xdg_surface =
wl_container_of(listener, roots_xdg_surface, request_move);
@@ -219,7 +236,7 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) {
return;
}
- view_maximize(view, surface->toplevel_state->next.maximized);
+ view_maximize(view, surface->toplevel->next.maximized);
}
static void handle_request_fullscreen(struct wl_listener *listener,
@@ -243,6 +260,10 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
struct roots_view *view = roots_surface->view;
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
+ if (!surface->mapped) {
+ return;
+ }
+
view_apply_damage(view);
struct wlr_box size;
@@ -277,20 +298,30 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
popup_create(roots_xdg_surface->view, wlr_popup);
}
+static void handle_map(struct wl_listener *listener, void *data) {
+ struct roots_xdg_surface_v6 *roots_xdg_surface =
+ wl_container_of(listener, roots_xdg_surface, map);
+ struct roots_view *view = roots_xdg_surface->view;
+
+ struct wlr_box box;
+ get_size(view, &box);
+ view->width = box.width;
+ view->height = box.height;
+
+ view_map(view, view->xdg_surface_v6->surface);
+ view_setup(view);
+}
+
+static void handle_unmap(struct wl_listener *listener, void *data) {
+ struct roots_xdg_surface_v6 *roots_xdg_surface =
+ wl_container_of(listener, roots_xdg_surface, unmap);
+ view_unmap(roots_xdg_surface->view);
+}
+
static void handle_destroy(struct wl_listener *listener, void *data) {
struct roots_xdg_surface_v6 *roots_xdg_surface =
wl_container_of(listener, roots_xdg_surface, destroy);
- wl_list_remove(&roots_xdg_surface->surface_commit.link);
- wl_list_remove(&roots_xdg_surface->destroy.link);
- wl_list_remove(&roots_xdg_surface->new_popup.link);
- wl_list_remove(&roots_xdg_surface->request_move.link);
- wl_list_remove(&roots_xdg_surface->request_resize.link);
- wl_list_remove(&roots_xdg_surface->request_maximize.link);
- wl_list_remove(&roots_xdg_surface->request_fullscreen.link);
- wl_list_remove(&roots_xdg_surface->view->link);
- view_finish(roots_xdg_surface->view);
- free(roots_xdg_surface->view);
- free(roots_xdg_surface);
+ view_destroy(roots_xdg_surface->view);
}
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
@@ -319,6 +350,10 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
&roots_surface->surface_commit);
roots_surface->destroy.notify = handle_destroy;
wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
+ roots_surface->map.notify = handle_map;
+ wl_signal_add(&surface->events.map, &roots_surface->map);
+ roots_surface->unmap.notify = handle_unmap;
+ wl_signal_add(&surface->events.unmap, &roots_surface->unmap);
roots_surface->request_move.notify = handle_request_move;
wl_signal_add(&surface->events.request_move, &roots_surface->request_move);
roots_surface->request_resize.notify = handle_request_resize;
@@ -333,7 +368,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
roots_surface->new_popup.notify = handle_new_popup;
wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup);
- struct roots_view *view = view_create();
+ struct roots_view *view = view_create(desktop);
if (!view) {
free(roots_surface);
return;
@@ -342,22 +377,19 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
view->xdg_surface_v6 = surface;
view->roots_xdg_surface_v6 = roots_surface;
- view->wlr_surface = surface->surface;
view->activate = activate;
view->resize = resize;
view->move_resize = move_resize;
view->maximize = maximize;
view->set_fullscreen = set_fullscreen;
view->close = close;
+ view->destroy = destroy;
roots_surface->view = view;
- struct wlr_box box;
- get_size(view, &box);
- view->width = box.width;
- view->height = box.height;
-
- view_init(view, desktop);
- wl_list_insert(&desktop->views, &view->link);
-
- view_setup(view);
+ if (surface->toplevel->next.maximized) {
+ view_maximize(view, true);
+ }
+ if (surface->toplevel->next.fullscreen) {
+ view_set_fullscreen(view, true, NULL);
+ }
}
diff --git a/rootston/xwayland.c b/rootston/xwayland.c
index 56f068ea..53331b1f 100644
--- a/rootston/xwayland.c
+++ b/rootston/xwayland.c
@@ -106,11 +106,9 @@ static void set_fullscreen(struct roots_view *view, bool fullscreen) {
wlr_xwayland_surface_set_fullscreen(view->xwayland_surface, fullscreen);
}
-static void handle_destroy(struct wl_listener *listener, void *data) {
- struct roots_xwayland_surface *roots_surface =
- wl_container_of(listener, roots_surface, destroy);
- struct wlr_xwayland_surface *xwayland_surface =
- roots_surface->view->xwayland_surface;
+static void destroy(struct roots_view *view) {
+ assert(view->type == ROOTS_XWAYLAND_VIEW);
+ struct roots_xwayland_surface *roots_surface = view->roots_xwayland_surface;
wl_list_remove(&roots_surface->destroy.link);
wl_list_remove(&roots_surface->request_configure.link);
wl_list_remove(&roots_surface->request_move.link);
@@ -118,14 +116,15 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
wl_list_remove(&roots_surface->request_maximize.link);
wl_list_remove(&roots_surface->map_notify.link);
wl_list_remove(&roots_surface->unmap_notify.link);
- if (xwayland_surface->mapped) {
- wl_list_remove(&roots_surface->view->link);
- }
- view_finish(roots_surface->view);
- free(roots_surface->view);
free(roots_surface);
}
+static void handle_destroy(struct wl_listener *listener, void *data) {
+ struct roots_xwayland_surface *roots_surface =
+ wl_container_of(listener, roots_surface, destroy);
+ view_destroy(roots_surface->view);
+}
+
static void handle_request_configure(struct wl_listener *listener, void *data) {
struct roots_xwayland_surface *roots_surface =
wl_container_of(listener, roots_surface, request_configure);
@@ -231,22 +230,13 @@ static void handle_map_notify(struct wl_listener *listener, void *data) {
wl_container_of(listener, roots_surface, map_notify);
struct wlr_xwayland_surface *xsurface = data;
struct roots_view *view = roots_surface->view;
- struct roots_desktop *desktop = view->desktop;
- view->wlr_surface = xsurface->surface;
view->x = xsurface->x;
view->y = xsurface->y;
view->width = xsurface->surface->current->width;
view->height = xsurface->surface->current->height;
- wl_list_insert(&desktop->views, &view->link);
- struct wlr_subsurface *subsurface;
- wl_list_for_each(subsurface, &view->wlr_surface->subsurface_list,
- parent_link) {
- subsurface_create(view, subsurface);
- }
-
- view_damage_whole(view);
+ view_map(view, xsurface->surface);
roots_surface->surface_commit.notify = handle_surface_commit;
wl_signal_add(&xsurface->surface->events.commit,
@@ -260,22 +250,7 @@ static void handle_unmap_notify(struct wl_listener *listener, void *data) {
wl_list_remove(&roots_surface->surface_commit.link);
- view_damage_whole(view);
-
- struct roots_view_child *child, *tmp;
- wl_list_for_each_safe(child, tmp, &view->children, link) {
- child->destroy(child);
- }
-
- if (view->fullscreen_output != NULL) {
- output_damage_whole(view->fullscreen_output);
- view->fullscreen_output->fullscreen_view = NULL;
- view->fullscreen_output = NULL;
- }
-
- view->wlr_surface = NULL;
- view->width = view->height = 0;
- wl_list_remove(&view->link);
+ view_unmap(view);
}
void handle_xwayland_surface(struct wl_listener *listener, void *data) {
@@ -317,7 +292,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
wl_signal_add(&surface->surface->events.commit,
&roots_surface->surface_commit);
- struct roots_view *view = view_create();
+ struct roots_view *view = view_create(desktop);
if (view == NULL) {
free(roots_surface);
return;
@@ -330,7 +305,6 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
view->xwayland_surface = surface;
view->roots_xwayland_surface = roots_surface;
- view->wlr_surface = surface->surface;
view->activate = activate;
view->resize = resize;
view->move = move;
@@ -338,9 +312,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
view->maximize = maximize;
view->set_fullscreen = set_fullscreen;
view->close = close;
+ view->destroy = destroy;
roots_surface->view = view;
- view_init(view, desktop);
- wl_list_insert(&desktop->views, &view->link);
+
+ view_map(view, surface->surface);
if (!surface->override_redirect) {
if (surface->decorations == WLR_XWAYLAND_SURFACE_DECORATIONS_ALL) {