expo: close on detected workspace change

ref #112
This commit is contained in:
Vaxry 2024-04-04 01:31:10 +01:00
parent 3d7667ecc4
commit 3dda0a55c5

View file

@ -209,6 +209,11 @@ COverview::COverview(PHLWORKSPACE startedOn_, bool swipe_) : startedOn(startedOn
} }
void COverview::redrawID(int id, bool forcelowres) { void COverview::redrawID(int id, bool forcelowres) {
if (pMonitor->activeWorkspace != startedOn && !closing) {
// likely user changed.
onWorkspaceChange();
}
blockOverviewRendering = true; blockOverviewRendering = true;
g_pHyprRenderer->makeEGLCurrent(); g_pHyprRenderer->makeEGLCurrent();
@ -356,8 +361,11 @@ void COverview::onPreRender() {
} }
void COverview::onWorkspaceChange() { void COverview::onWorkspaceChange() {
if (valid(startedOn))
startedOn->startAnim(false, false, true); startedOn->startAnim(false, false, true);
else
startedOn = pMonitor->activeWorkspace; startedOn = pMonitor->activeWorkspace;
for (size_t i = 0; i < SIDE_LENGTH * SIDE_LENGTH; ++i) { for (size_t i = 0; i < SIDE_LENGTH * SIDE_LENGTH; ++i) {
if (images[i].workspaceID != pMonitor->activeWorkspaceID()) if (images[i].workspaceID != pMonitor->activeWorkspaceID())
continue; continue;
@ -365,14 +373,16 @@ void COverview::onWorkspaceChange() {
openedID = i; openedID = i;
break; break;
} }
startedOn->startAnim(true, true, true);
closeOnID = openedID;
close();
} }
void COverview::render() { void COverview::render() {
const auto GAPSIZE = (closing ? (1.0 - size.getPercent()) : size.getPercent()) * GAP_WIDTH; const auto GAPSIZE = (closing ? (1.0 - size.getPercent()) : size.getPercent()) * GAP_WIDTH;
if (pMonitor->activeWorkspace != startedOn) { if (pMonitor->activeWorkspace != startedOn && !closing) {
// likely user changed. // likely user changed.
onWorkspaceChange(); onWorkspaceChange();
} }