mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
cursor: Handle min size better
Less janky than just returning if one extent reaches max, and also uses the new min_size function for xwayland hint support. Signed-off-by: Joshua Ashton <joshua@froggi.es>
This commit is contained in:
parent
a6e1ee0a25
commit
1db6c54e59
1 changed files with 15 additions and 7 deletions
22
src/cursor.c
22
src/cursor.c
|
|
@ -82,9 +82,6 @@ process_cursor_move(struct server *server, uint32_t time)
|
|||
view->impl->move(view, server->grab_box.x + dx, server->grab_box.y + dy);
|
||||
}
|
||||
|
||||
#define MIN_VIEW_WIDTH (100)
|
||||
#define MIN_VIEW_HEIGHT (60)
|
||||
|
||||
static void
|
||||
process_cursor_resize(struct server *server, uint32_t time)
|
||||
{
|
||||
|
|
@ -97,22 +94,33 @@ process_cursor_resize(struct server *server, uint32_t time)
|
|||
.x = view->x, .y = view->y, .width = view->w, .height = view->h
|
||||
};
|
||||
|
||||
int min_width, min_height;
|
||||
view_min_size(view, &min_width, &min_height);
|
||||
|
||||
if (server->resize_edges & WLR_EDGE_TOP) {
|
||||
if (server->grab_box.height - dy < min_height) {
|
||||
dy = server->grab_box.height - min_height;
|
||||
}
|
||||
new_view_geo.y = server->grab_box.y + dy;
|
||||
new_view_geo.height = server->grab_box.height - dy;
|
||||
} else if (server->resize_edges & WLR_EDGE_BOTTOM) {
|
||||
if (server->grab_box.height + dy < min_height) {
|
||||
dy = min_height - server->grab_box.height;
|
||||
}
|
||||
new_view_geo.height = server->grab_box.height + dy;
|
||||
}
|
||||
if (server->resize_edges & WLR_EDGE_LEFT) {
|
||||
if (server->grab_box.width - dx < min_width) {
|
||||
dx = server->grab_box.width - min_width;
|
||||
}
|
||||
new_view_geo.x = server->grab_box.x + dx;
|
||||
new_view_geo.width = server->grab_box.width - dx;
|
||||
} else if (server->resize_edges & WLR_EDGE_RIGHT) {
|
||||
if (server->grab_box.width + dx < min_width) {
|
||||
dx = min_width - server->grab_box.width;
|
||||
}
|
||||
new_view_geo.width = server->grab_box.width + dx;
|
||||
}
|
||||
if ((new_view_geo.height < MIN_VIEW_HEIGHT) ||
|
||||
(new_view_geo.width < MIN_VIEW_WIDTH)) {
|
||||
return;
|
||||
}
|
||||
|
||||
view_move_resize(view, new_view_geo);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue