aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/tree/container.h4
-rw-r--r--include/sway/tree/layout.h2
-rw-r--r--include/sway/tree/view.h10
-rw-r--r--sway/desktop/output.c14
-rw-r--r--sway/desktop/xwayland.c47
-rw-r--r--sway/input/cursor.c11
-rw-r--r--sway/tree/layout.c2
-rw-r--r--sway/tree/view.c36
8 files changed, 67 insertions, 59 deletions
diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h
index d707df17..423c0a22 100644
--- a/include/sway/tree/container.h
+++ b/include/sway/tree/container.h
@@ -70,7 +70,9 @@ struct sway_container {
70 enum sway_container_layout prev_layout; 70 enum sway_container_layout prev_layout;
71 enum sway_container_layout workspace_layout; 71 enum sway_container_layout workspace_layout;
72 72
73 // in output-local coordinates 73 // For C_ROOT, this has no meaning
74 // For C_OUTPUT, this is the output position in layout coordinates
75 // For other types, this is the position in output-local coordinates
74 double x, y; 76 double x, y;
75 // does not include borders or gaps. 77 // does not include borders or gaps.
76 double width, height; 78 double width, height;
diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h
index 0a904c4b..fecf1582 100644
--- a/include/sway/tree/layout.h
+++ b/include/sway/tree/layout.h
@@ -23,7 +23,7 @@ struct sway_root {
23 23
24 struct wl_listener output_layout_change; 24 struct wl_listener output_layout_change;
25 25
26 struct wl_list unmanaged_views; // sway_view::unmanaged_view_link 26 struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link
27 27
28 struct { 28 struct {
29 struct wl_signal new_container; 29 struct wl_signal new_container;
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 4e753b2a..4b84205e 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -39,6 +39,13 @@ struct sway_xwayland_surface {
39 int pending_width, pending_height; 39 int pending_width, pending_height;
40}; 40};
41 41
42struct sway_xwayland_unmanaged {
43 struct wlr_xwayland_surface *wlr_xwayland_surface;
44 struct wl_list link;
45
46 struct wl_listener destroy;
47};
48
42struct sway_wl_shell_surface { 49struct sway_wl_shell_surface {
43 struct sway_view *view; 50 struct sway_view *view;
44 51
@@ -127,9 +134,6 @@ void view_damage_from(struct sway_view *view);
127 134
128void view_map(struct sway_view *view, struct wlr_surface *wlr_surface); 135void view_map(struct sway_view *view, struct wlr_surface *wlr_surface);
129 136
130void view_map_unmanaged(struct sway_view *view,
131 struct wlr_surface *wlr_surface);
132
133void view_unmap(struct sway_view *view); 137void view_unmap(struct sway_view *view);
134 138
135void view_update_position(struct sway_view *view, double ox, double oy); 139void view_update_position(struct sway_view *view, double ox, double oy);
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 6c97ac37..352f4af3 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -257,15 +257,15 @@ static void render_output(struct sway_output *output, struct timespec *when,
257 container_descendants(workspace, C_VIEW, render_view, &rdata); 257 container_descendants(workspace, C_VIEW, render_view, &rdata);
258 258
259 // render unmanaged views on top 259 // render unmanaged views on top
260 struct sway_view *view; 260 struct wl_list *unmanaged = &root_container.sway_root->xwayland_unmanaged;
261 wl_list_for_each(view, &root_container.sway_root->unmanaged_views, 261 struct sway_xwayland_unmanaged *sway_surface;
262 unmanaged_view_link) { 262 wl_list_for_each(sway_surface, unmanaged, link) {
263 if (view->type != SWAY_XWAYLAND_VIEW) { 263 struct wlr_xwayland_surface *xsurface =
264 sway_surface->wlr_xwayland_surface;
265 if (xsurface->surface == NULL) {
264 continue; 266 continue;
265 } 267 }
266 268
267 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
268
269 const struct wlr_box view_box = { 269 const struct wlr_box view_box = {
270 .x = xsurface->x, 270 .x = xsurface->x,
271 .y = xsurface->y, 271 .y = xsurface->y,
@@ -277,7 +277,7 @@ static void render_output(struct sway_output *output, struct timespec *when,
277 continue; 277 continue;
278 } 278 }
279 279
280 render_surface(view->surface, wlr_output, &output->last_frame, 280 render_surface(xsurface->surface, wlr_output, &output->last_frame,
281 view_box.x - output_box->x, view_box.y - output_box->y, 0); 281 view_box.x - output_box->x, view_box.y - output_box->y, 0);
282 } 282 }
283 283
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 39076fab..bfef68cf 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -14,6 +14,33 @@
14#include "sway/input/input-manager.h" 14#include "sway/input/input-manager.h"
15#include "log.h" 15#include "log.h"
16 16
17static void unmanaged_handle_destroy(struct wl_listener *listener, void *data) {
18 struct sway_xwayland_unmanaged *sway_surface =
19 wl_container_of(listener, sway_surface, destroy);
20 wl_list_remove(&sway_surface->destroy.link);
21 wl_list_remove(&sway_surface->link);
22 free(sway_surface);
23}
24
25static void create_unmanaged(struct wlr_xwayland_surface *xsurface) {
26 struct sway_xwayland_unmanaged *sway_surface =
27 calloc(1, sizeof(struct sway_xwayland_unmanaged));
28 if (!sway_assert(sway_surface, "Failed to allocate surface")) {
29 return;
30 }
31
32 sway_surface->wlr_xwayland_surface = xsurface;
33
34 wl_signal_add(&xsurface->events.destroy, &sway_surface->destroy);
35 sway_surface->destroy.notify = unmanaged_handle_destroy;
36
37 wl_list_insert(&root_container.sway_root->xwayland_unmanaged,
38 &sway_surface->link);
39
40 // TODO: damage tracking
41}
42
43
17static bool assert_xwayland(struct sway_view *view) { 44static bool assert_xwayland(struct sway_view *view) {
18 return sway_assert(view->type == SWAY_XWAYLAND_VIEW, 45 return sway_assert(view->type == SWAY_XWAYLAND_VIEW,
19 "Expected xwayland view!"); 46 "Expected xwayland view!");
@@ -121,13 +148,8 @@ static void handle_map(struct wl_listener *listener, void *data) {
121 struct sway_view *view = sway_surface->view; 148 struct sway_view *view = sway_surface->view;
122 149
123 // put it back into the tree 150 // put it back into the tree
124 if (wlr_xwayland_surface_is_unmanaged(xsurface) || 151 wlr_xwayland_surface_set_maximized(xsurface, true);
125 xsurface->override_redirect) { 152 view_map(view, xsurface->surface);
126 view_map_unmanaged(view, xsurface->surface);
127 } else {
128 wlr_xwayland_surface_set_maximized(xsurface, true);
129 view_map(view, xsurface->surface);
130 }
131} 153}
132 154
133static void handle_request_configure(struct wl_listener *listener, void *data) { 155static void handle_request_configure(struct wl_listener *listener, void *data) {
@@ -147,12 +169,19 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
147 listener, server, xwayland_surface); 169 listener, server, xwayland_surface);
148 struct wlr_xwayland_surface *xsurface = data; 170 struct wlr_xwayland_surface *xsurface = data;
149 171
172 if (wlr_xwayland_surface_is_unmanaged(xsurface) ||
173 xsurface->override_redirect) {
174 wlr_log(L_DEBUG, "New xwayland unmanaged surface");
175 create_unmanaged(xsurface);
176 return;
177 }
178
150 wlr_log(L_DEBUG, "New xwayland surface title='%s' class='%s'", 179 wlr_log(L_DEBUG, "New xwayland surface title='%s' class='%s'",
151 xsurface->title, xsurface->class); 180 xsurface->title, xsurface->class);
152 181
153 struct sway_xwayland_surface *sway_surface = 182 struct sway_xwayland_surface *sway_surface =
154 calloc(1, sizeof(struct sway_xwayland_surface)); 183 calloc(1, sizeof(struct sway_xwayland_surface));
155 if (!sway_assert(sway_surface, "Failed to allocate surface!")) { 184 if (!sway_assert(sway_surface, "Failed to allocate surface")) {
156 return; 185 return;
157 } 186 }
158 187
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index d608a9cf..77ab9e31 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -47,14 +47,15 @@ static struct wlr_surface *layer_surface_at(struct sway_output *output,
47static struct sway_container *container_at_cursor(struct sway_cursor *cursor, 47static struct sway_container *container_at_cursor(struct sway_cursor *cursor,
48 struct wlr_surface **surface, double *sx, double *sy) { 48 struct wlr_surface **surface, double *sx, double *sy) {
49 // check for unmanaged views first 49 // check for unmanaged views first
50 struct wl_list *unmanaged = &root_container.sway_root->unmanaged_views; 50 struct wl_list *unmanaged = &root_container.sway_root->xwayland_unmanaged;
51 struct sway_view *view; 51 struct sway_xwayland_unmanaged *sway_surface;
52 wl_list_for_each_reverse(view, unmanaged, unmanaged_view_link) { 52 wl_list_for_each_reverse(sway_surface, unmanaged, link) {
53 if (view->type != SWAY_XWAYLAND_VIEW) { 53 struct wlr_xwayland_surface *xsurface =
54 sway_surface->wlr_xwayland_surface;
55 if (xsurface->surface == NULL) {
54 continue; 56 continue;
55 } 57 }
56 58
57 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
58 struct wlr_box box = { 59 struct wlr_box box = {
59 .x = xsurface->x, 60 .x = xsurface->x,
60 .y = xsurface->y, 61 .y = xsurface->y,
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 3fec02a1..122ea494 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -57,7 +57,7 @@ void layout_init(void) {
57 57
58 root_container.sway_root = calloc(1, sizeof(*root_container.sway_root)); 58 root_container.sway_root = calloc(1, sizeof(*root_container.sway_root));
59 root_container.sway_root->output_layout = wlr_output_layout_create(); 59 root_container.sway_root->output_layout = wlr_output_layout_create();
60 wl_list_init(&root_container.sway_root->unmanaged_views); 60 wl_list_init(&root_container.sway_root->xwayland_unmanaged);
61 wl_signal_init(&root_container.sway_root->events.new_container); 61 wl_signal_init(&root_container.sway_root->events.new_container);
62 62
63 root_container.sway_root->output_layout_change.notify = 63 root_container.sway_root->output_layout_change.notify =
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 73e3d445..8f044621 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -15,7 +15,6 @@ struct sway_view *view_create(enum sway_view_type type,
15 } 15 }
16 view->type = type; 16 view->type = type;
17 view->impl = impl; 17 view->impl = impl;
18 wl_list_init(&view->unmanaged_view_link);
19 return view; 18 return view;
20} 19}
21 20
@@ -27,10 +26,8 @@ void view_destroy(struct sway_view *view) {
27 if (view->surface != NULL) { 26 if (view->surface != NULL) {
28 view_unmap(view); 27 view_unmap(view);
29 } 28 }
30 if (view->swayc != NULL) {
31 container_view_destroy(view->swayc);
32 }
33 29
30 container_view_destroy(view->swayc);
34 free(view); 31 free(view);
35} 32}
36 33
@@ -106,15 +103,10 @@ void view_damage_from(struct sway_view *view) {
106} 103}
107 104
108static void view_get_layout_box(struct sway_view *view, struct wlr_box *box) { 105static void view_get_layout_box(struct sway_view *view, struct wlr_box *box) {
109 struct sway_container *cont = container_parent(view->swayc, C_OUTPUT); 106 struct sway_container *output = container_parent(view->swayc, C_OUTPUT);
110
111 struct wlr_output_layout *output_layout =
112 root_container.sway_root->output_layout;
113 struct wlr_box *output_box = wlr_output_layout_get_box(output_layout,
114 cont->sway_output->wlr_output);
115 107
116 box->x = output_box->x + view->swayc->x; 108 box->x = output->x + view->swayc->x;
117 box->y = output_box->y + view->swayc->y; 109 box->y = output->y + view->swayc->y;
118 box->width = view->width; 110 box->width = view->width;
119 box->height = view->height; 111 box->height = view->height;
120} 112}
@@ -161,23 +153,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) {
161 view_update_outputs(view, NULL); 153 view_update_outputs(view, NULL);
162} 154}
163 155
164void view_map_unmanaged(struct sway_view *view,
165 struct wlr_surface *wlr_surface) {
166 if (!sway_assert(view->surface == NULL, "cannot map mapped view")) {
167 return;
168 }
169
170 view->surface = wlr_surface;
171 view->swayc = NULL;
172
173 wl_list_insert(&root_container.sway_root->unmanaged_views,
174 &view->unmanaged_view_link);
175
176 view_damage_whole(view);
177 // TODO: make this work for unmanaged views
178 //view_update_outputs(view, NULL);
179}
180
181void view_unmap(struct sway_view *view) { 156void view_unmap(struct sway_view *view) {
182 if (!sway_assert(view->surface != NULL, "cannot unmap unmapped view")) { 157 if (!sway_assert(view->surface != NULL, "cannot unmap unmapped view")) {
183 return; 158 return;
@@ -185,9 +160,6 @@ void view_unmap(struct sway_view *view) {
185 160
186 view_damage_whole(view); 161 view_damage_whole(view);
187 162
188 wl_list_remove(&view->unmanaged_view_link);
189 wl_list_init(&view->unmanaged_view_link);
190
191 container_view_destroy(view->swayc); 163 container_view_destroy(view->swayc);
192 164
193 view->swayc = NULL; 165 view->swayc = NULL;