mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 10:25:59 +01:00
fadein and prep for fadeout
This commit is contained in:
parent
f5562941f7
commit
f8e0b0b448
11 changed files with 63 additions and 10 deletions
|
@ -230,7 +230,7 @@ SMonitor* CCompositor::getMonitorFromVector(const Vector2D& point) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCompositor::removeWindowFromVectorSafe(CWindow* pWindow) {
|
void CCompositor::removeWindowFromVectorSafe(CWindow* pWindow) {
|
||||||
if (windowExists(pWindow))
|
if (windowExists(pWindow) && !pWindow->m_bFadingOut)
|
||||||
m_lWindows.remove(*pWindow);
|
m_lWindows.remove(*pWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,4 +552,15 @@ void CCompositor::moveWindowToTop(CWindow* pWindow) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCompositor::cleanupWindows() {
|
||||||
|
for (auto& w : m_lWindowsFadingOut) {
|
||||||
|
if (!w->m_bFadingOut || w->m_fAlpha == 0.f) {
|
||||||
|
m_lWindows.remove(*w);
|
||||||
|
m_lWindowsFadingOut.remove(w);
|
||||||
|
Debug::log(LOG, "Cleanup: cleaned up a window");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -58,6 +58,7 @@ public:
|
||||||
std::list<SXDGPopup> m_lXDGPopups;
|
std::list<SXDGPopup> m_lXDGPopups;
|
||||||
std::list<SWorkspace> m_lWorkspaces;
|
std::list<SWorkspace> m_lWorkspaces;
|
||||||
std::list<SSubsurface> m_lSubsurfaces;
|
std::list<SSubsurface> m_lSubsurfaces;
|
||||||
|
std::list<CWindow*> m_lWindowsFadingOut;
|
||||||
|
|
||||||
void startCompositor();
|
void startCompositor();
|
||||||
|
|
||||||
|
@ -97,6 +98,7 @@ public:
|
||||||
bool doesSeatAcceptInput(wlr_surface*);
|
bool doesSeatAcceptInput(wlr_surface*);
|
||||||
bool isWindowActive(CWindow*);
|
bool isWindowActive(CWindow*);
|
||||||
void moveWindowToTop(CWindow*);
|
void moveWindowToTop(CWindow*);
|
||||||
|
void cleanupWindows();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initAllSignals();
|
void initAllSignals();
|
||||||
|
|
|
@ -68,6 +68,10 @@ public:
|
||||||
// Animated border
|
// Animated border
|
||||||
CColor m_cRealBorderColor = CColor(0,0,0,0);
|
CColor m_cRealBorderColor = CColor(0,0,0,0);
|
||||||
|
|
||||||
|
// Fade in-out
|
||||||
|
float m_fAlpha = 0.f;
|
||||||
|
bool m_bFadingOut = false;
|
||||||
|
|
||||||
|
|
||||||
// For the list lookup
|
// For the list lookup
|
||||||
bool operator==(const CWindow& rhs) {
|
bool operator==(const CWindow& rhs) {
|
||||||
|
|
|
@ -104,6 +104,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
||||||
if (PMONITOR->ID == 0) {
|
if (PMONITOR->ID == 0) {
|
||||||
g_pCompositor->sanityCheckWorkspaces();
|
g_pCompositor->sanityCheckWorkspaces();
|
||||||
g_pAnimationManager->tick();
|
g_pAnimationManager->tick();
|
||||||
|
g_pCompositor->cleanupWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
timespec now;
|
timespec now;
|
||||||
|
|
|
@ -191,6 +191,10 @@ void Events::listener_unmapWindow(void* owner, void* data) {
|
||||||
SubsurfaceTree::destroySurfaceTree(PWINDOW->m_pSurfaceTree);
|
SubsurfaceTree::destroySurfaceTree(PWINDOW->m_pSurfaceTree);
|
||||||
|
|
||||||
PWINDOW->m_pSurfaceTree = nullptr;
|
PWINDOW->m_pSurfaceTree = nullptr;
|
||||||
|
|
||||||
|
PWINDOW->m_bFadingOut = true;
|
||||||
|
|
||||||
|
g_pCompositor->m_lWindowsFadingOut.push_back(PWINDOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_commitWindow(void* owner, void* data) {
|
void Events::listener_commitWindow(void* owner, void* data) {
|
||||||
|
|
|
@ -42,6 +42,9 @@ struct SRenderData {
|
||||||
|
|
||||||
// for rounding
|
// for rounding
|
||||||
bool dontRound = true;
|
bool dontRound = true;
|
||||||
|
|
||||||
|
// for fade
|
||||||
|
float fadeAlpha = 255.f;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SKeyboard {
|
struct SKeyboard {
|
||||||
|
|
|
@ -259,6 +259,10 @@ void CHyprDwindleLayout::onWindowRemoved(CWindow* pWindow) {
|
||||||
|
|
||||||
m_lDwindleNodesData.remove(*PPARENT);
|
m_lDwindleNodesData.remove(*PPARENT);
|
||||||
m_lDwindleNodesData.remove(*PNODE);
|
m_lDwindleNodesData.remove(*PNODE);
|
||||||
|
|
||||||
|
// jump back like it jumps in
|
||||||
|
pWindow->m_vEffectivePosition = pWindow->m_vEffectivePosition + ((pWindow->m_vEffectiveSize - Vector2D(5, 5)) * 0.5f);
|
||||||
|
pWindow->m_vEffectiveSize = Vector2D(5, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
|
void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
|
||||||
|
|
|
@ -10,18 +10,43 @@ void CAnimationManager::tick() {
|
||||||
|
|
||||||
const bool WINDOWSENABLED = g_pConfigManager->getInt("animations:windows") && !animationsDisabled;
|
const bool WINDOWSENABLED = g_pConfigManager->getInt("animations:windows") && !animationsDisabled;
|
||||||
const bool BORDERSENABLED = g_pConfigManager->getInt("animations:borders") && !animationsDisabled;
|
const bool BORDERSENABLED = g_pConfigManager->getInt("animations:borders") && !animationsDisabled;
|
||||||
// const bool FADEENABLED = g_pConfigManager->getInt("animations:fadein") && !animationsDisabled;
|
const bool FADEENABLED = g_pConfigManager->getInt("animations:fadein") && !animationsDisabled;
|
||||||
const float ANIMSPEED = g_pConfigManager->getFloat("animations:speed");
|
const float ANIMSPEED = g_pConfigManager->getFloat("animations:speed");
|
||||||
|
|
||||||
// Process speeds
|
// Process speeds
|
||||||
const float WINDOWSPEED = g_pConfigManager->getFloat("animations:windows_speed") == 0 ? ANIMSPEED : g_pConfigManager->getFloat("animations:windows_speed");
|
const float WINDOWSPEED = g_pConfigManager->getFloat("animations:windows_speed") == 0 ? ANIMSPEED : g_pConfigManager->getFloat("animations:windows_speed");
|
||||||
const float BORDERSPEED = g_pConfigManager->getFloat("animations:borders_speed") == 0 ? ANIMSPEED : g_pConfigManager->getFloat("animations:borders_speed");
|
const float BORDERSPEED = g_pConfigManager->getFloat("animations:borders_speed") == 0 ? ANIMSPEED : g_pConfigManager->getFloat("animations:borders_speed");
|
||||||
|
const float FADESPEED = g_pConfigManager->getFloat("animations:fadein_speed") == 0 ? ANIMSPEED : g_pConfigManager->getFloat("animations:fadein_speed");
|
||||||
|
|
||||||
const auto BORDERACTIVECOL = CColor(g_pConfigManager->getInt("general:col.active_border"));
|
const auto BORDERACTIVECOL = CColor(g_pConfigManager->getInt("general:col.active_border"));
|
||||||
const auto BORDERINACTIVECOL = CColor(g_pConfigManager->getInt("general:col.inactive_border"));
|
const auto BORDERINACTIVECOL = CColor(g_pConfigManager->getInt("general:col.inactive_border"));
|
||||||
|
|
||||||
for (auto& w : g_pCompositor->m_lWindows) {
|
for (auto& w : g_pCompositor->m_lWindows) {
|
||||||
|
|
||||||
|
// process fadeinout
|
||||||
|
if (FADEENABLED) {
|
||||||
|
const auto GOALALPHA = w.m_bIsMapped ? 255.f : 0.f;
|
||||||
|
w.m_bFadingOut = false;
|
||||||
|
|
||||||
|
if (!deltazero(w.m_fAlpha, GOALALPHA)) {
|
||||||
|
if (deltaSmallToFlip(w.m_fAlpha, GOALALPHA)) {
|
||||||
|
w.m_fAlpha = GOALALPHA;
|
||||||
|
} else {
|
||||||
|
if (w.m_fAlpha > GOALALPHA)
|
||||||
|
w.m_bFadingOut = true;
|
||||||
|
w.m_fAlpha = parabolic(w.m_fAlpha, GOALALPHA, FADESPEED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (w.m_bIsMapped)
|
||||||
|
w.m_fAlpha = 255.f;
|
||||||
|
else {
|
||||||
|
w.m_fAlpha = 0.f;
|
||||||
|
w.m_bFadingOut = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// process the borders
|
// process the borders
|
||||||
const auto& COLOR = g_pCompositor->isWindowActive(&w) ? BORDERACTIVECOL : BORDERINACTIVECOL;
|
const auto& COLOR = g_pCompositor->isWindowActive(&w) ? BORDERACTIVECOL : BORDERINACTIVECOL;
|
||||||
|
|
||||||
|
|
|
@ -114,9 +114,6 @@ void CHyprXWaylandManager::sendCloseWindow(CWindow* pWindow) {
|
||||||
} else {
|
} else {
|
||||||
wlr_xdg_toplevel_send_close(pWindow->m_uSurface.xdg->toplevel);
|
wlr_xdg_toplevel_send_close(pWindow->m_uSurface.xdg->toplevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pWindow);
|
|
||||||
g_pCompositor->removeWindowFromVectorSafe(pWindow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprXWaylandManager::setWindowSize(CWindow* pWindow, const Vector2D& size) {
|
void CHyprXWaylandManager::setWindowSize(CWindow* pWindow, const Vector2D& size) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
wlr_matrix_project_box(matrix, &windowBox, TRANSFORM, 0, RDATA->output->transform_matrix);
|
wlr_matrix_project_box(matrix, &windowBox, TRANSFORM, 0, RDATA->output->transform_matrix);
|
||||||
|
|
||||||
g_pHyprOpenGL->renderTexture(TEXTURE, matrix, 255.f, RDATA->dontRound ? 0 : g_pConfigManager->getInt("decoration:rounding")); // TODO: fadeinout
|
g_pHyprOpenGL->renderTexture(TEXTURE, matrix, RDATA->fadeAlpha, RDATA->dontRound ? 0 : g_pConfigManager->getInt("decoration:rounding")); // TODO: fadeinout
|
||||||
|
|
||||||
wlr_surface_send_frame_done(surface, RDATA->when);
|
wlr_surface_send_frame_done(surface, RDATA->when);
|
||||||
|
|
||||||
|
@ -88,12 +88,13 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec*
|
||||||
renderdata.w = pWindow->m_vRealSize.x;
|
renderdata.w = pWindow->m_vRealSize.x;
|
||||||
renderdata.h = pWindow->m_vRealSize.y;
|
renderdata.h = pWindow->m_vRealSize.y;
|
||||||
renderdata.dontRound = false;
|
renderdata.dontRound = false;
|
||||||
|
renderdata.fadeAlpha = pWindow->m_fAlpha;
|
||||||
|
|
||||||
wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(pWindow), renderSurface, &renderdata);
|
wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(pWindow), renderSurface, &renderdata);
|
||||||
|
|
||||||
// border
|
// border
|
||||||
if (decorate && !pWindow->m_bX11DoesntWantBorders)
|
if (decorate && !pWindow->m_bX11DoesntWantBorders)
|
||||||
drawBorderForWindow(pWindow, pMonitor);
|
drawBorderForWindow(pWindow, pMonitor, pWindow->m_fAlpha);
|
||||||
|
|
||||||
if (pWindow->m_bIsX11) {
|
if (pWindow->m_bIsX11) {
|
||||||
if (pWindow->m_uSurface.xwayland->surface) {
|
if (pWindow->m_uSurface.xwayland->surface) {
|
||||||
|
@ -394,13 +395,14 @@ void CHyprRenderer::arrangeLayersForMonitor(const int& monitor) {
|
||||||
Debug::log(LOG, "Monitor %s layers arranged: reserved: %f %f %f %f", PMONITOR->szName.c_str(), PMONITOR->vecReservedTopLeft.x, PMONITOR->vecReservedTopLeft.y, PMONITOR->vecReservedBottomRight.x, PMONITOR->vecReservedBottomRight.y);
|
Debug::log(LOG, "Monitor %s layers arranged: reserved: %f %f %f %f", PMONITOR->szName.c_str(), PMONITOR->vecReservedTopLeft.x, PMONITOR->vecReservedTopLeft.y, PMONITOR->vecReservedBottomRight.x, PMONITOR->vecReservedBottomRight.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprRenderer::drawBorderForWindow(CWindow* pWindow, SMonitor* pMonitor) {
|
void CHyprRenderer::drawBorderForWindow(CWindow* pWindow, SMonitor* pMonitor, float alpha) {
|
||||||
const auto BORDERSIZE = g_pConfigManager->getInt("general:border_size");
|
const auto BORDERSIZE = g_pConfigManager->getInt("general:border_size");
|
||||||
|
|
||||||
if (BORDERSIZE < 1)
|
if (BORDERSIZE < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto BORDERCOL = pWindow->m_cRealBorderColor;
|
auto BORDERCOL = pWindow->m_cRealBorderColor;
|
||||||
|
BORDERCOL.a *= (alpha / 255.f);
|
||||||
|
|
||||||
Vector2D correctPos = pWindow->m_vRealPosition - pMonitor->vecPosition;
|
Vector2D correctPos = pWindow->m_vRealPosition - pMonitor->vecPosition;
|
||||||
Vector2D correctSize = pWindow->m_vRealSize;
|
Vector2D correctSize = pWindow->m_vRealSize;
|
||||||
|
|
|
@ -16,7 +16,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void arrangeLayerArray(SMonitor*, const std::list<SLayerSurface*>&, bool, wlr_box*);
|
void arrangeLayerArray(SMonitor*, const std::list<SLayerSurface*>&, bool, wlr_box*);
|
||||||
void drawBorderForWindow(CWindow*, SMonitor*);
|
void drawBorderForWindow(CWindow*, SMonitor*, float a = 255.f);
|
||||||
void renderWorkspaceWithFullscreenWindow(SMonitor*, SWorkspace*, timespec*);
|
void renderWorkspaceWithFullscreenWindow(SMonitor*, SWorkspace*, timespec*);
|
||||||
void renderWindow(CWindow*, SMonitor*, timespec*, bool);
|
void renderWindow(CWindow*, SMonitor*, timespec*, bool);
|
||||||
void renderDragIcon(SMonitor*, timespec*);
|
void renderDragIcon(SMonitor*, timespec*);
|
||||||
|
|
Loading…
Reference in a new issue