desktopAnimationMgr: fix slide direction
ref https://github.com/hyprwm/Hyprland/discussions/12744
This commit is contained in:
parent
f8464866eb
commit
293d3e5de9
1 changed files with 20 additions and 24 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
#include "DesktopAnimationManager.hpp"
|
#include "DesktopAnimationManager.hpp"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "../../desktop/view/LayerSurface.hpp"
|
#include "../../desktop/view/LayerSurface.hpp"
|
||||||
#include "../../desktop/view/Window.hpp"
|
#include "../../desktop/view/Window.hpp"
|
||||||
#include "../../desktop/Workspace.hpp"
|
#include "../../desktop/Workspace.hpp"
|
||||||
|
|
@ -406,32 +408,26 @@ void CDesktopAnimationManager::animationSlide(PHLWINDOW pWindow, std::string for
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto MIDPOINT = GOALPOS + GOALSIZE / 2.f;
|
const auto MIDPOINT = GOALPOS + GOALSIZE / 2.f;
|
||||||
|
const auto MONBOX = PMONITOR->logicalBox();
|
||||||
|
|
||||||
// check sides it touches
|
// find the closest edge to midpoint
|
||||||
const auto MONITOR_WORKAREA = PMONITOR->logicalBoxMinusReserved();
|
// CSS style, top right bottom left
|
||||||
const bool DISPLAYLEFT = STICKS(pWindow->m_position.x, MONITOR_WORKAREA.x);
|
std::array<float, 4> distances = {
|
||||||
const bool DISPLAYRIGHT = STICKS(pWindow->m_position.x + pWindow->m_size.x, MONITOR_WORKAREA.x + MONITOR_WORKAREA.w);
|
MIDPOINT.y - MONBOX.y, //
|
||||||
const bool DISPLAYTOP = STICKS(pWindow->m_position.y, MONITOR_WORKAREA.y);
|
MONBOX.x + MONBOX.w - MIDPOINT.x, //
|
||||||
const bool DISPLAYBOTTOM = STICKS(pWindow->m_position.y + pWindow->m_size.y, MONITOR_WORKAREA.y + MONITOR_WORKAREA.h);
|
MONBOX.y + MONBOX.h - MIDPOINT.y, //
|
||||||
|
MIDPOINT.x - MONBOX.x, //
|
||||||
|
};
|
||||||
|
|
||||||
if (DISPLAYBOTTOM && DISPLAYTOP) {
|
const auto MIN_DIST = std::min({distances[0], distances[1], distances[2], distances[3]});
|
||||||
if (DISPLAYLEFT && DISPLAYRIGHT) {
|
if (MIN_DIST == distances[2])
|
||||||
posOffset = GOALPOS + Vector2D(0.0, GOALSIZE.y);
|
posOffset = Vector2D(GOALPOS.x, PMONITOR->m_position.y + PMONITOR->m_size.y);
|
||||||
} else if (DISPLAYLEFT) {
|
else if (MIN_DIST == distances[3])
|
||||||
posOffset = GOALPOS - Vector2D(GOALSIZE.x, 0.0);
|
posOffset = GOALPOS - Vector2D(GOALSIZE.x, 0.0);
|
||||||
} else {
|
else if (MIN_DIST == distances[1])
|
||||||
posOffset = GOALPOS + Vector2D(GOALSIZE.x, 0.0);
|
posOffset = GOALPOS + Vector2D(GOALSIZE.x, 0.0);
|
||||||
}
|
else
|
||||||
} else if (DISPLAYTOP) {
|
posOffset = Vector2D(GOALPOS.x, PMONITOR->m_position.y - GOALSIZE.y);
|
||||||
posOffset = GOALPOS - Vector2D(0.0, GOALSIZE.y);
|
|
||||||
} else if (DISPLAYBOTTOM) {
|
|
||||||
posOffset = GOALPOS + Vector2D(0.0, GOALSIZE.y);
|
|
||||||
} else {
|
|
||||||
if (MIDPOINT.y > PMONITOR->m_position.y + PMONITOR->m_size.y / 2.f)
|
|
||||||
posOffset = Vector2D(GOALPOS.x, PMONITOR->m_position.y + PMONITOR->m_size.y);
|
|
||||||
else
|
|
||||||
posOffset = Vector2D(GOALPOS.x, PMONITOR->m_position.y - GOALSIZE.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!close)
|
if (!close)
|
||||||
pWindow->m_realPosition->setValue(posOffset);
|
pWindow->m_realPosition->setValue(posOffset);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue