Fix floating position when view is floated when mapped
This commit is contained in:
parent
f7cadf2333
commit
9119f87655
|
@ -173,17 +173,13 @@ static void handle_commit(struct wl_listener *listener, void *data) {
|
|||
struct sway_xdg_shell_view *xdg_shell_view =
|
||||
wl_container_of(listener, xdg_shell_view, commit);
|
||||
struct sway_view *view = &xdg_shell_view->view;
|
||||
if (view->swayc && container_is_floating(view->swayc)) {
|
||||
int width = view->wlr_xdg_surface->geometry.width;
|
||||
int height = view->wlr_xdg_surface->geometry.height;
|
||||
if (!width && !height) {
|
||||
width = view->wlr_xdg_surface->surface->current->width;
|
||||
height = view->wlr_xdg_surface->surface->current->height;
|
||||
}
|
||||
if (!view->natural_width && !view->natural_height) {
|
||||
view->natural_width = width;
|
||||
view->natural_height = height;
|
||||
}
|
||||
if (view->swayc && container_is_floating(view->swayc)) {
|
||||
view_update_size(view, width, height);
|
||||
} else {
|
||||
view_update_size(view, xdg_shell_view->pending_width,
|
||||
|
@ -216,6 +212,12 @@ static void handle_map(struct wl_listener *listener, void *data) {
|
|||
struct sway_view *view = &xdg_shell_view->view;
|
||||
struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface;
|
||||
|
||||
view->natural_width = view->wlr_xdg_surface->geometry.width;
|
||||
view->natural_height = view->wlr_xdg_surface->geometry.height;
|
||||
if (!view->natural_width && !view->natural_height) {
|
||||
view->natural_width = view->wlr_xdg_surface->surface->current->width;
|
||||
view->natural_height = view->wlr_xdg_surface->surface->current->height;
|
||||
}
|
||||
view_map(view, view->wlr_xdg_surface->surface);
|
||||
|
||||
xdg_shell_view->commit.notify = handle_commit;
|
||||
|
|
|
@ -172,17 +172,13 @@ static void handle_commit(struct wl_listener *listener, void *data) {
|
|||
struct sway_xdg_shell_v6_view *xdg_shell_v6_view =
|
||||
wl_container_of(listener, xdg_shell_v6_view, commit);
|
||||
struct sway_view *view = &xdg_shell_v6_view->view;
|
||||
if (view->swayc && container_is_floating(view->swayc)) {
|
||||
int width = view->wlr_xdg_surface_v6->geometry.width;
|
||||
int height = view->wlr_xdg_surface_v6->geometry.height;
|
||||
if (!width && !height) {
|
||||
width = view->wlr_xdg_surface_v6->surface->current->width;
|
||||
height = view->wlr_xdg_surface_v6->surface->current->height;
|
||||
}
|
||||
if (!view->natural_width && !view->natural_height) {
|
||||
view->natural_width = width;
|
||||
view->natural_height = height;
|
||||
}
|
||||
if (view->swayc && container_is_floating(view->swayc)) {
|
||||
view_update_size(view, width, height);
|
||||
} else {
|
||||
view_update_size(view, xdg_shell_v6_view->pending_width,
|
||||
|
@ -215,6 +211,12 @@ static void handle_map(struct wl_listener *listener, void *data) {
|
|||
struct sway_view *view = &xdg_shell_v6_view->view;
|
||||
struct wlr_xdg_surface_v6 *xdg_surface = view->wlr_xdg_surface_v6;
|
||||
|
||||
view->natural_width = view->wlr_xdg_surface_v6->geometry.width;
|
||||
view->natural_height = view->wlr_xdg_surface_v6->geometry.height;
|
||||
if (!view->natural_width && !view->natural_height) {
|
||||
view->natural_width = view->wlr_xdg_surface_v6->surface->current->width;
|
||||
view->natural_height = view->wlr_xdg_surface_v6->surface->current->height;
|
||||
}
|
||||
view_map(view, view->wlr_xdg_surface_v6->surface);
|
||||
|
||||
xdg_shell_v6_view->commit.notify = handle_commit;
|
||||
|
|
|
@ -235,10 +235,6 @@ static void handle_commit(struct wl_listener *listener, void *data) {
|
|||
wl_container_of(listener, xwayland_view, commit);
|
||||
struct sway_view *view = &xwayland_view->view;
|
||||
struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
|
||||
if (!view->natural_width && !view->natural_height) {
|
||||
view->natural_width = xsurface->width;
|
||||
view->natural_height = xsurface->height;
|
||||
}
|
||||
if (view->swayc && container_is_floating(view->swayc)) {
|
||||
view_update_size(view, xsurface->width, xsurface->height);
|
||||
view_update_position(view,
|
||||
|
@ -263,6 +259,9 @@ static void handle_map(struct wl_listener *listener, void *data) {
|
|||
struct wlr_xwayland_surface *xsurface = data;
|
||||
struct sway_view *view = &xwayland_view->view;
|
||||
|
||||
view->natural_width = xsurface->width;
|
||||
view->natural_height = xsurface->height;
|
||||
|
||||
// Wire up the commit listener here, because xwayland map/unmap can change
|
||||
// the underlying wlr_surface
|
||||
wl_signal_add(&xsurface->surface->events.commit, &xwayland_view->commit);
|
||||
|
|
Loading…
Reference in a new issue