mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2026-05-09 01:58:17 +02:00
fix: Support contain/tile modes with wallpaper rotation
This commit is contained in:
parent
6b1b348b9c
commit
bed886d9a0
3 changed files with 27 additions and 6 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
#include <cairo/cairo.h>
|
||||
#include <hyprutils/math/Vector2D.hpp>
|
||||
|
||||
// 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",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue