summaryrefslogtreecommitdiffstats
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.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index b2b95fa0..d2b8822c 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -87,7 +87,7 @@ static const char *get_string_prop(struct sway_view *view, enum sway_view_prop p
87 } 87 }
88} 88}
89 89
90static void configure(struct sway_view *view, double ox, double oy, int width, 90static void configure(struct sway_view *view, double lx, double ly, int width,
91 int height) { 91 int height) {
92 struct sway_xdg_shell_view *xdg_shell_view = 92 struct sway_xdg_shell_view *xdg_shell_view =
93 xdg_shell_view_from_view(view); 93 xdg_shell_view_from_view(view);
@@ -98,6 +98,7 @@ static void configure(struct sway_view *view, double ox, double oy, int width,
98 xdg_shell_view->pending_width = width; 98 xdg_shell_view->pending_width = width;
99 xdg_shell_view->pending_height = height; 99 xdg_shell_view->pending_height = height;
100 wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height); 100 wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height);
101 view_update_position(view, lx, ly);
101} 102}
102 103
103static void set_activated(struct sway_view *view, bool activated) { 104static void set_activated(struct sway_view *view, bool activated) {
@@ -118,6 +119,14 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) {
118 wlr_xdg_toplevel_set_fullscreen(surface, fullscreen); 119 wlr_xdg_toplevel_set_fullscreen(surface, fullscreen);
119} 120}
120 121
122static bool wants_floating(struct sway_view *view) {
123 struct wlr_xdg_toplevel_state *state =
124 &view->wlr_xdg_surface->toplevel->current;
125 return state->min_width != 0 && state->min_height != 0
126 && state->min_width == state->max_width
127 && state->min_height == state->max_height;
128}
129
121static void for_each_surface(struct sway_view *view, 130static void for_each_surface(struct sway_view *view,
122 wlr_surface_iterator_func_t iterator, void *user_data) { 131 wlr_surface_iterator_func_t iterator, void *user_data) {
123 if (xdg_shell_view_from_view(view) == NULL) { 132 if (xdg_shell_view_from_view(view) == NULL) {
@@ -155,6 +164,7 @@ static const struct sway_view_impl view_impl = {
155 .configure = configure, 164 .configure = configure,
156 .set_activated = set_activated, 165 .set_activated = set_activated,
157 .set_fullscreen = set_fullscreen, 166 .set_fullscreen = set_fullscreen,
167 .wants_floating = wants_floating,
158 .for_each_surface = for_each_surface, 168 .for_each_surface = for_each_surface,
159 .close = _close, 169 .close = _close,
160 .destroy = destroy, 170 .destroy = destroy,
@@ -164,11 +174,18 @@ static void handle_commit(struct wl_listener *listener, void *data) {
164 struct sway_xdg_shell_view *xdg_shell_view = 174 struct sway_xdg_shell_view *xdg_shell_view =
165 wl_container_of(listener, xdg_shell_view, commit); 175 wl_container_of(listener, xdg_shell_view, commit);
166 struct sway_view *view = &xdg_shell_view->view; 176 struct sway_view *view = &xdg_shell_view->view;
167 // NOTE: We intentionally discard the view's desired width here 177 if (view->swayc && container_is_floating(view->swayc)) {
168 // TODO: Store this for restoration when moving to floating plane 178 int width = view->wlr_xdg_surface->geometry.width;
169 // TODO: Let floating views do whatever 179 int height = view->wlr_xdg_surface->geometry.height;
170 view_update_size(view, xdg_shell_view->pending_width, 180 if (!width && !height) {
171 xdg_shell_view->pending_height); 181 width = view->wlr_xdg_surface->surface->current->width;
182 height = view->wlr_xdg_surface->surface->current->height;
183 }
184 view_update_size(view, width, height);
185 } else {
186 view_update_size(view, xdg_shell_view->pending_width,
187 xdg_shell_view->pending_height);
188 }
172 view_update_title(view, false); 189 view_update_title(view, false);
173 view_damage_from(view); 190 view_damage_from(view);
174} 191}
@@ -196,6 +213,12 @@ static void handle_map(struct wl_listener *listener, void *data) {
196 struct sway_view *view = &xdg_shell_view->view; 213 struct sway_view *view = &xdg_shell_view->view;
197 struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface; 214 struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface;
198 215
216 view->natural_width = view->wlr_xdg_surface->geometry.width;
217 view->natural_height = view->wlr_xdg_surface->geometry.height;
218 if (!view->natural_width && !view->natural_height) {
219 view->natural_width = view->wlr_xdg_surface->surface->current->width;
220 view->natural_height = view->wlr_xdg_surface->surface->current->height;
221 }
199 view_map(view, view->wlr_xdg_surface->surface); 222 view_map(view, view->wlr_xdg_surface->surface);
200 223
201 xdg_shell_view->commit.notify = handle_commit; 224 xdg_shell_view->commit.notify = handle_commit;