Store geometry in the view and handle any floating view resizing

This commit is contained in:
Ryan Dwyer 2018-08-18 15:10:06 +10:00
parent 4e755c4b12
commit b0a5f3a25f
11 changed files with 144 additions and 112 deletions

View file

@ -277,6 +277,17 @@ static const struct sway_view_impl view_impl = {
.destroy = destroy,
};
static void get_geometry(struct sway_view *view, struct wlr_box *box) {
box->x = box->y = 0;
if (view->surface) {
box->width = view->surface->current.width;
box->height = view->surface->current.height;
} else {
box->width = 0;
box->height = 0;
}
}
static void handle_commit(struct wl_listener *listener, void *data) {
struct sway_xwayland_view *xwayland_view =
wl_container_of(listener, xwayland_view, commit);
@ -285,18 +296,25 @@ static void handle_commit(struct wl_listener *listener, void *data) {
struct wlr_surface_state *state = &xsurface->surface->current;
if (view->swayc->instruction) {
get_geometry(view, &view->geometry);
transaction_notify_view_ready_by_size(view,
state->width, state->height);
} else if ((state->width != view->width || state->height != view->height) &&
} else {
struct wlr_box new_geo;
get_geometry(view, &new_geo);
if ((new_geo.width != view->width || new_geo.height != view->height) &&
container_is_floating(view->swayc)) {
// eg. The Firefox "Save As" dialog when downloading a file
// It maps at a small size then changes afterwards.
view->width = state->width;
view->height = state->height;
view->swayc->current.view_width = state->width;
view->swayc->current.view_height = state->height;
container_set_geometry_from_floating_view(view->swayc);
transaction_commit_dirty();
// A floating view has unexpectedly sent a new size
// eg. The Firefox "Save As" dialog when downloading a file
desktop_damage_view(view);
view_update_size(view, new_geo.width, new_geo.height);
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
desktop_damage_view(view);
transaction_commit_dirty();
} else {
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
}
}
view_damage_from(view);