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:
Kirill Chibisov 2024-04-26 19:11:44 +04:00 committed by GitHub
parent 7006c7ceca
commit 7b0c7b6cb2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
154 changed files with 3439 additions and 5891 deletions

View file

@ -12,8 +12,7 @@ use std::time::{Duration, Instant};
use sctk::reexports::calloop::Error as CalloopError;
use sctk::reexports::calloop_wayland_source::WaylandSource;
use sctk::reexports::client::globals;
use sctk::reexports::client::{Connection, QueueHandle};
use sctk::reexports::client::{globals, Connection, QueueHandle};
use crate::cursor::OnlyCursorImage;
use crate::dpi::LogicalSize;
@ -81,26 +80,19 @@ impl<T: 'static> EventLoop<T> {
let connection = map_err!(Connection::connect_to_env(), WaylandError::Connection)?;
let (globals, mut event_queue) = map_err!(
globals::registry_queue_init(&connection),
WaylandError::Global
)?;
let (globals, mut event_queue) =
map_err!(globals::registry_queue_init(&connection), WaylandError::Global)?;
let queue_handle = event_queue.handle();
let event_loop = map_err!(
calloop::EventLoop::<WinitState>::try_new(),
WaylandError::Calloop
)?;
let event_loop =
map_err!(calloop::EventLoop::<WinitState>::try_new(), WaylandError::Calloop)?;
let mut winit_state = WinitState::new(&globals, &queue_handle, event_loop.handle())
.map_err(|error| os_error!(error))?;
// NOTE: do a roundtrip after binding the globals to prevent potential
// races with the server.
map_err!(
event_queue.roundtrip(&mut winit_state),
WaylandError::Dispatch
)?;
map_err!(event_queue.roundtrip(&mut winit_state), WaylandError::Dispatch)?;
// Register Wayland source.
let wayland_source = WaylandSource::new(connection.clone(), event_queue);
@ -117,9 +109,7 @@ impl<T: 'static> EventLoop<T> {
});
map_err!(
event_loop
.handle()
.register_dispatcher(wayland_dispatcher.clone()),
event_loop.handle().register_dispatcher(wayland_dispatcher.clone()),
WaylandError::Calloop
)?;
@ -129,15 +119,12 @@ impl<T: 'static> EventLoop<T> {
let (user_events_sender, user_events_channel) = calloop::channel::channel();
let result = event_loop
.handle()
.insert_source(
user_events_channel,
move |event, _, winit_state: &mut WinitState| {
if let calloop::channel::Event::Msg(msg) = event {
winit_state.dispatched_events = true;
pending_user_events_clone.borrow_mut().push(msg);
}
},
)
.insert_source(user_events_channel, move |event, _, winit_state: &mut WinitState| {
if let calloop::channel::Event::Msg(msg) = event {
winit_state.dispatched_events = true;
pending_user_events_clone.borrow_mut().push(msg);
}
})
.map_err(|error| error.error);
map_err!(result, WaylandError::Calloop)?;
@ -150,13 +137,10 @@ impl<T: 'static> EventLoop<T> {
let result = event_loop
.handle()
.insert_source(
event_loop_awakener_source,
move |_, _, winit_state: &mut WinitState| {
// Mark that we have something to dispatch.
winit_state.dispatched_events = true;
},
)
.insert_source(event_loop_awakener_source, move |_, _, winit_state: &mut WinitState| {
// Mark that we have something to dispatch.
winit_state.dispatched_events = true;
})
.map_err(|error| error.error);
map_err!(result, WaylandError::Calloop)?;
@ -197,13 +181,13 @@ impl<T: 'static> EventLoop<T> {
match self.pump_events(None, &mut event_handler) {
PumpStatus::Exit(0) => {
break Ok(());
}
},
PumpStatus::Exit(code) => {
break Err(EventLoopError::ExitFailure(code));
}
},
_ => {
continue;
}
},
}
};
@ -256,7 +240,7 @@ impl<T: 'static> EventLoop<T> {
ControlFlow::Poll => Some(Duration::ZERO),
ControlFlow::WaitUntil(wait_deadline) => {
Some(wait_deadline.saturating_duration_since(start))
}
},
};
min_timeout(control_flow_timeout, timeout)
};
@ -274,11 +258,12 @@ impl<T: 'static> EventLoop<T> {
if let Err(error) = self.loop_dispatch(timeout) {
// NOTE We exit on errors from dispatches, since if we've got protocol error
// libwayland-client/wayland-rs will inform us anyway, but crashing downstream is not
// really an option. Instead we inform that the event loop got destroyed. We may
// communicate an error that something was terminated, but winit doesn't provide us
// with an API to do that via some event.
// Still, we set the exit code to the error's OS error code, or to 1 if not possible.
// libwayland-client/wayland-rs will inform us anyway, but crashing downstream is
// not really an option. Instead we inform that the event loop got
// destroyed. We may communicate an error that something was
// terminated, but winit doesn't provide us with an API to do that
// via some event. Still, we set the exit code to the error's OS
// error code, or to 1 if not possible.
let exit_code = error.raw_os_error().unwrap_or(1);
self.set_exit_code(exit_code);
return;
@ -288,23 +273,14 @@ impl<T: 'static> EventLoop<T> {
// to be considered here
let cause = match self.control_flow() {
ControlFlow::Poll => StartCause::Poll,
ControlFlow::Wait => StartCause::WaitCancelled {
start,
requested_resume: None,
},
ControlFlow::Wait => StartCause::WaitCancelled { start, requested_resume: None },
ControlFlow::WaitUntil(deadline) => {
if Instant::now() < deadline {
StartCause::WaitCancelled {
start,
requested_resume: Some(deadline),
}
StartCause::WaitCancelled { start, requested_resume: Some(deadline) }
} else {
StartCause::ResumeTimeReached {
start,
requested_resume: deadline,
}
StartCause::ResumeTimeReached { start, requested_resume: deadline }
}
}
},
};
// Reduce spurious wake-ups.
@ -471,13 +447,8 @@ impl<T: 'static> EventLoop<T> {
return Some(WindowEvent::Destroyed);
}
let mut window = state
.windows
.get_mut()
.get_mut(window_id)
.unwrap()
.lock()
.unwrap();
let mut window =
state.windows.get_mut().get_mut(window_id).unwrap().lock().unwrap();
if window.frame_callback_state() == FrameCallbackState::Requested {
return None;
@ -485,10 +456,8 @@ impl<T: 'static> EventLoop<T> {
// Reset the frame callbacks state.
window.frame_callback_reset();
let mut redraw_requested = window_requests
.get(window_id)
.unwrap()
.take_redraw_requested();
let mut redraw_requested =
window_requests.get(window_id).unwrap().take_redraw_requested();
// Redraw the frame while at it.
redraw_requested |= window.refresh_frame();
@ -498,10 +467,7 @@ impl<T: 'static> EventLoop<T> {
if let Some(event) = event {
callback(
Event::WindowEvent {
window_id: crate::window::WindowId(*window_id),
event,
},
Event::WindowEvent { window_id: crate::window::WindowId(*window_id), event },
&self.window_target,
);
}
@ -532,7 +498,7 @@ impl<T: 'static> EventLoop<T> {
}
refresh
}
},
None => false,
});
}
@ -545,7 +511,7 @@ impl<T: 'static> EventLoop<T> {
match &self.window_target.p {
PlatformActiveEventLoop::Wayland(window_target) => {
window_target.event_loop_awakener.ping();
}
},
#[cfg(x11_platform)]
PlatformActiveEventLoop::X(_) => unreachable!(),
}
@ -599,9 +565,7 @@ impl<T: 'static> EventLoop<T> {
let mut wayland_source = self.wayland_dispatcher.as_source_mut();
let event_queue = wayland_source.queue();
event_queue.roundtrip(state).map_err(|error| {
os_error!(OsError::WaylandError(Arc::new(WaylandError::Dispatch(
error
))))
os_error!(OsError::WaylandError(Arc::new(WaylandError::Dispatch(error))))
})
}

View file

@ -13,9 +13,7 @@ pub struct EventLoopProxy<T: 'static> {
impl<T: 'static> Clone for EventLoopProxy<T> {
fn clone(&self) -> Self {
EventLoopProxy {
user_events_sender: self.user_events_sender.clone(),
}
EventLoopProxy { user_events_sender: self.user_events_sender.clone() }
}
}
@ -25,8 +23,6 @@ impl<T: 'static> EventLoopProxy<T> {
}
pub fn send_event(&self, event: T) -> Result<(), EventLoopClosed<T>> {
self.user_events_sender
.send(event)
.map_err(|SendError(error)| EventLoopClosed(error))
self.user_events_sender.send(event).map_err(|SendError(error)| EventLoopClosed(error))
}
}

View file

@ -38,10 +38,7 @@ impl EventSink {
/// Add new window event to a queue.
#[inline]
pub fn push_window_event(&mut self, event: WindowEvent, window_id: WindowId) {
self.window_events.push(Event::WindowEvent {
event,
window_id: RootWindowId(window_id),
});
self.window_events.push(Event::WindowEvent { event, window_id: RootWindowId(window_id) });
}
#[inline]

View file

@ -11,11 +11,7 @@ use super::event_loop::ActiveEventLoop;
impl ActiveEventLoop {
#[inline]
pub fn available_monitors(&self) -> impl Iterator<Item = MonitorHandle> {
self.state
.borrow()
.output_state
.outputs()
.map(MonitorHandle::new)
self.state.borrow().output_state.outputs().map(MonitorHandle::new)
}
#[inline]
@ -52,9 +48,7 @@ impl MonitorHandle {
pub fn size(&self) -> PhysicalSize<u32> {
let output_data = self.proxy.data::<OutputData>().unwrap();
let dimensions = output_data.with_output_info(|info| {
info.modes
.iter()
.find_map(|mode| mode.current.then_some(mode.dimensions))
info.modes.iter().find_map(|mode| mode.current.then_some(mode.dimensions))
});
match dimensions {
@ -85,9 +79,7 @@ impl MonitorHandle {
pub fn refresh_rate_millihertz(&self) -> Option<u32> {
let output_data = self.proxy.data::<OutputData>().unwrap();
output_data.with_output_info(|info| {
info.modes
.iter()
.find_map(|mode| mode.current.then_some(mode.refresh_rate as u32))
info.modes.iter().find_map(|mode| mode.current.then_some(mode.refresh_rate as u32))
})
}

View file

@ -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);
}
}

View file

@ -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);
}
}
}

View file

@ -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
}

View file

@ -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,
);
}

View file

@ -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.
}
_ => {}
},
_ => {},
}
}
}

View file

@ -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()
}
}

View file

@ -135,7 +135,7 @@ impl WinitState {
Err(e) => {
tracing::warn!("Subcompositor protocol not available, ignoring CSD: {e:?}");
None
}
},
};
let output_state = OutputState::new(globals, queue_handle);
@ -218,8 +218,7 @@ impl WinitState {
{
pos
} else {
self.window_compositor_updates
.push(WindowCompositorUpdate::new(window_id));
self.window_compositor_updates.push(WindowCompositorUpdate::new(window_id));
self.window_compositor_updates.len() - 1
};
@ -240,9 +239,7 @@ impl WinitState {
}
pub fn queue_close(updates: &mut Vec<WindowCompositorUpdate>, window_id: WindowId) {
let pos = if let Some(pos) = updates
.iter()
.position(|update| update.window_id == window_id)
let pos = if let Some(pos) = updates.iter().position(|update| update.window_id == window_id)
{
pos
} else {
@ -276,15 +273,12 @@ impl WindowHandler for WinitState {
) {
let window_id = super::make_wid(window.wl_surface());
let pos = if let Some(pos) = self
.window_compositor_updates
.iter()
.position(|update| update.window_id == window_id)
let pos = if let Some(pos) =
self.window_compositor_updates.iter().position(|update| update.window_id == window_id)
{
pos
} else {
self.window_compositor_updates
.push(WindowCompositorUpdate::new(window_id));
self.window_compositor_updates.push(WindowCompositorUpdate::new(window_id));
self.window_compositor_updates.len() - 1
};
@ -318,10 +312,7 @@ impl OutputHandler for WinitState {
}
fn new_output(&mut self, _: &Connection, _: &QueueHandle<Self>, output: WlOutput) {
self.monitors
.lock()
.unwrap()
.push(MonitorHandle::new(output));
self.monitors.lock().unwrap().push(MonitorHandle::new(output));
}
fn update_output(&mut self, _: &Connection, _: &QueueHandle<Self>, updated: WlOutput) {
@ -388,11 +379,11 @@ impl CompositorHandler for WinitState {
}
impl ProvidesRegistryState for WinitState {
sctk::registry_handlers![OutputState, SeatState];
fn registry(&mut self) -> &mut RegistryState {
&mut self.registry_state
}
sctk::registry_handlers![OutputState, SeatState];
}
// The window update coming from the compositor.
@ -413,12 +404,7 @@ pub struct WindowCompositorUpdate {
impl WindowCompositorUpdate {
fn new(window_id: WindowId) -> Self {
Self {
window_id,
resized: false,
scale_changed: false,
close_window: false,
}
Self { window_id, resized: false, scale_changed: false, close_window: false }
}
}

View file

@ -2,11 +2,9 @@
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, Connection, Proxy, QueueHandle};
use wayland_protocols_plasma::blur::client::{
org_kde_kwin_blur::OrgKdeKwinBlur, org_kde_kwin_blur_manager::OrgKdeKwinBlurManager,
};
use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle};
use wayland_protocols_plasma::blur::client::org_kde_kwin_blur::OrgKdeKwinBlur;
use wayland_protocols_plasma::blur::client::org_kde_kwin_blur_manager::OrgKdeKwinBlurManager;
use sctk::globals::GlobalData;

View file

@ -2,11 +2,11 @@
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, Connection, Proxy, QueueHandle};
use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle};
use sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_scale_manager_v1::WpFractionalScaleManagerV1;
use sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_scale_v1::Event as FractionalScalingEvent;
use sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_scale_v1::WpFractionalScaleV1;
use sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_scale_v1::{
Event as FractionalScalingEvent, WpFractionalScaleV1,
};
use sctk::globals::GlobalData;
@ -41,11 +41,8 @@ impl FractionalScalingManager {
surface: &WlSurface,
queue_handle: &QueueHandle<WinitState>,
) -> WpFractionalScaleV1 {
let data = FractionalScaling {
surface: surface.clone(),
};
self.manager
.get_fractional_scale(surface, queue_handle, data)
let data = FractionalScaling { surface: surface.clone() };
self.manager.get_fractional_scale(surface, queue_handle, data)
}
}

View file

@ -2,8 +2,7 @@
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, Connection, Proxy, QueueHandle};
use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle};
use sctk::reexports::protocols::wp::viewporter::client::wp_viewport::WpViewport;
use sctk::reexports::protocols::wp::viewporter::client::wp_viewporter::WpViewporter;
@ -33,8 +32,7 @@ impl ViewporterState {
surface: &WlSurface,
queue_handle: &QueueHandle<WinitState>,
) -> WpViewport {
self.viewporter
.get_viewport(surface, queue_handle, GlobalData)
self.viewporter.get_viewport(surface, queue_handle, GlobalData)
}
}

View file

@ -3,12 +3,9 @@
use std::sync::atomic::AtomicBool;
use std::sync::Weak;
use sctk::reexports::client::delegate_dispatch;
use sctk::reexports::client::globals::BindError;
use sctk::reexports::client::globals::GlobalList;
use sctk::reexports::client::globals::{BindError, GlobalList};
use sctk::reexports::client::protocol::wl_surface::WlSurface;
use sctk::reexports::client::Dispatch;
use sctk::reexports::client::{Connection, Proxy, QueueHandle};
use sctk::reexports::client::{delegate_dispatch, Connection, Dispatch, Proxy, QueueHandle};
use sctk::reexports::protocols::xdg::activation::v1::client::xdg_activation_token_v1::{
Event as ActivationTokenEvent, XdgActivationTokenV1,
};
@ -78,7 +75,7 @@ impl Dispatch<XdgActivationTokenV1, XdgActivationTokenData, WinitState> for XdgA
if let Some(attention_requested) = fence.upgrade() {
attention_requested.store(false, std::sync::atomic::Ordering::Relaxed);
}
}
},
XdgActivationTokenData::Obtain((window_id, serial)) => {
state.events_sink.push_window_event(
crate::event::WindowEvent::ActivationTokenDone {
@ -87,7 +84,7 @@ impl Dispatch<XdgActivationTokenV1, XdgActivationTokenData, WinitState> for XdgA
},
*window_id,
);
}
},
}
proxy.destroy();

View file

@ -5,13 +5,11 @@ use std::sync::{Arc, Mutex};
use sctk::reexports::client::protocol::wl_display::WlDisplay;
use sctk::reexports::client::protocol::wl_surface::WlSurface;
use sctk::reexports::client::Proxy;
use sctk::reexports::client::QueueHandle;
use sctk::reexports::client::{Proxy, QueueHandle};
use sctk::compositor::{CompositorState, Region, SurfaceData};
use sctk::reexports::protocols::xdg::activation::v1::client::xdg_activation_v1::XdgActivationV1;
use sctk::shell::xdg::window::Window as SctkWindow;
use sctk::shell::xdg::window::WindowDecorations;
use sctk::shell::xdg::window::{Window as SctkWindow, WindowDecorations};
use sctk::shell::WaylandSurface;
use tracing::warn;
@ -90,15 +88,11 @@ impl Window {
let surface = state.compositor_state.create_surface(&queue_handle);
let compositor = state.compositor_state.clone();
let xdg_activation = state
.xdg_activation
.as_ref()
.map(|activation_state| activation_state.global().clone());
let xdg_activation =
state.xdg_activation.as_ref().map(|activation_state| activation_state.global().clone());
let display = event_loop_window_target.connection.display();
let size: Size = attributes
.inner_size
.unwrap_or(LogicalSize::new(800., 600.).into());
let size: Size = attributes.inner_size.unwrap_or(LogicalSize::new(800., 600.).into());
// We prefer server side decorations, however to not have decorations we ask for client
// side decorations instead.
@ -109,9 +103,7 @@ impl Window {
};
let window =
state
.xdg_shell
.create_window(surface.clone(), default_decorations, &queue_handle);
state.xdg_shell.create_window(surface.clone(), default_decorations, &queue_handle);
let mut window_state = WindowState::new(
event_loop_window_target.connection.clone(),
@ -152,7 +144,7 @@ impl Window {
match attributes.fullscreen.map(Into::into) {
Some(Fullscreen::Exclusive(_)) => {
warn!("`Fullscreen::Exclusive` is ignored on Wayland");
}
},
#[cfg_attr(not(x11_platform), allow(clippy::bind_instead_of_map))]
Some(Fullscreen::Borderless(monitor)) => {
let output = monitor.and_then(|monitor| match monitor {
@ -162,7 +154,7 @@ impl Window {
});
window.set_fullscreen(output.as_ref())
}
},
_ if attributes.maximized => window.set_maximized(),
_ => (),
};
@ -173,10 +165,9 @@ impl Window {
}
// Activate the window when the token is passed.
if let (Some(xdg_activation), Some(token)) = (
xdg_activation.as_ref(),
attributes.platform_specific.activation_token,
) {
if let (Some(xdg_activation), Some(token)) =
(xdg_activation.as_ref(), attributes.platform_specific.activation_token)
{
xdg_activation.activate(token._token, &surface);
}
@ -186,20 +177,14 @@ impl Window {
// Add the window and window requests into the state.
let window_state = Arc::new(Mutex::new(window_state));
let window_id = super::make_wid(&surface);
state
.windows
.get_mut()
.insert(window_id, window_state.clone());
state.windows.get_mut().insert(window_id, window_state.clone());
let window_requests = WindowRequests {
redraw_requested: AtomicBool::new(true),
closed: AtomicBool::new(false),
};
let window_requests = Arc::new(window_requests);
state
.window_requests
.get_mut()
.insert(window_id, window_requests.clone());
state.window_requests.get_mut().insert(window_id, window_requests.clone());
// Setup the event sync to insert `WindowEvents` right from the window.
let window_events_sink = state.window_events_sink.clone();
@ -209,17 +194,13 @@ impl Window {
// Do a roundtrip.
event_queue.roundtrip(&mut state).map_err(|error| {
os_error!(OsError::WaylandError(Arc::new(WaylandError::Dispatch(
error
))))
os_error!(OsError::WaylandError(Arc::new(WaylandError::Dispatch(error))))
})?;
// XXX Wait for the initial configure to arrive.
while !window_state.lock().unwrap().is_configured() {
event_queue.blocking_dispatch(&mut state).map_err(|error| {
os_error!(OsError::WaylandError(Arc::new(WaylandError::Dispatch(
error
))))
os_error!(OsError::WaylandError(Arc::new(WaylandError::Dispatch(error))))
})?;
}
@ -329,10 +310,7 @@ impl Window {
pub fn set_min_inner_size(&self, min_size: Option<Size>) {
let scale_factor = self.scale_factor();
let min_size = min_size.map(|size| size.to_logical(scale_factor));
self.window_state
.lock()
.unwrap()
.set_min_inner_size(min_size);
self.window_state.lock().unwrap().set_min_inner_size(min_size);
// NOTE: Requires commit to be applied.
self.request_redraw();
}
@ -342,10 +320,7 @@ impl Window {
pub fn set_max_inner_size(&self, max_size: Option<Size>) {
let scale_factor = self.scale_factor();
let max_size = max_size.map(|size| size.to_logical(scale_factor));
self.window_state
.lock()
.unwrap()
.set_max_inner_size(max_size);
self.window_state.lock().unwrap().set_max_inner_size(max_size);
// NOTE: Requires commit to be applied.
self.request_redraw();
}
@ -362,10 +337,7 @@ impl Window {
#[inline]
pub fn set_transparent(&self, transparent: bool) {
self.window_state
.lock()
.unwrap()
.set_transparent(transparent);
self.window_state.lock().unwrap().set_transparent(transparent);
}
#[inline]
@ -388,10 +360,7 @@ impl Window {
#[inline]
pub fn drag_resize_window(&self, direction: ResizeDirection) -> Result<(), ExternalError> {
self.window_state
.lock()
.unwrap()
.drag_resize_window(direction)
self.window_state.lock().unwrap().drag_resize_window(direction)
}
#[inline]
@ -499,7 +468,7 @@ impl Window {
match fullscreen {
Some(Fullscreen::Exclusive(_)) => {
warn!("`Fullscreen::Exclusive` is ignored on Wayland");
}
},
#[cfg_attr(not(x11_platform), allow(clippy::bind_instead_of_map))]
Some(Fullscreen::Borderless(monitor)) => {
let output = monitor.and_then(|monitor| match monitor {
@ -509,7 +478,7 @@ impl Window {
});
self.window.set_fullscreen(output.as_ref())
}
},
None => self.window.unset_fullscreen(),
}
}
@ -526,10 +495,7 @@ impl Window {
#[inline]
pub fn set_cursor_visible(&self, visible: bool) {
self.window_state
.lock()
.unwrap()
.set_cursor_visible(visible);
self.window_state.lock().unwrap().set_cursor_visible(visible);
}
pub fn request_user_attention(&self, request_type: Option<UserAttentionType>) {
@ -538,7 +504,7 @@ impl Window {
None => {
warn!("`request_user_attention` isn't supported");
return;
}
},
};
// Urgency is only removed by the compositor and there's no need to raise urgency when it
@ -630,10 +596,7 @@ impl Window {
if window_state.ime_allowed() != allowed && window_state.set_ime_allowed(allowed) {
let event = WindowEvent::Ime(if allowed { Ime::Enabled } else { Ime::Disabled });
self.window_events_sink
.lock()
.unwrap()
.push_window_event(event, self.window_id);
self.window_events_sink.lock().unwrap().push_window_event(event, self.window_id);
self.event_loop_awakener.ping();
}
}

View file

@ -226,13 +226,10 @@ impl WindowState {
&self,
callback: F,
) {
self.pointers
.iter()
.filter_map(Weak::upgrade)
.for_each(|pointer| {
let data = pointer.pointer().winit_data();
callback(pointer.as_ref(), data);
})
self.pointers.iter().filter_map(Weak::upgrade).for_each(|pointer| {
let data = pointer.pointer().winit_data();
callback(pointer.as_ref(), data);
})
}
/// Get the current state of the frame callback.
@ -257,7 +254,7 @@ impl WindowState {
FrameCallbackState::None | FrameCallbackState::Received => {
self.frame_callback_state = FrameCallbackState::Requested;
surface.frame(&self.queue_handle, surface.clone());
}
},
FrameCallbackState::Requested => (),
}
}
@ -297,11 +294,11 @@ impl WindowState {
// Hide the frame if we were asked to not decorate.
frame.set_hidden(!self.decorate);
self.frame = Some(frame);
}
},
Err(err) => {
warn!("Failed to create client side decorations frame: {err}");
self.csd_fails = true;
}
},
}
} else if configure.decoration_mode == DecorationMode::Server {
// Drop the frame for server side decorations to save resources.
@ -320,8 +317,8 @@ impl WindowState {
let width = width.map(|w| w.get()).unwrap_or(1);
let height = height.map(|h| h.get()).unwrap_or(1);
((width, height).into(), false)
}
(_, _) if stateless => (self.stateless_size, true),
},
(..) if stateless => (self.stateless_size, true),
_ => (self.size, true),
}
} else {
@ -335,10 +332,8 @@ impl WindowState {
// Apply configure bounds only when compositor let the user decide what size to pick.
if constrain {
let bounds = self.inner_size_bounds(&configure);
new_size.width = bounds
.0
.map(|bound_w| new_size.width.min(bound_w.get()))
.unwrap_or(new_size.width);
new_size.width =
bounds.0.map(|bound_w| new_size.width.min(bound_w.get())).unwrap_or(new_size.width);
new_size.height = bounds
.1
.map(|bound_h| new_size.height.min(bound_h.get()))
@ -346,10 +341,7 @@ impl WindowState {
}
let new_state = configure.state;
let old_state = self
.last_configure
.as_ref()
.map(|configure| configure.state);
let old_state = self.last_configure.as_ref().map(|configure| configure.state);
let state_change_requires_resize = old_state
.map(|old_state| {
@ -387,10 +379,7 @@ impl WindowState {
configure_bounds.0.unwrap_or(NonZeroU32::new(1).unwrap()),
configure_bounds.1.unwrap_or(NonZeroU32::new(1).unwrap()),
);
(
configure_bounds.0.and(width),
configure_bounds.1.and(height),
)
(configure_bounds.0.and(width), configure_bounds.1.and(height))
} else {
configure_bounds
}
@ -460,7 +449,7 @@ impl WindowState {
_ => return None,
};
self.window.resize(seat, serial, edge);
}
},
FrameAction::ShowMenu(x, y) => self.window.show_window_menu(seat, serial, (x, y)),
_ => (),
};
@ -643,12 +632,7 @@ impl WindowState {
/// Try to resize the window when the user can do so.
pub fn request_inner_size(&mut self, inner_size: Size) -> PhysicalSize<u32> {
if self
.last_configure
.as_ref()
.map(Self::is_stateless)
.unwrap_or(true)
{
if self.last_configure.as_ref().map(Self::is_stateless).unwrap_or(true) {
self.resize(inner_size.to_logical(self.scale_factor()))
}
@ -674,10 +658,7 @@ impl WindowState {
);
}
(
frame.location(),
frame.add_borders(self.size.width, self.size.height).into(),
)
(frame.location(), frame.add_borders(self.size.width, self.size.height).into())
} else {
((0, 0), self.size)
};
@ -724,16 +705,12 @@ impl WindowState {
/// Set the custom cursor icon.
pub(crate) fn set_custom_cursor(&mut self, cursor: RootCustomCursor) {
let cursor = match cursor {
RootCustomCursor {
inner: PlatformCustomCursor::Wayland(cursor),
} => cursor.0,
RootCustomCursor { inner: PlatformCustomCursor::Wayland(cursor) } => cursor.0,
#[cfg(x11_platform)]
RootCustomCursor {
inner: PlatformCustomCursor::X(_),
} => {
RootCustomCursor { inner: PlatformCustomCursor::X(_) } => {
tracing::error!("passed a X11 cursor to Wayland backend");
return;
}
},
};
let cursor = {
@ -752,11 +729,7 @@ impl WindowState {
self.apply_on_pointer(|pointer, _| {
let surface = pointer.surface();
let scale = surface
.data::<SurfaceData>()
.unwrap()
.surface_data()
.scale_factor();
let scale = surface.data::<SurfaceData>().unwrap().surface_data().scale_factor();
surface.set_buffer_scale(scale);
surface.attach(Some(cursor.buffer.wl_buffer()), 0, 0);
@ -864,7 +837,7 @@ impl WindowState {
}),
CursorGrabMode::Locked => {
self.apply_on_pointer(|_, data| data.unlock_pointer());
}
},
}
let surface = self.window.wl_surface();
@ -879,7 +852,7 @@ impl WindowState {
}),
CursorGrabMode::None => {
// Current lock/confine was already removed.
}
},
}
Ok(())
@ -902,11 +875,9 @@ impl WindowState {
// Position can be set only for locked cursor.
if self.cursor_grab_mode.current_grab_mode != CursorGrabMode::Locked {
return Err(ExternalError::Os(os_error!(
crate::platform_impl::OsError::Misc(
"cursor position can be set only for locked cursor."
)
)));
return Err(ExternalError::Os(os_error!(crate::platform_impl::OsError::Misc(
"cursor position can be set only for locked cursor."
))));
}
self.apply_on_pointer(|_, data| {
@ -929,9 +900,7 @@ impl WindowState {
for pointer in self.pointers.iter().filter_map(|pointer| pointer.upgrade()) {
let latest_enter_serial = pointer.pointer().winit_data().latest_enter_serial();
pointer
.pointer()
.set_cursor(latest_enter_serial, None, 0, 0);
pointer.pointer().set_cursor(latest_enter_serial, None, 0, 0);
}
}
}
@ -945,19 +914,12 @@ impl WindowState {
self.decorate = decorate;
match self
.last_configure
.as_ref()
.map(|configure| configure.decoration_mode)
{
match self.last_configure.as_ref().map(|configure| configure.decoration_mode) {
Some(DecorationMode::Server) if !self.decorate => {
// To disable decorations we should request client and hide the frame.
self.window
.request_decoration_mode(Some(DecorationMode::Client))
}
_ if self.decorate => self
.window
.request_decoration_mode(Some(DecorationMode::Server)),
self.window.request_decoration_mode(Some(DecorationMode::Client))
},
_ if self.decorate => self.window.request_decoration_mode(Some(DecorationMode::Server)),
_ => (),
}
@ -1054,10 +1016,7 @@ impl WindowState {
info!("Blur manager unavailable, unable to change blur")
}
} else if !blurred && self.blur.is_some() {
self.blur_manager
.as_ref()
.unwrap()
.unset(self.window.wl_surface());
self.blur_manager.as_ref().unwrap().unset(self.window.wl_surface());
self.blur.take().unwrap().release();
}
}
@ -1146,10 +1105,7 @@ struct GrabState {
impl GrabState {
fn new() -> Self {
Self {
user_grab_mode: CursorGrabMode::None,
current_grab_mode: CursorGrabMode::None,
}
Self { user_grab_mode: CursorGrabMode::None, current_grab_mode: CursorGrabMode::None }
}
}