aboutsummaryrefslogtreecommitdiff
path: root/rootston/xdg_shell_v6.c
diff options
context:
space:
mode:
Diffstat (limited to 'rootston/xdg_shell_v6.c')
-rw-r--r--rootston/xdg_shell_v6.c39
1 files changed, 35 insertions, 4 deletions
diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c
index ab34f52a..9b8d8882 100644
--- a/rootston/xdg_shell_v6.c
+++ b/rootston/xdg_shell_v6.c
@@ -33,6 +33,14 @@ static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
}
}
+static void close(struct roots_view *view) {
+ assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
+ struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
+ if (surf->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
+ wlr_xdg_toplevel_v6_send_close(surf);
+ }
+}
+
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);
@@ -59,6 +67,17 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
view_begin_resize(input, event->cursor, view, e->edges);
}
+static void handle_commit(struct wl_listener *listener, void *data) {
+ struct roots_xdg_surface_v6 *roots_xdg_surface =
+ wl_container_of(listener, roots_xdg_surface, commit);
+ struct roots_view *view = roots_xdg_surface->view;
+
+ if (view->xdg_surface_v6->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL &&
+ !roots_xdg_surface->initialized) {
+ roots_xdg_surface->initialized = view_initialize(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);
@@ -73,17 +92,29 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
}
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
+ struct wlr_xdg_surface_v6 *surface = data;
+ assert(surface->role != WLR_XDG_SURFACE_V6_ROLE_NONE);
+
+ if (surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP) {
+ wlr_log(L_DEBUG, "new xdg popup");
+ return;
+ }
+
struct roots_desktop *desktop =
wl_container_of(listener, desktop, xdg_shell_v6_surface);
- struct wlr_xdg_surface_v6 *surface = data;
- wlr_log(L_DEBUG, "new xdg surface: title=%s, app_id=%s",
+ wlr_log(L_DEBUG, "new xdg toplevel: title=%s, app_id=%s",
surface->title, surface->app_id);
wlr_xdg_surface_v6_ping(surface);
struct roots_xdg_surface_v6 *roots_surface =
calloc(1, sizeof(struct roots_xdg_surface_v6));
- // TODO: all of the trimmings
+ if (!roots_surface) {
+ return;
+ }
+ wl_list_init(&roots_surface->commit.link);
+ roots_surface->commit.notify = handle_commit;
+ wl_signal_add(&surface->events.commit, &roots_surface->commit);
wl_list_init(&roots_surface->destroy.link);
roots_surface->destroy.notify = handle_destroy;
wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
@@ -100,13 +131,13 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
struct roots_view *view = calloc(1, sizeof(struct roots_view));
view->type = ROOTS_XDG_SHELL_V6_VIEW;
- view->x = view->y = 200;
view->xdg_surface_v6 = surface;
view->roots_xdg_surface_v6 = roots_surface;
view->wlr_surface = surface->surface;
view->get_size = get_size;
view->activate = activate;
view->resize = resize;
+ view->close = close;
view->desktop = desktop;
roots_surface->view = view;
list_add(desktop->views, view);