chore(rustfmt): use nightly (#2325)
Stable rustfmt lacks a lot of features resulting in worse formatted code, thus use nightly formatter.
This commit is contained in:
parent
7006c7ceca
commit
7b0c7b6cb2
154 changed files with 3439 additions and 5891 deletions
|
|
@ -7,9 +7,8 @@ use calloop::timer::{TimeoutAction, Timer};
|
|||
use calloop::{LoopHandle, RegistrationToken};
|
||||
use tracing::warn;
|
||||
|
||||
use sctk::reexports::client::protocol::wl_keyboard::WlKeyboard;
|
||||
use sctk::reexports::client::protocol::wl_keyboard::{
|
||||
Event as WlKeyboardEvent, KeyState as WlKeyState, KeymapFormat as WlKeymapFormat,
|
||||
Event as WlKeyboardEvent, KeyState as WlKeyState, KeymapFormat as WlKeymapFormat, WlKeyboard,
|
||||
};
|
||||
use sctk::reexports::client::protocol::wl_seat::WlSeat;
|
||||
use sctk::reexports::client::{Connection, Dispatch, Proxy, QueueHandle, WEnum};
|
||||
|
|
@ -42,16 +41,16 @@ impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
|||
WEnum::Value(format) => match format {
|
||||
WlKeymapFormat::NoKeymap => {
|
||||
warn!("non-xkb compatible keymap")
|
||||
}
|
||||
},
|
||||
WlKeymapFormat::XkbV1 => {
|
||||
let context = &mut seat_state.keyboard_state.as_mut().unwrap().xkb_context;
|
||||
context.set_keymap_from_fd(fd, size as usize);
|
||||
}
|
||||
},
|
||||
_ => unreachable!(),
|
||||
},
|
||||
WEnum::Unknown(value) => {
|
||||
warn!("unknown keymap format 0x{:x}", value)
|
||||
}
|
||||
},
|
||||
},
|
||||
WlKeyboardEvent::Enter { surface, .. } => {
|
||||
let window_id = wayland::make_wid(&surface);
|
||||
|
|
@ -63,7 +62,7 @@ impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
|||
let was_unfocused = !window.has_focus();
|
||||
window.add_seat_focus(data.seat.id());
|
||||
was_unfocused
|
||||
}
|
||||
},
|
||||
None => return,
|
||||
};
|
||||
|
||||
|
|
@ -78,9 +77,7 @@ impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
|||
|
||||
// The keyboard focus is considered as general focus.
|
||||
if was_unfocused {
|
||||
state
|
||||
.events_sink
|
||||
.push_window_event(WindowEvent::Focused(true), window_id);
|
||||
state.events_sink.push_window_event(WindowEvent::Focused(true), window_id);
|
||||
}
|
||||
|
||||
// HACK: this is just for GNOME not fixing their ordering issue of modifiers.
|
||||
|
|
@ -90,7 +87,7 @@ impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
|||
window_id,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
WlKeyboardEvent::Leave { surface, .. } => {
|
||||
let window_id = wayland::make_wid(&surface);
|
||||
|
||||
|
|
@ -109,7 +106,7 @@ impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
|||
let mut window = window.lock().unwrap();
|
||||
window.remove_seat_focus(&data.seat.id());
|
||||
window.has_focus()
|
||||
}
|
||||
},
|
||||
None => return,
|
||||
};
|
||||
|
||||
|
|
@ -124,16 +121,10 @@ impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
|||
window_id,
|
||||
);
|
||||
|
||||
state
|
||||
.events_sink
|
||||
.push_window_event(WindowEvent::Focused(false), window_id);
|
||||
state.events_sink.push_window_event(WindowEvent::Focused(false), window_id);
|
||||
}
|
||||
}
|
||||
WlKeyboardEvent::Key {
|
||||
key,
|
||||
state: WEnum::Value(WlKeyState::Pressed),
|
||||
..
|
||||
} => {
|
||||
},
|
||||
WlKeyboardEvent::Key { key, state: WEnum::Value(WlKeyState::Pressed), .. } => {
|
||||
let key = key + 8;
|
||||
|
||||
key_input(
|
||||
|
|
@ -151,12 +142,7 @@ impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
|||
RepeatInfo::Disable => return,
|
||||
};
|
||||
|
||||
if !keyboard_state
|
||||
.xkb_context
|
||||
.keymap_mut()
|
||||
.unwrap()
|
||||
.key_repeats(key)
|
||||
{
|
||||
if !keyboard_state.xkb_context.keymap_mut().unwrap().key_repeats(key) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -203,12 +189,8 @@ impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
|||
}
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
WlKeyboardEvent::Key {
|
||||
key,
|
||||
state: WEnum::Value(WlKeyState::Released),
|
||||
..
|
||||
} => {
|
||||
},
|
||||
WlKeyboardEvent::Key { key, state: WEnum::Value(WlKeyState::Released), .. } => {
|
||||
let key = key + 8;
|
||||
|
||||
key_input(
|
||||
|
|
@ -222,11 +204,7 @@ impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
|||
|
||||
let keyboard_state = seat_state.keyboard_state.as_mut().unwrap();
|
||||
if keyboard_state.repeat_info != RepeatInfo::Disable
|
||||
&& keyboard_state
|
||||
.xkb_context
|
||||
.keymap_mut()
|
||||
.unwrap()
|
||||
.key_repeats(key)
|
||||
&& keyboard_state.xkb_context.keymap_mut().unwrap().key_repeats(key)
|
||||
&& Some(key) == keyboard_state.current_repeat
|
||||
{
|
||||
keyboard_state.current_repeat = None;
|
||||
|
|
@ -234,13 +212,9 @@ impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
|||
keyboard_state.loop_handle.remove(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
WlKeyboardEvent::Modifiers {
|
||||
mods_depressed,
|
||||
mods_latched,
|
||||
mods_locked,
|
||||
group,
|
||||
..
|
||||
mods_depressed, mods_latched, mods_locked, group, ..
|
||||
} => {
|
||||
let xkb_context = &mut seat_state.keyboard_state.as_mut().unwrap().xkb_context;
|
||||
let xkb_state = match xkb_context.state_mut() {
|
||||
|
|
@ -257,14 +231,14 @@ impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
|||
None => {
|
||||
seat_state.modifiers_pending = true;
|
||||
return;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
state.events_sink.push_window_event(
|
||||
WindowEvent::ModifiersChanged(seat_state.modifiers.into()),
|
||||
window_id,
|
||||
);
|
||||
}
|
||||
},
|
||||
WlKeyboardEvent::RepeatInfo { rate, delay } => {
|
||||
let keyboard_state = seat_state.keyboard_state.as_mut().unwrap();
|
||||
keyboard_state.repeat_info = if rate == 0 {
|
||||
|
|
@ -279,7 +253,7 @@ impl Dispatch<WlKeyboard, KeyboardData, WinitState> for WinitState {
|
|||
let delay = Duration::from_millis(delay as u64);
|
||||
RepeatInfo::Repeat { gap, delay }
|
||||
};
|
||||
}
|
||||
},
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
|
@ -353,10 +327,7 @@ impl Default for RepeatInfo {
|
|||
///
|
||||
/// The values are picked based on the default in various compositors and Xorg.
|
||||
fn default() -> Self {
|
||||
Self::Repeat {
|
||||
gap: Duration::from_millis(40),
|
||||
delay: Duration::from_millis(200),
|
||||
}
|
||||
Self::Repeat { gap: Duration::from_millis(40), delay: Duration::from_millis(200) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -372,10 +343,7 @@ pub struct KeyboardData {
|
|||
|
||||
impl KeyboardData {
|
||||
pub fn new(seat: WlSeat) -> Self {
|
||||
Self {
|
||||
window_id: Default::default(),
|
||||
seat,
|
||||
}
|
||||
Self { window_id: Default::default(), seat }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -397,11 +365,7 @@ fn key_input(
|
|||
let device_id = crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId));
|
||||
if let Some(mut key_context) = keyboard_state.xkb_context.key_context() {
|
||||
let event = key_context.process_key_event(keycode, state, repeat);
|
||||
let event = WindowEvent::KeyboardInput {
|
||||
device_id,
|
||||
event,
|
||||
is_synthetic: false,
|
||||
};
|
||||
let event = WindowEvent::KeyboardInput { device_id, event, is_synthetic: false };
|
||||
event_sink.push_window_event(event, window_id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,12 +81,12 @@ impl SeatHandler for WinitState {
|
|||
match capability {
|
||||
SeatCapability::Touch if seat_state.touch.is_none() => {
|
||||
seat_state.touch = self.seat_state.get_touch(queue_handle, &seat).ok();
|
||||
}
|
||||
},
|
||||
SeatCapability::Keyboard if seat_state.keyboard_state.is_none() => {
|
||||
let keyboard = seat.get_keyboard(queue_handle, KeyboardData::new(seat.clone()));
|
||||
seat_state.keyboard_state =
|
||||
Some(KeyboardState::new(keyboard, self.loop_handle.clone()));
|
||||
}
|
||||
},
|
||||
SeatCapability::Pointer if seat_state.pointer.is_none() => {
|
||||
let surface = self.compositor_state.create_surface(queue_handle);
|
||||
let surface_id = surface.id();
|
||||
|
|
@ -114,19 +114,15 @@ impl SeatHandler for WinitState {
|
|||
let themed_pointer = Arc::new(themed_pointer);
|
||||
|
||||
// Register cursor surface.
|
||||
self.pointer_surfaces
|
||||
.insert(surface_id, themed_pointer.clone());
|
||||
self.pointer_surfaces.insert(surface_id, themed_pointer.clone());
|
||||
|
||||
seat_state.pointer = Some(themed_pointer);
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
|
||||
if let Some(text_input_state) = seat_state
|
||||
.text_input
|
||||
.is_none()
|
||||
.then_some(self.text_input_state.as_ref())
|
||||
.flatten()
|
||||
if let Some(text_input_state) =
|
||||
seat_state.text_input.is_none().then_some(self.text_input_state.as_ref()).flatten()
|
||||
{
|
||||
seat_state.text_input = Some(Arc::new(text_input_state.get_text_input(
|
||||
&seat,
|
||||
|
|
@ -156,7 +152,7 @@ impl SeatHandler for WinitState {
|
|||
touch.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
SeatCapability::Pointer => {
|
||||
if let Some(relative_pointer) = seat_state.relative_pointer.take() {
|
||||
relative_pointer.destroy();
|
||||
|
|
@ -177,11 +173,11 @@ impl SeatHandler for WinitState {
|
|||
pointer.pointer().release();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
SeatCapability::Keyboard => {
|
||||
seat_state.keyboard_state = None;
|
||||
self.on_keyboard_destroy(&seat.id());
|
||||
}
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
@ -213,8 +209,7 @@ impl WinitState {
|
|||
let had_focus = window.has_focus();
|
||||
window.remove_seat_focus(seat);
|
||||
if had_focus != window.has_focus() {
|
||||
self.events_sink
|
||||
.push_window_event(WindowEvent::Focused(false), *window_id);
|
||||
self.events_sink.push_window_event(WindowEvent::Focused(false), *window_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,9 @@ use sctk::reexports::csd_frame::FrameClick;
|
|||
|
||||
use sctk::compositor::SurfaceData;
|
||||
use sctk::globals::GlobalData;
|
||||
use sctk::seat::pointer::{PointerData, PointerDataExt};
|
||||
use sctk::seat::pointer::{PointerEvent, PointerEventKind, PointerHandler};
|
||||
use sctk::seat::pointer::{
|
||||
PointerData, PointerDataExt, PointerEvent, PointerEventKind, PointerHandler,
|
||||
};
|
||||
use sctk::seat::SeatState;
|
||||
|
||||
use crate::dpi::{LogicalPosition, PhysicalPosition};
|
||||
|
|
@ -81,20 +82,14 @@ impl PointerHandler for WinitState {
|
|||
let _ = pointer.set_cursor(connection, icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
PointerEventKind::Leave { .. } if parent_surface != surface => {
|
||||
window.frame_point_left();
|
||||
}
|
||||
ref kind @ PointerEventKind::Press {
|
||||
button,
|
||||
serial,
|
||||
time,
|
||||
}
|
||||
| ref kind @ PointerEventKind::Release {
|
||||
button,
|
||||
serial,
|
||||
time,
|
||||
} if parent_surface != surface => {
|
||||
},
|
||||
ref kind @ PointerEventKind::Press { button, serial, time }
|
||||
| ref kind @ PointerEventKind::Release { button, serial, time }
|
||||
if parent_surface != surface =>
|
||||
{
|
||||
let click = match wayland_button_to_winit(button) {
|
||||
MouseButton::Left => FrameClick::Normal,
|
||||
MouseButton::Right => FrameClick::Alternate,
|
||||
|
|
@ -112,7 +107,7 @@ impl PointerHandler for WinitState {
|
|||
window_id,
|
||||
&mut self.window_compositor_updates,
|
||||
);
|
||||
}
|
||||
},
|
||||
// Regular events on the main surface.
|
||||
PointerEventKind::Enter { .. } => {
|
||||
self.events_sink
|
||||
|
|
@ -126,13 +121,10 @@ impl PointerHandler for WinitState {
|
|||
pointer.winit_data().inner.lock().unwrap().surface = Some(window_id);
|
||||
|
||||
self.events_sink.push_window_event(
|
||||
WindowEvent::CursorMoved {
|
||||
device_id,
|
||||
position,
|
||||
},
|
||||
WindowEvent::CursorMoved { device_id, position },
|
||||
window_id,
|
||||
);
|
||||
}
|
||||
},
|
||||
PointerEventKind::Leave { .. } => {
|
||||
if let Some(pointer) = seat_state.pointer.as_ref().map(Arc::downgrade) {
|
||||
window.pointer_left(pointer);
|
||||
|
|
@ -143,25 +135,17 @@ impl PointerHandler for WinitState {
|
|||
|
||||
self.events_sink
|
||||
.push_window_event(WindowEvent::CursorLeft { device_id }, window_id);
|
||||
}
|
||||
},
|
||||
PointerEventKind::Motion { .. } => {
|
||||
self.events_sink.push_window_event(
|
||||
WindowEvent::CursorMoved {
|
||||
device_id,
|
||||
position,
|
||||
},
|
||||
WindowEvent::CursorMoved { device_id, position },
|
||||
window_id,
|
||||
);
|
||||
}
|
||||
},
|
||||
ref kind @ PointerEventKind::Press { button, serial, .. }
|
||||
| ref kind @ PointerEventKind::Release { button, serial, .. } => {
|
||||
// Update the last button serial.
|
||||
pointer
|
||||
.winit_data()
|
||||
.inner
|
||||
.lock()
|
||||
.unwrap()
|
||||
.latest_button_serial = serial;
|
||||
pointer.winit_data().inner.lock().unwrap().latest_button_serial = serial;
|
||||
|
||||
let button = wayland_button_to_winit(button);
|
||||
let state = if matches!(kind, PointerEventKind::Press { .. }) {
|
||||
|
|
@ -170,19 +154,11 @@ impl PointerHandler for WinitState {
|
|||
ElementState::Released
|
||||
};
|
||||
self.events_sink.push_window_event(
|
||||
WindowEvent::MouseInput {
|
||||
device_id,
|
||||
state,
|
||||
button,
|
||||
},
|
||||
WindowEvent::MouseInput { device_id, state, button },
|
||||
window_id,
|
||||
);
|
||||
}
|
||||
PointerEventKind::Axis {
|
||||
horizontal,
|
||||
vertical,
|
||||
..
|
||||
} => {
|
||||
},
|
||||
PointerEventKind::Axis { horizontal, vertical, .. } => {
|
||||
// Get the current phase.
|
||||
let mut pointer_data = pointer.winit_data().inner.lock().unwrap();
|
||||
|
||||
|
|
@ -223,14 +199,10 @@ impl PointerHandler for WinitState {
|
|||
};
|
||||
|
||||
self.events_sink.push_window_event(
|
||||
WindowEvent::MouseWheel {
|
||||
device_id,
|
||||
delta,
|
||||
phase,
|
||||
},
|
||||
WindowEvent::MouseWheel { device_id, delta, phase },
|
||||
window_id,
|
||||
)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -407,8 +379,7 @@ pub trait WinitPointerDataExt {
|
|||
|
||||
impl WinitPointerDataExt for WlPointer {
|
||||
fn winit_data(&self) -> &WinitPointerData {
|
||||
self.data::<WinitPointerData>()
|
||||
.expect("failed to get pointer data.")
|
||||
self.data::<WinitPointerData>().expect("failed to get pointer data.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -422,14 +393,13 @@ impl PointerConstraintsState {
|
|||
queue_handle: &QueueHandle<WinitState>,
|
||||
) -> Result<Self, BindError> {
|
||||
let pointer_constraints = globals.bind(queue_handle, 1..=1, GlobalData)?;
|
||||
Ok(Self {
|
||||
pointer_constraints,
|
||||
})
|
||||
Ok(Self { pointer_constraints })
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for PointerConstraintsState {
|
||||
type Target = ZwpPointerConstraintsV1;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.pointer_constraints
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,31 +61,19 @@ impl Dispatch<ZwpRelativePointerV1, GlobalData, WinitState> for RelativePointerS
|
|||
_qhandle: &QueueHandle<WinitState>,
|
||||
) {
|
||||
let (dx_unaccel, dy_unaccel) = match event {
|
||||
zwp_relative_pointer_v1::Event::RelativeMotion {
|
||||
dx_unaccel,
|
||||
dy_unaccel,
|
||||
..
|
||||
} => (dx_unaccel, dy_unaccel),
|
||||
zwp_relative_pointer_v1::Event::RelativeMotion { dx_unaccel, dy_unaccel, .. } => {
|
||||
(dx_unaccel, dy_unaccel)
|
||||
},
|
||||
_ => return,
|
||||
};
|
||||
state
|
||||
.events_sink
|
||||
.push_device_event(DeviceEvent::Motion { axis: 0, value: dx_unaccel }, super::DeviceId);
|
||||
state
|
||||
.events_sink
|
||||
.push_device_event(DeviceEvent::Motion { axis: 1, value: dy_unaccel }, super::DeviceId);
|
||||
state.events_sink.push_device_event(
|
||||
DeviceEvent::Motion {
|
||||
axis: 0,
|
||||
value: dx_unaccel,
|
||||
},
|
||||
super::DeviceId,
|
||||
);
|
||||
state.events_sink.push_device_event(
|
||||
DeviceEvent::Motion {
|
||||
axis: 1,
|
||||
value: dy_unaccel,
|
||||
},
|
||||
super::DeviceId,
|
||||
);
|
||||
state.events_sink.push_device_event(
|
||||
DeviceEvent::MouseMotion {
|
||||
delta: (dx_unaccel, dy_unaccel),
|
||||
},
|
||||
DeviceEvent::MouseMotion { delta: (dx_unaccel, dy_unaccel) },
|
||||
super::DeviceId,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,14 +3,12 @@ use std::ops::Deref;
|
|||
use sctk::globals::GlobalData;
|
||||
use sctk::reexports::client::{Connection, Proxy, QueueHandle};
|
||||
|
||||
use sctk::reexports::client::delegate_dispatch;
|
||||
use sctk::reexports::client::globals::{BindError, GlobalList};
|
||||
use sctk::reexports::client::protocol::wl_surface::WlSurface;
|
||||
use sctk::reexports::client::Dispatch;
|
||||
use sctk::reexports::client::{delegate_dispatch, Dispatch};
|
||||
use sctk::reexports::protocols::wp::text_input::zv3::client::zwp_text_input_manager_v3::ZwpTextInputManagerV3;
|
||||
use sctk::reexports::protocols::wp::text_input::zv3::client::zwp_text_input_v3::Event as TextInputEvent;
|
||||
use sctk::reexports::protocols::wp::text_input::zv3::client::zwp_text_input_v3::{
|
||||
ContentHint, ContentPurpose, ZwpTextInputV3,
|
||||
ContentHint, ContentPurpose, Event as TextInputEvent, ZwpTextInputV3,
|
||||
};
|
||||
|
||||
use crate::event::{Ime, WindowEvent};
|
||||
|
|
@ -77,13 +75,11 @@ impl Dispatch<ZwpTextInputV3, TextInputData, WinitState> for TextInputState {
|
|||
text_input.enable();
|
||||
text_input.set_content_type_by_purpose(window.ime_purpose());
|
||||
text_input.commit();
|
||||
state
|
||||
.events_sink
|
||||
.push_window_event(WindowEvent::Ime(Ime::Enabled), window_id);
|
||||
state.events_sink.push_window_event(WindowEvent::Ime(Ime::Enabled), window_id);
|
||||
}
|
||||
|
||||
window.text_input_entered(text_input);
|
||||
}
|
||||
},
|
||||
TextInputEvent::Leave { surface } => {
|
||||
text_input_data.surface = None;
|
||||
|
||||
|
|
@ -102,15 +98,9 @@ impl Dispatch<ZwpTextInputV3, TextInputData, WinitState> for TextInputState {
|
|||
|
||||
window.text_input_left(text_input);
|
||||
|
||||
state
|
||||
.events_sink
|
||||
.push_window_event(WindowEvent::Ime(Ime::Disabled), window_id);
|
||||
}
|
||||
TextInputEvent::PreeditString {
|
||||
text,
|
||||
cursor_begin,
|
||||
cursor_end,
|
||||
} => {
|
||||
state.events_sink.push_window_event(WindowEvent::Ime(Ime::Disabled), window_id);
|
||||
},
|
||||
TextInputEvent::PreeditString { text, cursor_begin, cursor_end } => {
|
||||
let text = text.unwrap_or_default();
|
||||
let cursor_begin = usize::try_from(cursor_begin)
|
||||
.ok()
|
||||
|
|
@ -119,16 +109,12 @@ impl Dispatch<ZwpTextInputV3, TextInputData, WinitState> for TextInputState {
|
|||
.ok()
|
||||
.and_then(|idx| text.is_char_boundary(idx).then_some(idx));
|
||||
|
||||
text_input_data.pending_preedit = Some(Preedit {
|
||||
text,
|
||||
cursor_begin,
|
||||
cursor_end,
|
||||
})
|
||||
}
|
||||
text_input_data.pending_preedit = Some(Preedit { text, cursor_begin, cursor_end })
|
||||
},
|
||||
TextInputEvent::CommitString { text } => {
|
||||
text_input_data.pending_preedit = None;
|
||||
text_input_data.pending_commit = text;
|
||||
}
|
||||
},
|
||||
TextInputEvent::Done { .. } => {
|
||||
let window_id = match text_input_data.surface.as_ref() {
|
||||
Some(surface) => wayland::make_wid(surface),
|
||||
|
|
@ -150,20 +136,19 @@ impl Dispatch<ZwpTextInputV3, TextInputData, WinitState> for TextInputState {
|
|||
|
||||
// Send preedit.
|
||||
if let Some(preedit) = text_input_data.pending_preedit.take() {
|
||||
let cursor_range = preedit
|
||||
.cursor_begin
|
||||
.map(|b| (b, preedit.cursor_end.unwrap_or(b)));
|
||||
let cursor_range =
|
||||
preedit.cursor_begin.map(|b| (b, preedit.cursor_end.unwrap_or(b)));
|
||||
|
||||
state.events_sink.push_window_event(
|
||||
WindowEvent::Ime(Ime::Preedit(preedit.text, cursor_range)),
|
||||
window_id,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
TextInputEvent::DeleteSurroundingText { .. } => {
|
||||
// Not handled.
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,9 +36,7 @@ impl TouchHandler for WinitState {
|
|||
let seat_state = self.seats.get_mut(&touch.seat().id()).unwrap();
|
||||
|
||||
// Update the state of the point.
|
||||
seat_state
|
||||
.touch_map
|
||||
.insert(id, TouchPoint { surface, location });
|
||||
seat_state.touch_map.insert(id, TouchPoint { surface, location });
|
||||
|
||||
self.events_sink.push_window_event(
|
||||
WindowEvent::Touch(Touch {
|
||||
|
|
@ -190,9 +188,7 @@ pub trait TouchDataExt {
|
|||
|
||||
impl TouchDataExt for WlTouch {
|
||||
fn seat(&self) -> &WlSeat {
|
||||
self.data::<TouchData>()
|
||||
.expect("failed to get touch data.")
|
||||
.seat()
|
||||
self.data::<TouchData>().expect("failed to get touch data.").seat()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue