summaryrefslogtreecommitdiffstats
path: root/sway/desktop/wl_shell.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/desktop/wl_shell.c')
-rw-r--r--sway/desktop/wl_shell.c61
1 files changed, 21 insertions, 40 deletions
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c
index c44fcf27..6528a397 100644
--- a/sway/desktop/wl_shell.c
+++ b/sway/desktop/wl_shell.c
@@ -30,28 +30,18 @@ static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) {
30 } 30 }
31} 31}
32 32
33static void set_size(struct sway_view *view, int width, int height) { 33static void configure(struct sway_view *view, double ox, double oy, int width,
34 int height) {
34 if (!assert_wl_shell(view)) { 35 if (!assert_wl_shell(view)) {
35 return; 36 return;
36 } 37 }
38 view_update_position(view, ox, oy);
37 view->sway_wl_shell_surface->pending_width = width; 39 view->sway_wl_shell_surface->pending_width = width;
38 view->sway_wl_shell_surface->pending_height = height; 40 view->sway_wl_shell_surface->pending_height = height;
39 wlr_wl_shell_surface_configure(view->wlr_wl_shell_surface, 0, width, height); 41 wlr_wl_shell_surface_configure(view->wlr_wl_shell_surface, 0, width, height);
40} 42}
41 43
42static void set_position(struct sway_view *view, double ox, double oy) { 44static void _close(struct sway_view *view) {
43 if (!assert_wl_shell(view)) {
44 return;
45 }
46 view->swayc->x = ox;
47 view->swayc->y = oy;
48}
49
50static void set_activated(struct sway_view *view, bool activated) {
51 // no way to activate wl_shell
52}
53
54static void close(struct sway_view *view) {
55 if (!assert_wl_shell(view)) { 45 if (!assert_wl_shell(view)) {
56 return; 46 return;
57 } 47 }
@@ -59,14 +49,20 @@ static void close(struct sway_view *view) {
59 wl_client_destroy(view->wlr_wl_shell_surface->client); 49 wl_client_destroy(view->wlr_wl_shell_surface->client);
60} 50}
61 51
52static const struct sway_view_impl view_impl = {
53 .get_prop = get_prop,
54 .configure = configure,
55 .close = _close,
56};
57
62static void handle_commit(struct wl_listener *listener, void *data) { 58static void handle_commit(struct wl_listener *listener, void *data) {
63 struct sway_wl_shell_surface *sway_surface = 59 struct sway_wl_shell_surface *sway_surface =
64 wl_container_of(listener, sway_surface, commit); 60 wl_container_of(listener, sway_surface, commit);
65 struct sway_view *view = sway_surface->view; 61 struct sway_view *view = sway_surface->view;
66 // NOTE: We intentionally discard the view's desired width here 62 // NOTE: We intentionally discard the view's desired width here
67 // TODO: Let floating views do whatever 63 // TODO: Let floating views do whatever
68 view->width = sway_surface->pending_width; 64 view_update_size(view, sway_surface->pending_width,
69 view->height = sway_surface->pending_height; 65 sway_surface->pending_height);
70 view_damage_from(view); 66 view_damage_from(view);
71} 67}
72 68
@@ -75,15 +71,13 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
75 wl_container_of(listener, sway_surface, destroy); 71 wl_container_of(listener, sway_surface, destroy);
76 wl_list_remove(&sway_surface->commit.link); 72 wl_list_remove(&sway_surface->commit.link);
77 wl_list_remove(&sway_surface->destroy.link); 73 wl_list_remove(&sway_surface->destroy.link);
78 struct sway_container *parent = container_view_destroy(sway_surface->view->swayc); 74 view_destroy(sway_surface->view);
79 free(sway_surface->view);
80 free(sway_surface); 75 free(sway_surface);
81 arrange_windows(parent, -1, -1);
82} 76}
83 77
84void handle_wl_shell_surface(struct wl_listener *listener, void *data) { 78void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
85 struct sway_server *server = wl_container_of( 79 struct sway_server *server = wl_container_of(listener, server,
86 listener, server, wl_shell_surface); 80 wl_shell_surface);
87 struct wlr_wl_shell_surface *shell_surface = data; 81 struct wlr_wl_shell_surface *shell_surface = data;
88 82
89 if (shell_surface->state == WLR_WL_SHELL_SURFACE_STATE_POPUP) { 83 if (shell_surface->state == WLR_WL_SHELL_SURFACE_STATE_POPUP) {
@@ -103,20 +97,13 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
103 return; 97 return;
104 } 98 }
105 99
106 struct sway_view *sway_view = calloc(1, sizeof(struct sway_view)); 100 struct sway_view *view = view_create(SWAY_WL_SHELL_VIEW, &view_impl);
107 if (!sway_assert(sway_view, "Failed to allocate view!")) { 101 if (!sway_assert(view, "Failed to allocate view")) {
108 return; 102 return;
109 } 103 }
110 sway_view->type = SWAY_WL_SHELL_VIEW; 104 view->wlr_wl_shell_surface = shell_surface;
111 sway_view->iface.get_prop = get_prop; 105 view->sway_wl_shell_surface = sway_surface;
112 sway_view->iface.set_size = set_size; 106 sway_surface->view = view;
113 sway_view->iface.set_position = set_position;
114 sway_view->iface.set_activated = set_activated;
115 sway_view->iface.close = close;
116 sway_view->wlr_wl_shell_surface = shell_surface;
117 sway_view->sway_wl_shell_surface = sway_surface;
118 sway_view->surface = shell_surface->surface;
119 sway_surface->view = sway_view;
120 107
121 // TODO: 108 // TODO:
122 // - Wire up listeners 109 // - Wire up listeners
@@ -132,11 +119,5 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
132 sway_surface->destroy.notify = handle_destroy; 119 sway_surface->destroy.notify = handle_destroy;
133 wl_signal_add(&shell_surface->events.destroy, &sway_surface->destroy); 120 wl_signal_add(&shell_surface->events.destroy, &sway_surface->destroy);
134 121
135 struct sway_seat *seat = input_manager_current_seat(input_manager); 122 view_map(view, shell_surface->surface);
136 struct sway_container *focus = seat_get_focus_inactive(seat, &root_container);
137 struct sway_container *cont = container_view_create(focus, sway_view);
138 sway_view->swayc = cont;
139
140 arrange_windows(cont->parent, -1, -1);
141 input_manager_set_focus(input_manager, cont);
142} 123}