alt-tab
This commit is contained in:
+43
-2
@@ -37,12 +37,17 @@ use wayland_protocols::wp::cursor_shape::v1::client::{
|
||||
wp_cursor_shape_device_v1::WpCursorShapeDeviceV1,
|
||||
wp_cursor_shape_manager_v1::WpCursorShapeManagerV1,
|
||||
};
|
||||
use wayland_protocols::wp::keyboard_shortcuts_inhibit::zv1::client::{
|
||||
zwp_keyboard_shortcuts_inhibit_manager_v1::ZwpKeyboardShortcutsInhibitManagerV1,
|
||||
zwp_keyboard_shortcuts_inhibitor_v1::ZwpKeyboardShortcutsInhibitorV1,
|
||||
};
|
||||
use wayland_protocols::wp::viewporter::client::{
|
||||
wp_viewport::WpViewport, wp_viewporter::WpViewporter,
|
||||
};
|
||||
use wayland_protocols_wlr::layer_shell::v1::client::zwlr_layer_shell_v1::ZwlrLayerShellV1;
|
||||
|
||||
use crate::capture::{Live, Tile};
|
||||
use crate::config::AltTabMode;
|
||||
use crate::overlay;
|
||||
use crate::shm;
|
||||
use crate::target::Target;
|
||||
@@ -60,6 +65,7 @@ pub struct Settings {
|
||||
/// the overlay maps there rather than wherever the compositor would put it.
|
||||
pub scale: i32,
|
||||
pub output: String,
|
||||
pub alt_tab: AltTabMode,
|
||||
}
|
||||
|
||||
pub struct App {
|
||||
@@ -113,6 +119,14 @@ pub struct App {
|
||||
pub(crate) focused: bool,
|
||||
pub(crate) picked: Option<Target>,
|
||||
pub(crate) stats: Stats,
|
||||
|
||||
pub(crate) seat: Option<WlSeat>,
|
||||
pub(crate) inhibit_mgr: Option<ZwpKeyboardShortcutsInhibitManagerV1>,
|
||||
pub(crate) inhibitor: Option<ZwpKeyboardShortcutsInhibitorV1>,
|
||||
pub(crate) alt_tab: AltTabMode,
|
||||
pub(crate) is_alt_tab: bool,
|
||||
pub(crate) latched_modifiers: std::collections::BTreeSet<u32>,
|
||||
pub(crate) initial_stepped: bool,
|
||||
}
|
||||
|
||||
/// Counters worth reporting with --verbose. Live capture is easy to get subtly
|
||||
@@ -166,7 +180,15 @@ impl App {
|
||||
fps,
|
||||
scale,
|
||||
output,
|
||||
alt_tab,
|
||||
} = settings;
|
||||
let focused_idx = targets.iter().position(|t| t.focused).unwrap_or(0);
|
||||
let sel = if alt_tab == AltTabMode::Yes && targets.len() > 1 {
|
||||
(focused_idx + 1) % targets.len()
|
||||
} else {
|
||||
focused_idx
|
||||
};
|
||||
let is_alt_tab = alt_tab == AltTabMode::Yes;
|
||||
// Bind everything up front so a compositor missing a protocol fails
|
||||
// here, with a name, rather than halfway through a capture.
|
||||
let mut app = Self {
|
||||
@@ -187,7 +209,7 @@ impl App {
|
||||
live,
|
||||
fps,
|
||||
scale,
|
||||
sel: 0,
|
||||
sel,
|
||||
scroll: 0,
|
||||
shift: false,
|
||||
hover: None,
|
||||
@@ -204,6 +226,13 @@ impl App {
|
||||
focused: false,
|
||||
picked: None,
|
||||
stats: Stats::default(),
|
||||
seat: None,
|
||||
inhibit_mgr: None,
|
||||
inhibitor: None,
|
||||
alt_tab,
|
||||
is_alt_tab,
|
||||
latched_modifiers: std::collections::BTreeSet::new(),
|
||||
initial_stepped: alt_tab == AltTabMode::Yes,
|
||||
};
|
||||
let _: ExtForeignToplevelListV1 = globals.bind(qh, 1..=1, ())?;
|
||||
// One wl_output per display, bound at v4 so it tells us its name.
|
||||
@@ -216,7 +245,9 @@ impl App {
|
||||
}
|
||||
}
|
||||
}
|
||||
let _: WlSeat = globals.bind(qh, 1..=7, ())?;
|
||||
let seat: WlSeat = globals.bind(qh, 1..=7, ())?;
|
||||
app.seat = Some(seat);
|
||||
app.inhibit_mgr = globals.bind(qh, 1..=1, ()).ok();
|
||||
Ok(app)
|
||||
}
|
||||
|
||||
@@ -387,3 +418,13 @@ delegate_noop!(App: ignore WlSurface);
|
||||
delegate_noop!(App: WpCursorShapeManagerV1);
|
||||
delegate_noop!(App: WpCursorShapeDeviceV1);
|
||||
delegate_noop!(App: ignore WlBuffer);
|
||||
delegate_noop!(App: ZwpKeyboardShortcutsInhibitManagerV1);
|
||||
delegate_noop!(App: ignore ZwpKeyboardShortcutsInhibitorV1);
|
||||
|
||||
impl Drop for App {
|
||||
fn drop(&mut self) {
|
||||
if let Some(inhibitor) = self.inhibitor.take() {
|
||||
inhibitor.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user