input: Add some basic keyboard control
This commit is contained in:
parent
c562955c80
commit
0ff1afd662
1 changed files with 41 additions and 4 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use crate::state::Common;
|
use crate::state::Common;
|
||||||
#[cfg(feature = "debug")]
|
|
||||||
use smithay::{backend::input::KeyState, wayland::seat::keysyms};
|
use smithay::{backend::input::KeyState, wayland::seat::keysyms};
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::input::{Device, DeviceCapability, InputBackend, InputEvent},
|
backend::input::{Device, DeviceCapability, InputBackend, InputEvent},
|
||||||
|
|
@ -208,11 +207,50 @@ impl Common {
|
||||||
serial,
|
serial,
|
||||||
time,
|
time,
|
||||||
|modifiers, handle| {
|
|modifiers, handle| {
|
||||||
// here we can handle global shortcuts and the like
|
if state == KeyState::Released && userdata.get::<SupressedKeys>().unwrap().filter(&handle) {
|
||||||
if userdata.get::<SupressedKeys>().unwrap().filter(&handle) {
|
|
||||||
return FilterResult::Intercept(());
|
return FilterResult::Intercept(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// here we can handle global shortcuts and the like
|
||||||
|
if modifiers.logo
|
||||||
|
&& handle.raw_syms().contains(&keysyms::KEY_Return)
|
||||||
|
&& state == KeyState::Pressed
|
||||||
|
{
|
||||||
|
if let Err(err) = std::process::Command::new("gnome-terminal")
|
||||||
|
.env("WAYLAND_DISPLAY", &self.socket)
|
||||||
|
.spawn()
|
||||||
|
{
|
||||||
|
slog_scope::warn!("Failed to spawn terminal: {}", err);
|
||||||
|
}
|
||||||
|
userdata.get::<SupressedKeys>().unwrap().add(&handle);
|
||||||
|
return FilterResult::Intercept(());
|
||||||
|
}
|
||||||
|
|
||||||
|
if modifiers.logo
|
||||||
|
&& handle.raw_syms().iter().any(|sym| *sym >= keysyms::KEY_0 && *sym <= keysyms::KEY_9)
|
||||||
|
&& state == KeyState::Pressed
|
||||||
|
{
|
||||||
|
let current_output = active_output(seat, &self);
|
||||||
|
let key_num = handle.raw_syms()
|
||||||
|
.iter()
|
||||||
|
.find(|sym| **sym >= keysyms::KEY_0 && **sym <= keysyms::KEY_9)
|
||||||
|
.unwrap() - keysyms::KEY_0;
|
||||||
|
let workspace = match key_num {
|
||||||
|
0 => 9,
|
||||||
|
x => x - 1,
|
||||||
|
};
|
||||||
|
self.spaces.activate(¤t_output, workspace as usize);
|
||||||
|
userdata.get::<SupressedKeys>().unwrap().add(&handle);
|
||||||
|
return FilterResult::Intercept(());
|
||||||
|
}
|
||||||
|
|
||||||
|
if modifiers.logo && modifiers.shift
|
||||||
|
&& handle.raw_syms().contains(&keysyms::KEY_Escape)
|
||||||
|
&& state == KeyState::Pressed
|
||||||
|
{
|
||||||
|
self.should_stop = true;
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
{
|
{
|
||||||
self.egui.modifiers = modifiers.clone();
|
self.egui.modifiers = modifiers.clone();
|
||||||
|
|
@ -247,7 +285,6 @@ impl Common {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = (modifiers, handle);
|
|
||||||
FilterResult::Forward
|
FilterResult::Forward
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue