diff --git a/src/Hyprpaper.cpp b/src/Hyprpaper.cpp index 279e17c..1a3b425 100644 --- a/src/Hyprpaper.cpp +++ b/src/Hyprpaper.cpp @@ -571,7 +571,9 @@ void CHyprpaper::renderWallpaperForMonitor(SMonitor* pMonitor) { PCAIRO, Vector2D(PWALLPAPERTARGET->m_vSize.x, PWALLPAPERTARGET->m_vSize.y), DIMENSIONS, - pMonitor->wallpaperRotation + pMonitor->wallpaperRotation, + CONTAIN, + TILE ); if (TILE) { diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 38e36f3..c5539cc 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -71,12 +71,19 @@ static Hyprlang::CParseResult handleWallpaper(const char* C, const char* V) { g_pHyprpaper->m_mMonitorWallpaperRenderData[MONITOR].tile = tile; // Set wallpaper rotation for the monitor + printf("DEBUG: Setting rotation %d for monitor '%s'\n", rotation, MONITOR.c_str()); + bool rotationSet = false; for (auto& m : g_pHyprpaper->m_vMonitors) { if (m->name == MONITOR) { m->wallpaperRotation = rotation; + printf("DEBUG: Applied rotation %d to monitor %s\n", rotation, m->name.c_str()); + rotationSet = true; break; } } + if (!rotationSet && !MONITOR.empty()) { + printf("DEBUG: Monitor '%s' not found, rotation not applied\n", MONITOR.c_str()); + } if (MONITOR.empty()) { for (auto& m : g_pHyprpaper->m_vMonitors) { @@ -85,6 +92,7 @@ static Hyprlang::CParseResult handleWallpaper(const char* C, const char* V) { g_pHyprpaper->m_mMonitorActiveWallpapers[m->name] = WALLPAPER; g_pHyprpaper->m_mMonitorWallpaperRenderData[m->name].contain = contain; g_pHyprpaper->m_mMonitorWallpaperRenderData[m->name].tile = tile; + m->wallpaperRotation = rotation; // Apply rotation to wildcard monitors too } } } else { diff --git a/src/render/WallpaperTransform.hpp b/src/render/WallpaperTransform.hpp index 4d17704..94addc8 100644 --- a/src/render/WallpaperTransform.hpp +++ b/src/render/WallpaperTransform.hpp @@ -2,9 +2,9 @@ #include #include -// Applies robust rotation, scaling, and centering for wallpaper rendering -// Always fills the monitor (cover mode), centers image, and handles all rotations correctly -inline void applyWallpaperTransform(cairo_t* cr, const Vector2D& imgSize, const Vector2D& monSize, int rotation) { +// Applies rotation, scaling, and centering for wallpaper rendering +// Supports cover, contain, and tile modes with proper rotation handling +inline void applyWallpaperTransform(cairo_t* cr, const Vector2D& imgSize, const Vector2D& monSize, int rotation, bool contain = false, bool tile = false) { double imgW = imgSize.x; double imgH = imgSize.y; double monW = monSize.x; @@ -19,10 +19,21 @@ inline void applyWallpaperTransform(cairo_t* cr, const Vector2D& imgSize, const double effectiveImgW = isRotated90or270 ? imgH : imgW; double effectiveImgH = isRotated90or270 ? imgW : imgH; - // Calculate scale to cover the monitor (larger scale wins) + // Calculate scale based on mode double scaleX = monW / effectiveImgW; double scaleY = monH / effectiveImgH; - double scale = std::max(scaleX, scaleY); + double scale; + + if (contain) { + // Contain mode: fit entire image (smaller scale wins) + scale = std::min(scaleX, scaleY); + } else if (tile) { + // Tile mode: use 1:1 scale + scale = 1.0; + } else { + // Cover mode: fill monitor (larger scale wins) + scale = std::max(scaleX, scaleY); + } // Debug output printf("DEBUG Transform: rotation=%d, imgSize=[%.1f,%.1f], monSize=[%.1f,%.1f]\n",