mirror of
https://github.com/hyprwm/Hyprland.git
synced 2024-12-19 13:41:42 +03:00
Added closing animations (reverse of open)
This commit is contained in:
parent
7f1f14fe85
commit
15553804d6
@ -82,6 +82,8 @@ public:
|
|||||||
CAnimatedVariable m_fAlpha;
|
CAnimatedVariable m_fAlpha;
|
||||||
bool m_bFadingOut = false;
|
bool m_bFadingOut = false;
|
||||||
bool m_bReadyToDelete = false;
|
bool m_bReadyToDelete = false;
|
||||||
|
Vector2D m_vOriginalClosedPos; // these will be used for calculations later on in
|
||||||
|
Vector2D m_vOriginalClosedSize; // drawing the closing animations
|
||||||
|
|
||||||
// For hidden windows and stuff
|
// For hidden windows and stuff
|
||||||
bool m_bHidden = false;
|
bool m_bHidden = false;
|
||||||
|
@ -190,7 +190,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// do the animation thing
|
// do the animation thing
|
||||||
g_pAnimationManager->onWindowPostCreate(PWINDOW);
|
g_pAnimationManager->onWindowPostCreateClose(PWINDOW, false);
|
||||||
|
|
||||||
Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y, PWINDOW->m_vRealSize.goalv().x, PWINDOW->m_vRealSize.goalv().y);
|
Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y, PWINDOW->m_vRealSize.goalv().x, PWINDOW->m_vRealSize.goalv().y);
|
||||||
}
|
}
|
||||||
@ -250,6 +250,12 @@ void Events::listener_unmapWindow(void* owner, void* data) {
|
|||||||
g_pCompositor->m_lWindowsFadingOut.push_back(PWINDOW);
|
g_pCompositor->m_lWindowsFadingOut.push_back(PWINDOW);
|
||||||
|
|
||||||
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID));
|
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID));
|
||||||
|
|
||||||
|
// do the animation thing
|
||||||
|
PWINDOW->m_vOriginalClosedPos = PWINDOW->m_vRealPosition.vec();
|
||||||
|
PWINDOW->m_vOriginalClosedSize = PWINDOW->m_vRealSize.vec();
|
||||||
|
PWINDOW->m_vRealPosition = PWINDOW->m_vRealPosition.vec() + Vector2D(0.01f, 0.01f); // it has to be animated, otherwise onWindowPostCreateClose will ignore it
|
||||||
|
g_pAnimationManager->onWindowPostCreateClose(PWINDOW, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_commitWindow(void* owner, void* data) {
|
void Events::listener_commitWindow(void* owner, void* data) {
|
||||||
|
@ -208,15 +208,20 @@ bool CAnimationManager::deltazero(const CColor& a, const CColor& b) {
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
void CAnimationManager::animationPopin(CWindow* pWindow) {
|
void CAnimationManager::animationPopin(CWindow* pWindow, bool close) {
|
||||||
const auto GOALPOS = pWindow->m_vRealPosition.goalv();
|
const auto GOALPOS = pWindow->m_vRealPosition.goalv();
|
||||||
const auto GOALSIZE = pWindow->m_vRealSize.goalv();
|
const auto GOALSIZE = pWindow->m_vRealSize.goalv();
|
||||||
|
|
||||||
|
if (!close) {
|
||||||
pWindow->m_vRealPosition.setValue(GOALPOS + GOALSIZE / 2.f);
|
pWindow->m_vRealPosition.setValue(GOALPOS + GOALSIZE / 2.f);
|
||||||
pWindow->m_vRealSize.setValue(Vector2D(5, 5));
|
pWindow->m_vRealSize.setValue(Vector2D(5, 5));
|
||||||
|
} else {
|
||||||
|
pWindow->m_vRealPosition = GOALPOS + GOALSIZE / 2.f;
|
||||||
|
pWindow->m_vRealSize = Vector2D(5, 5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimationManager::animationSlide(CWindow* pWindow, std::string force) {
|
void CAnimationManager::animationSlide(CWindow* pWindow, std::string force, bool close) {
|
||||||
pWindow->m_vRealSize.warp(); // size we preserve in slide
|
pWindow->m_vRealSize.warp(); // size we preserve in slide
|
||||||
|
|
||||||
const auto GOALPOS = pWindow->m_vRealPosition.goalv();
|
const auto GOALPOS = pWindow->m_vRealPosition.goalv();
|
||||||
@ -224,11 +229,18 @@ void CAnimationManager::animationSlide(CWindow* pWindow, std::string force) {
|
|||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
||||||
|
|
||||||
|
Vector2D posOffset;
|
||||||
|
|
||||||
if (force != "") {
|
if (force != "") {
|
||||||
if (force == "bottom") pWindow->m_vRealPosition.setValue(Vector2D(GOALPOS.x, PMONITOR->vecPosition.y + PMONITOR->vecSize.y));
|
if (force == "bottom") posOffset = Vector2D(GOALPOS.x, PMONITOR->vecPosition.y + PMONITOR->vecSize.y);
|
||||||
else if (force == "left") pWindow->m_vRealPosition.setValue(GOALPOS - Vector2D(GOALSIZE.x, 0));
|
else if (force == "left") posOffset = GOALPOS - Vector2D(GOALSIZE.x, 0);
|
||||||
else if (force == "right") pWindow->m_vRealPosition.setValue(GOALPOS + Vector2D(GOALSIZE.x, 0));
|
else if (force == "right") posOffset = GOALPOS + Vector2D(GOALSIZE.x, 0);
|
||||||
else pWindow->m_vRealPosition.setValue(Vector2D(GOALPOS.x, PMONITOR->vecPosition.y - GOALSIZE.y));
|
else posOffset = Vector2D(GOALPOS.x, PMONITOR->vecPosition.y - GOALSIZE.y);
|
||||||
|
|
||||||
|
if (!close)
|
||||||
|
pWindow->m_vRealPosition.setValue(posOffset);
|
||||||
|
else
|
||||||
|
pWindow->m_vRealPosition = posOffset;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -243,25 +255,30 @@ void CAnimationManager::animationSlide(CWindow* pWindow, std::string force) {
|
|||||||
|
|
||||||
if (DISPLAYBOTTOM && DISPLAYTOP) {
|
if (DISPLAYBOTTOM && DISPLAYTOP) {
|
||||||
if (DISPLAYLEFT && DISPLAYRIGHT) {
|
if (DISPLAYLEFT && DISPLAYRIGHT) {
|
||||||
pWindow->m_vRealPosition.setValue(GOALPOS + Vector2D(0, GOALSIZE.y));
|
posOffset = GOALPOS + Vector2D(0, GOALSIZE.y);
|
||||||
} else if (DISPLAYLEFT) {
|
} else if (DISPLAYLEFT) {
|
||||||
pWindow->m_vRealPosition.setValue(GOALPOS - Vector2D(GOALSIZE.x, 0));
|
posOffset = GOALPOS - Vector2D(GOALSIZE.x, 0);
|
||||||
} else {
|
} else {
|
||||||
pWindow->m_vRealPosition.setValue(GOALPOS + Vector2D(GOALSIZE.x, 0));
|
posOffset = GOALPOS + Vector2D(GOALSIZE.x, 0);
|
||||||
}
|
}
|
||||||
} else if (DISPLAYTOP) {
|
} else if (DISPLAYTOP) {
|
||||||
pWindow->m_vRealPosition.setValue(GOALPOS - Vector2D(0, GOALSIZE.y));
|
posOffset = GOALPOS - Vector2D(0, GOALSIZE.y);
|
||||||
} else if (DISPLAYBOTTOM) {
|
} else if (DISPLAYBOTTOM) {
|
||||||
pWindow->m_vRealPosition.setValue(GOALPOS + Vector2D(0, GOALSIZE.y));
|
posOffset = GOALPOS + Vector2D(0, GOALSIZE.y);
|
||||||
} else {
|
} else {
|
||||||
if (MIDPOINT.y > PMONITOR->vecPosition.y + PMONITOR->vecSize.y / 2.f)
|
if (MIDPOINT.y > PMONITOR->vecPosition.y + PMONITOR->vecSize.y / 2.f)
|
||||||
pWindow->m_vRealPosition.setValue(Vector2D(GOALPOS.x, PMONITOR->vecPosition.y + PMONITOR->vecSize.y));
|
posOffset = Vector2D(GOALPOS.x, PMONITOR->vecPosition.y + PMONITOR->vecSize.y);
|
||||||
else
|
else
|
||||||
pWindow->m_vRealPosition.setValue(Vector2D(GOALPOS.x, PMONITOR->vecPosition.y - GOALSIZE.y));
|
posOffset = Vector2D(GOALPOS.x, PMONITOR->vecPosition.y - GOALSIZE.y);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimationManager::onWindowPostCreate(CWindow* pWindow) {
|
if (!close)
|
||||||
|
pWindow->m_vRealPosition.setValue(posOffset);
|
||||||
|
else
|
||||||
|
pWindow->m_vRealPosition = posOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) {
|
||||||
auto ANIMSTYLE = g_pConfigManager->getString("animations:windows_style");
|
auto ANIMSTYLE = g_pConfigManager->getString("animations:windows_style");
|
||||||
transform(ANIMSTYLE.begin(), ANIMSTYLE.end(), ANIMSTYLE.begin(), ::tolower);
|
transform(ANIMSTYLE.begin(), ANIMSTYLE.end(), ANIMSTYLE.begin(), ::tolower);
|
||||||
|
|
||||||
@ -274,20 +291,20 @@ void CAnimationManager::onWindowPostCreate(CWindow* pWindow) {
|
|||||||
if (pWindow->m_sAdditionalConfigData.animationStyle.find("slide") == 0) {
|
if (pWindow->m_sAdditionalConfigData.animationStyle.find("slide") == 0) {
|
||||||
if (pWindow->m_sAdditionalConfigData.animationStyle.find(' ') != std::string::npos) {
|
if (pWindow->m_sAdditionalConfigData.animationStyle.find(' ') != std::string::npos) {
|
||||||
// has a direction
|
// has a direction
|
||||||
animationSlide(pWindow, pWindow->m_sAdditionalConfigData.animationStyle.substr(pWindow->m_sAdditionalConfigData.animationStyle.find(' ') + 1));
|
animationSlide(pWindow, pWindow->m_sAdditionalConfigData.animationStyle.substr(pWindow->m_sAdditionalConfigData.animationStyle.find(' ') + 1), close);
|
||||||
} else {
|
} else {
|
||||||
animationSlide(pWindow);
|
animationSlide(pWindow, "", close);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// anim popin, fallback
|
// anim popin, fallback
|
||||||
animationPopin(pWindow);
|
animationPopin(pWindow, close);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ANIMSTYLE == "slide") {
|
if (ANIMSTYLE == "slide") {
|
||||||
animationSlide(pWindow);
|
animationSlide(pWindow, "", close);
|
||||||
} else {
|
} else {
|
||||||
// anim popin, fallback
|
// anim popin, fallback
|
||||||
animationPopin(pWindow);
|
animationPopin(pWindow, close);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,7 +16,7 @@ public:
|
|||||||
void addBezierWithName(std::string, const Vector2D&, const Vector2D&);
|
void addBezierWithName(std::string, const Vector2D&, const Vector2D&);
|
||||||
void removeAllBeziers();
|
void removeAllBeziers();
|
||||||
|
|
||||||
void onWindowPostCreate(CWindow*);
|
void onWindowPostCreateClose(CWindow*, bool close = false);
|
||||||
|
|
||||||
std::list<CAnimatedVariable*> m_lAnimatedVariables;
|
std::list<CAnimatedVariable*> m_lAnimatedVariables;
|
||||||
|
|
||||||
@ -31,8 +31,8 @@ private:
|
|||||||
std::unordered_map<std::string, CBezierCurve> m_mBezierCurves;
|
std::unordered_map<std::string, CBezierCurve> m_mBezierCurves;
|
||||||
|
|
||||||
// Anim stuff
|
// Anim stuff
|
||||||
void animationPopin(CWindow*);
|
void animationPopin(CWindow*, bool close = false);
|
||||||
void animationSlide(CWindow*, std::string force = "");
|
void animationSlide(CWindow*, std::string force = "", bool close = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CAnimationManager> g_pAnimationManager;
|
inline std::unique_ptr<CAnimationManager> g_pAnimationManager;
|
@ -756,7 +756,14 @@ void CHyprOpenGLImpl::renderSnapshot(CWindow** pWindow) {
|
|||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||||
|
|
||||||
wlr_box windowBox = {0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y};
|
wlr_box windowBox;
|
||||||
|
// some mafs to figure out the correct box
|
||||||
|
Vector2D scaleXY = Vector2D((PWINDOW->m_vRealSize.vec().x / PWINDOW->m_vOriginalClosedSize.x), (PWINDOW->m_vRealSize.vec().y / PWINDOW->m_vOriginalClosedSize.y));
|
||||||
|
|
||||||
|
windowBox.width = PMONITOR->vecPixelSize.x * scaleXY.x;
|
||||||
|
windowBox.height = PMONITOR->vecPixelSize.y * scaleXY.y;
|
||||||
|
windowBox.x = PWINDOW->m_vRealPosition.vec().x - (PWINDOW->m_vOriginalClosedPos.x * scaleXY.x);
|
||||||
|
windowBox.y = PWINDOW->m_vRealPosition.vec().y - (PWINDOW->m_vOriginalClosedPos.y * scaleXY.y);
|
||||||
|
|
||||||
pixman_region32_t fakeDamage;
|
pixman_region32_t fakeDamage;
|
||||||
pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y);
|
pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y);
|
||||||
|
Loading…
Reference in New Issue
Block a user