more oled features and system freeze fixes
This commit is contained in:
+48
-16
@@ -2,6 +2,7 @@ import GLib from 'gi://GLib';
|
||||
import Gio from 'gi://Gio';
|
||||
import St from 'gi://St';
|
||||
import Clutter from 'gi://Clutter';
|
||||
import Graphene from 'gi://Graphene';
|
||||
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
|
||||
import {SettingsKey} from './settingsKeys.js';
|
||||
@@ -40,6 +41,7 @@ export class RotationManager {
|
||||
enable() {
|
||||
this._settingsSignals.push(
|
||||
this._settings.connect(`changed::${SettingsKey.WALLPAPER_FOLDERS}`, () => this._reloadImages()),
|
||||
this._settings.connect(`changed::${SettingsKey.WALLPAPER_RESCAN_REQUEST}`, () => this._reloadImages()),
|
||||
this._settings.connect(`changed::${SettingsKey.ROTATION_ENABLED}`, () => this._restartTimer()),
|
||||
this._settings.connect(`changed::${SettingsKey.ROTATION_INTERVAL_SECONDS}`, () => this._restartTimer()),
|
||||
this._settings.connect(`changed::${SettingsKey.ROTATION_MODE}`, () => this._onModeChanged())
|
||||
@@ -185,7 +187,7 @@ export class RotationManager {
|
||||
const uri = GLib.filename_to_uri(path, null);
|
||||
|
||||
if (this._settings.get_boolean(SettingsKey.TRANSITION_ENABLED) && previousPath)
|
||||
this._playCrossfade(previousPath);
|
||||
this._playTransition(previousPath);
|
||||
|
||||
this._backgroundSettings.set_string('picture-uri', uri);
|
||||
if (this._backgroundSettings.settings_schema.has_key('picture-uri-dark'))
|
||||
@@ -200,15 +202,19 @@ export class RotationManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* The real background actor doesn't crossfade on its own, so we paint the
|
||||
* *old* image full-screen on a throwaway overlay right as the new image
|
||||
* is set underneath, then fade the overlay out to reveal it.
|
||||
* The real background actor doesn't animate changes on its own, so we
|
||||
* paint the *old* image full-screen on a throwaway overlay right as the
|
||||
* new image is set underneath, then animate the overlay away to reveal
|
||||
* it. Which animation runs is picked per monitor by style.
|
||||
*/
|
||||
_playCrossfade(previousPath) {
|
||||
_playTransition(previousPath) {
|
||||
this._clearTransitionOverlays();
|
||||
|
||||
const durationMs = this._settings.get_uint(SettingsKey.TRANSITION_DURATION_MS);
|
||||
const uri = GLib.filename_to_uri(previousPath, null).replace(/"/g, '%22');
|
||||
let style = this._settings.get_string(SettingsKey.TRANSITION_STYLE);
|
||||
if (style === 'random')
|
||||
style = ['fade', 'slide', 'zoom'][Math.floor(Math.random() * 3)];
|
||||
|
||||
for (const monitor of Main.layoutManager.monitors) {
|
||||
const overlay = new St.Widget({
|
||||
@@ -217,23 +223,49 @@ export class RotationManager {
|
||||
y: monitor.y,
|
||||
width: monitor.width,
|
||||
height: monitor.height,
|
||||
pivot_point: new Graphene.Point({x: 0.5, y: 0.5}),
|
||||
style: `background-image: url("${uri}"); background-size: cover; background-position: center;`,
|
||||
opacity: 255,
|
||||
});
|
||||
Main.layoutManager._backgroundGroup.add_child(overlay);
|
||||
this._transitionOverlays.push(overlay);
|
||||
|
||||
overlay.ease({
|
||||
opacity: 0,
|
||||
duration: durationMs,
|
||||
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
||||
onComplete: () => {
|
||||
overlay.destroy();
|
||||
const idx = this._transitionOverlays.indexOf(overlay);
|
||||
if (idx >= 0)
|
||||
this._transitionOverlays.splice(idx, 1);
|
||||
},
|
||||
});
|
||||
const onComplete = () => {
|
||||
overlay.destroy();
|
||||
const idx = this._transitionOverlays.indexOf(overlay);
|
||||
if (idx >= 0)
|
||||
this._transitionOverlays.splice(idx, 1);
|
||||
};
|
||||
|
||||
switch (style) {
|
||||
case 'slide':
|
||||
overlay.ease({
|
||||
x: monitor.x - monitor.width,
|
||||
duration: durationMs,
|
||||
mode: Clutter.AnimationMode.EASE_IN_OUT_QUAD,
|
||||
onComplete,
|
||||
});
|
||||
break;
|
||||
case 'zoom':
|
||||
overlay.ease({
|
||||
scale_x: 1.15,
|
||||
scale_y: 1.15,
|
||||
opacity: 0,
|
||||
duration: durationMs,
|
||||
mode: Clutter.AnimationMode.EASE_IN_QUAD,
|
||||
onComplete,
|
||||
});
|
||||
break;
|
||||
case 'fade':
|
||||
default:
|
||||
overlay.ease({
|
||||
opacity: 0,
|
||||
duration: durationMs,
|
||||
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
||||
onComplete,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user