Skip to content

Commit 4b1cd34

Browse files
committed
Allow resizing via SSDs
1 parent cf210fe commit 4b1cd34

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

src/input/cursor.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ void Cursor::process_resize(const uint32_t time) const {
4141
return;
4242
}
4343

44-
const wlr_box min_size = view->get_min_size_with_decorations();
45-
const wlr_box max_size = view->get_max_size_with_decorations();
44+
const wlr_box min_size = view->get_surface_min_size();
45+
const wlr_box max_size = view->get_surface_max_size();
4646
const double border_x = wlr.x - seat.server.grab_x;
4747
const double border_y = wlr.y - seat.server.grab_y;
4848
int32_t new_left = seat.server.grab_geobox.x;
@@ -199,8 +199,27 @@ static void cursor_button_notify(wl_listener* listener, void* data) {
199199
/* Focus that client if the button was _pressed_ */
200200
server.focus_view(std::dynamic_pointer_cast<View>(magpie_surface));
201201

202-
if (server.ssd_at(cursor.wlr.x, cursor.wlr.y) == SceneRectType::TITLEBAR) {
202+
auto ssd_at_cursor = server.ssd_at(cursor.wlr.x, cursor.wlr.y);
203+
if (ssd_at_cursor == SceneRectType::TITLEBAR) {
203204
view->begin_interactive(MAGPIE_CURSOR_MOVE, 0);
205+
} else if (ssd_at_cursor == SceneRectType::BORDER || ssd_at_cursor == SceneRectType::EXTENTS) {
206+
auto surface_geo = view->surface_current;
207+
208+
uint8_t edges = WLR_EDGE_NONE;
209+
if (cursor.wlr.x < surface_geo.x) {
210+
edges |= WLR_EDGE_LEFT;
211+
}
212+
if (cursor.wlr.y < surface_geo.y) {
213+
edges |= WLR_EDGE_TOP;
214+
}
215+
if (cursor.wlr.x > surface_geo.x + surface_geo.width) {
216+
edges |= WLR_EDGE_RIGHT;
217+
}
218+
if (cursor.wlr.y > surface_geo.y + surface_geo.height) {
219+
edges |= WLR_EDGE_BOTTOM;
220+
}
221+
222+
view->begin_interactive(MAGPIE_CURSOR_RESIZE, edges);
204223
}
205224
} else {
206225
server.focus_view(nullptr);

src/surface/view.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ void View::set_geometry(const int32_t x, const int32_t y, const int32_t width, c
159159
}
160160

161161
impl_set_geometry(surface_current.x, surface_current.y, surface_current.width, surface_current.height);
162+
163+
if (ssd.has_value()) {
164+
ssd->update();
165+
}
162166
}
163167

164168
void View::set_position(const int32_t x, const int32_t y) {

0 commit comments

Comments
 (0)