Tell Wayland compositor we can handle keyboard ver 4 for repeat info (#8446)
Fixes us not getting Wayland key repeat info from the compositor Release Notes: - N/A
This commit is contained in:
parent
3b2e315ead
commit
d4584a10b6
2 changed files with 19 additions and 17 deletions
|
@ -227,7 +227,8 @@ impl Platform for LinuxPlatform {
|
||||||
options: PathPromptOptions,
|
options: PathPromptOptions,
|
||||||
) -> oneshot::Receiver<Option<Vec<PathBuf>>> {
|
) -> oneshot::Receiver<Option<Vec<PathBuf>>> {
|
||||||
let (done_tx, done_rx) = oneshot::channel();
|
let (done_tx, done_rx) = oneshot::channel();
|
||||||
self.foreground_executor()
|
self.inner
|
||||||
|
.foreground_executor
|
||||||
.spawn(async move {
|
.spawn(async move {
|
||||||
let title = if options.multiple {
|
let title = if options.multiple {
|
||||||
if !options.files {
|
if !options.files {
|
||||||
|
@ -270,7 +271,8 @@ impl Platform for LinuxPlatform {
|
||||||
fn prompt_for_new_path(&self, directory: &Path) -> oneshot::Receiver<Option<PathBuf>> {
|
fn prompt_for_new_path(&self, directory: &Path) -> oneshot::Receiver<Option<PathBuf>> {
|
||||||
let (done_tx, done_rx) = oneshot::channel();
|
let (done_tx, done_rx) = oneshot::channel();
|
||||||
let directory = directory.to_owned();
|
let directory = directory.to_owned();
|
||||||
self.foreground_executor()
|
self.inner
|
||||||
|
.foreground_executor
|
||||||
.spawn(async move {
|
.spawn(async move {
|
||||||
let result = SaveFileRequest::default()
|
let result = SaveFileRequest::default()
|
||||||
.modal(true)
|
.modal(true)
|
||||||
|
|
|
@ -65,8 +65,8 @@ pub(crate) struct WaylandClientStateInner {
|
||||||
pub(crate) struct WaylandClientState(Rc<RefCell<WaylandClientStateInner>>);
|
pub(crate) struct WaylandClientState(Rc<RefCell<WaylandClientStateInner>>);
|
||||||
|
|
||||||
pub(crate) struct KeyRepeat {
|
pub(crate) struct KeyRepeat {
|
||||||
rate: i32,
|
characters_per_second: u32,
|
||||||
delay: i32,
|
delay: Duration,
|
||||||
current_id: u64,
|
current_id: u64,
|
||||||
current_keysym: Option<xkb::Keysym>,
|
current_keysym: Option<xkb::Keysym>,
|
||||||
}
|
}
|
||||||
|
@ -93,8 +93,8 @@ impl WaylandClient {
|
||||||
wl_seat: None,
|
wl_seat: None,
|
||||||
keymap_state: None,
|
keymap_state: None,
|
||||||
repeat: KeyRepeat {
|
repeat: KeyRepeat {
|
||||||
rate: 16,
|
characters_per_second: 16,
|
||||||
delay: 500,
|
delay: Duration::from_millis(500),
|
||||||
current_id: 0,
|
current_id: 0,
|
||||||
current_keysym: None,
|
current_keysym: None,
|
||||||
},
|
},
|
||||||
|
@ -242,7 +242,7 @@ impl Dispatch<wl_registry::WlRegistry, ()> for WaylandClientState {
|
||||||
state.wm_base = Some(wm_base);
|
state.wm_base = Some(wm_base);
|
||||||
}
|
}
|
||||||
"wl_seat" => {
|
"wl_seat" => {
|
||||||
let seat = registry.bind::<wl_seat::WlSeat, _, _>(name, 1, qh, ());
|
let seat = registry.bind::<wl_seat::WlSeat, _, _>(name, 4, qh, ());
|
||||||
state.wl_seat = Some(seat);
|
state.wl_seat = Some(seat);
|
||||||
}
|
}
|
||||||
"wp_fractional_scale_manager_v1" => {
|
"wp_fractional_scale_manager_v1" => {
|
||||||
|
@ -412,18 +412,18 @@ impl Dispatch<wl_seat::WlSeat, ()> for WaylandClientState {
|
||||||
|
|
||||||
impl Dispatch<wl_keyboard::WlKeyboard, ()> for WaylandClientState {
|
impl Dispatch<wl_keyboard::WlKeyboard, ()> for WaylandClientState {
|
||||||
fn event(
|
fn event(
|
||||||
state_container: &mut Self,
|
this: &mut Self,
|
||||||
keyboard: &wl_keyboard::WlKeyboard,
|
keyboard: &wl_keyboard::WlKeyboard,
|
||||||
event: wl_keyboard::Event,
|
event: wl_keyboard::Event,
|
||||||
data: &(),
|
data: &(),
|
||||||
conn: &Connection,
|
conn: &Connection,
|
||||||
qh: &QueueHandle<Self>,
|
qh: &QueueHandle<Self>,
|
||||||
) {
|
) {
|
||||||
let mut state = state_container.0.borrow_mut();
|
let mut state = this.0.borrow_mut();
|
||||||
match event {
|
match event {
|
||||||
wl_keyboard::Event::RepeatInfo { rate, delay } => {
|
wl_keyboard::Event::RepeatInfo { rate, delay } => {
|
||||||
state.repeat.rate = rate;
|
state.repeat.characters_per_second = rate as u32;
|
||||||
state.repeat.delay = delay;
|
state.repeat.delay = Duration::from_millis(delay as u64);
|
||||||
}
|
}
|
||||||
wl_keyboard::Event::Keymap {
|
wl_keyboard::Event::Keymap {
|
||||||
format: WEnum::Value(format),
|
format: WEnum::Value(format),
|
||||||
|
@ -524,25 +524,25 @@ impl Dispatch<wl_keyboard::WlKeyboard, ()> for WaylandClientState {
|
||||||
state.repeat.current_id += 1;
|
state.repeat.current_id += 1;
|
||||||
state.repeat.current_keysym = Some(keysym);
|
state.repeat.current_keysym = Some(keysym);
|
||||||
|
|
||||||
let rate = state.repeat.rate;
|
let rate = state.repeat.characters_per_second;
|
||||||
let delay = state.repeat.delay;
|
let delay = state.repeat.delay;
|
||||||
let id = state.repeat.current_id;
|
let id = state.repeat.current_id;
|
||||||
let keysym = state.repeat.current_keysym;
|
let this = this.clone();
|
||||||
let state_container = state_container.clone();
|
|
||||||
|
|
||||||
state
|
state
|
||||||
.platform_inner
|
.platform_inner
|
||||||
.foreground_executor
|
.foreground_executor
|
||||||
.spawn(async move {
|
.spawn(async move {
|
||||||
let mut wait_time = Duration::from_millis(delay as u64);
|
let mut wait_time = delay;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
Timer::after(wait_time).await;
|
Timer::after(wait_time).await;
|
||||||
|
|
||||||
let state = state_container.0.borrow_mut();
|
let state = this.0.borrow_mut();
|
||||||
let is_repeating = id == state.repeat.current_id
|
let is_repeating = id == state.repeat.current_id
|
||||||
&& state.repeat.current_keysym.is_some()
|
&& state.repeat.current_keysym.is_some()
|
||||||
&& state.keyboard_focused_window.is_some();
|
&& state.keyboard_focused_window.is_some();
|
||||||
|
|
||||||
if !is_repeating {
|
if !is_repeating {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -553,7 +553,7 @@ impl Dispatch<wl_keyboard::WlKeyboard, ()> for WaylandClientState {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.handle_input(input.clone());
|
.handle_input(input.clone());
|
||||||
|
|
||||||
wait_time = Duration::from_millis(1000 / rate as u64);
|
wait_time = Duration::from_secs(1) / rate;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue