aboutsummaryrefslogtreecommitdiff
path: root/rootston/wl_shell.c
diff options
context:
space:
mode:
Diffstat (limited to 'rootston/wl_shell.c')
-rw-r--r--rootston/wl_shell.c92
1 files changed, 85 insertions, 7 deletions
diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c
index 65067920..267e2cf5 100644
--- a/rootston/wl_shell.c
+++ b/rootston/wl_shell.c
@@ -10,6 +10,61 @@
#include "rootston/server.h"
#include "rootston/input.h"
+static void popup_destroy(struct roots_view_child *child) {
+ assert(child->destroy == popup_destroy);
+ struct roots_wl_shell_popup *popup = (struct roots_wl_shell_popup *)child;
+ if (popup == NULL) {
+ return;
+ }
+ wl_list_remove(&popup->destroy.link);
+ wl_list_remove(&popup->set_state.link);
+ wl_list_remove(&popup->new_popup.link);
+ view_child_finish(&popup->view_child);
+ free(popup);
+}
+
+static void popup_handle_destroy(struct wl_listener *listener, void *data) {
+ struct roots_wl_shell_popup *popup =
+ wl_container_of(listener, popup, destroy);
+ popup_destroy((struct roots_view_child *)popup);
+}
+
+static void popup_handle_set_state(struct wl_listener *listener, void *data) {
+ struct roots_wl_shell_popup *popup =
+ wl_container_of(listener, popup, set_state);
+ popup_destroy((struct roots_view_child *)popup);
+}
+
+static struct roots_wl_shell_popup *popup_create(struct roots_view *view,
+ struct wlr_wl_shell_surface *wlr_wl_shell_surface);
+
+static void popup_handle_new_popup(struct wl_listener *listener, void *data) {
+ struct roots_wl_shell_popup *popup =
+ wl_container_of(listener, popup, new_popup);
+ struct wlr_wl_shell_surface *wlr_wl_shell_surface = data;
+ popup_create(popup->view_child.view, wlr_wl_shell_surface);
+}
+
+static struct roots_wl_shell_popup *popup_create(struct roots_view *view,
+ struct wlr_wl_shell_surface *wlr_wl_shell_surface) {
+ struct roots_wl_shell_popup *popup =
+ calloc(1, sizeof(struct roots_wl_shell_popup));
+ if (popup == NULL) {
+ return NULL;
+ }
+ popup->wlr_wl_shell_surface = wlr_wl_shell_surface;
+ popup->view_child.destroy = popup_destroy;
+ view_child_init(&popup->view_child, view, wlr_wl_shell_surface->surface);
+ popup->destroy.notify = popup_handle_destroy;
+ wl_signal_add(&wlr_wl_shell_surface->events.destroy, &popup->destroy);
+ popup->set_state.notify = popup_handle_set_state;
+ wl_signal_add(&wlr_wl_shell_surface->events.set_state, &popup->set_state);
+ popup->new_popup.notify = popup_handle_new_popup;
+ wl_signal_add(&wlr_wl_shell_surface->events.new_popup, &popup->new_popup);
+ return popup;
+}
+
+
static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
assert(view->type == ROOTS_WL_SHELL_VIEW);
struct wlr_wl_shell_surface *surf = view->wl_shell_surface;
@@ -88,19 +143,32 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
struct roots_view *view = roots_surface->view;
struct wlr_surface *wlr_surface = view->wlr_surface;
+ view_apply_damage(view);
+
int width = wlr_surface->current->width;
int height = wlr_surface->current->height;
+ view_update_size(view, width, height);
+ double x = view->x;
+ double y = view->y;
if (view->pending_move_resize.update_x) {
- view->x = view->pending_move_resize.x +
- view->pending_move_resize.width - width;
+ x = view->pending_move_resize.x + view->pending_move_resize.width -
+ width;
view->pending_move_resize.update_x = false;
}
if (view->pending_move_resize.update_y) {
- view->y = view->pending_move_resize.y +
- view->pending_move_resize.height - height;
+ y = view->pending_move_resize.y + view->pending_move_resize.height -
+ height;
view->pending_move_resize.update_y = false;
}
+ view_update_position(view, x, y);
+}
+
+static void handle_new_popup(struct wl_listener *listener, void *data) {
+ struct roots_wl_shell_surface *roots_surface =
+ wl_container_of(listener, roots_surface, new_popup);
+ struct wlr_wl_shell_surface *wlr_wl_shell_surface = data;
+ popup_create(roots_surface->view, wlr_wl_shell_surface);
}
static void handle_destroy(struct wl_listener *listener, void *data) {
@@ -114,16 +182,22 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
wl_list_remove(&roots_surface->set_state.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);
}
void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
struct roots_desktop *desktop =
wl_container_of(listener, desktop, wl_shell_surface);
-
struct wlr_wl_shell_surface *surface = data;
- wlr_log(L_DEBUG, "new shell surface: title=%s, class=%s",
+
+ if (surface->state == WLR_WL_SHELL_SURFACE_STATE_POPUP) {
+ wlr_log(L_DEBUG, "new wl shell popup");
+ return;
+ }
+
+ wlr_log(L_DEBUG, "new wl shell surface: title=%s, class=%s",
surface->title, surface->class);
wlr_wl_shell_surface_ping(surface);
@@ -134,6 +208,8 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
}
roots_surface->destroy.notify = handle_destroy;
wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
+ roots_surface->new_popup.notify = handle_new_popup;
+ wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup);
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;
@@ -157,6 +233,8 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
return;
}
view->type = ROOTS_WL_SHELL_VIEW;
+ view->width = surface->surface->current->width;
+ view->height = surface->surface->current->height;
view->wl_shell_surface = surface;
view->roots_wl_shell_surface = roots_surface;