Skip to content

Commit 5cbca60

Browse files
committed
WIP: mild optimization pass
1 parent 5c3463b commit 5cbca60

1 file changed

Lines changed: 26 additions & 34 deletions

File tree

quickshell/Modules/WallpaperBackground.qml

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,10 @@ Variants {
384384
property int physicalWidth: Math.round(modelData.width * screenScale)
385385
property int physicalHeight: Math.round(modelData.height * screenScale)
386386

387-
Rectangle {
387+
Item {
388388
id: currentWallpaperContainer
389389
anchors.fill: parent
390-
color: "transparent"
391-
clip: true
390+
clip: false
392391

393392
Image {
394393
id: currentWallpaper
@@ -399,6 +398,11 @@ Variants {
399398
smooth: true
400399
cache: true
401400

401+
anchors.left: root.effectiveScrolling && root.isVerticalScrolling ? parent.left : undefined
402+
anchors.right: root.effectiveScrolling && root.isVerticalScrolling ? parent.right : undefined
403+
anchors.top: root.effectiveScrolling && !root.isVerticalScrolling ? parent.top : undefined
404+
anchors.bottom: root.effectiveScrolling && !root.isVerticalScrolling ? parent.bottom : undefined
405+
402406
fillMode: root.effectiveScrolling ? Image.PreserveAspectFit : root.getFillMode(SettingsData.wallpaperFillMode)
403407

404408
sourceSize: {
@@ -439,34 +443,25 @@ Variants {
439443
}
440444

441445
x: {
442-
if (!root.effectiveScrolling) return 0;
446+
if (!root.effectiveScrolling || root.isVerticalScrolling) return 0;
443447

444-
if (root.isVerticalScrolling) {
445-
return 0;
446-
} else {
447-
const scrollRange = Math.max(0, width - parent.width);
448-
return -(scrollRange * root.currentScrollPercentage / 100.0);
449-
}
448+
const scrollRange = Math.max(0, width - parent.width);
449+
return -(scrollRange * root.currentScrollPercentage / 100.0);
450450
}
451451

452452
y: {
453-
if (!root.effectiveScrolling) return 0;
453+
if (!root.effectiveScrolling || !root.isVerticalScrolling) return 0;
454454

455-
if (root.isVerticalScrolling) {
456-
const scrollRange = Math.max(0, height - parent.height);
457-
return -(scrollRange * root.currentScrollPercentage / 100.0);
458-
} else {
459-
return 0;
460-
}
455+
const scrollRange = Math.max(0, height - parent.height);
456+
return -(scrollRange * root.currentScrollPercentage / 100.0);
461457
}
462458
}
463459
}
464460

465-
Rectangle {
461+
Item {
466462
id: nextWallpaperContainer
467463
anchors.fill: parent
468-
color: "transparent"
469-
clip: true
464+
clip: false
470465

471466
Image {
472467
id: nextWallpaper
@@ -477,6 +472,11 @@ Variants {
477472
smooth: true
478473
cache: false
479474

475+
anchors.left: root.effectiveScrolling && root.isVerticalScrolling ? parent.left : undefined
476+
anchors.right: root.effectiveScrolling && root.isVerticalScrolling ? parent.right : undefined
477+
anchors.top: root.effectiveScrolling && !root.isVerticalScrolling ? parent.top : undefined
478+
anchors.bottom: root.effectiveScrolling && !root.isVerticalScrolling ? parent.bottom : undefined
479+
480480
fillMode: root.effectiveScrolling ? Image.PreserveAspectFit : root.getFillMode(SettingsData.wallpaperFillMode)
481481

482482
sourceSize: {
@@ -517,25 +517,17 @@ Variants {
517517
}
518518

519519
x: {
520-
if (!root.effectiveScrolling) return 0;
520+
if (!root.effectiveScrolling || root.isVerticalScrolling) return 0;
521521

522-
if (root.isVerticalScrolling) {
523-
return 0;
524-
} else {
525-
const scrollRange = Math.max(0, width - parent.width / 2);
526-
return -(scrollRange * root.currentScrollPercentage / 100.0);
527-
}
522+
const scrollRange = Math.max(0, width - parent.width / 2);
523+
return -(scrollRange * root.currentScrollPercentage / 100.0);
528524
}
529525

530526
y: {
531-
if (!root.effectiveScrolling) return 0;
527+
if (!root.effectiveScrolling || !root.isVerticalScrolling) return 0;
532528

533-
if (root.isVerticalScrolling) {
534-
const scrollRange = Math.max(0, height - parent.height / 2);
535-
return -(scrollRange * root.currentScrollPercentage / 100.0);
536-
} else {
537-
return 0;
538-
}
529+
const scrollRange = Math.max(0, height - parent.height / 2);
530+
return -(scrollRange * root.currentScrollPercentage / 100.0);
539531
}
540532

541533
onStatusChanged: {

0 commit comments

Comments
 (0)