aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-05-30 10:22:35 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-06-01 23:14:58 +1000
commit9119f876552a47716bd317524bf5d786f909e5e5 (patch)
tree43c14f317a4e971e0f76cbbaf446a91179505cc2
parentAdjust move command to account for changed coordinate system (diff)
downloadsway-9119f876552a47716bd317524bf5d786f909e5e5.tar.gz
sway-9119f876552a47716bd317524bf5d786f909e5e5.tar.zst
sway-9119f876552a47716bd317524bf5d786f909e5e5.zip
Fix floating position when view is floated when mapped
-rw-r--r--sway/desktop/xdg_shell.c22
-rw-r--r--sway/desktop/xdg_shell_v6.c22
-rw-r--r--sway/desktop/xwayland.c7
3 files changed, 27 insertions, 24 deletions
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index 7a39a84c..32d1e3ca 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -173,17 +173,13 @@ static void handle_commit(struct wl_listener *listener, void *data) {
173 struct sway_xdg_shell_view *xdg_shell_view = 173 struct sway_xdg_shell_view *xdg_shell_view =
174 wl_container_of(listener, xdg_shell_view, commit); 174 wl_container_of(listener, xdg_shell_view, commit);
175 struct sway_view *view = &xdg_shell_view->view; 175 struct sway_view *view = &xdg_shell_view->view;
176 int width = view->wlr_xdg_surface->geometry.width;
177 int height = view->wlr_xdg_surface->geometry.height;
178 if (!width && !height) {
179 width = view->wlr_xdg_surface->surface->current->width;
180 height = view->wlr_xdg_surface->surface->current->height;
181 }
182 if (!view->natural_width && !view->natural_height) {
183 view->natural_width = width;
184 view->natural_height = height;
185 }
186 if (view->swayc && container_is_floating(view->swayc)) { 176 if (view->swayc && container_is_floating(view->swayc)) {
177 int width = view->wlr_xdg_surface->geometry.width;
178 int height = view->wlr_xdg_surface->geometry.height;
179 if (!width && !height) {
180 width = view->wlr_xdg_surface->surface->current->width;
181 height = view->wlr_xdg_surface->surface->current->height;
182 }
187 view_update_size(view, width, height); 183 view_update_size(view, width, height);
188 } else { 184 } else {
189 view_update_size(view, xdg_shell_view->pending_width, 185 view_update_size(view, xdg_shell_view->pending_width,
@@ -216,6 +212,12 @@ static void handle_map(struct wl_listener *listener, void *data) {
216 struct sway_view *view = &xdg_shell_view->view; 212 struct sway_view *view = &xdg_shell_view->view;
217 struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface; 213 struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface;
218 214
215 view->natural_width = view->wlr_xdg_surface->geometry.width;
216 view->natural_height = view->wlr_xdg_surface->geometry.height;
217 if (!view->natural_width && !view->natural_height) {
218 view->natural_width = view->wlr_xdg_surface->surface->current->width;
219 view->natural_height = view->wlr_xdg_surface->surface->current->height;
220 }
219 view_map(view, view->wlr_xdg_surface->surface); 221 view_map(view, view->wlr_xdg_surface->surface);
220 222
221 xdg_shell_view->commit.notify = handle_commit; 223 xdg_shell_view->commit.notify = handle_commit;
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index b1b8091b..6cb489db 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -172,17 +172,13 @@ static void handle_commit(struct wl_listener *listener, void *data) {
172 struct sway_xdg_shell_v6_view *xdg_shell_v6_view = 172 struct sway_xdg_shell_v6_view *xdg_shell_v6_view =
173 wl_container_of(listener, xdg_shell_v6_view, commit); 173 wl_container_of(listener, xdg_shell_v6_view, commit);
174 struct sway_view *view = &xdg_shell_v6_view->view; 174 struct sway_view *view = &xdg_shell_v6_view->view;
175 int width = view->wlr_xdg_surface_v6->geometry.width;
176 int height = view->wlr_xdg_surface_v6->geometry.height;
177 if (!width && !height) {
178 width = view->wlr_xdg_surface_v6->surface->current->width;
179 height = view->wlr_xdg_surface_v6->surface->current->height;
180 }
181 if (!view->natural_width && !view->natural_height) {
182 view->natural_width = width;
183 view->natural_height = height;
184 }
185 if (view->swayc && container_is_floating(view->swayc)) { 175 if (view->swayc && container_is_floating(view->swayc)) {
176 int width = view->wlr_xdg_surface_v6->geometry.width;
177 int height = view->wlr_xdg_surface_v6->geometry.height;
178 if (!width && !height) {
179 width = view->wlr_xdg_surface_v6->surface->current->width;
180 height = view->wlr_xdg_surface_v6->surface->current->height;
181 }
186 view_update_size(view, width, height); 182 view_update_size(view, width, height);
187 } else { 183 } else {
188 view_update_size(view, xdg_shell_v6_view->pending_width, 184 view_update_size(view, xdg_shell_v6_view->pending_width,
@@ -215,6 +211,12 @@ static void handle_map(struct wl_listener *listener, void *data) {
215 struct sway_view *view = &xdg_shell_v6_view->view; 211 struct sway_view *view = &xdg_shell_v6_view->view;
216 struct wlr_xdg_surface_v6 *xdg_surface = view->wlr_xdg_surface_v6; 212 struct wlr_xdg_surface_v6 *xdg_surface = view->wlr_xdg_surface_v6;
217 213
214 view->natural_width = view->wlr_xdg_surface_v6->geometry.width;
215 view->natural_height = view->wlr_xdg_surface_v6->geometry.height;
216 if (!view->natural_width && !view->natural_height) {
217 view->natural_width = view->wlr_xdg_surface_v6->surface->current->width;
218 view->natural_height = view->wlr_xdg_surface_v6->surface->current->height;
219 }
218 view_map(view, view->wlr_xdg_surface_v6->surface); 220 view_map(view, view->wlr_xdg_surface_v6->surface);
219 221
220 xdg_shell_v6_view->commit.notify = handle_commit; 222 xdg_shell_v6_view->commit.notify = handle_commit;
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index d0fbcaeb..76265ea9 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -235,10 +235,6 @@ static void handle_commit(struct wl_listener *listener, void *data) {
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 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; 237 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
238 if (!view->natural_width && !view->natural_height) {
239 view->natural_width = xsurface->width;
240 view->natural_height = xsurface->height;
241 }
242 if (view->swayc && container_is_floating(view->swayc)) { 238 if (view->swayc && container_is_floating(view->swayc)) {
243 view_update_size(view, xsurface->width, xsurface->height); 239 view_update_size(view, xsurface->width, xsurface->height);
244 view_update_position(view, 240 view_update_position(view,
@@ -263,6 +259,9 @@ static void handle_map(struct wl_listener *listener, void *data) {
263 struct wlr_xwayland_surface *xsurface = data; 259 struct wlr_xwayland_surface *xsurface = data;
264 struct sway_view *view = &xwayland_view->view; 260 struct sway_view *view = &xwayland_view->view;
265 261
262 view->natural_width = xsurface->width;
263 view->natural_height = xsurface->height;
264
266 // 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
267 // the underlying wlr_surface 266 // the underlying wlr_surface
268 wl_signal_add(&xsurface->surface->events.commit, &xwayland_view->commit); 267 wl_signal_add(&xsurface->surface->events.commit, &xwayland_view->commit);