diff options
Diffstat (limited to 'sway/desktop/xwayland.c')
-rw-r--r-- | sway/desktop/xwayland.c | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 6a99a66a..75bfb7b2 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -152,7 +152,7 @@ static uint32_t get_int_prop(struct sway_view *view, enum sway_view_prop prop) { | |||
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | static void configure(struct sway_view *view, double ox, double oy, int width, | 155 | static void configure(struct sway_view *view, double lx, double ly, int width, |
156 | int height) { | 156 | int height) { |
157 | struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view); | 157 | struct sway_xwayland_view *xwayland_view = xwayland_view_from_view(view); |
158 | if (xwayland_view == NULL) { | 158 | if (xwayland_view == NULL) { |
@@ -160,25 +160,11 @@ static void configure(struct sway_view *view, double ox, double oy, int width, | |||
160 | } | 160 | } |
161 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | 161 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; |
162 | 162 | ||
163 | struct sway_container *output = container_parent(view->swayc, C_OUTPUT); | 163 | xwayland_view->pending_lx = lx; |
164 | if (!sway_assert(output, "view must be within tree to set position")) { | 164 | xwayland_view->pending_ly = ly; |
165 | return; | ||
166 | } | ||
167 | struct sway_container *root = container_parent(output, C_ROOT); | ||
168 | if (!sway_assert(root, "output must be within tree to set position")) { | ||
169 | return; | ||
170 | } | ||
171 | struct wlr_output_layout *layout = root->sway_root->output_layout; | ||
172 | struct wlr_output_layout_output *loutput = | ||
173 | wlr_output_layout_get(layout, output->sway_output->wlr_output); | ||
174 | if (!sway_assert(loutput, "output must be within layout to set position")) { | ||
175 | return; | ||
176 | } | ||
177 | |||
178 | xwayland_view->pending_width = width; | 165 | xwayland_view->pending_width = width; |
179 | xwayland_view->pending_height = height; | 166 | xwayland_view->pending_height = height; |
180 | wlr_xwayland_surface_configure(xsurface, ox + loutput->x, oy + loutput->y, | 167 | wlr_xwayland_surface_configure(xsurface, lx, ly, width, height); |
181 | width, height); | ||
182 | } | 168 | } |
183 | 169 | ||
184 | static void set_activated(struct sway_view *view, bool activated) { | 170 | static void set_activated(struct sway_view *view, bool activated) { |
@@ -197,6 +183,19 @@ static void set_fullscreen(struct sway_view *view, bool fullscreen) { | |||
197 | wlr_xwayland_surface_set_fullscreen(surface, fullscreen); | 183 | wlr_xwayland_surface_set_fullscreen(surface, fullscreen); |
198 | } | 184 | } |
199 | 185 | ||
186 | static bool wants_floating(struct sway_view *view) { | ||
187 | // TODO: | ||
188 | // We want to return true if the window type contains any of these: | ||
189 | // NET_WM_WINDOW_TYPE_DIALOG | ||
190 | // NET_WM_WINDOW_TYPE_UTILITY | ||
191 | // NET_WM_WINDOW_TYPE_TOOLBAR | ||
192 | // NET_WM_WINDOW_TYPE_SPLASH | ||
193 | // | ||
194 | // We also want to return true if the NET_WM_STATE is MODAL. | ||
195 | // wlroots doesn't appear to provide all this information at the moment. | ||
196 | return false; | ||
197 | } | ||
198 | |||
200 | static void _close(struct sway_view *view) { | 199 | static void _close(struct sway_view *view) { |
201 | if (xwayland_view_from_view(view) == NULL) { | 200 | if (xwayland_view_from_view(view) == NULL) { |
202 | return; | 201 | return; |
@@ -226,6 +225,7 @@ static const struct sway_view_impl view_impl = { | |||
226 | .configure = configure, | 225 | .configure = configure, |
227 | .set_activated = set_activated, | 226 | .set_activated = set_activated, |
228 | .set_fullscreen = set_fullscreen, | 227 | .set_fullscreen = set_fullscreen, |
228 | .wants_floating = wants_floating, | ||
229 | .close = _close, | 229 | .close = _close, |
230 | .destroy = destroy, | 230 | .destroy = destroy, |
231 | }; | 231 | }; |
@@ -234,10 +234,15 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
234 | struct sway_xwayland_view *xwayland_view = | 234 | struct sway_xwayland_view *xwayland_view = |
235 | wl_container_of(listener, xwayland_view, commit); | 235 | wl_container_of(listener, xwayland_view, commit); |
236 | struct sway_view *view = &xwayland_view->view; | 236 | struct sway_view *view = &xwayland_view->view; |
237 | // NOTE: We intentionally discard the view's desired width here | 237 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; |
238 | // TODO: Let floating views do whatever | 238 | if (view->swayc && container_is_floating(view->swayc)) { |
239 | view_update_size(view, xwayland_view->pending_width, | 239 | view_update_size(view, xsurface->width, xsurface->height); |
240 | xwayland_view->pending_height); | 240 | } else { |
241 | view_update_size(view, xwayland_view->pending_width, | ||
242 | xwayland_view->pending_height); | ||
243 | } | ||
244 | view_update_position(view, | ||
245 | xwayland_view->pending_lx, xwayland_view->pending_ly); | ||
241 | view_damage_from(view); | 246 | view_damage_from(view); |
242 | } | 247 | } |
243 | 248 | ||
@@ -254,6 +259,9 @@ static void handle_map(struct wl_listener *listener, void *data) { | |||
254 | struct wlr_xwayland_surface *xsurface = data; | 259 | struct wlr_xwayland_surface *xsurface = data; |
255 | struct sway_view *view = &xwayland_view->view; | 260 | struct sway_view *view = &xwayland_view->view; |
256 | 261 | ||
262 | view->natural_width = xsurface->width; | ||
263 | view->natural_height = xsurface->height; | ||
264 | |||
257 | // Wire up the commit listener here, because xwayland map/unmap can change | 265 | // Wire up the commit listener here, because xwayland map/unmap can change |
258 | // the underlying wlr_surface | 266 | // the underlying wlr_surface |
259 | wl_signal_add(&xsurface->surface->events.commit, &xwayland_view->commit); | 267 | wl_signal_add(&xsurface->surface->events.commit, &xwayland_view->commit); |