mirror of
https://github.com/swaywm/sway.git
synced 2026-04-25 06:46:24 -04:00
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:
parent
b1b104152e
commit
728aca6155
5 changed files with 15 additions and 7 deletions
|
|
@ -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_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_center_surface(struct sway_view *view);
|
||||||
|
|
||||||
void view_child_init(struct sway_view_child *child,
|
void view_child_init(struct sway_view_child *child,
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,8 @@ static bool get_surface_box(struct surface_iterator_data *data,
|
||||||
int sw = surface->current.width;
|
int sw = surface->current.width;
|
||||||
int sh = surface->current.height;
|
int sh = surface->current.height;
|
||||||
|
|
||||||
double _sx = sx + surface->sx;
|
double _sx = sx;
|
||||||
double _sy = sy + surface->sy;
|
double _sy = sy;
|
||||||
rotate_child_position(&_sx, &_sy, sw, sh, data->width, data->height,
|
rotate_child_position(&_sx, &_sy, sw, sh, data->width, data->height,
|
||||||
data->rotation);
|
data->rotation);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -284,20 +284,25 @@ static void handle_commit(struct wl_listener *listener, void *data) {
|
||||||
wl_container_of(listener, xdg_shell_view, commit);
|
wl_container_of(listener, xdg_shell_view, commit);
|
||||||
struct sway_view *view = &xdg_shell_view->view;
|
struct sway_view *view = &xdg_shell_view->view;
|
||||||
struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface;
|
struct wlr_xdg_surface *xdg_surface = view->wlr_xdg_surface;
|
||||||
|
struct wlr_surface *surface = xdg_surface->surface;
|
||||||
|
|
||||||
struct wlr_box new_geo;
|
struct wlr_box new_geo;
|
||||||
wlr_xdg_surface_get_geometry(xdg_surface, &new_geo);
|
wlr_xdg_surface_get_geometry(xdg_surface, &new_geo);
|
||||||
bool new_size = new_geo.width != view->geometry.width ||
|
bool new_size = new_geo.width != view->geometry.width ||
|
||||||
new_geo.height != view->geometry.height ||
|
new_geo.height != view->geometry.height ||
|
||||||
new_geo.x != view->geometry.x ||
|
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) {
|
if (new_size) {
|
||||||
// The view has unexpectedly sent a new size
|
// The view has unexpectedly sent a new size
|
||||||
desktop_damage_view(view);
|
desktop_damage_view(view);
|
||||||
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
|
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
|
||||||
if (container_is_floating(view->container)) {
|
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_commit_dirty();
|
||||||
transaction_notify_view_ready_immediately(view);
|
transaction_notify_view_ready_immediately(view);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -412,7 +412,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
|
||||||
desktop_damage_view(view);
|
desktop_damage_view(view);
|
||||||
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
|
memcpy(&view->geometry, &new_geo, sizeof(struct wlr_box));
|
||||||
if (container_is_floating(view->container)) {
|
if (container_is_floating(view->container)) {
|
||||||
view_update_size(view);
|
view_update_size(view, 0, 0);
|
||||||
transaction_commit_dirty();
|
transaction_commit_dirty();
|
||||||
} else {
|
} else {
|
||||||
view_center_surface(view);
|
view_center_surface(view);
|
||||||
|
|
|
||||||
|
|
@ -872,10 +872,13 @@ void view_unmap(struct sway_view *view) {
|
||||||
view->surface = NULL;
|
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;
|
struct sway_container *con = view->container;
|
||||||
|
con->content_x += dx;
|
||||||
|
con->content_y += dy;
|
||||||
con->content_width = view->geometry.width;
|
con->content_width = view->geometry.width;
|
||||||
con->content_height = view->geometry.height;
|
con->content_height = view->geometry.height;
|
||||||
|
|
||||||
container_set_geometry_from_content(con);
|
container_set_geometry_from_content(con);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue