aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/layer_shell.c9
-rw-r--r--sway/desktop/output.c3
-rw-r--r--sway/desktop/xdg_shell.c9
-rw-r--r--sway/desktop/xdg_shell_v6.c10
-rw-r--r--sway/desktop/xwayland.c94
5 files changed, 100 insertions, 25 deletions
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c
index fe5fc316..ff37bbf1 100644
--- a/sway/desktop/layer_shell.c
+++ b/sway/desktop/layer_shell.c
@@ -219,6 +219,8 @@ static void handle_output_destroy(struct wl_listener *listener, void *data) {
219 struct sway_layer_surface *sway_layer = 219 struct sway_layer_surface *sway_layer =
220 wl_container_of(listener, sway_layer, output_destroy); 220 wl_container_of(listener, sway_layer, output_destroy);
221 wl_list_remove(&sway_layer->output_destroy.link); 221 wl_list_remove(&sway_layer->output_destroy.link);
222 wl_list_remove(&sway_layer->link);
223 wl_list_init(&sway_layer->link);
222 sway_layer->layer_surface->output = NULL; 224 sway_layer->layer_surface->output = NULL;
223 wlr_layer_surface_close(sway_layer->layer_surface); 225 wlr_layer_surface_close(sway_layer->layer_surface);
224} 226}
@@ -350,10 +352,6 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
350 wl_signal_add(&layer_surface->surface->events.commit, 352 wl_signal_add(&layer_surface->surface->events.commit,
351 &sway_layer->surface_commit); 353 &sway_layer->surface_commit);
352 354
353 sway_layer->output_destroy.notify = handle_output_destroy;
354 wl_signal_add(&layer_surface->output->events.destroy,
355 &sway_layer->output_destroy);
356
357 sway_layer->destroy.notify = handle_destroy; 355 sway_layer->destroy.notify = handle_destroy;
358 wl_signal_add(&layer_surface->events.destroy, &sway_layer->destroy); 356 wl_signal_add(&layer_surface->events.destroy, &sway_layer->destroy);
359 sway_layer->map.notify = handle_map; 357 sway_layer->map.notify = handle_map;
@@ -366,6 +364,9 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
366 layer_surface->data = sway_layer; 364 layer_surface->data = sway_layer;
367 365
368 struct sway_output *output = layer_surface->output->data; 366 struct sway_output *output = layer_surface->output->data;
367 sway_layer->output_destroy.notify = handle_output_destroy;
368 wl_signal_add(&output->events.destroy, &sway_layer->output_destroy);
369
369 wl_list_insert(&output->layers[layer_surface->layer], &sway_layer->link); 370 wl_list_insert(&output->layers[layer_surface->layer], &sway_layer->link);
370 371
371 // Temporarily set the layer's current state to client_pending 372 // Temporarily set the layer's current state to client_pending
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 34fefaa9..69d0bdd4 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -1263,6 +1263,8 @@ static void damage_handle_destroy(struct wl_listener *listener, void *data) {
1263 1263
1264static void handle_destroy(struct wl_listener *listener, void *data) { 1264static void handle_destroy(struct wl_listener *listener, void *data) {
1265 struct sway_output *output = wl_container_of(listener, output, destroy); 1265 struct sway_output *output = wl_container_of(listener, output, destroy);
1266 wl_signal_emit(&output->events.destroy, output);
1267
1266 if (output->swayc) { 1268 if (output->swayc) {
1267 container_destroy(output->swayc); 1269 container_destroy(output->swayc);
1268 } 1270 }
@@ -1343,6 +1345,7 @@ void output_enable(struct sway_output *output) {
1343 for (size_t i = 0; i < len; ++i) { 1345 for (size_t i = 0; i < len; ++i) {
1344 wl_list_init(&output->layers[i]); 1346 wl_list_init(&output->layers[i]);
1345 } 1347 }
1348 wl_signal_init(&output->events.destroy);
1346 1349
1347 input_manager_configure_xcursor(input_manager); 1350 input_manager_configure_xcursor(input_manager);
1348 1351
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index b076d772..0f45399d 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -117,11 +117,12 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) {
117} 117}
118 118
119static bool wants_floating(struct sway_view *view) { 119static bool wants_floating(struct sway_view *view) {
120 struct wlr_xdg_toplevel_state *state = 120 struct wlr_xdg_toplevel *toplevel = view->wlr_xdg_surface->toplevel;
121 &view->wlr_xdg_surface->toplevel->current; 121 struct wlr_xdg_toplevel_state *state = &toplevel->current;
122 return state->min_width != 0 && state->min_height != 0 122 return (state->min_width != 0 && state->min_height != 0
123 && state->min_width == state->max_width 123 && state->min_width == state->max_width
124 && state->min_height == state->max_height; 124 && state->min_height == state->max_height)
125 || toplevel->parent;
125} 126}
126 127
127static void for_each_surface(struct sway_view *view, 128static void for_each_surface(struct sway_view *view,
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index 7320e629..b296f1a8 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -117,11 +117,13 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) {
117} 117}
118 118
119static bool wants_floating(struct sway_view *view) { 119static bool wants_floating(struct sway_view *view) {
120 struct wlr_xdg_toplevel_v6_state *state = 120 struct wlr_xdg_toplevel_v6 *toplevel =
121 &view->wlr_xdg_surface_v6->toplevel->current; 121 view->wlr_xdg_surface_v6->toplevel;
122 return state->min_width != 0 && state->min_height != 0 122 struct wlr_xdg_toplevel_v6_state *state = &toplevel->current;
123 return (state->min_width != 0 && state->min_height != 0
123 && state->min_width == state->max_width 124 && state->min_width == state->max_width
124 && state->min_height == state->max_height; 125 && state->min_height == state->max_height)
126 || toplevel->parent;
125} 127}
126 128
127static void for_each_surface(struct sway_view *view, 129static void for_each_surface(struct sway_view *view,
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 854da006..023fb2a7 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -17,6 +17,14 @@
17#include "sway/tree/layout.h" 17#include "sway/tree/layout.h"
18#include "sway/tree/view.h" 18#include "sway/tree/view.h"
19 19
20static const char *atom_map[ATOM_LAST] = {
21 "_NET_WM_WINDOW_TYPE_DIALOG",
22 "_NET_WM_WINDOW_TYPE_UTILITY",
23 "_NET_WM_WINDOW_TYPE_TOOLBAR",
24 "_NET_WM_WINDOW_TYPE_SPLASH",
25 "_NET_WM_STATE_MODAL",
26};
27
20static void unmanaged_handle_request_configure(struct wl_listener *listener, 28static void unmanaged_handle_request_configure(struct wl_listener *listener,
21 void *data) { 29 void *data) {
22 struct sway_xwayland_unmanaged *surface = 30 struct sway_xwayland_unmanaged *surface =
@@ -63,7 +71,8 @@ static void unmanaged_handle_map(struct wl_listener *listener, void *data) {
63 71
64 if (!wlr_xwayland_surface_is_unmanaged(xsurface)) { 72 if (!wlr_xwayland_surface_is_unmanaged(xsurface)) {
65 struct sway_seat *seat = input_manager_current_seat(input_manager); 73 struct sway_seat *seat = input_manager_current_seat(input_manager);
66 struct wlr_xwayland *xwayland = seat->input->server->xwayland; 74 struct wlr_xwayland *xwayland =
75 seat->input->server->xwayland.wlr_xwayland;
67 wlr_xwayland_set_seat(xwayland, seat->wlr_seat); 76 wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
68 seat_set_focus_surface(seat, xsurface->surface); 77 seat_set_focus_surface(seat, xsurface->surface);
69 } 78 }
@@ -200,15 +209,32 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) {
200} 209}
201 210
202static bool wants_floating(struct sway_view *view) { 211static bool wants_floating(struct sway_view *view) {
203 // TODO: 212 if (xwayland_view_from_view(view) == NULL) {
204 // We want to return true if the window type contains any of these: 213 return false;
205 // NET_WM_WINDOW_TYPE_DIALOG 214 }
206 // NET_WM_WINDOW_TYPE_UTILITY 215 struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface;
207 // NET_WM_WINDOW_TYPE_TOOLBAR 216 struct sway_xwayland *xwayland = &server.xwayland;
208 // NET_WM_WINDOW_TYPE_SPLASH 217
209 // 218 // TODO: return true if the NET_WM_STATE is MODAL
210 // We also want to return true if the NET_WM_STATE is MODAL. 219
211 // wlroots doesn't appear to provide all this information at the moment. 220 for (size_t i = 0; i < surface->window_type_len; ++i) {
221 xcb_atom_t type = surface->window_type[i];
222 if (type == xwayland->atoms[NET_WM_WINDOW_TYPE_DIALOG] ||
223 type == xwayland->atoms[NET_WM_WINDOW_TYPE_UTILITY] ||
224 type == xwayland->atoms[NET_WM_WINDOW_TYPE_TOOLBAR] ||
225 type == xwayland->atoms[NET_WM_WINDOW_TYPE_SPLASH]) {
226 return true;
227 }
228 }
229
230 struct wlr_xwayland_surface_size_hints *size_hints = surface->size_hints;
231 if (size_hints != NULL &&
232 size_hints->min_width != 0 && size_hints->min_height != 0 &&
233 size_hints->max_width == size_hints->min_width &&
234 size_hints->max_height == size_hints->min_height) {
235 return true;
236 }
237
212 return false; 238 return false;
213} 239}
214 240
@@ -324,9 +350,14 @@ static void handle_request_configure(struct wl_listener *listener, void *data) {
324 ev->width, ev->height); 350 ev->width, ev->height);
325 return; 351 return;
326 } 352 }
327 // TODO: Let floating views do whatever 353 if (container_is_floating(view->swayc)) {
328 configure(view, view->swayc->current.view_x, view->swayc->current.view_y, 354 configure(view, view->swayc->current.view_x,
329 view->swayc->current.view_width, view->swayc->current.view_height); 355 view->swayc->current.view_y, ev->width, ev->height);
356 } else {
357 configure(view, view->swayc->current.view_x,
358 view->swayc->current.view_y, view->swayc->current.view_width,
359 view->swayc->current.view_height);
360 }
330} 361}
331 362
332static void handle_request_fullscreen(struct wl_listener *listener, void *data) { 363static void handle_request_fullscreen(struct wl_listener *listener, void *data) {
@@ -431,3 +462,40 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
431 wl_signal_add(&xsurface->events.map, &xwayland_view->map); 462 wl_signal_add(&xsurface->events.map, &xwayland_view->map);
432 xwayland_view->map.notify = handle_map; 463 xwayland_view->map.notify = handle_map;
433} 464}
465
466void handle_xwayland_ready(struct wl_listener *listener, void *data) {
467 struct sway_server *server =
468 wl_container_of(listener, server, xwayland_ready);
469 struct sway_xwayland *xwayland = &server->xwayland;
470
471 xcb_connection_t *xcb_conn = xcb_connect(NULL, NULL);
472 int err = xcb_connection_has_error(xcb_conn);
473 if (err) {
474 wlr_log(L_ERROR, "XCB connect failed: %d", err);
475 return;
476 }
477
478 xcb_intern_atom_cookie_t cookies[ATOM_LAST];
479 for (size_t i = 0; i < ATOM_LAST; i++) {
480 cookies[i] =
481 xcb_intern_atom(xcb_conn, 0, strlen(atom_map[i]), atom_map[i]);
482 }
483 for (size_t i = 0; i < ATOM_LAST; i++) {
484 xcb_generic_error_t *error = NULL;
485 xcb_intern_atom_reply_t *reply =
486 xcb_intern_atom_reply(xcb_conn, cookies[i], &error);
487 if (reply != NULL && error == NULL) {
488 xwayland->atoms[i] = reply->atom;
489 }
490 free(reply);
491
492 if (error != NULL) {
493 wlr_log(L_ERROR, "could not resolve atom %s, X11 error code %d",
494 atom_map[i], error->error_code);
495 free(error);
496 break;
497 }
498 }
499
500 xcb_disconnect(xcb_conn);
501}