feat: add optional background blur, align to shared texture pattern

Gaussian blur applied at texture load time when `background_blur` is
set in moonlock.toml. Refactored wallpaper loading from per-window
Picture::for_filename() to shared gdk::Texture pattern (matching
moonset/moongreet), avoiding redundant JPEG decoding on multi-monitor.
This commit is contained in:
2026-03-28 14:53:27 +01:00
parent 09e0d47a38
commit de9a3e9e6a
6 changed files with 220 additions and 18 deletions
+7 -7
View File
@@ -14,7 +14,6 @@ use gtk4::prelude::*;
use gtk4::{self as gtk, gio};
use gtk4_session_lock;
use std::cell::RefCell;
use std::path::PathBuf;
use std::rc::Rc;
use crate::fingerprint::FingerprintListener;
@@ -42,14 +41,15 @@ fn activate(app: &gtk::Application) {
let config = config::load_config(None);
let bg_path = config::resolve_background_path(&config);
let bg_texture = lockscreen::load_background_texture(&bg_path, config.background_blur);
if gtk4_session_lock::is_supported() {
activate_with_session_lock(app, &display, &bg_path, &config);
activate_with_session_lock(app, &display, &bg_texture, &config);
} else {
#[cfg(debug_assertions)]
{
log::warn!("ext-session-lock-v1 not supported — running in development mode");
activate_without_lock(app, &bg_path, &config);
activate_without_lock(app, &bg_texture, &config);
}
#[cfg(not(debug_assertions))]
{
@@ -62,7 +62,7 @@ fn activate(app: &gtk::Application) {
fn activate_with_session_lock(
app: &gtk::Application,
display: &gdk::Display,
bg_path: &PathBuf,
bg_texture: &gdk::Texture,
config: &config::Config,
) {
let lock = gtk4_session_lock::Instance::new();
@@ -87,7 +87,7 @@ fn activate_with_session_lock(
.and_then(|obj| obj.downcast::<gdk::Monitor>().ok())
{
let handles = lockscreen::create_lockscreen_window(
bg_path,
bg_texture,
config,
app,
unlock_callback.clone(),
@@ -144,7 +144,7 @@ fn init_fingerprint_async(all_handles: Vec<lockscreen::LockscreenHandles>) {
#[cfg(debug_assertions)]
fn activate_without_lock(
app: &gtk::Application,
bg_path: &PathBuf,
bg_texture: &gdk::Texture,
config: &config::Config,
) {
let app_clone = app.clone();
@@ -153,7 +153,7 @@ fn activate_without_lock(
});
let handles = lockscreen::create_lockscreen_window(
bg_path,
bg_texture,
config,
app,
unlock_callback,