more logs and allow mons without a wp

This commit is contained in:
vaxerski 2022-07-02 15:27:05 +02:00
parent 8df121070a
commit 7ea6e34d3f
3 changed files with 13 additions and 6 deletions

View file

@ -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) {

View file

@ -10,6 +10,7 @@ struct SMonitor {
int scale;
bool readyForLS = false;
bool hasATarget = true;
zwlr_layer_surface_v1* pLayerSurface = nullptr;
wl_surface* pSurface = nullptr;

View file

@ -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::microseconds>(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;
}