summaryrefslogtreecommitdiff
path: root/sway/desktop/xdg_shell.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/desktop/xdg_shell.c')
-rw-r--r--sway/desktop/xdg_shell.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index 2d79727d..6dde98bd 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -67,7 +67,13 @@ static void popup_unconstrain(struct sway_xdg_popup *popup) {
struct sway_view *view = popup->child.view;
struct wlr_xdg_popup *wlr_popup = popup->wlr_xdg_popup;
- struct sway_output *output = view->container->pending.workspace->output;
+ struct sway_workspace *workspace = view->container->pending.workspace;
+ if (!workspace) {
+ // is null if in the scratchpad
+ return;
+ }
+
+ struct sway_output *output = workspace->output;
// the output box expressed in the coordinate system of the toplevel parent
// of the popup
@@ -98,8 +104,8 @@ static struct sway_xdg_popup *popup_create(
wl_signal_add(&xdg_surface->events.destroy, &popup->destroy);
popup->destroy.notify = popup_handle_destroy;
- wl_signal_add(&xdg_surface->events.map, &popup->child.surface_map);
- wl_signal_add(&xdg_surface->events.unmap, &popup->child.surface_unmap);
+ wl_signal_add(&xdg_surface->surface->events.map, &popup->child.surface_map);
+ wl_signal_add(&xdg_surface->surface->events.unmap, &popup->child.surface_unmap);
popup_unconstrain(popup);
@@ -163,12 +169,19 @@ static void set_tiled(struct sway_view *view, bool tiled) {
if (xdg_shell_view_from_view(view) == NULL) {
return;
}
- enum wlr_edges edges = WLR_EDGE_NONE;
- if (tiled) {
- edges = WLR_EDGE_LEFT | WLR_EDGE_RIGHT | WLR_EDGE_TOP |
- WLR_EDGE_BOTTOM;
+ if (wl_resource_get_version(view->wlr_xdg_toplevel->resource) >=
+ XDG_TOPLEVEL_STATE_TILED_LEFT_SINCE_VERSION) {
+ enum wlr_edges edges = WLR_EDGE_NONE;
+ if (tiled) {
+ edges = WLR_EDGE_LEFT | WLR_EDGE_RIGHT | WLR_EDGE_TOP |
+ WLR_EDGE_BOTTOM;
+ }
+ wlr_xdg_toplevel_set_tiled(view->wlr_xdg_toplevel, edges);
+ } else {
+ // The version is too low for the tiled state; configure as maximized instead
+ // to stop the client from drawing decorations outside of the toplevel geometry.
+ wlr_xdg_toplevel_set_maximized(view->wlr_xdg_toplevel, tiled);
}
- wlr_xdg_toplevel_set_tiled(view->wlr_xdg_toplevel, edges);
}
static void set_fullscreen(struct sway_view *view, bool fullscreen) {
@@ -288,6 +301,11 @@ static void handle_commit(struct wl_listener *listener, void *data) {
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
if (container_is_floating(view->container)) {
view_update_size(view);
+ // Only set the toplevel size the current container actually has a size.
+ if (view->container->current.width) {
+ wlr_xdg_toplevel_set_size(view->wlr_xdg_toplevel, view->geometry.width,
+ view->geometry.height);
+ }
transaction_commit_dirty_client();
} else {
view_center_surface(view);
@@ -356,7 +374,7 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
struct wlr_xdg_toplevel *toplevel = xdg_shell_view->view.wlr_xdg_toplevel;
struct sway_view *view = &xdg_shell_view->view;
- if (!toplevel->base->mapped) {
+ if (!toplevel->base->surface->mapped) {
return;
}
@@ -550,10 +568,10 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
xdg_shell_view->view.wlr_xdg_toplevel = xdg_surface->toplevel;
xdg_shell_view->map.notify = handle_map;
- wl_signal_add(&xdg_surface->events.map, &xdg_shell_view->map);
+ wl_signal_add(&xdg_surface->surface->events.map, &xdg_shell_view->map);
xdg_shell_view->unmap.notify = handle_unmap;
- wl_signal_add(&xdg_surface->events.unmap, &xdg_shell_view->unmap);
+ wl_signal_add(&xdg_surface->surface->events.unmap, &xdg_shell_view->unmap);
xdg_shell_view->destroy.notify = handle_destroy;
wl_signal_add(&xdg_surface->events.destroy, &xdg_shell_view->destroy);