From 0d1972eacf3689e708c98ef39a16ea062e6c630f Mon Sep 17 00:00:00 2001 From: tiosgz Date: Sat, 11 Sep 2021 18:56:43 +0000 Subject: [PATCH 1/4] Fix getting view position view->geom.{x,y} tell the compositor where to place the buffer relatively to the view, view->{x,y} is the view's absolute position. --- kiwmi/desktop/desktop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kiwmi/desktop/desktop.c b/kiwmi/desktop/desktop.c index 6ec16eb..5cbd97b 100644 --- a/kiwmi/desktop/desktop.c +++ b/kiwmi/desktop/desktop.c @@ -105,8 +105,8 @@ desktop_active_output(struct kiwmi_server *server) break; // get first element of list } - double lx = view->geom.x + view->geom.width / 2; - double ly = view->geom.y + view->geom.height / 2; + double lx = view->x + view->geom.width / 2; + double ly = view->y + view->geom.height / 2; struct wlr_output *wlr_output = wlr_output_layout_output_at(server->desktop.output_layout, lx, ly); From 8e58279c26bfd0fe4608f62199b42270e0233ecb Mon Sep 17 00:00:00 2001 From: tiosgz Date: Wed, 15 Sep 2021 16:58:02 +0000 Subject: [PATCH 2/4] Fix xdg_shell_view_get_size If the view doesn't set its size explicitly (e.g. imv), it returned 0 --- kiwmi/desktop/xdg_shell.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kiwmi/desktop/xdg_shell.c b/kiwmi/desktop/xdg_shell.c index 3402a02..107675f 100644 --- a/kiwmi/desktop/xdg_shell.c +++ b/kiwmi/desktop/xdg_shell.c @@ -388,10 +388,11 @@ xdg_shell_view_get_size( uint32_t *width, uint32_t *height) { - struct wlr_box *geom = &view->xdg_surface->geometry; + struct wlr_box geom; + wlr_xdg_surface_get_geometry(view->xdg_surface, &geom); - *width = geom->width; - *height = geom->height; + *width = geom.width; + *height = geom.height; } static const char * From 251afa161d5f5a77ad2f45bd2108ec1c586c456b Mon Sep 17 00:00:00 2001 From: tiosgz Date: Wed, 15 Sep 2021 17:02:06 +0000 Subject: [PATCH 3/4] Fix top edge interactive resize The view jumped to the cursor position vertically. While making this change, I also put some consistency into how position and size are set (first the original ones are considered, and then only updated as needed). It doesn't change the functionality, but is easier to understand IMO. --- kiwmi/input/cursor.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kiwmi/input/cursor.c b/kiwmi/input/cursor.c index 5f253da..9e7c3cc 100644 --- a/kiwmi/input/cursor.c +++ b/kiwmi/input/cursor.c @@ -47,14 +47,14 @@ process_cursor_motion(struct kiwmi_server *server, uint32_t time) int dy = cursor->cursor->y - cursor->grabbed.orig_y; struct wlr_box new_geom = { - .x = view->x, - .y = view->y, + .x = cursor->grabbed.orig_geom.x, + .y = cursor->grabbed.orig_geom.y, .width = cursor->grabbed.orig_geom.width, .height = cursor->grabbed.orig_geom.height, }; if (cursor->grabbed.resize_edges & WLR_EDGE_TOP) { - new_geom.y = cursor->grabbed.orig_y + dy; + new_geom.y += dy; new_geom.height -= dy; if (new_geom.height < 1) { new_geom.y += new_geom.height; @@ -64,7 +64,7 @@ process_cursor_motion(struct kiwmi_server *server, uint32_t time) } if (cursor->grabbed.resize_edges & WLR_EDGE_LEFT) { - new_geom.x = cursor->grabbed.orig_geom.x + dx; + new_geom.x += dx; new_geom.width -= dx; if (new_geom.width < 1) { new_geom.x += new_geom.width; From 09d0802a59f360b2b31e9d3ec9a0f53394ccc1d7 Mon Sep 17 00:00:00 2001 From: tiosgz Date: Wed, 15 Sep 2021 17:15:45 +0000 Subject: [PATCH 4/4] Allow interactive move and resize at once There is no technical reason not to allow resizing on opposite edges, effectively getting single-directional interactive move (which can be combined with another edge for resizing in the other direction). --- kiwmi/input/cursor.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kiwmi/input/cursor.c b/kiwmi/input/cursor.c index 9e7c3cc..b86fc30 100644 --- a/kiwmi/input/cursor.c +++ b/kiwmi/input/cursor.c @@ -59,7 +59,8 @@ process_cursor_motion(struct kiwmi_server *server, uint32_t time) if (new_geom.height < 1) { new_geom.y += new_geom.height; } - } else if (cursor->grabbed.resize_edges & WLR_EDGE_BOTTOM) { + } + if (cursor->grabbed.resize_edges & WLR_EDGE_BOTTOM) { new_geom.height += dy; } @@ -69,7 +70,8 @@ process_cursor_motion(struct kiwmi_server *server, uint32_t time) if (new_geom.width < 1) { new_geom.x += new_geom.width; } - } else if (cursor->grabbed.resize_edges & WLR_EDGE_RIGHT) { + } + if (cursor->grabbed.resize_edges & WLR_EDGE_RIGHT) { new_geom.width += dx; }