From bc9d9c9c8dccee6f453250a3a767f2270e45a79a Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 19 Mar 2022 14:07:18 +0100 Subject: [PATCH] outputmgr applytest --- src/events/Events.cpp | 4 ++-- src/render/Renderer.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ src/render/Renderer.hpp | 1 + 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/events/Events.cpp b/src/events/Events.cpp index 1cca53f8..1c40e520 100644 --- a/src/events/Events.cpp +++ b/src/events/Events.cpp @@ -394,12 +394,12 @@ void Events::listener_newXDGSurface(wl_listener* listener, void* data) { void Events::listener_outputMgrApply(wl_listener* listener, void* data) { const auto CONFIG = (wlr_output_configuration_v1*)data; - + g_pHyprRenderer->outputMgrApplyTest(CONFIG, false); } void Events::listener_outputMgrTest(wl_listener* listener, void* data) { const auto CONFIG = (wlr_output_configuration_v1*)data; - + g_pHyprRenderer->outputMgrApplyTest(CONFIG, true); } void Events::listener_requestMouse(wl_listener* listener, void* data) { diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 14e47ba3..0ad0c1ba 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -99,3 +99,44 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) { wlr_surface_for_each_surface(ls->layerSurface->surface, renderSurface, &renderdata); } } + +void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool test) { + wlr_output_configuration_head_v1* head; + bool noError = true; + + wl_list_for_each(head, &config->heads, link) { + const auto OUTPUT = head->state.output; + + wlr_output_enable(OUTPUT, head->state.enabled); + if (head->state.enabled) { + if (head->state.mode) + wlr_output_set_mode(OUTPUT, head->state.mode); + else + wlr_output_set_custom_mode(OUTPUT, head->state.custom_mode.width, head->state.custom_mode.height, head->state.custom_mode.refresh); + + wlr_output_layout_move(g_pCompositor->m_sWLROutputLayout, OUTPUT, head->state.x, head->state.y); + wlr_output_set_transform(OUTPUT, head->state.transform); + wlr_output_set_scale(OUTPUT, head->state.scale); + } + + noError = wlr_output_test(OUTPUT); + + if (!noError) + break; + } + + wl_list_for_each(head, &config->heads, link) { + if (noError && !test) + wlr_output_commit(head->state.output); + else + wlr_output_rollback(head->state.output); + } + + if (noError) + wlr_output_configuration_v1_send_succeeded(config); + else + wlr_output_configuration_v1_send_failed(config); + wlr_output_configuration_v1_destroy(config); + + Debug::log(LOG, "OutputMgr Applied/Tested."); +} \ No newline at end of file diff --git a/src/render/Renderer.hpp b/src/render/Renderer.hpp index ae7e5476..e1d6894f 100644 --- a/src/render/Renderer.hpp +++ b/src/render/Renderer.hpp @@ -6,6 +6,7 @@ class CHyprRenderer { public: void renderAllClientsForMonitor(const int&, timespec*); + void outputMgrApplyTest(wlr_output_configuration_v1*, bool); private: };