feat(wayland): shortcut inhibit
This commit is contained in:
parent
8e7b7e586f
commit
54a69a0523
11 changed files with 360 additions and 8 deletions
|
|
@ -51,6 +51,7 @@ use std::{
|
|||
use tracing::error;
|
||||
use wayland_backend::client::Backend;
|
||||
use wayland_client::globals::GlobalError;
|
||||
use wayland_protocols::wp::keyboard_shortcuts_inhibit::zv1::client::zwp_keyboard_shortcuts_inhibit_manager_v1;
|
||||
use winit::{dpi::LogicalSize, event_loop::OwnedDisplayHandle};
|
||||
|
||||
use self::state::SctkState;
|
||||
|
|
@ -309,11 +310,19 @@ impl SctkEventLoop {
|
|||
®istry_state,
|
||||
&qh,
|
||||
),
|
||||
inhibitor_manager: registry_state.bind_one::<zwp_keyboard_shortcuts_inhibit_manager_v1::ZwpKeyboardShortcutsInhibitManagerV1, _, _>(
|
||||
&qh,
|
||||
1..=1,
|
||||
(),
|
||||
).ok(),
|
||||
registry_state,
|
||||
|
||||
queue_handle: qh,
|
||||
loop_handle,
|
||||
|
||||
|
||||
inhibitor: None,
|
||||
inhibited: false,
|
||||
_cursor_surface: None,
|
||||
_multipool: None,
|
||||
outputs: Vec::new(),
|
||||
|
|
@ -323,7 +332,6 @@ impl SctkEventLoop {
|
|||
popups: Vec::new(),
|
||||
lock_surfaces: Vec::new(),
|
||||
subsurfaces: Vec::new(),
|
||||
_kbd_focus: None,
|
||||
touch_points: HashMap::new(),
|
||||
sctk_events: Vec::new(),
|
||||
frame_status: HashMap::new(),
|
||||
|
|
|
|||
|
|
@ -94,8 +94,7 @@ use cctk::{cosmic_protocols::overlap_notify::v1::client::zcosmic_overlap_notific
|
|||
}, toplevel_info::ToplevelInfoState, toplevel_management::ToplevelManagerState};
|
||||
use wayland_protocols::{
|
||||
wp::{
|
||||
fractional_scale::v1::client::wp_fractional_scale_v1::WpFractionalScaleV1,
|
||||
viewporter::client::wp_viewport::WpViewport,
|
||||
fractional_scale::v1::client::wp_fractional_scale_v1::WpFractionalScaleV1, keyboard_shortcuts_inhibit::zv1::client::{zwp_keyboard_shortcuts_inhibit_manager_v1, zwp_keyboard_shortcuts_inhibitor_v1}, viewporter::client::wp_viewport::WpViewport
|
||||
},
|
||||
xdg::shell::client::xdg_surface::XdgSurface,
|
||||
};
|
||||
|
|
@ -388,7 +387,6 @@ pub struct SctkState {
|
|||
pub(crate) popups: Vec<SctkPopup>,
|
||||
pub(crate) subsurfaces: Vec<SctkSubsurface>,
|
||||
pub(crate) lock_surfaces: Vec<SctkLockSurface>,
|
||||
pub(crate) _kbd_focus: Option<WlSurface>,
|
||||
pub(crate) touch_points: HashMap<touch::Finger, (WlSurface, Point)>,
|
||||
|
||||
/// Window updates, which are coming from SCTK or the compositor, which require
|
||||
|
|
@ -434,6 +432,10 @@ pub struct SctkState {
|
|||
|
||||
pub(crate) activation_token_ctr: u32,
|
||||
pub(crate) token_senders: HashMap<u32, oneshot::Sender<Option<String>>>,
|
||||
|
||||
pub(crate) inhibitor: Option<zwp_keyboard_shortcuts_inhibitor_v1::ZwpKeyboardShortcutsInhibitorV1>,
|
||||
pub(crate) inhibited: bool,
|
||||
pub(crate) inhibitor_manager: Option<zwp_keyboard_shortcuts_inhibit_manager_v1::ZwpKeyboardShortcutsInhibitManagerV1>,
|
||||
}
|
||||
|
||||
/// An error that occurred while running an application.
|
||||
|
|
@ -1463,6 +1465,17 @@ impl SctkState {
|
|||
}
|
||||
},
|
||||
},
|
||||
Action::InhibitShortcuts(v) => {
|
||||
if let Some(manager) = self.inhibitor_manager.as_ref() {
|
||||
if let Some(inhibit) = self.inhibitor.take() {
|
||||
inhibit.destroy();
|
||||
}
|
||||
if v {
|
||||
self.inhibitor = self.seats.iter().next()
|
||||
.and_then(|s| s.kbd_focus.as_ref().map(|surface| manager.inhibit_shortcuts(surface, &s.seat, &self.queue_handle, ())));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue