internal: allow opening empty special workspaces

Fixes point 2 of #2596
This commit is contained in:
vaxerski 2023-08-25 18:05:08 +02:00
parent 23e17700a7
commit 870471dd96
5 changed files with 47 additions and 37 deletions

View file

@ -1145,14 +1145,20 @@ void CCompositor::sanityCheckWorkspaces() {
const auto WINDOWSONWORKSPACE = getWindowsOnWorkspace((*it)->m_iID); const auto WINDOWSONWORKSPACE = getWindowsOnWorkspace((*it)->m_iID);
if ((*it)->m_bIsSpecialWorkspace && WINDOWSONWORKSPACE == 0) { if ((WINDOWSONWORKSPACE == 0 && !isWorkspaceVisible((*it)->m_iID))) {
getMonitorFromID((*it)->m_iMonitorID)->setSpecialWorkspace(nullptr);
it = m_vWorkspaces.erase(it); if ((*it)->m_bIsSpecialWorkspace) {
if ((*it)->m_fAlpha.fl() > 0.f /* don't abruptly end the fadeout */) {
++it;
continue; continue;
} }
if ((WINDOWSONWORKSPACE == 0 && !isWorkspaceVisible((*it)->m_iID))) { const auto PMONITOR = getMonitorFromID((*it)->m_iMonitorID);
if (PMONITOR && PMONITOR->specialWorkspaceID == (*it)->m_iID)
PMONITOR->setSpecialWorkspace(nullptr);
}
it = m_vWorkspaces.erase(it); it = m_vWorkspaces.erase(it);
continue; continue;
} }

View file

@ -142,10 +142,12 @@ void Events::listener_mapWindow(void* owner, void* data) {
} }
} }
PWINDOW->m_iWorkspaceID = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID)->activeWorkspace; const auto PMONITORFROMID = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
PWINDOW->m_iWorkspaceID = PMONITOR->specialWorkspaceID ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace;
if (PWINDOW->m_iMonitorID != PMONITOR->ID) { if (PWINDOW->m_iMonitorID != PMONITOR->ID) {
g_pKeybindManager->m_mDispatchers["focusmonitor"](std::to_string(PWINDOW->m_iMonitorID)); g_pKeybindManager->m_mDispatchers["focusmonitor"](std::to_string(PWINDOW->m_iMonitorID));
PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID); PMONITOR = PMONITORFROMID;
} }
Debug::log(ERR, "Rule monitor, applying to window %lx -> mon: %i, workspace: %i", PWINDOW, PWINDOW->m_iMonitorID, PWINDOW->m_iWorkspaceID); Debug::log(ERR, "Rule monitor, applying to window %lx -> mon: %i, workspace: %i", PWINDOW, PWINDOW->m_iMonitorID, PWINDOW->m_iWorkspaceID);

View file

@ -66,9 +66,7 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
try { try {
auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1); auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' ') + 1);
movePerc = std::stoi(percstr.substr(0, percstr.length() - 1)); movePerc = std::stoi(percstr.substr(0, percstr.length() - 1));
} catch (std::exception& e) { } catch (std::exception& e) { Debug::log(ERR, "Error in startAnim: invalid percentage"); }
Debug::log(ERR, "Error in startAnim: invalid percentage");
}
} }
m_fAlpha.setValueAndWarp(1.f); m_fAlpha.setValueAndWarp(1.f);
@ -133,6 +131,17 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
} }
} }
if (m_bIsSpecialWorkspace) {
// required for open/close animations
if (in) {
m_fAlpha.setValueAndWarp(0.f);
m_fAlpha = 1.f;
} else {
m_fAlpha.setValueAndWarp(1.f);
m_fAlpha = 0.f;
}
}
if (instant) { if (instant) {
m_vRenderOffset.warp(); m_vRenderOffset.warp();
m_fAlpha.warp(); m_fAlpha.warp();

View file

@ -1515,12 +1515,8 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) {
return; return;
} }
if (g_pCompositor->getWindowsOnWorkspace(workspaceID) == 0) {
Debug::log(LOG, "Can't open empty special workspace!");
return;
}
bool requestedWorkspaceIsAlreadyOpen = false; bool requestedWorkspaceIsAlreadyOpen = false;
bool requestedWorkspaceExists = g_pCompositor->getWorkspaceByID(workspaceID);
const auto PMONITOR = *PFOLLOWMOUSE == 1 ? g_pCompositor->getMonitorFromCursor() : g_pCompositor->m_pLastMonitor; const auto PMONITOR = *PFOLLOWMOUSE == 1 ? g_pCompositor->getMonitorFromCursor() : g_pCompositor->m_pLastMonitor;
int specialOpenOnMonitor = PMONITOR->specialWorkspaceID; int specialOpenOnMonitor = PMONITOR->specialWorkspaceID;
@ -1566,10 +1562,8 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) {
// not open anywhere // not open anywhere
auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceID); auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceID);
if (!PSPECIALWORKSPACE) { if (!PSPECIALWORKSPACE)
// ??? happens sometimes...?
PSPECIALWORKSPACE = g_pCompositor->createNewWorkspace(workspaceID, PMONITOR->ID, workspaceName); PSPECIALWORKSPACE = g_pCompositor->createNewWorkspace(workspaceID, PMONITOR->ID, workspaceName);
}
PMONITOR->setSpecialWorkspace(PSPECIALWORKSPACE); PMONITOR->setSpecialWorkspace(PSPECIALWORKSPACE);
} }

View file

@ -594,21 +594,9 @@ void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, CWorkspace*
} }
// and then special // and then special
bool renderedSpecialBG = false; for (auto& ws : g_pCompositor->m_vWorkspaces) {
for (auto& w : g_pCompositor->m_vWindows) { if (ws->m_iMonitorID == pMonitor->ID && ws->m_fAlpha.fl() > 0.f && ws->m_bIsSpecialWorkspace) {
if (w->isHidden() && !w->m_bIsMapped && !w->m_bFadingOut) const auto SPECIALANIMPROGRS = ws->m_vRenderOffset.isBeingAnimated() ? ws->m_vRenderOffset.getCurveValue() : ws->m_fAlpha.getCurveValue();
continue;
if (!g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue;
if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace))
continue;
if (!renderedSpecialBG) {
const auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID);
const auto SPECIALANIMPROGRS =
PSPECIALWORKSPACE->m_vRenderOffset.isBeingAnimated() ? PSPECIALWORKSPACE->m_vRenderOffset.getCurveValue() : PSPECIALWORKSPACE->m_fAlpha.getCurveValue();
const bool ANIMOUT = !pMonitor->specialWorkspaceID; const bool ANIMOUT = !pMonitor->specialWorkspaceID;
if (*PDIMSPECIAL != 0.f) { if (*PDIMSPECIAL != 0.f) {
@ -621,8 +609,19 @@ void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, CWorkspace*
g_pHyprOpenGL->renderRectWithBlur(&monbox, CColor(0, 0, 0, 0), 0, (ANIMOUT ? (1.0 - SPECIALANIMPROGRS) : SPECIALANIMPROGRS)); g_pHyprOpenGL->renderRectWithBlur(&monbox, CColor(0, 0, 0, 0), 0, (ANIMOUT ? (1.0 - SPECIALANIMPROGRS) : SPECIALANIMPROGRS));
} }
renderedSpecialBG = true; break;
} }
}
for (auto& w : g_pCompositor->m_vWindows) {
if (w->isHidden() && !w->m_bIsMapped && !w->m_bFadingOut)
continue;
if (!g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue;
if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace))
continue;
// render the bad boy // render the bad boy
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL); renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL);