diff --git a/keep-wallpaper-aspect-ratio-wallpaper-on-screen-resolution-change.diff b/keep-wallpaper-aspect-ratio-wallpaper-on-screen-resolution-change.diff new file mode 100644 index 0000000..1809b1d --- /dev/null +++ b/keep-wallpaper-aspect-ratio-wallpaper-on-screen-resolution-change.diff @@ -0,0 +1,38 @@ +diff --git a/wallpapers/image/image.cpp b/wallpapers/image/image.cpp +index 0aa72bb..0a65b7d 100644 +--- a/wallpapers/image/image.cpp ++++ b/wallpapers/image/image.cpp +@@ -192,7 +192,7 @@ void Image::findPreferedImageInPackage(KPackage::Package &package) + // choose the nearest resolution, always preferring images with the same aspect ratio + float best = FLT_MAX; + float bestWithSameAspectRatio = FLT_MAX; +- float targetAspectRatio = m_targetSize.width()/(float)m_targetSize.height(); ++ float targetAspectRatio = ( m_targetSize.height() > 0 ) ? m_targetSize.width() / (float)m_targetSize.height() : 0; + + QString bestImage; + QString bestImageWithSameAspectRatio; +@@ -201,7 +201,7 @@ void Image::findPreferedImageInPackage(KPackage::Package &package) + if (candidate == QSize()) { + continue; + } +- float candidateAspectRatio = candidate.width()/(float)candidate.height(); ++ float candidateAspectRatio = (candidate.height() > 0 ) ? candidate.width() / (float)candidate.height() : FLT_MAX; + + double dist = distance(candidate, m_targetSize); + //qDebug() << "candidate" << candidate << "distance" << dist << "aspect ratio" << candidateAspectRatio; +@@ -235,9 +235,15 @@ QSize Image::targetSize() const + + void Image::setTargetSize(const QSize &size) + { ++ bool sizeChanged = m_targetSize != size; + m_targetSize = size; + + if (m_mode == SingleImage) { ++ if (sizeChanged) { ++ // If screen size was changed, we may want to select a new preferred image ++ // which has correct aspect ratio for the new screen size. ++ m_wallpaperPackage.removeDefinition("preferred"); ++ } + setSingleImage(); + } + } diff --git a/plasma5-workspace.changes b/plasma5-workspace.changes index bb3babf..059979e 100644 --- a/plasma5-workspace.changes +++ b/plasma5-workspace.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Fri Oct 7 16:46:37 UTC 2016 - alarrosa@suse.com + +- Add keep-wallpaper-aspect-ratio-wallpaper-on-screen-resolution-change.diff: + * Chooses a new preferred background image when the screen + resolution is changed to keep the correct aspect ratio (boo#990257). + Also check for division by zero. + ------------------------------------------------------------------- Thu Oct 6 17:18:45 UTC 2016 - fabian@ritter-vogt.de diff --git a/plasma5-workspace.spec b/plasma5-workspace.spec index 2b30dd5..f0dc5bf 100644 --- a/plasma5-workspace.spec +++ b/plasma5-workspace.spec @@ -37,6 +37,8 @@ Patch1: change-kioremote-severity.patch Patch2: 0001-Ignore-default-sddm-face-icons.patch # PATCH-FIX-OPENSUSE add-tray-icon-cache.patch kde#356479 fabian@ritter-vogt.de -- Workaround for high load due to animated tray icons Patch3: add-tray-icon-cache.patch +# PATCH-FIX-UPSTREAM keep-wallpaper-aspect-ratio-wallpaper-on-screen-resolution-change.diff alarrosa@suse.com -- Keep wallpaper aspect ratio on screen resolution change +Patch4: keep-wallpaper-aspect-ratio-wallpaper-on-screen-resolution-change.diff # PATCHES 100-200 and above are from upstream 5.8 branch # PATCH-FIX-UPSTREAM 0001-save-the-containment-only-aftyer-switch.patch -- Do not overwrite containment on startup Patch100: 0001-save-the-containment-only-aftyer-switch.patch @@ -210,6 +212,7 @@ workspace. Development files. %patch1 -p1 %patch2 -p1 %patch3 -p1 +%patch4 -p1 %patch100 -p1 %build