mirror of
https://github.com/YaLTeR/niri.git
synced 2024-09-11 12:35:58 +03:00
parent
a55e385b12
commit
bc3d6cac80
@ -48,6 +48,9 @@ use smithay::wayland::session_lock::{
|
||||
LockSurface, SessionLockHandler, SessionLockManagerState, SessionLocker,
|
||||
};
|
||||
use smithay::wayland::tablet_manager::TabletSeatHandler;
|
||||
use smithay::wayland::xdg_activation::{
|
||||
XdgActivationHandler, XdgActivationState, XdgActivationToken, XdgActivationTokenData,
|
||||
};
|
||||
use smithay::{
|
||||
delegate_cursor_shape, delegate_data_control, delegate_data_device, delegate_dmabuf,
|
||||
delegate_drm_lease, delegate_idle_inhibit, delegate_idle_notify, delegate_input_method_manager,
|
||||
@ -55,6 +58,7 @@ use smithay::{
|
||||
delegate_presentation, delegate_primary_selection, delegate_relative_pointer, delegate_seat,
|
||||
delegate_security_context, delegate_session_lock, delegate_tablet_manager,
|
||||
delegate_text_input_manager, delegate_viewporter, delegate_virtual_keyboard_manager,
|
||||
delegate_xdg_activation,
|
||||
};
|
||||
|
||||
use crate::niri::{ClientState, State};
|
||||
@ -498,3 +502,40 @@ impl GammaControlHandler for State {
|
||||
}
|
||||
}
|
||||
delegate_gamma_control!(State);
|
||||
|
||||
impl XdgActivationHandler for State {
|
||||
fn activation_state(&mut self) -> &mut XdgActivationState {
|
||||
&mut self.niri.activation_state
|
||||
}
|
||||
|
||||
fn token_created(&mut self, _token: XdgActivationToken, data: XdgActivationTokenData) -> bool {
|
||||
// Only tokens that were created while the application has keyboard focus are valid.
|
||||
let Some((serial, seat)) = data.serial else {
|
||||
return false;
|
||||
};
|
||||
let Some(seat) = Seat::<State>::from_resource(&seat) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
let keyboard = seat.get_keyboard().unwrap();
|
||||
return keyboard
|
||||
.last_enter()
|
||||
.map(|last_enter| serial.is_no_older_than(&last_enter))
|
||||
.unwrap_or(false);
|
||||
}
|
||||
|
||||
fn request_activation(
|
||||
&mut self,
|
||||
_token: XdgActivationToken,
|
||||
token_data: XdgActivationTokenData,
|
||||
surface: WlSurface,
|
||||
) {
|
||||
if token_data.timestamp.elapsed().as_secs() < 10 {
|
||||
if let Some((mapped, _)) = self.niri.layout.find_window_and_output(&surface) {
|
||||
let window = mapped.window.clone();
|
||||
self.niri.layout.activate_window(&window);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
delegate_xdg_activation!(State);
|
||||
|
@ -90,6 +90,7 @@ use smithay::wayland::tablet_manager::TabletManagerState;
|
||||
use smithay::wayland::text_input::TextInputManagerState;
|
||||
use smithay::wayland::viewporter::ViewporterState;
|
||||
use smithay::wayland::virtual_keyboard::VirtualKeyboardManagerState;
|
||||
use smithay::wayland::xdg_activation::XdgActivationState;
|
||||
use smithay::wayland::xdg_foreign::XdgForeignState;
|
||||
|
||||
use crate::backend::tty::SurfaceDmabufFeedback;
|
||||
@ -217,6 +218,7 @@ pub struct Niri {
|
||||
pub presentation_state: PresentationState,
|
||||
pub security_context_state: SecurityContextState,
|
||||
pub gamma_control_manager_state: GammaControlManagerState,
|
||||
pub activation_state: XdgActivationState,
|
||||
|
||||
pub seat: Seat<State>,
|
||||
/// Scancodes of the keys to suppress.
|
||||
@ -1369,6 +1371,7 @@ impl Niri {
|
||||
GammaControlManagerState::new::<State, _>(&display_handle, move |client| {
|
||||
is_tty && !client.get_data::<ClientState>().unwrap().restricted
|
||||
});
|
||||
let activation_state = XdgActivationState::new::<State>(&display_handle);
|
||||
|
||||
let mut seat: Seat<State> = seat_state.new_wl_seat(&display_handle, backend.seat_name());
|
||||
seat.add_keyboard(
|
||||
@ -1527,6 +1530,7 @@ impl Niri {
|
||||
presentation_state,
|
||||
security_context_state,
|
||||
gamma_control_manager_state,
|
||||
activation_state,
|
||||
|
||||
seat,
|
||||
keyboard_focus: KeyboardFocus::Layout { surface: None },
|
||||
|
Loading…
Reference in New Issue
Block a user