From 4b1cd342d03b0336f6740f0ae00d98bc964bceca Mon Sep 17 00:00:00 2001 From: Campbell Jones Date: Sat, 9 Nov 2024 15:07:03 -0500 Subject: [PATCH] Allow resizing via SSDs --- src/input/cursor.cpp | 25 ++++++++++++++++++++++--- src/surface/view.cpp | 4 ++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/input/cursor.cpp b/src/input/cursor.cpp index b18f3a805..a374994f6 100644 --- a/src/input/cursor.cpp +++ b/src/input/cursor.cpp @@ -41,8 +41,8 @@ void Cursor::process_resize(const uint32_t time) const { return; } - const wlr_box min_size = view->get_min_size_with_decorations(); - const wlr_box max_size = view->get_max_size_with_decorations(); + const wlr_box min_size = view->get_surface_min_size(); + const wlr_box max_size = view->get_surface_max_size(); const double border_x = wlr.x - seat.server.grab_x; const double border_y = wlr.y - seat.server.grab_y; int32_t new_left = seat.server.grab_geobox.x; @@ -199,8 +199,27 @@ static void cursor_button_notify(wl_listener* listener, void* data) { /* Focus that client if the button was _pressed_ */ server.focus_view(std::dynamic_pointer_cast(magpie_surface)); - if (server.ssd_at(cursor.wlr.x, cursor.wlr.y) == SceneRectType::TITLEBAR) { + auto ssd_at_cursor = server.ssd_at(cursor.wlr.x, cursor.wlr.y); + if (ssd_at_cursor == SceneRectType::TITLEBAR) { view->begin_interactive(MAGPIE_CURSOR_MOVE, 0); + } else if (ssd_at_cursor == SceneRectType::BORDER || ssd_at_cursor == SceneRectType::EXTENTS) { + auto surface_geo = view->surface_current; + + uint8_t edges = WLR_EDGE_NONE; + if (cursor.wlr.x < surface_geo.x) { + edges |= WLR_EDGE_LEFT; + } + if (cursor.wlr.y < surface_geo.y) { + edges |= WLR_EDGE_TOP; + } + if (cursor.wlr.x > surface_geo.x + surface_geo.width) { + edges |= WLR_EDGE_RIGHT; + } + if (cursor.wlr.y > surface_geo.y + surface_geo.height) { + edges |= WLR_EDGE_BOTTOM; + } + + view->begin_interactive(MAGPIE_CURSOR_RESIZE, edges); } } else { server.focus_view(nullptr); diff --git a/src/surface/view.cpp b/src/surface/view.cpp index 08d8999f4..9db016c2e 100644 --- a/src/surface/view.cpp +++ b/src/surface/view.cpp @@ -159,6 +159,10 @@ void View::set_geometry(const int32_t x, const int32_t y, const int32_t width, c } impl_set_geometry(surface_current.x, surface_current.y, surface_current.width, surface_current.height); + + if (ssd.has_value()) { + ssd->update(); + } } void View::set_position(const int32_t x, const int32_t y) {