xdg_shell: Move floating window with attach point

The buffer attach point was previously just used as an offset used
during buffer rendering, while the purpose of the attach point is to
move the window itself by the delta value.

Use the delta to move floating containers, ignore it for tiling
containers, and remove it as a variable in rendering.

Closes: https://github.com/swaywm/sway/issues/6020
This commit is contained in:
Kenny Levinsen 2021-02-11 01:34:04 +01:00
parent b1b104152e
commit 728aca6155
5 changed files with 15 additions and 7 deletions

View file

@ -316,7 +316,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface,
void view_unmap(struct sway_view *view);
void view_update_size(struct sway_view *view);
void view_update_size(struct sway_view *view, int dx, int dy);
void view_center_surface(struct sway_view *view);
void view_child_init(struct sway_view_child *child,

View file

@ -99,8 +99,8 @@ static bool get_surface_box(struct surface_iterator_data *data,
int sw = surface->current.width;
int sh = surface->current.height;
double _sx = sx + surface->sx;
double _sy = sy + surface->sy;
double _sx = sx;
double _sy = sy;
rotate_child_position(&_sx, &_sy, sw, sh, data->width, data->height,
data->rotation);

View file

@ -284,20 +284,25 @@ static void handle_commit(struct wl_listener *listener, void *data) {
wl_container_of(listener, xdg_shell_view, commit);
struct sway_view *view = &xdg_shell_view->view;
struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface;
struct wlr_surface *surface = xdg_surface->surface;
struct wlr_box new_geo;
wlr_xdg_surface_get_geometry(xdg_surface, &new_geo);
bool new_size = new_geo.width != view->geometry.width ||
new_geo.height != view->geometry.height ||
new_geo.x != view->geometry.x ||
new_geo.y != view->geometry.y;
new_geo.y != view->geometry.y ||
surface->sx != 0 ||
surface->sy != 0;
if (new_size) {
// The view has unexpectedly sent a new size
desktop_damage_view(view);
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
if (container_is_floating(view->container)) {
view_update_size(view);
view_update_size(view, xdg_surface->surface->sx, xdg_surface->surface->sy);
xdg_surface->surface->sx = 0;
xdg_surface->surface->sy = 0;
transaction_commit_dirty();
transaction_notify_view_ready_immediately(view);
} else {

View file

@ -412,7 +412,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
desktop_damage_view(view);
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
if (container_is_floating(view->container)) {
view_update_size(view);
view_update_size(view, 0, 0);
transaction_commit_dirty();
} else {
view_center_surface(view);

View file

@ -872,10 +872,13 @@ void view_unmap(struct sway_view *view) {
view->surface = NULL;
}
void view_update_size(struct sway_view *view) {
void view_update_size(struct sway_view *view, int dx, int dy) {
struct sway_container *con = view->container;
con->content_x += dx;
con->content_y += dy;
con->content_width = view->geometry.width;
con->content_height = view->geometry.height;
container_set_geometry_from_content(con);
}