Avoid additional calculations in WindowHelper::updateMargins

This commit is contained in:
Ilya Fedin 2023-08-12 04:01:21 +04:00 committed by John Preston
parent 92cb6f6809
commit e66ad9c80c

View file

@ -851,19 +851,11 @@ void WindowHelper::updateMargins() {
_updatingMargins = true;
const auto guard = gsl::finally([&] { _updatingMargins = false; });
RECT r, a;
GetClientRect(_handle, &r);
a = r;
RECT r{};
const auto style = GetWindowLongPtr(_handle, GWL_STYLE);
const auto styleEx = GetWindowLongPtr(_handle, GWL_EXSTYLE);
AdjustWindowRectEx(&a, style, false, styleEx);
auto margins = QMargins(
a.left - r.left,
a.top - r.top,
r.right - a.right,
r.bottom - a.bottom);
auto margins = QMargins(r.left, r.top, -r.right, -r.bottom);
if (style & WS_MAXIMIZE) {
RECT w, m;
GetWindowRect(_handle , &w);