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

[Xwayland] Fix broken rescaling #3050

Merged
merged 2 commits into from
Sep 22, 2023
Merged
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
29 changes: 17 additions & 12 deletions src/server/frontend_xwayland/xwayland_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1221,20 +1221,25 @@ void mf::XWaylandSurface::prep_surface_spec(ProofOfMutexLock const&, msh::Surfac
}
}

#define SCALE_SIZE(type, prop) \
if (mods.prop) \
{ \
mods.prop = std::max(geom::type{1}, mods.prop.value() * inv_scale); \
}
auto scale_size_clamped = [inv_scale](auto& optional_prop)
{
if (optional_prop)
{
using ValueType = typename std::remove_reference<decltype(optional_prop.value())>::type;
using UnderlyingType = typename ValueType::ValueType;
auto constexpr raw_max = std::numeric_limits<UnderlyingType>::max();

SCALE_SIZE(Width, width);
SCALE_SIZE(Height, height);
SCALE_SIZE(Width, min_width);
SCALE_SIZE(Height, min_height);
SCALE_SIZE(Width, max_width);
SCALE_SIZE(Height, max_height);
double const double_value = optional_prop.value().as_value() * inv_scale;
optional_prop = std::max(ValueType{1}, ValueType{std::min(double_value, double{raw_max})});
}
};

#undef SCALE_SIZE
scale_size_clamped(mods.width);
scale_size_clamped(mods.height);
scale_size_clamped(mods.min_width);
scale_size_clamped(mods.min_height);
scale_size_clamped(mods.max_width);
scale_size_clamped(mods.max_height);

// NOTE: exclusive rect not checked because it is not used by XWayland surfaces
// NOTE: aux rect related properties not checks because they are only set in this method
Expand Down
Loading