diff --git a/src/Hyprpaper.cpp b/src/Hyprpaper.cpp index 4e32e37..559de83 100644 --- a/src/Hyprpaper.cpp +++ b/src/Hyprpaper.cpp @@ -50,7 +50,7 @@ void CHyprpaper::recheckAllMonitors() { } void CHyprpaper::ensureMonitorHasActiveWallpaper(SMonitor* pMonitor) { - if (!pMonitor->readyForLS) + if (!pMonitor->readyForLS || !pMonitor->hasATarget) return; auto it = m_mMonitorActiveWallpaperTargets.find(pMonitor); @@ -63,9 +63,6 @@ void CHyprpaper::ensureMonitorHasActiveWallpaper(SMonitor* pMonitor) { if (it->second) return; // has - // create it for thy - createLSForMonitor(pMonitor); - // get the target for (auto&[mon, path1] : m_mMonitorActiveWallpapers) { if (mon == pMonitor->name) { @@ -80,10 +77,13 @@ void CHyprpaper::ensureMonitorHasActiveWallpaper(SMonitor* pMonitor) { } if (!it->second) { - Debug::log(CRIT, "No target for monitor %s!!", pMonitor->name.c_str()); - exit(1); + pMonitor->hasATarget = false; + Debug::log(WARN, "Monitor %s does not have a target! A wallpaper will not be created.", pMonitor->name.c_str()); return; } + + // create it for thy + createLSForMonitor(pMonitor); } void CHyprpaper::createLSForMonitor(SMonitor* pMonitor) { diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 2b0ad81..4b8ec0e 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -10,6 +10,7 @@ struct SMonitor { int scale; bool readyForLS = false; + bool hasATarget = true; zwlr_layer_surface_v1* pLayerSurface = nullptr; wl_surface* pSurface = nullptr; diff --git a/src/render/WallpaperTarget.cpp b/src/render/WallpaperTarget.cpp index a6cc607..e7f21c2 100644 --- a/src/render/WallpaperTarget.cpp +++ b/src/render/WallpaperTarget.cpp @@ -3,6 +3,8 @@ void CWallpaperTarget::create(const std::string& path) { m_szPath = path; + const auto BEGINLOAD = std::chrono::system_clock::now(); + cairo_surface_t* CAIROSURFACE = nullptr; if (path.find(".png") == path.length() - 4) { CAIROSURFACE = cairo_image_surface_create_from_png(path.c_str()); @@ -23,5 +25,9 @@ void CWallpaperTarget::create(const std::string& path) { m_vSize = { cairo_image_surface_get_width(CAIROSURFACE), cairo_image_surface_get_height(CAIROSURFACE) }; + const auto MS = std::chrono::duration_cast(std::chrono::system_clock::now() - BEGINLOAD).count() / 1000.f; + + Debug::log(LOG, "Preloaded target %s in %.2fms -> Pixel size: [%i, %i]", path.c_str(), MS, (int)m_vSize.x, (int)m_vSize.y); + m_pCairoSurface = CAIROSURFACE; } \ No newline at end of file