mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 00:05:59 +01:00
parent
93d0511471
commit
132ab8d035
1 changed files with 27 additions and 10 deletions
|
@ -65,11 +65,26 @@ void SLayerSurface::applyRules() {
|
||||||
void SLayerSurface::startAnimation(bool in, bool instant) {
|
void SLayerSurface::startAnimation(bool in, bool instant) {
|
||||||
const auto ANIMSTYLE = animationStyle.value_or(realPosition.m_pConfig->pValues->internalStyle);
|
const auto ANIMSTYLE = animationStyle.value_or(realPosition.m_pConfig->pValues->internalStyle);
|
||||||
|
|
||||||
if (ANIMSTYLE == "slide") {
|
if (ANIMSTYLE.starts_with("slide")) {
|
||||||
// get closest edge
|
// get closest edge
|
||||||
const auto MIDDLE = geometry.middle();
|
const auto MIDDLE = geometry.middle();
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromVector(MIDDLE);
|
const auto PMONITOR = g_pCompositor->getMonitorFromVector(MIDDLE);
|
||||||
|
|
||||||
|
int force = -1;
|
||||||
|
|
||||||
|
CVarList args(ANIMSTYLE, 0, 's');
|
||||||
|
if (args.size() > 1) {
|
||||||
|
const auto ARG2 = args[1];
|
||||||
|
if (ARG2 == "top")
|
||||||
|
force = 0;
|
||||||
|
else if (ARG2 == "bottom")
|
||||||
|
force = 1;
|
||||||
|
else if (ARG2 == "left")
|
||||||
|
force = 2;
|
||||||
|
else if (ARG2 == "right")
|
||||||
|
force = 3;
|
||||||
|
}
|
||||||
|
|
||||||
const std::array<Vector2D, 4> edgePoints = {
|
const std::array<Vector2D, 4> edgePoints = {
|
||||||
PMONITOR->vecPosition + Vector2D{PMONITOR->vecSize.x / 2, 0},
|
PMONITOR->vecPosition + Vector2D{PMONITOR->vecSize.x / 2, 0},
|
||||||
|
@ -78,13 +93,15 @@ void SLayerSurface::startAnimation(bool in, bool instant) {
|
||||||
PMONITOR->vecPosition + Vector2D{PMONITOR->vecSize.x, PMONITOR->vecSize.y / 2},
|
PMONITOR->vecPosition + Vector2D{PMONITOR->vecSize.x, PMONITOR->vecSize.y / 2},
|
||||||
};
|
};
|
||||||
|
|
||||||
float closest = std::numeric_limits<float>::max();
|
float closest = std::numeric_limits<float>::max();
|
||||||
size_t leader = 0;
|
int leader = force;
|
||||||
for (size_t i = 0; i < 4; ++i) {
|
if (leader == -1) {
|
||||||
float dist = MIDDLE.distance(edgePoints[i]);
|
for (size_t i = 0; i < 4; ++i) {
|
||||||
if (dist < closest) {
|
float dist = MIDDLE.distance(edgePoints[i]);
|
||||||
leader = i;
|
if (dist < closest) {
|
||||||
closest = dist;
|
leader = i;
|
||||||
|
closest = dist;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue