renderer: separate workspace window render logic

Makes the logic used to render stuff over the windows (special, popups, ime, lockscreen) unified by yeeting the workspace window logic (which is separate cuz fullscreen windows) into their own funcs. Fixes #2053
This commit is contained in:
vaxerski 2023-09-04 15:07:56 +02:00
parent 35df4693ea
commit 32f75ebb70
2 changed files with 79 additions and 129 deletions

View file

@ -136,7 +136,7 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow) {
return false; return false;
} }
void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* time) { void CHyprRenderer::renderWorkspaceWindowsFullscreen(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* time) {
CWindow* pWorkspaceWindow = nullptr; CWindow* pWorkspaceWindow = nullptr;
EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOWS); EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOWS);
@ -201,14 +201,67 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWor
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL); renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL);
} }
}
// and then special windows void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, CWorkspace* pWorkspace, timespec* time) {
if (pMonitor->specialWorkspaceID) CWindow* lastWindow = nullptr;
EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOWS);
// Non-floating main
for (auto& w : g_pCompositor->m_vWindows) { for (auto& w : g_pCompositor->m_vWindows) {
if (!g_pCompositor->windowValidMapped(w.get()) && !w->m_bFadingOut) if (w->isHidden() && !w->m_bIsMapped && !w->m_bFadingOut)
continue; continue;
if (w->m_iWorkspaceID != pMonitor->specialWorkspaceID) if (w->m_bIsFloating)
continue; // floating are in the second pass
if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue; // special are in the third pass
if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace))
continue;
// render active window after all others of this pass
if (w.get() == g_pCompositor->m_pLastWindow) {
lastWindow = w.get();
continue;
}
// render the bad boy
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_MAIN);
}
if (lastWindow)
renderWindow(lastWindow, pMonitor, time, true, RENDER_PASS_MAIN);
// Non-floating popup
for (auto& w : g_pCompositor->m_vWindows) {
if (w->isHidden() && !w->m_bIsMapped && !w->m_bFadingOut)
continue;
if (w->m_bIsFloating)
continue; // floating are in the second pass
if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue; // special are in the third pass
if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace))
continue;
// render the bad boy
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_POPUP);
}
// floating on top
for (auto& w : g_pCompositor->m_vWindows) {
if (w->isHidden() && !w->m_bIsMapped && !w->m_bFadingOut)
continue;
if (!w->m_bIsFloating || w->m_bPinned)
continue;
if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue; continue;
if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace)) if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace))
@ -218,39 +271,22 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWor
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL); renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL);
} }
EMIT_HOOK_EVENT("render", RENDER_POST_WINDOWS); // pinned always above
for (auto& w : g_pCompositor->m_vWindows) {
if (w->isHidden() && !w->m_bIsMapped && !w->m_bFadingOut)
continue;
// and the overlay layers if (!w->m_bPinned || !w->m_bIsFloating)
for (auto& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) { continue;
if (ls->alpha.fl() != 0.f)
renderLayer(ls.get(), pMonitor, time);
}
for (auto& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]) { if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
renderLayer(ls.get(), pMonitor, time); continue;
}
// Render IME popups if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace))
for (auto& imep : g_pInputManager->m_sIMERelay.m_lIMEPopups) { continue;
renderIMEPopup(&imep, pMonitor, time);
}
renderDragIcon(pMonitor, time); // render the bad boy
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL);
// if correct monitor draw hyprerror
if (pMonitor == g_pCompositor->m_vMonitors.front().get())
g_pHyprError->draw();
if (g_pSessionLockManager->isSessionLocked()) {
const auto PSLS = g_pSessionLockManager->getSessionLockSurfaceForMonitor(pMonitor->ID);
if (!PSLS) {
// locked with no surface, fill with red
wlr_box boxe = {0, 0, INT16_MAX, INT16_MAX};
g_pHyprOpenGL->renderRect(&boxe, CColor(1.0, 0.2, 0.2, 1.0));
} else {
renderSessionLockSurface(PSLS, pMonitor, time);
}
} }
} }
@ -505,99 +541,12 @@ void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, CWorkspace*
// pre window pass // pre window pass
g_pHyprOpenGL->preWindowPass(); g_pHyprOpenGL->preWindowPass();
// if there is a fullscreen window, render it and then do not render anymore. if (pWorkspace->m_bHasFullscreenWindow)
// fullscreen window will hide other windows and top layers renderWorkspaceWindowsFullscreen(pMonitor, pWorkspace, time);
else
renderWorkspaceWindows(pMonitor, pWorkspace, time);
if (pWorkspace->m_bHasFullscreenWindow) {
renderWorkspaceWithFullscreenWindow(pMonitor, pWorkspace, time);
g_pHyprOpenGL->m_RenderData.renderModif = {}; g_pHyprOpenGL->m_RenderData.renderModif = {};
return;
}
CWindow* lastWindow = nullptr;
EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOWS);
// Non-floating main
for (auto& w : g_pCompositor->m_vWindows) {
if (w->isHidden() && !w->m_bIsMapped && !w->m_bFadingOut)
continue;
if (w->m_bIsFloating)
continue; // floating are in the second pass
if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue; // special are in the third pass
if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace))
continue;
// render active window after all others of this pass
if (w.get() == g_pCompositor->m_pLastWindow) {
lastWindow = w.get();
continue;
}
// render the bad boy
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_MAIN);
}
if (lastWindow)
renderWindow(lastWindow, pMonitor, time, true, RENDER_PASS_MAIN);
// Non-floating popup
for (auto& w : g_pCompositor->m_vWindows) {
if (w->isHidden() && !w->m_bIsMapped && !w->m_bFadingOut)
continue;
if (w->m_bIsFloating)
continue; // floating are in the second pass
if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue; // special are in the third pass
if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace))
continue;
// render the bad boy
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_POPUP);
}
// floating on top
for (auto& w : g_pCompositor->m_vWindows) {
if (w->isHidden() && !w->m_bIsMapped && !w->m_bFadingOut)
continue;
if (!w->m_bIsFloating || w->m_bPinned)
continue;
if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue;
if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace))
continue;
// render the bad boy
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL);
}
// pinned always above
for (auto& w : g_pCompositor->m_vWindows) {
if (w->isHidden() && !w->m_bIsMapped && !w->m_bFadingOut)
continue;
if (!w->m_bPinned || !w->m_bIsFloating)
continue;
if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
continue;
if (!shouldRenderWindow(w.get(), pMonitor, pWorkspace))
continue;
// render the bad boy
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL);
}
// and then special // and then special
for (auto& ws : g_pCompositor->m_vWorkspaces) { for (auto& ws : g_pCompositor->m_vWorkspaces) {

View file

@ -77,7 +77,8 @@ class CHyprRenderer {
private: private:
void arrangeLayerArray(CMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, wlr_box*); void arrangeLayerArray(CMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, wlr_box*);
void renderWorkspaceWithFullscreenWindow(CMonitor*, CWorkspace*, timespec*); void renderWorkspaceWindowsFullscreen(CMonitor*, CWorkspace*, timespec*); // renders workspace windows (fullscreen) (tiled, floating, pinned, but no special)
void renderWorkspaceWindows(CMonitor*, CWorkspace*, timespec*); // renders workspace windows (no fullscreen) (tiled, floating, pinned, but no special)
void renderWindow(CWindow*, CMonitor*, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool ignoreAllGeometry = false); void renderWindow(CWindow*, CMonitor*, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool ignoreAllGeometry = false);
void renderLayer(SLayerSurface*, CMonitor*, timespec*); void renderLayer(SLayerSurface*, CMonitor*, timespec*);
void renderSessionLockSurface(SSessionLockSurface*, CMonitor*, timespec*); void renderSessionLockSurface(SSessionLockSurface*, CMonitor*, timespec*);