From d743ac7bb1339a7407affb97792eb47fb0fe708c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 6 Jun 2022 13:48:17 +0200 Subject: [PATCH] added forcerendererreload and some more vt changes --- src/Compositor.cpp | 1 + src/events/Events.hpp | 3 +++ src/events/Misc.cpp | 4 ++++ src/events/Monitors.cpp | 11 ++++++++--- src/helpers/Monitor.hpp | 3 ++- src/managers/KeybindManager.cpp | 19 ++++++++++++++++++- src/managers/KeybindManager.hpp | 1 + src/render/Renderer.cpp | 2 +- 8 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index f53d0272..0f6dd8d3 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -142,6 +142,7 @@ void CCompositor::initAllSignals() { addWLSignal(&m_sWLRPointerConstraints->events.new_constraint, &Events::listen_newConstraint, m_sWLRPointerConstraints, "PointerConstraints"); addWLSignal(&m_sWLRXDGDecoMgr->events.new_toplevel_decoration, &Events::listen_NewXDGDeco, m_sWLRXDGDecoMgr, "XDGDecoMgr"); addWLSignal(&m_sWLRVirtPtrMgr->events.new_virtual_pointer, &Events::listen_newVirtPtr, m_sWLRVirtPtrMgr, "VirtPtrMgr"); + addWLSignal(&m_sWLRRenderer->events.destroy, &Events::listen_RendererDestroy, m_sWLRRenderer, "WLRRenderer"); signal(SIGINT, handleCritSignal); signal(SIGTERM, handleCritSignal); diff --git a/src/events/Events.hpp b/src/events/Events.hpp index 3b5d29ab..9d1fdb53 100644 --- a/src/events/Events.hpp +++ b/src/events/Events.hpp @@ -109,4 +109,7 @@ namespace Events { // Deco XDG LISTENER(NewXDGDeco); + + // Renderer destroy + LISTENER(RendererDestroy); }; \ No newline at end of file diff --git a/src/events/Misc.cpp b/src/events/Misc.cpp index 55ca6434..eec42f6d 100644 --- a/src/events/Misc.cpp +++ b/src/events/Misc.cpp @@ -153,4 +153,8 @@ void Events::listener_InhibitDeactivate(wl_listener* listener, void* data) { g_pCompositor->m_sSeat.exclusiveClient = nullptr; g_pInputManager->refocus(); +} + +void Events::listener_RendererDestroy(wl_listener* listener, void* data) { + Debug::log(LOG, "!!Renderer destroyed!!"); } \ No newline at end of file diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index 0db620fc..661babeb 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -180,9 +180,14 @@ void Events::listener_monitorFrame(void* owner, void* data) { g_pConfigManager->performMonitorReload(); } - if (PMONITOR->needsFrameSkip) { - PMONITOR->needsFrameSkip = false; - wlr_output_schedule_frame(PMONITOR->output); + if (PMONITOR->framesToSkip > 0) { + PMONITOR->framesToSkip -= 1; + + if (!PMONITOR->noFrameSchedule) + wlr_output_schedule_frame(PMONITOR->output); + else { + Debug::log(LOG, "NoFrameSchedule hit for %s.", PMONITOR->szName.c_str()); + } g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID); return; } diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 818d4a36..4767fd78 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -27,7 +27,8 @@ struct SMonitor { wlr_output* output = nullptr; float refreshRate = 60; wlr_output_damage* damage = nullptr; - bool needsFrameSkip = false; + int framesToSkip = 0; + bool noFrameSchedule = false; wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL; // for the special workspace diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 82aa5575..7d08d358 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -24,6 +24,7 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["movecurrentworkspacetomonitor"] = moveCurrentWorkspaceToMonitor; m_mDispatchers["moveworkspacetomonitor"] = moveWorkspaceToMonitor; m_mDispatchers["togglespecialworkspace"] = toggleSpecialWorkspace; + m_mDispatchers["forcerendererreload"] = forceRendererReload; } void CKeybindManager::addKeybind(SKeybind kb) { @@ -109,8 +110,17 @@ bool CKeybindManager::handleInternalKeybinds(xkb_keysym_t keysym) { const auto PSESSION = wlr_backend_get_session(g_pCompositor->m_sWLRBackend); if (PSESSION) { - const auto TTY = keysym - XKB_KEY_XF86Switch_VT_1 + 1; + const int TTY = keysym - XKB_KEY_XF86Switch_VT_1 + 1; wlr_session_change_vt(PSESSION, TTY); + + for (auto& m : g_pCompositor->m_lMonitors) { + g_pHyprOpenGL->destroyMonitorResources(&m); // mark resources as unusable anymore + m.noFrameSchedule = true; + m.framesToSkip = 2; + } + + Debug::log(LOG, "Switched to VT %i, destroyed all render data, frames to skip for each: 2", TTY); + return true; } @@ -826,4 +836,11 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) { } g_pInputManager->refocus(); +} + +void CKeybindManager::forceRendererReload(std::string args) { + for (auto& m : g_pCompositor->m_lMonitors) { + auto rule = g_pConfigManager->getMonitorRuleFor(m.szName); + g_pHyprRenderer->applyMonitorRule(&m, &rule, true); + } } \ No newline at end of file diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index 7cbdd9a4..0cb7c0b5 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -54,6 +54,7 @@ private: static void moveCurrentWorkspaceToMonitor(std::string); static void moveWorkspaceToMonitor(std::string); static void toggleSpecialWorkspace(std::string); + static void forceRendererReload(std::string); friend class CCompositor; }; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 1386d1c7..09acaa77 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -717,5 +717,5 @@ void CHyprRenderer::applyMonitorRule(SMonitor* pMonitor, SMonitorRule* pMonitorR arrangeLayersForMonitor(pMonitor->ID); // frame skip - pMonitor->needsFrameSkip = true; + pMonitor->framesToSkip = 1; }