rootston: add view_map and view_unmap
This commit is contained in:
parent
bfc0e95d2c
commit
c27fd1e1ee
|
@ -71,14 +71,16 @@ struct roots_output *desktop_output_from_wlr_output(
|
||||||
struct roots_view *desktop_view_at(struct roots_desktop *desktop, double lx,
|
struct roots_view *desktop_view_at(struct roots_desktop *desktop, double lx,
|
||||||
double ly, struct wlr_surface **surface, double *sx, double *sy);
|
double ly, struct wlr_surface **surface, double *sx, double *sy);
|
||||||
|
|
||||||
void view_init(struct roots_view *view, struct roots_desktop *desktop);
|
struct roots_view *view_create(struct roots_desktop *desktop);
|
||||||
void view_finish(struct roots_view *view);
|
void view_destroy(struct roots_view *view);
|
||||||
void view_activate(struct roots_view *view, bool activate);
|
void view_activate(struct roots_view *view, bool activate);
|
||||||
void view_apply_damage(struct roots_view *view);
|
void view_apply_damage(struct roots_view *view);
|
||||||
void view_damage_whole(struct roots_view *view);
|
void view_damage_whole(struct roots_view *view);
|
||||||
void view_update_position(struct roots_view *view, double x, double y);
|
void view_update_position(struct roots_view *view, double x, double y);
|
||||||
void view_update_size(struct roots_view *view, uint32_t width, uint32_t height);
|
void view_update_size(struct roots_view *view, uint32_t width, uint32_t height);
|
||||||
void view_initial_focus(struct roots_view *view);
|
void view_initial_focus(struct roots_view *view);
|
||||||
|
void view_map(struct roots_view *view, struct wlr_surface *surface);
|
||||||
|
void view_unmap(struct roots_view *view);
|
||||||
|
|
||||||
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
|
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
|
||||||
void handle_xdg_shell_surface(struct wl_listener *listener, void *data);
|
void handle_xdg_shell_surface(struct wl_listener *listener, void *data);
|
||||||
|
|
|
@ -181,7 +181,6 @@ struct roots_xdg_popup {
|
||||||
struct wl_listener new_popup;
|
struct wl_listener new_popup;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct roots_view *view_create();
|
|
||||||
void view_get_box(const struct roots_view *view, struct wlr_box *box);
|
void view_get_box(const struct roots_view *view, struct wlr_box *box);
|
||||||
void view_activate(struct roots_view *view, bool active);
|
void view_activate(struct roots_view *view, bool active);
|
||||||
void view_move(struct roots_view *view, double x, double y);
|
void view_move(struct roots_view *view, double x, double y);
|
||||||
|
|
|
@ -23,13 +23,15 @@
|
||||||
#include "rootston/view.h"
|
#include "rootston/view.h"
|
||||||
#include "rootston/xcursor.h"
|
#include "rootston/xcursor.h"
|
||||||
|
|
||||||
|
struct roots_view *view_create(struct roots_desktop *desktop) {
|
||||||
struct roots_view *view_create() {
|
|
||||||
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
||||||
if (!view) {
|
if (!view) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
view->desktop = desktop;
|
||||||
view->alpha = 1.0f;
|
view->alpha = 1.0f;
|
||||||
|
wl_signal_init(&view->events.destroy);
|
||||||
|
wl_list_init(&view->children);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,20 +404,18 @@ struct roots_subsurface *subsurface_create(struct roots_view *view,
|
||||||
return subsurface;
|
return subsurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_finish(struct roots_view *view) {
|
void view_destroy(struct roots_view *view) {
|
||||||
view_damage_whole(view);
|
if (view == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view->wlr_surface != NULL) {
|
||||||
|
view_unmap(view);
|
||||||
|
}
|
||||||
|
|
||||||
wl_signal_emit(&view->events.destroy, view);
|
wl_signal_emit(&view->events.destroy, view);
|
||||||
|
|
||||||
wl_list_remove(&view->new_subsurface.link);
|
free(view);
|
||||||
|
|
||||||
struct roots_view_child *child, *tmp;
|
|
||||||
wl_list_for_each_safe(child, tmp, &view->children, link) {
|
|
||||||
child->destroy(child);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (view->fullscreen_output) {
|
|
||||||
view->fullscreen_output->fullscreen_view = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void view_handle_new_subsurface(struct wl_listener *listener,
|
static void view_handle_new_subsurface(struct wl_listener *listener,
|
||||||
|
@ -425,12 +425,10 @@ static void view_handle_new_subsurface(struct wl_listener *listener,
|
||||||
subsurface_create(view, wlr_subsurface);
|
subsurface_create(view, wlr_subsurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_init(struct roots_view *view, struct roots_desktop *desktop) {
|
void view_map(struct roots_view *view, struct wlr_surface *surface) {
|
||||||
assert(view->wlr_surface);
|
assert(view->wlr_surface == NULL);
|
||||||
|
|
||||||
view->desktop = desktop;
|
view->wlr_surface = surface;
|
||||||
wl_signal_init(&view->events.destroy);
|
|
||||||
wl_list_init(&view->children);
|
|
||||||
|
|
||||||
struct wlr_subsurface *subsurface;
|
struct wlr_subsurface *subsurface;
|
||||||
wl_list_for_each(subsurface, &view->wlr_surface->subsurface_list,
|
wl_list_for_each(subsurface, &view->wlr_surface->subsurface_list,
|
||||||
|
@ -442,9 +440,33 @@ void view_init(struct roots_view *view, struct roots_desktop *desktop) {
|
||||||
wl_signal_add(&view->wlr_surface->events.new_subsurface,
|
wl_signal_add(&view->wlr_surface->events.new_subsurface,
|
||||||
&view->new_subsurface);
|
&view->new_subsurface);
|
||||||
|
|
||||||
|
wl_list_insert(&view->desktop->views, &view->link);
|
||||||
view_damage_whole(view);
|
view_damage_whole(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void view_unmap(struct roots_view *view) {
|
||||||
|
assert(view->wlr_surface != NULL);
|
||||||
|
|
||||||
|
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) {
|
void view_initial_focus(struct roots_view *view) {
|
||||||
struct roots_input *input = view->desktop->server->input;
|
struct roots_input *input = view->desktop->server->input;
|
||||||
// TODO what seat gets focus? the one with the last input event?
|
// TODO what seat gets focus? the one with the last input event?
|
||||||
|
|
|
@ -181,9 +181,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
wl_list_remove(&roots_surface->request_fullscreen.link);
|
wl_list_remove(&roots_surface->request_fullscreen.link);
|
||||||
wl_list_remove(&roots_surface->set_state.link);
|
wl_list_remove(&roots_surface->set_state.link);
|
||||||
wl_list_remove(&roots_surface->surface_commit.link);
|
wl_list_remove(&roots_surface->surface_commit.link);
|
||||||
wl_list_remove(&roots_surface->view->link);
|
view_destroy(roots_surface->view);
|
||||||
view_finish(roots_surface->view);
|
|
||||||
free(roots_surface->view);
|
|
||||||
free(roots_surface);
|
free(roots_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +225,7 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
roots_surface->surface_commit.notify = handle_surface_commit;
|
roots_surface->surface_commit.notify = handle_surface_commit;
|
||||||
wl_signal_add(&surface->surface->events.commit, &roots_surface->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) {
|
if (!view) {
|
||||||
free(roots_surface);
|
free(roots_surface);
|
||||||
return;
|
return;
|
||||||
|
@ -238,13 +236,11 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
view->wl_shell_surface = surface;
|
view->wl_shell_surface = surface;
|
||||||
view->roots_wl_shell_surface = roots_surface;
|
view->roots_wl_shell_surface = roots_surface;
|
||||||
view->wlr_surface = surface->surface;
|
|
||||||
view->resize = resize;
|
view->resize = resize;
|
||||||
view->close = close;
|
view->close = close;
|
||||||
roots_surface->view = view;
|
roots_surface->view = view;
|
||||||
view_init(view, desktop);
|
|
||||||
wl_list_insert(&desktop->views, &view->link);
|
|
||||||
|
|
||||||
|
view_map(view, surface->surface);
|
||||||
view_setup(view);
|
view_setup(view);
|
||||||
|
|
||||||
if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TRANSIENT) {
|
if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TRANSIENT) {
|
||||||
|
|
|
@ -287,9 +287,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
wl_list_remove(&roots_xdg_surface->request_resize.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_maximize.link);
|
||||||
wl_list_remove(&roots_xdg_surface->request_fullscreen.link);
|
wl_list_remove(&roots_xdg_surface->request_fullscreen.link);
|
||||||
wl_list_remove(&roots_xdg_surface->view->link);
|
view_destroy(roots_xdg_surface->view);
|
||||||
view_finish(roots_xdg_surface->view);
|
|
||||||
free(roots_xdg_surface->view);
|
|
||||||
free(roots_xdg_surface);
|
free(roots_xdg_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +331,7 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
roots_surface->new_popup.notify = handle_new_popup;
|
roots_surface->new_popup.notify = handle_new_popup;
|
||||||
wl_signal_add(&surface->events.new_popup, &roots_surface->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) {
|
if (!view) {
|
||||||
free(roots_surface);
|
free(roots_surface);
|
||||||
return;
|
return;
|
||||||
|
@ -342,7 +340,6 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
view->xdg_surface = surface;
|
view->xdg_surface = surface;
|
||||||
view->roots_xdg_surface = roots_surface;
|
view->roots_xdg_surface = roots_surface;
|
||||||
view->wlr_surface = surface->surface;
|
|
||||||
view->activate = activate;
|
view->activate = activate;
|
||||||
view->resize = resize;
|
view->resize = resize;
|
||||||
view->move_resize = move_resize;
|
view->move_resize = move_resize;
|
||||||
|
@ -356,8 +353,6 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
view->width = box.width;
|
view->width = box.width;
|
||||||
view->height = box.height;
|
view->height = box.height;
|
||||||
|
|
||||||
view_init(view, desktop);
|
view_map(view, surface->surface);
|
||||||
wl_list_insert(&desktop->views, &view->link);
|
|
||||||
|
|
||||||
view_setup(view);
|
view_setup(view);
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,9 +287,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
wl_list_remove(&roots_xdg_surface->request_resize.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_maximize.link);
|
||||||
wl_list_remove(&roots_xdg_surface->request_fullscreen.link);
|
wl_list_remove(&roots_xdg_surface->request_fullscreen.link);
|
||||||
wl_list_remove(&roots_xdg_surface->view->link);
|
view_destroy(roots_xdg_surface->view);
|
||||||
view_finish(roots_xdg_surface->view);
|
|
||||||
free(roots_xdg_surface->view);
|
|
||||||
free(roots_xdg_surface);
|
free(roots_xdg_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +331,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
roots_surface->new_popup.notify = handle_new_popup;
|
roots_surface->new_popup.notify = handle_new_popup;
|
||||||
wl_signal_add(&surface->events.new_popup, &roots_surface->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) {
|
if (!view) {
|
||||||
free(roots_surface);
|
free(roots_surface);
|
||||||
return;
|
return;
|
||||||
|
@ -342,7 +340,6 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
view->xdg_surface_v6 = surface;
|
view->xdg_surface_v6 = surface;
|
||||||
view->roots_xdg_surface_v6 = roots_surface;
|
view->roots_xdg_surface_v6 = roots_surface;
|
||||||
view->wlr_surface = surface->surface;
|
|
||||||
view->activate = activate;
|
view->activate = activate;
|
||||||
view->resize = resize;
|
view->resize = resize;
|
||||||
view->move_resize = move_resize;
|
view->move_resize = move_resize;
|
||||||
|
@ -356,8 +353,6 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
view->width = box.width;
|
view->width = box.width;
|
||||||
view->height = box.height;
|
view->height = box.height;
|
||||||
|
|
||||||
view_init(view, desktop);
|
view_map(view, surface->surface);
|
||||||
wl_list_insert(&desktop->views, &view->link);
|
|
||||||
|
|
||||||
view_setup(view);
|
view_setup(view);
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,8 +109,6 @@ static void set_fullscreen(struct roots_view *view, bool fullscreen) {
|
||||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xwayland_surface *roots_surface =
|
struct roots_xwayland_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, destroy);
|
wl_container_of(listener, roots_surface, destroy);
|
||||||
struct wlr_xwayland_surface *xwayland_surface =
|
|
||||||
roots_surface->view->xwayland_surface;
|
|
||||||
wl_list_remove(&roots_surface->destroy.link);
|
wl_list_remove(&roots_surface->destroy.link);
|
||||||
wl_list_remove(&roots_surface->request_configure.link);
|
wl_list_remove(&roots_surface->request_configure.link);
|
||||||
wl_list_remove(&roots_surface->request_move.link);
|
wl_list_remove(&roots_surface->request_move.link);
|
||||||
|
@ -118,11 +116,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
wl_list_remove(&roots_surface->request_maximize.link);
|
wl_list_remove(&roots_surface->request_maximize.link);
|
||||||
wl_list_remove(&roots_surface->map_notify.link);
|
wl_list_remove(&roots_surface->map_notify.link);
|
||||||
wl_list_remove(&roots_surface->unmap_notify.link);
|
wl_list_remove(&roots_surface->unmap_notify.link);
|
||||||
if (xwayland_surface->mapped) {
|
view_destroy(roots_surface->view);
|
||||||
wl_list_remove(&roots_surface->view->link);
|
|
||||||
}
|
|
||||||
view_finish(roots_surface->view);
|
|
||||||
free(roots_surface->view);
|
|
||||||
free(roots_surface);
|
free(roots_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,22 +225,13 @@ static void handle_map_notify(struct wl_listener *listener, void *data) {
|
||||||
wl_container_of(listener, roots_surface, map_notify);
|
wl_container_of(listener, roots_surface, map_notify);
|
||||||
struct wlr_xwayland_surface *xsurface = data;
|
struct wlr_xwayland_surface *xsurface = data;
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = roots_surface->view;
|
||||||
struct roots_desktop *desktop = view->desktop;
|
|
||||||
|
|
||||||
view->wlr_surface = xsurface->surface;
|
|
||||||
view->x = xsurface->x;
|
view->x = xsurface->x;
|
||||||
view->y = xsurface->y;
|
view->y = xsurface->y;
|
||||||
view->width = xsurface->surface->current->width;
|
view->width = xsurface->surface->current->width;
|
||||||
view->height = xsurface->surface->current->height;
|
view->height = xsurface->surface->current->height;
|
||||||
wl_list_insert(&desktop->views, &view->link);
|
|
||||||
|
|
||||||
struct wlr_subsurface *subsurface;
|
view_map(view, xsurface->surface);
|
||||||
wl_list_for_each(subsurface, &view->wlr_surface->subsurface_list,
|
|
||||||
parent_link) {
|
|
||||||
subsurface_create(view, subsurface);
|
|
||||||
}
|
|
||||||
|
|
||||||
view_damage_whole(view);
|
|
||||||
|
|
||||||
roots_surface->surface_commit.notify = handle_surface_commit;
|
roots_surface->surface_commit.notify = handle_surface_commit;
|
||||||
wl_signal_add(&xsurface->surface->events.commit,
|
wl_signal_add(&xsurface->surface->events.commit,
|
||||||
|
@ -260,22 +245,7 @@ static void handle_unmap_notify(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
wl_list_remove(&roots_surface->surface_commit.link);
|
wl_list_remove(&roots_surface->surface_commit.link);
|
||||||
|
|
||||||
view_damage_whole(view);
|
view_unmap(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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
||||||
|
@ -317,7 +287,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
||||||
wl_signal_add(&surface->surface->events.commit,
|
wl_signal_add(&surface->surface->events.commit,
|
||||||
&roots_surface->surface_commit);
|
&roots_surface->surface_commit);
|
||||||
|
|
||||||
struct roots_view *view = view_create();
|
struct roots_view *view = view_create(desktop);
|
||||||
if (view == NULL) {
|
if (view == NULL) {
|
||||||
free(roots_surface);
|
free(roots_surface);
|
||||||
return;
|
return;
|
||||||
|
@ -330,7 +300,6 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
view->xwayland_surface = surface;
|
view->xwayland_surface = surface;
|
||||||
view->roots_xwayland_surface = roots_surface;
|
view->roots_xwayland_surface = roots_surface;
|
||||||
view->wlr_surface = surface->surface;
|
|
||||||
view->activate = activate;
|
view->activate = activate;
|
||||||
view->resize = resize;
|
view->resize = resize;
|
||||||
view->move = move;
|
view->move = move;
|
||||||
|
@ -339,8 +308,8 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
||||||
view->set_fullscreen = set_fullscreen;
|
view->set_fullscreen = set_fullscreen;
|
||||||
view->close = close;
|
view->close = close;
|
||||||
roots_surface->view = view;
|
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->override_redirect) {
|
||||||
if (surface->decorations == WLR_XWAYLAND_SURFACE_DECORATIONS_ALL) {
|
if (surface->decorations == WLR_XWAYLAND_SURFACE_DECORATIONS_ALL) {
|
||||||
|
|
Loading…
Reference in New Issue