From 5c8992bafc590b2cc7b1f61d5e8a1fbdade65901 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 20 Apr 2023 23:04:32 +0100 Subject: [PATCH] better handling of monitors --- .../Render/Drivers/CWaylandOpenGLDriver.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp b/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp index d64ee1e..80b79d1 100644 --- a/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp +++ b/src/WallpaperEngine/Render/Drivers/CWaylandOpenGLDriver.cpp @@ -336,22 +336,23 @@ CWaylandOpenGLDriver::CWaylandOpenGLDriver(const char* windowTitle, CApplication if (!waylandContext.compositor || !waylandContext.shm || !waylandContext.layerShell || m_outputs.empty()) sLog.exception("Failed to bind to required interfaces"); - SWaylandOutput* outputToUse = nullptr; + initEGL(); + + bool any = false; for (auto& o : m_outputs) { if (std::find_if(context.settings.general.screenBackgrounds.begin(), context.settings.general.screenBackgrounds.end(), [&] (const auto& e) { return e.first == o->name; }) != context.settings.general.screenBackgrounds.end()) { - outputToUse = o.get(); - break; + o->layerSurface = std::make_unique(this, o.get()); + any = true; } } - if (!outputToUse) { - sLog.debug("Failed to find any output, using first"); - outputToUse = m_outputs[0].get(); + if (!any && std::find_if(context.settings.general.screenBackgrounds.begin(), context.settings.general.screenBackgrounds.end(), [&] (const auto& e) { return e.first == "auto"; }) != context.settings.general.screenBackgrounds.end()) { + m_outputs[0]->layerSurface = std::make_unique(this, m_outputs[0].get()); + any = true; } - initEGL(); - - const auto PLS = (outputToUse->layerSurface = std::make_unique(this, outputToUse)).get(); + if (!any) + sLog.exception("No outputs could be initialized!"); GLenum result = glewInit ();