From dc3b6a930311ab4dea9d18a7340db6c8d7cf2be6 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 add373e..d6dee0b 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 ff762668a63fcd30dddc402634ddee707ad8b256 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 8e9dabb..d24ab50 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 b364634a9c9d83f127088d45a32fde8bb8f91eb5 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 c15e1fa..d52222a 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 b9078f543b989b0943d1d577da72a49e13d57ab4 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 d52222a..6fff8ec 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; }