mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-21 08:01:39 +01:00
feat(record): --probe-windows on KDE, on by default as on Windows
This commit is contained in:
1 parent
df4e076e60
commit
5585f42161
3 files changed
+24
-13
No files matched your search
@@ -84,7 +84,8 @@ pub struct RecordArgs {
|
||||
/// cloaked, minimized, where it is) and, now and then, komorebi's own answer to "would you manage
|
||||
/// this window, and why", so that a window komorebi shows but Windows has hidden (or the
|
||||
/// reverse) can be found. This is what a recording on Windows does unless told not to
|
||||
/// (`--no-probe-windows`); on a Mac there is nothing to read, and asking for it is an error
|
||||
/// (`--no-probe-windows`), and on KDE, where KWin is asked the same (and the window is told from the
|
||||
/// others by its class, title and frame); on a Mac there is nothing to read, and asking for it is an error
|
||||
#[arg(long, conflicts_with = "no_probe_windows")]
|
||||
pub probe_windows: bool,
|
||||
/// Do not read what Windows says about each window (see `--probe-windows`, which Windows
|
||||
@@ -241,8 +242,8 @@ impl RecordArgs {
|
||||
|
||||
/// Returns whether the recording reads what Windows says about each window.
|
||||
///
|
||||
/// It does on Windows, unless `--no-probe-windows` says not to, and it does not elsewhere,
|
||||
/// where there is nothing to read: `--probe-windows` asked for outright is kept as asked, so
|
||||
/// It does on Windows and on KDE, unless `--no-probe-windows` says not to, and it does not on a
|
||||
/// Mac, where there is nothing to read: `--probe-windows` asked for outright is kept as asked, so
|
||||
/// that a host that cannot do it says so instead of recording without it. The recorder window
|
||||
/// takes its options from [`RecordArgs::default`], so it follows the same rule.
|
||||
///
|
||||
@@ -251,8 +252,11 @@ impl RecordArgs {
|
||||
/// ```rust
|
||||
/// use komorebi_recorder::cli::RecordArgs;
|
||||
///
|
||||
/// // the default follows the host: Windows can be asked, a Mac cannot
|
||||
/// assert_eq!(RecordArgs::default().probes_windows(), cfg!(windows));
|
||||
/// // the default follows the host: Windows and KWin can be asked, macOS cannot
|
||||
/// assert_eq!(
|
||||
/// RecordArgs::default().probes_windows(),
|
||||
/// komorebi_recorder::platform::window::CAN_PROBE
|
||||
/// );
|
||||
///
|
||||
/// // and can be turned off
|
||||
/// let off = RecordArgs {
|
||||
@@ -270,7 +274,7 @@ impl RecordArgs {
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn probes_windows(&self) -> bool {
|
||||
!self.no_probe_windows && (self.probe_windows || cfg!(windows))
|
||||
!self.no_probe_windows && (self.probe_windows || crate::platform::window::CAN_PROBE)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -736,10 +736,10 @@ impl<'a> Recording<'a> {
|
||||
/// Start every source, in the order that makes the non-video sources a superset of the video.
|
||||
#[allow(clippy::too_many_lines)]
|
||||
fn begin(options: &'a RecordOptions, live: &'a Live) -> eyre::Result<Self> {
|
||||
if options.probe_windows && !cfg!(windows) {
|
||||
if options.probe_windows && !crate::platform::window::CAN_PROBE {
|
||||
eyre::bail!(
|
||||
"--probe-windows reads the state of komorebi for Windows' windows from Windows, \
|
||||
and this is not Windows"
|
||||
"--probe-windows reads what the OS says about a window komorebi has reported on, \
|
||||
which Windows and KWin can say, and this host cannot"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -964,7 +964,13 @@ impl<'a> Recording<'a> {
|
||||
let events = if options.no_komorebi {
|
||||
None
|
||||
} else {
|
||||
let prober = options.probe_windows.then(EventProber::windows);
|
||||
let prober = options.probe_windows.then(|| {
|
||||
if cfg!(windows) {
|
||||
EventProber::windows()
|
||||
} else {
|
||||
EventProber::kde()
|
||||
}
|
||||
});
|
||||
match EventRecorder::start_with(&session.dir, Some(discovery_tx), prober) {
|
||||
Ok(recorder) => {
|
||||
manifest.komorebi.subscriber = Some(recorder.subscriber_name().to_string());
|
||||
|
||||
@@ -257,9 +257,10 @@ fn a_recording_without_probes_says_nothing_about_them() {
|
||||
assert!(trace["data"].get("window_probe").is_none(), "{trace}");
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
// Windows and KDE can be asked what the OS says about a window; macOS cannot
|
||||
#[cfg(not(any(windows, target_os = "linux")))]
|
||||
#[test]
|
||||
fn a_host_that_is_not_windows_refuses_to_probe_windows_before_it_records_anything() {
|
||||
fn a_host_that_cannot_be_asked_refuses_to_probe_windows_before_it_records_anything() {
|
||||
let out = std::env::temp_dir().join(format!("komorebi-probe-refused-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&out);
|
||||
|
||||
@@ -278,7 +279,7 @@ fn a_host_that_is_not_windows_refuses_to_probe_windows_before_it_records_anythin
|
||||
|
||||
assert!(!output.status.success());
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
assert!(stderr.contains("not Windows"), "{stderr}");
|
||||
assert!(stderr.contains("this host cannot"), "{stderr}");
|
||||
assert!(!out.exists(), "no session was started");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user