mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-12-22 04:19:47 +01:00
wallpapers are now cover
This commit is contained in:
parent
ae2c232afc
commit
8df121070a
2 changed files with 21 additions and 3 deletions
|
@ -216,9 +216,25 @@ void CHyprpaper::renderWallpaperForMonitor(SMonitor* pMonitor) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
Debug::log(LOG, "Scale: %i", pMonitor->scale);
|
||||
cairo_scale(PCAIRO, pMonitor->scale, pMonitor->scale);
|
||||
cairo_set_source_surface(PCAIRO, PWALLPAPERTARGET->m_pCairoSurface, 0, 0);
|
||||
// get scale
|
||||
// we always do cover
|
||||
float scale;
|
||||
Vector2D origin;
|
||||
if (pMonitor->size.x / pMonitor->size.y > PWALLPAPERTARGET->m_vSize.x / PWALLPAPERTARGET->m_vSize.y) {
|
||||
scale = pMonitor->size.x / PWALLPAPERTARGET->m_vSize.x;
|
||||
|
||||
origin.y = - (PWALLPAPERTARGET->m_vSize.y * scale - pMonitor->size.y) / 2.f / scale;
|
||||
|
||||
} else {
|
||||
scale = pMonitor->size.y / PWALLPAPERTARGET->m_vSize.y;
|
||||
|
||||
origin.x = - (PWALLPAPERTARGET->m_vSize.x * scale - pMonitor->size.x) / 2.f / scale;
|
||||
}
|
||||
|
||||
Debug::log(LOG, "Image data for %s: %s at [%.2f, %.2f], scale: %.2f (original image size: [%i, %i])", pMonitor->name.c_str(), PWALLPAPERTARGET->m_szPath.c_str(), origin.x, origin.y, scale, (int)PWALLPAPERTARGET->m_vSize.x, (int)PWALLPAPERTARGET->m_vSize.y);
|
||||
|
||||
cairo_scale(PCAIRO, scale, scale);
|
||||
cairo_set_source_surface(PCAIRO, PWALLPAPERTARGET->m_pCairoSurface, origin.x, origin.y);
|
||||
|
||||
cairo_paint(PCAIRO);
|
||||
cairo_restore(PCAIRO);
|
||||
|
|
|
@ -21,5 +21,7 @@ void CWallpaperTarget::create(const std::string& path) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
m_vSize = { cairo_image_surface_get_width(CAIROSURFACE), cairo_image_surface_get_height(CAIROSURFACE) };
|
||||
|
||||
m_pCairoSurface = CAIROSURFACE;
|
||||
}
|
Loading…
Reference in a new issue