diff --git a/src/ui/fit_bounds.cpp b/src/ui/fit_bounds.cpp index 4aa36ad5d..60bc7dc9a 100644 --- a/src/ui/fit_bounds.cpp +++ b/src/ui/fit_bounds.cpp @@ -1,5 +1,5 @@ // Aseprite UI Library -// Copyright (C) 2019-2022 Igara Studio S.A. +// Copyright (C) 2019-2023 Igara Studio S.A. // Copyright (C) 2001-2016 David Capello // // This file is released under the terms of the MIT license. @@ -128,8 +128,8 @@ void fit_bounds(const Display* parentDisplay, if (fitLogic) fitLogic(workarea, frame, [](Widget* widget){ return widget->boundsOnScreen(); }); - frame.x = std::clamp(frame.x, workarea.x, workarea.x2() - frame.w); - frame.y = std::clamp(frame.y, workarea.y, workarea.y2() - frame.h); + frame.x = std::clamp(frame.x, workarea.x, std::max(workarea.x, workarea.x2() - frame.w)); + frame.y = std::clamp(frame.y, workarea.y, std::max(workarea.y, workarea.y2() - frame.h)); // Set frame bounds directly window->setBounds(gfx::Rect(0, 0, frame.w / scale, frame.h / scale));