Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resize: Respect client minimum and maximum sizes #2434

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 48 additions & 3 deletions plugins/single_plugins/resize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class wayfire_resize : public wf::per_output_plugin_instance_t, public wf::point
bool preserve_aspect = false;
wf::point_t grab_start;
wf::geometry_t grabbed_geometry;
wf::dimensions_t min_size, max_size;

uint32_t edges;
wf::option_wrapper_t<wf::buttonbinding_t> button{"resize/activate"};
Expand Down Expand Up @@ -222,6 +223,8 @@ class wayfire_resize : public wf::per_output_plugin_instance_t, public wf::point

grab_start = get_input_coords();
grabbed_geometry = view->get_geometry();
min_size = view->toplevel()->get_min_size();
max_size = view->toplevel()->get_max_size();
if (view->pending_tiled_edges())
{
view->toplevel()->pending().tiled_edges = 0;
Expand Down Expand Up @@ -349,9 +352,51 @@ class wayfire_resize : public wf::per_output_plugin_instance_t, public wf::point
desired.height = std::max(desired.height, 1);
}

view->toplevel()->pending().gravity = calculate_gravity();
view->toplevel()->pending().geometry = desired;
wf::get_core().tx_manager->schedule_object(view->toplevel());
auto desired_unconstrained = desired;

if (min_size.width > 0)
{
desired.width =
std::max(min_size.width +
(view->toplevel()->pending().margins.left + view->toplevel()->pending().margins.right),
desired.width);
}

if (max_size.width > 0)
{
desired.width =
std::min(max_size.width -
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the subtraction here? max_size is what the client reports, but our full geometry can grow to client_max_size + margins from the decoration.

(view->toplevel()->pending().margins.left + view->toplevel()->pending().margins.right),
desired.width);
}

if (min_size.height > 0)
{
desired.height =
std::max(min_size.height +
(view->toplevel()->pending().margins.top + view->toplevel()->pending().margins.bottom),
desired.height);
}

if (max_size.height > 0)
{
desired.height =
std::min(max_size.height -
(view->toplevel()->pending().margins.top + view->toplevel()->pending().margins.bottom),
desired.height);
}

auto desired_constrained = desired;
desired.x += desired_unconstrained.width - desired_constrained.width;
desired.y += desired_unconstrained.height - desired_constrained.height;

if ((view->toplevel()->pending().geometry.width != desired.width) ||
(view->toplevel()->pending().geometry.height != desired.height))
{
view->toplevel()->pending().gravity = calculate_gravity();
view->toplevel()->pending().geometry = desired;
wf::get_core().tx_manager->schedule_object(view->toplevel());
}
}

void fini() override
Expand Down
Loading