diff --git a/c_engine/privacy_wallpaper.c b/c_engine/privacy_wallpaper.c index e1904e6..fd4f2d4 100644 --- a/c_engine/privacy_wallpaper.c +++ b/c_engine/privacy_wallpaper.c @@ -73,6 +73,9 @@ int uu_privacy_wallpaper_run(const char *image, const int *rects, int count) { shown++; } if (!shown) return 2; + /* Map the covers before reporting ready: the host marks them skip-taskbar through KWin right + after this line, and KWin can only list windows whose surfaces already exist. */ + while (gtk_events_pending()) gtk_main_iteration_do(FALSE); /* EOF follows the host process, including crashes, rather than its spawning worker thread. */ GIOChannel *host = g_io_channel_unix_new(0); guint watch = g_io_add_watch(host, G_IO_HUP | G_IO_ERR | G_IO_NVAL, host_closed, NULL); diff --git a/src/privacy_screen/kde/kwin.rs b/src/privacy_screen/kde/kwin.rs index 1fb7901..b411a3f 100644 --- a/src/privacy_screen/kde/kwin.rs +++ b/src/privacy_screen/kde/kwin.rs @@ -23,3 +23,12 @@ pub fn move_windows_to(output: &str) -> Result<(), String> { script(&format!(r#"const v = workspace.screens.find(o => o.name == "{output}"); if (v) for (const w of workspace.windowList()) if (w.normalWindow || w.dialog) workspace.sendClientToScreen(w, v);"#)) } +/// Hides the cover window from the task manager. GTK's skip-taskbar hint is an X11 hint and KWin +/// ignores it on Wayland, so the cover showed up as an unidentified window with the theme's +/// generic "wayland" icon. `skipTaskbar` is writable through KWin scripting. Picture mode creates +/// one cover per physical monitor with the same title, and KWin appends " <2>" and so on to +/// duplicate captions, so match the title as a prefix. +pub fn hide_cover_from_taskbar() -> Result<(), String> { + script(r#"for (const w of workspace.windowList()) +if (w.resourceClass === "uuremote-server" && w.caption.indexOf("uu-remote-linux privacy") === 0) w.skipTaskbar = true;"#) +} diff --git a/src/privacy_screen/kde/mod.rs b/src/privacy_screen/kde/mod.rs index b974310..25a4f2b 100644 --- a/src/privacy_screen/kde/mod.rs +++ b/src/privacy_screen/kde/mod.rs @@ -47,6 +47,13 @@ fn cover(data: &Data) -> Result<[f64; 4], String> { if physical.len() != data.outputs.len() { return Err("physical outputs did not come back".into()); } let region = outputs::region(&layout, &virtual_name).ok_or("virtual output geometry")?; super::cover::show(wallpaper().as_deref(), &physical)?; + // The cover is a plain Wayland toplevel: GTK's skip-taskbar hint is X11-only, so without this + // the task manager shows it as an unidentified window with the theme's generic "wayland" icon. + // KWin lists a freshly mapped window asynchronously, so one more pass catches a late cover. + for pass in 0..2 { + if let Err(e) = kwin::hide_cover_from_taskbar() { log::warn!("Privacy cover taskbar: {e}"); break; } + if pass == 0 { std::thread::sleep(std::time::Duration::from_millis(200)); } + } Ok(region) }