Accepting request 433788 from home:alarrosa:branches:KDE:Frameworks5:LTS

- 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.

Note that for this patch to work correctly, it needs a kpackage with https://build.opensuse.org/request/show/433784 applied.

OBS-URL: https://build.opensuse.org/request/show/433788
OBS-URL: https://build.opensuse.org/package/show/KDE:Frameworks5:LTS/plasma5-workspace?expand=0&rev=28
This commit is contained in:
Hrvoje Senjan 2016-10-07 18:24:54 +00:00 committed by Git OBS Bridge
parent cb9b31b4b3
commit ec14fb7a2a
3 changed files with 49 additions and 0 deletions

View File

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

View File

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

View File

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