Skip to content

Commit

Permalink
Ensure surfaces can only resize down to 32x32
Browse files Browse the repository at this point in the history
  • Loading branch information
serebit committed Nov 9, 2024
1 parent 7ddfe20 commit eaf506f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/surface/xdg_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,13 @@ wlr_box XdgView::get_surface_geometry() const {
return box;
}

constexpr int32_t XDG_SURFACE_MIN_SIZE = 32;

wlr_box XdgView::get_surface_min_size() const {
return {.x = 0, .y = 0, .width = wlr.current.min_width, .height = wlr.current.min_height};
return {.x = 0,
.y = 0,
.width = std::max(XDG_SURFACE_MIN_SIZE, wlr.current.min_width),
.height = std::max(XDG_SURFACE_MIN_SIZE, wlr.current.min_height)};
}

wlr_box XdgView::get_surface_max_size() const {
Expand Down
6 changes: 4 additions & 2 deletions src/surface/xwayland_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,14 @@ wlr_box XWaylandView::get_surface_geometry() const {
return {.x = wlr.x, .y = wlr.y, .width = wlr.width, .height = wlr.height};
}

constexpr int32_t XWAYLAND_SURFACE_MIN_SIZE = 32;

wlr_box XWaylandView::get_surface_min_size() const {
wlr_box min = {.x = 0, .y = 0, .width = 0, .height = 0};
if (wlr.size_hints != nullptr) {
const auto& hints = *wlr.size_hints;
min.width = std::max(hints.min_width, hints.base_width);
min.height = std::max(hints.min_height, hints.base_height);
min.width = std::max({XWAYLAND_SURFACE_MIN_SIZE, hints.min_width, hints.base_width});
min.height = std::max({XWAYLAND_SURFACE_MIN_SIZE, hints.min_height, hints.base_height});
}
return min;
}
Expand Down

0 comments on commit eaf506f

Please sign in to comment.