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 <algorithm>
|
||||
|
||||
#include "../../desktop/view/LayerSurface.hpp"
|
||||
#include "../../desktop/view/Window.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 MONBOX = PMONITOR->logicalBox();
|
||||
|
||||
// check sides it touches
|
||||
const auto MONITOR_WORKAREA = PMONITOR->logicalBoxMinusReserved();
|
||||
const bool DISPLAYLEFT = STICKS(pWindow->m_position.x, MONITOR_WORKAREA.x);
|
||||
const bool DISPLAYRIGHT = STICKS(pWindow->m_position.x + pWindow->m_size.x, MONITOR_WORKAREA.x + MONITOR_WORKAREA.w);
|
||||
const bool DISPLAYTOP = STICKS(pWindow->m_position.y, MONITOR_WORKAREA.y);
|
||||
const bool DISPLAYBOTTOM = STICKS(pWindow->m_position.y + pWindow->m_size.y, MONITOR_WORKAREA.y + MONITOR_WORKAREA.h);
|
||||
// find the closest edge to midpoint
|
||||
// CSS style, top right bottom left
|
||||
std::array<float, 4> distances = {
|
||||
MIDPOINT.y - MONBOX.y, //
|
||||
MONBOX.x + MONBOX.w - MIDPOINT.x, //
|
||||
MONBOX.y + MONBOX.h - MIDPOINT.y, //
|
||||
MIDPOINT.x - MONBOX.x, //
|
||||
};
|
||||
|
||||
if (DISPLAYBOTTOM && DISPLAYTOP) {
|
||||
if (DISPLAYLEFT && DISPLAYRIGHT) {
|
||||
posOffset = GOALPOS + Vector2D(0.0, GOALSIZE.y);
|
||||
} else if (DISPLAYLEFT) {
|
||||
posOffset = GOALPOS - Vector2D(GOALSIZE.x, 0.0);
|
||||
} else {
|
||||
posOffset = GOALPOS + Vector2D(GOALSIZE.x, 0.0);
|
||||
}
|
||||
} else if (DISPLAYTOP) {
|
||||
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);
|
||||
}
|
||||
const auto MIN_DIST = std::min({distances[0], distances[1], distances[2], distances[3]});
|
||||
if (MIN_DIST == distances[2])
|
||||
posOffset = Vector2D(GOALPOS.x, PMONITOR->m_position.y + PMONITOR->m_size.y);
|
||||
else if (MIN_DIST == distances[3])
|
||||
posOffset = GOALPOS - Vector2D(GOALSIZE.x, 0.0);
|
||||
else if (MIN_DIST == distances[1])
|
||||
posOffset = GOALPOS + Vector2D(GOALSIZE.x, 0.0);
|
||||
else
|
||||
posOffset = Vector2D(GOALPOS.x, PMONITOR->m_position.y - GOALSIZE.y);
|
||||
|
||||
if (!close)
|
||||
pWindow->m_realPosition->setValue(posOffset);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue