fix some default floating windows crashing

This commit is contained in:
vaxerski 2021-12-04 23:38:31 +01:00
parent aacdd572f4
commit d1f1643a8f
2 changed files with 10 additions and 4 deletions

View file

@ -129,10 +129,10 @@ CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) {
window.setDefaultSize(Vector2D(g_pWindowManager->Screen->width_in_pixels / 2.f, g_pWindowManager->Screen->height_in_pixels / 2.f));
}
if (window.getDefaultSize().x < 20 || window.getDefaultSize().y < 20) {
if (window.getDefaultSize().x < 40 || window.getDefaultSize().y < 40) {
// min size
window.setDefaultSize(Vector2D( std::clamp(window.getDefaultSize().x, (double)20, (double)99999),
std::clamp(window.getDefaultSize().y, (double)20, (double)99999)));
window.setDefaultSize(Vector2D(std::clamp(window.getDefaultSize().x, (double)40, (double)99999),
std::clamp(window.getDefaultSize().y, (double)40, (double)99999)));
}
if (nextWindowCentered) {
@ -172,6 +172,9 @@ CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) {
//
//
window.setSize(window.getDefaultSize());
window.setPosition(window.getDefaultPosition());
// Also sets the old one
g_pWindowManager->calculateNewWindowParams(&window);

View file

@ -681,7 +681,6 @@ void CWindowManager::applyRoundedCornersToWindow(CWindow* pWindow) {
}
void CWindowManager::setEffectiveSizePosUsingConfig(CWindow* pWindow) {
if (!pWindow || pWindow->getIsFloating())
return;
@ -907,6 +906,10 @@ void CWindowManager::calculateNewFloatingWindow(CWindow* pWindow) {
pWindow->setPosition(pWindow->getEffectivePosition() + Vector2D(3,3));
pWindow->setSize(pWindow->getEffectiveSize() - Vector2D(6, 6));
// min size
pWindow->setSize(Vector2D(std::clamp(pWindow->getSize().x, (double)40, (double)99999),
std::clamp(pWindow->getSize().y, (double)40, (double)99999)));
pWindow->setEffectivePosition(pWindow->getPosition() + Vector2D(10, 10));
pWindow->setEffectiveSize(pWindow->getSize());