perf: optimize startup by caching icons, texture, and async avatar
- Replace manual icon theme lookup + Pixbuf scaling with native GTK4 Image::from_icon_name() (uses internal cache + GPU rendering) - Decode wallpaper texture once and share across all windows instead of N+1 separate JPEG decodes - Load file-based avatars asynchronously via gio::spawn_blocking to avoid blocking the UI thread
This commit is contained in:
+4
-3
@@ -51,12 +51,13 @@ fn activate(app: >k::Application) {
|
||||
|
||||
load_css(&display);
|
||||
|
||||
// Resolve wallpaper once, share across all windows
|
||||
// Resolve wallpaper once, decode texture once, share across all windows
|
||||
let config = config::load_config(None);
|
||||
let bg_path = config::resolve_background_path(&config);
|
||||
let texture = panel::load_background_texture(&bg_path);
|
||||
|
||||
// Panel on focused output (no set_monitor → compositor picks focused)
|
||||
let panel = panel::create_panel_window(&bg_path, app);
|
||||
let panel = panel::create_panel_window(&texture, app);
|
||||
setup_layer_shell(&panel, true, gtk4_layer_shell::Layer::Overlay);
|
||||
panel.present();
|
||||
|
||||
@@ -64,7 +65,7 @@ fn activate(app: >k::Application) {
|
||||
let monitors = display.monitors();
|
||||
for i in 0..monitors.n_items() {
|
||||
if let Some(monitor) = monitors.item(i).and_then(|obj| obj.downcast::<gdk::Monitor>().ok()) {
|
||||
let wallpaper = panel::create_wallpaper_window(&bg_path, app);
|
||||
let wallpaper = panel::create_wallpaper_window(&texture, app);
|
||||
setup_layer_shell(&wallpaper, false, gtk4_layer_shell::Layer::Top);
|
||||
wallpaper.set_monitor(Some(&monitor));
|
||||
wallpaper.present();
|
||||
|
||||
Reference in New Issue
Block a user