hex/src/linux/meeting_capsules.rs
Dax ece7cf9bfb
Linux: Annotate on GNOME lab (capsule and ink float on XWayland) (#1529)
* add a Labs toggle for Annotate overlays on GNOME

Rune won't back an overlay with an XWayland window when it asks for keys
on demand, so Annotate's recording capsule, ink, and picker never show on
GNOME Wayland: a capture records with nothing on screen. With Labs ›
Annotate on GNOME (`labs.gnome_annotate`, off by default), open them on an
already running XWayland like the meeting capsules do, with the same
checks at each show and without ever starting XWayland. The ink is made
with pointer regions and no keys, since it must take the pointer later
and Rune refuses an OnDemand overlay there; Esc can't stop drawing, so
the capsule's pen button or the Annotate key does.

idea and diagnosis from @pkkid in #1526

* Bump Rune to f2fb51ea

XWayland overlays now update their input shape on every drawn frame

* fix the Annotate lab copy and the XWayland checks

Esc can't stop drawing on the GNOME path, and a tap of the Annotate key
stops the recording, not the pen; the capsule's pen button or letting go
of a held key ends drawing. Use each language's existing name for the
Annotate feature, evaluate the ink's XWayland check once at install, and
skip the picker's check when nothing shows.
2026-11-08 04:13:40 -05:00

73 lines
2.6 KiB
Rust
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//! Labs › Floating meeting capsules on GNOME (#1274). A Wayland compositor
//! without layer-shell (GNOME) has no surface for an overlay that takes
//! clicks, so the recording offer and recording capsule can't float there and
//! Hex opens the Meetings pane instead (#1271). With this explicit opt-in, Rune
//! opens them on XWayland as override-redirect windows that take clicks only
//! on their buttons and never keyboard focus, and only while this user's
//! XWayland already runs: Hex never starts it.
/// Whether the meeting capsules may float on XWayland, read as each capsule
/// shows.
pub(crate) fn on_xwayland() -> bool {
on_xwayland_for(crate::labs::gnome_meeting_capsules())
}
/// Whether a Labs overlay this user opted into may float on XWayland: only on
/// a Wayland compositor without layer-shell (GNOME), and only while this
/// user's XWayland already runs. Each check runs only when the ones before
/// pass, so with the lab off Hex never looks for layer-shell or XWayland.
pub(super) fn on_xwayland_for(opted_in: bool) -> bool {
floats_on_xwayland(
opted_in,
without_layer_shell,
crate::linux::clipboard::xwayland_running,
)
}
/// Whether this session is Wayland on a compositor without layer-shell
/// (GNOME), where an overlay that takes clicks can only show on XWayland.
pub(super) fn without_layer_shell() -> bool {
crate::linux::session::LinuxSession::detect().is_wayland()
&& !crate::linux::paste::wayland_offers(crate::linux::rune_hud::LAYER_SHELL)
}
fn floats_on_xwayland(
opted_in: bool,
without_layer_shell: impl FnOnce() -> bool,
running: impl FnOnce() -> bool,
) -> bool {
opted_in && without_layer_shell() && running()
}
#[cfg(test)]
mod tests {
use super::floats_on_xwayland;
#[test]
fn floats_only_by_opt_in_without_layer_shell_while_xwayland_runs() {
assert!(floats_on_xwayland(true, || true, || true));
assert!(
!floats_on_xwayland(false, || true, || true),
"off by default"
);
assert!(
!floats_on_xwayland(true, || false, || true),
"layer-shell (or X11) keeps its own overlays"
);
assert!(
!floats_on_xwayland(true, || true, || false),
"never starts XWayland"
);
}
#[test]
fn looks_for_nothing_while_the_lab_is_off() {
let looked = std::cell::Cell::new(false);
let look = || {
looked.set(true);
true
};
assert!(!floats_on_xwayland(false, look, look));
assert!(!looked.get());
}
}