Migrate to 2018 edition. (#924)
* Migrate to 2018 edition. * Use impl Iterator at one site. * Fix more rust 2018 idioms.
This commit is contained in:
parent
2e0bbc091f
commit
f879bca21c
71 changed files with 411 additions and 436 deletions
|
|
@ -7,15 +7,15 @@ use std::os::raw::*;
|
|||
use std::sync::Arc;
|
||||
|
||||
use parking_lot::Mutex;
|
||||
use sctk::reexports::client::ConnectError;
|
||||
use smithay_client_toolkit::reexports::client::ConnectError;
|
||||
|
||||
use dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize};
|
||||
use icon::Icon;
|
||||
use error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
||||
use event::Event;
|
||||
use event_loop::{EventLoopClosed, ControlFlow, EventLoopWindowTarget as RootELW};
|
||||
use monitor::{MonitorHandle as RootMonitorHandle, VideoMode};
|
||||
use window::{WindowAttributes, CursorIcon};
|
||||
use crate::dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize};
|
||||
use crate::icon::Icon;
|
||||
use crate::error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
||||
use crate::event::Event;
|
||||
use crate::event_loop::{EventLoopClosed, ControlFlow, EventLoopWindowTarget as RootELW};
|
||||
use crate::monitor::{MonitorHandle as RootMonitorHandle, VideoMode};
|
||||
use crate::window::{WindowAttributes, CursorIcon};
|
||||
use self::x11::{XConnection, XError};
|
||||
use self::x11::ffi::XVisualInfo;
|
||||
pub use self::x11::XNotSupported;
|
||||
|
|
@ -59,7 +59,7 @@ pub enum OsError {
|
|||
}
|
||||
|
||||
impl fmt::Display for OsError {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
match self {
|
||||
OsError::XError(e) => formatter.pad(&e.description),
|
||||
OsError::XMisc(e) => formatter.pad(e),
|
||||
|
|
@ -529,7 +529,7 @@ impl<T:'static> EventLoop<T> {
|
|||
}
|
||||
|
||||
pub fn run_return<F>(&mut self, callback: F)
|
||||
where F: FnMut(::event::Event<T>, &RootELW<T>, &mut ControlFlow)
|
||||
where F: FnMut(crate::event::Event<T>, &RootELW<T>, &mut ControlFlow)
|
||||
{
|
||||
match *self {
|
||||
EventLoop::Wayland(ref mut evlp) => evlp.run_return(callback),
|
||||
|
|
@ -538,7 +538,7 @@ impl<T:'static> EventLoop<T> {
|
|||
}
|
||||
|
||||
pub fn run<F>(self, callback: F) -> !
|
||||
where F: 'static + FnMut(::event::Event<T>, &RootELW<T>, &mut ControlFlow)
|
||||
where F: 'static + FnMut(crate::event::Event<T>, &RootELW<T>, &mut ControlFlow)
|
||||
{
|
||||
match self {
|
||||
EventLoop::Wayland(evlp) => evlp.run(callback),
|
||||
|
|
@ -554,7 +554,7 @@ impl<T:'static> EventLoop<T> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn window_target(&self) -> &::event_loop::EventLoopWindowTarget<T> {
|
||||
pub fn window_target(&self) -> &crate::event_loop::EventLoopWindowTarget<T> {
|
||||
match *self {
|
||||
EventLoop::Wayland(ref evl) => evl.window_target(),
|
||||
EventLoop::X(ref evl) => evl.window_target()
|
||||
|
|
|
|||
|
|
@ -5,24 +5,24 @@ use std::rc::Rc;
|
|||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Instant;
|
||||
|
||||
use event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootELW};
|
||||
use event::ModifiersState;
|
||||
use dpi::{PhysicalPosition, PhysicalSize};
|
||||
use platform_impl::platform::sticky_exit_callback;
|
||||
use monitor::VideoMode;
|
||||
use crate::event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootELW};
|
||||
use crate::event::ModifiersState;
|
||||
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
||||
use crate::platform_impl::platform::sticky_exit_callback;
|
||||
use crate::monitor::VideoMode;
|
||||
|
||||
use super::window::WindowStore;
|
||||
use super::WindowId;
|
||||
|
||||
use sctk::output::OutputMgr;
|
||||
use sctk::reexports::client::protocol::{
|
||||
use smithay_client_toolkit::output::OutputMgr;
|
||||
use smithay_client_toolkit::reexports::client::protocol::{
|
||||
wl_keyboard, wl_output, wl_pointer, wl_registry, wl_seat, wl_touch,
|
||||
};
|
||||
use sctk::reexports::client::{ConnectError, Display, EventQueue, GlobalEvent};
|
||||
use sctk::Environment;
|
||||
use smithay_client_toolkit::reexports::client::{ConnectError, Display, EventQueue, GlobalEvent};
|
||||
use smithay_client_toolkit::Environment;
|
||||
|
||||
pub struct WindowEventsSink {
|
||||
buffer: VecDeque<(::event::WindowEvent, ::window::WindowId)>,
|
||||
buffer: VecDeque<(crate::event::WindowEvent, crate::window::WindowId)>,
|
||||
}
|
||||
|
||||
impl WindowEventsSink {
|
||||
|
|
@ -32,16 +32,16 @@ impl WindowEventsSink {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn send_event(&mut self, evt: ::event::WindowEvent, wid: WindowId) {
|
||||
self.buffer.push_back((evt, ::window::WindowId(::platform_impl::WindowId::Wayland(wid))));
|
||||
pub fn send_event(&mut self, evt: crate::event::WindowEvent, wid: WindowId) {
|
||||
self.buffer.push_back((evt, crate::window::WindowId(crate::platform_impl::WindowId::Wayland(wid))));
|
||||
}
|
||||
|
||||
fn empty_with<F, T>(&mut self, mut callback: F)
|
||||
where
|
||||
F: FnMut(::event::Event<T>),
|
||||
F: FnMut(crate::event::Event<T>),
|
||||
{
|
||||
for (evt, wid) in self.buffer.drain(..) {
|
||||
callback(::event::Event::WindowEvent { event: evt, window_id: wid})
|
||||
callback(crate::event::Event::WindowEvent { event: evt, window_id: wid})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ pub struct EventLoop<T: 'static> {
|
|||
pending_user_events: Rc<RefCell<VecDeque<T>>>,
|
||||
_user_source: ::calloop::Source<::calloop::channel::Channel<T>>,
|
||||
user_sender: ::calloop::channel::Sender<T>,
|
||||
_kbd_source: ::calloop::Source<::calloop::channel::Channel<(::event::WindowEvent, super::WindowId)>>,
|
||||
_kbd_source: ::calloop::Source<::calloop::channel::Channel<(crate::event::WindowEvent, super::WindowId)>>,
|
||||
window_target: RootELW<T>
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
user_sender,
|
||||
_kbd_source: kbd_source,
|
||||
window_target: RootELW {
|
||||
p: ::platform_impl::EventLoopWindowTarget::Wayland(EventLoopWindowTarget {
|
||||
p: crate::platform_impl::EventLoopWindowTarget::Wayland(EventLoopWindowTarget {
|
||||
evq: RefCell::new(source),
|
||||
store,
|
||||
env,
|
||||
|
|
@ -181,14 +181,14 @@ impl<T: 'static> EventLoop<T> {
|
|||
}
|
||||
|
||||
pub fn run<F>(mut self, callback: F) -> !
|
||||
where F: 'static + FnMut(::event::Event<T>, &RootELW<T>, &mut ControlFlow)
|
||||
where F: 'static + FnMut(crate::event::Event<T>, &RootELW<T>, &mut ControlFlow)
|
||||
{
|
||||
self.run_return(callback);
|
||||
::std::process::exit(0);
|
||||
}
|
||||
|
||||
pub fn run_return<F>(&mut self, mut callback: F)
|
||||
where F: FnMut(::event::Event<T>, &RootELW<T>, &mut ControlFlow)
|
||||
where F: FnMut(crate::event::Event<T>, &RootELW<T>, &mut ControlFlow)
|
||||
{
|
||||
// send pending events to the server
|
||||
self.display.flush().expect("Wayland connection lost.");
|
||||
|
|
@ -198,7 +198,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
let sink = self.sink.clone();
|
||||
let user_events = self.pending_user_events.clone();
|
||||
|
||||
callback(::event::Event::NewEvents(::event::StartCause::Init), &self.window_target, &mut control_flow);
|
||||
callback(crate::event::Event::NewEvents(crate::event::StartCause::Init), &self.window_target, &mut control_flow);
|
||||
|
||||
loop {
|
||||
self.post_dispatch_triggers();
|
||||
|
|
@ -215,7 +215,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
let mut guard = user_events.borrow_mut();
|
||||
for evt in guard.drain(..) {
|
||||
sticky_exit_callback(
|
||||
::event::Event::UserEvent(evt),
|
||||
crate::event::Event::UserEvent(evt),
|
||||
&self.window_target,
|
||||
&mut control_flow,
|
||||
&mut callback
|
||||
|
|
@ -234,7 +234,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
// send Events cleared
|
||||
{
|
||||
sticky_exit_callback(
|
||||
::event::Event::EventsCleared,
|
||||
crate::event::Event::EventsCleared,
|
||||
&self.window_target,
|
||||
&mut control_flow,
|
||||
&mut callback
|
||||
|
|
@ -249,12 +249,12 @@ impl<T: 'static> EventLoop<T> {
|
|||
ControlFlow::Poll => {
|
||||
// non-blocking dispatch
|
||||
self.inner_loop.dispatch(Some(::std::time::Duration::from_millis(0)), &mut ()).unwrap();
|
||||
callback(::event::Event::NewEvents(::event::StartCause::Poll), &self.window_target, &mut control_flow);
|
||||
callback(crate::event::Event::NewEvents(crate::event::StartCause::Poll), &self.window_target, &mut control_flow);
|
||||
},
|
||||
ControlFlow::Wait => {
|
||||
self.inner_loop.dispatch(None, &mut ()).unwrap();
|
||||
callback(
|
||||
::event::Event::NewEvents(::event::StartCause::WaitCancelled {
|
||||
crate::event::Event::NewEvents(crate::event::StartCause::WaitCancelled {
|
||||
start: Instant::now(),
|
||||
requested_resume: None
|
||||
}),
|
||||
|
|
@ -274,7 +274,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
let now = Instant::now();
|
||||
if now < deadline {
|
||||
callback(
|
||||
::event::Event::NewEvents(::event::StartCause::WaitCancelled {
|
||||
crate::event::Event::NewEvents(crate::event::StartCause::WaitCancelled {
|
||||
start,
|
||||
requested_resume: Some(deadline)
|
||||
}),
|
||||
|
|
@ -283,7 +283,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
);
|
||||
} else {
|
||||
callback(
|
||||
::event::Event::NewEvents(::event::StartCause::ResumeTimeReached {
|
||||
crate::event::Event::NewEvents(crate::event::StartCause::ResumeTimeReached {
|
||||
start,
|
||||
requested_resume: deadline
|
||||
}),
|
||||
|
|
@ -295,7 +295,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
}
|
||||
}
|
||||
|
||||
callback(::event::Event::LoopDestroyed, &self.window_target, &mut control_flow);
|
||||
callback(crate::event::Event::LoopDestroyed, &self.window_target, &mut control_flow);
|
||||
}
|
||||
|
||||
pub fn primary_monitor(&self) -> MonitorHandle {
|
||||
|
|
@ -323,7 +323,7 @@ impl<T> EventLoop<T> {
|
|||
fn post_dispatch_triggers(&mut self) {
|
||||
let mut sink = self.sink.lock().unwrap();
|
||||
let window_target = match self.window_target.p {
|
||||
::platform_impl::EventLoopWindowTarget::Wayland(ref wt) => wt,
|
||||
crate::platform_impl::EventLoopWindowTarget::Wayland(ref wt) => wt,
|
||||
_ => unreachable!()
|
||||
};
|
||||
// prune possible dead windows
|
||||
|
|
@ -333,7 +333,7 @@ impl<T> EventLoop<T> {
|
|||
let pruned = window_target.store.lock().unwrap().cleanup();
|
||||
*cleanup_needed = false;
|
||||
for wid in pruned {
|
||||
sink.send_event(::event::WindowEvent::Destroyed, wid);
|
||||
sink.send_event(crate::event::WindowEvent::Destroyed, wid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -344,8 +344,8 @@ impl<T> EventLoop<T> {
|
|||
if let Some((w, h)) = newsize {
|
||||
frame.resize(w, h);
|
||||
frame.refresh();
|
||||
let logical_size = ::dpi::LogicalSize::new(w as f64, h as f64);
|
||||
sink.send_event(::event::WindowEvent::Resized(logical_size), wid);
|
||||
let logical_size = crate::dpi::LogicalSize::new(w as f64, h as f64);
|
||||
sink.send_event(crate::event::WindowEvent::Resized(logical_size), wid);
|
||||
*size = (w, h);
|
||||
} else if frame_refresh {
|
||||
frame.refresh();
|
||||
|
|
@ -355,13 +355,13 @@ impl<T> EventLoop<T> {
|
|||
}
|
||||
}
|
||||
if let Some(dpi) = new_dpi {
|
||||
sink.send_event(::event::WindowEvent::HiDpiFactorChanged(dpi as f64), wid);
|
||||
sink.send_event(crate::event::WindowEvent::HiDpiFactorChanged(dpi as f64), wid);
|
||||
}
|
||||
if refresh {
|
||||
sink.send_event(::event::WindowEvent::RedrawRequested, wid);
|
||||
sink.send_event(crate::event::WindowEvent::RedrawRequested, wid);
|
||||
}
|
||||
if closed {
|
||||
sink.send_event(::event::WindowEvent::CloseRequested, wid);
|
||||
sink.send_event(crate::event::WindowEvent::CloseRequested, wid);
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
@ -376,7 +376,7 @@ struct SeatManager {
|
|||
sink: Arc<Mutex<WindowEventsSink>>,
|
||||
store: Arc<Mutex<WindowStore>>,
|
||||
seats: Arc<Mutex<Vec<(u32, wl_seat::WlSeat)>>>,
|
||||
kbd_sender: ::calloop::channel::Sender<(::event::WindowEvent, super::WindowId)>
|
||||
kbd_sender: ::calloop::channel::Sender<(crate::event::WindowEvent, super::WindowId)>
|
||||
}
|
||||
|
||||
impl SeatManager {
|
||||
|
|
@ -417,7 +417,7 @@ impl SeatManager {
|
|||
struct SeatData {
|
||||
sink: Arc<Mutex<WindowEventsSink>>,
|
||||
store: Arc<Mutex<WindowStore>>,
|
||||
kbd_sender: ::calloop::channel::Sender<(::event::WindowEvent, super::WindowId)>,
|
||||
kbd_sender: ::calloop::channel::Sender<(crate::event::WindowEvent, super::WindowId)>,
|
||||
pointer: Option<wl_pointer::WlPointer>,
|
||||
keyboard: Option<wl_keyboard::WlKeyboard>,
|
||||
touch: Option<wl_touch::WlTouch>,
|
||||
|
|
@ -523,7 +523,7 @@ impl Clone for MonitorHandle {
|
|||
}
|
||||
|
||||
impl fmt::Debug for MonitorHandle {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
#[derive(Debug)]
|
||||
struct MonitorHandle {
|
||||
name: Option<String>,
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use super::{make_wid, DeviceId};
|
||||
use sctk::keyboard::{
|
||||
use smithay_client_toolkit::keyboard::{
|
||||
self, map_keyboard_auto_with_repeat, Event as KbEvent, KeyRepeatEvent, KeyRepeatKind,
|
||||
};
|
||||
use sctk::reexports::client::protocol::{wl_keyboard, wl_seat};
|
||||
use smithay_client_toolkit::reexports::client::protocol::{wl_keyboard, wl_seat};
|
||||
|
||||
use event::{ElementState, KeyboardInput, ModifiersState, VirtualKeyCode, WindowEvent};
|
||||
use crate::event::{ElementState, KeyboardInput, ModifiersState, VirtualKeyCode, WindowEvent};
|
||||
|
||||
pub fn init_keyboard(
|
||||
seat: &wl_seat::WlSeat,
|
||||
sink: ::calloop::channel::Sender<(::event::WindowEvent, super::WindowId)>,
|
||||
sink: ::calloop::channel::Sender<(crate::event::WindowEvent, super::WindowId)>,
|
||||
modifiers_tracker: Arc<Mutex<ModifiersState>>,
|
||||
) -> wl_keyboard::WlKeyboard {
|
||||
// { variables to be captured by the closures
|
||||
|
|
@ -23,7 +23,7 @@ pub fn init_keyboard(
|
|||
let ret = map_keyboard_auto_with_repeat(
|
||||
seat,
|
||||
KeyRepeatKind::System,
|
||||
move |evt: KbEvent, _| match evt {
|
||||
move |evt: KbEvent<'_>, _| match evt {
|
||||
KbEvent::Enter { surface, .. } => {
|
||||
let wid = make_wid(&surface);
|
||||
my_sink.send((WindowEvent::Focused(true), wid)).unwrap();
|
||||
|
|
@ -50,7 +50,7 @@ pub fn init_keyboard(
|
|||
let vkcode = key_to_vkey(rawkey, keysym);
|
||||
my_sink.send(
|
||||
(WindowEvent::KeyboardInput {
|
||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
input: KeyboardInput {
|
||||
state: state,
|
||||
scancode: rawkey,
|
||||
|
|
@ -82,7 +82,7 @@ pub fn init_keyboard(
|
|||
let vkcode = key_to_vkey(repeat_event.rawkey, repeat_event.keysym);
|
||||
repeat_sink.send((
|
||||
WindowEvent::KeyboardInput {
|
||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
input: KeyboardInput {
|
||||
state: state,
|
||||
scancode: repeat_event.rawkey,
|
||||
|
|
@ -136,7 +136,7 @@ pub fn init_keyboard(
|
|||
};
|
||||
my_sink.send((
|
||||
WindowEvent::KeyboardInput {
|
||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
input: KeyboardInput {
|
||||
state: state,
|
||||
scancode: key,
|
||||
|
|
@ -173,7 +173,7 @@ fn key_to_vkey(rawkey: u32, keysym: u32) -> Option<VirtualKeyCode> {
|
|||
}
|
||||
|
||||
fn keysym_to_vkey(keysym: u32) -> Option<VirtualKeyCode> {
|
||||
use sctk::keyboard::keysyms;
|
||||
use smithay_client_toolkit::keyboard::keysyms;
|
||||
match keysym {
|
||||
// letters
|
||||
keysyms::XKB_KEY_A | keysyms::XKB_KEY_a => Some(VirtualKeyCode::A),
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
pub use self::window::Window;
|
||||
pub use self::event_loop::{EventLoop, EventLoopWindowTarget, EventLoopProxy, WindowEventsSink, MonitorHandle};
|
||||
|
||||
use sctk::reexports::client::protocol::wl_surface;
|
||||
use smithay_client_toolkit::reexports::client::protocol::wl_surface;
|
||||
|
||||
mod event_loop;
|
||||
mod pointer;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use event::{ElementState, MouseButton, MouseScrollDelta, TouchPhase, WindowEvent, ModifiersState};
|
||||
use crate::event::{ElementState, MouseButton, MouseScrollDelta, TouchPhase, WindowEvent, ModifiersState};
|
||||
|
||||
use super::DeviceId;
|
||||
use super::event_loop::WindowEventsSink;
|
||||
use super::window::WindowStore;
|
||||
|
||||
use sctk::reexports::client::protocol::wl_pointer::{self, Event as PtrEvent, WlPointer};
|
||||
use sctk::reexports::client::protocol::wl_seat;
|
||||
use smithay_client_toolkit::reexports::client::protocol::wl_pointer::{self, Event as PtrEvent, WlPointer};
|
||||
use smithay_client_toolkit::reexports::client::protocol::wl_seat;
|
||||
|
||||
pub fn implement_pointer(
|
||||
seat: &wl_seat::WlSeat,
|
||||
|
|
@ -36,13 +36,13 @@ pub fn implement_pointer(
|
|||
mouse_focus = Some(wid);
|
||||
sink.send_event(
|
||||
WindowEvent::CursorEntered {
|
||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
},
|
||||
wid,
|
||||
);
|
||||
sink.send_event(
|
||||
WindowEvent::CursorMoved {
|
||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
position: (surface_x, surface_y).into(),
|
||||
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||
},
|
||||
|
|
@ -56,7 +56,7 @@ pub fn implement_pointer(
|
|||
if let Some(wid) = wid {
|
||||
sink.send_event(
|
||||
WindowEvent::CursorLeft {
|
||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
},
|
||||
wid,
|
||||
);
|
||||
|
|
@ -70,7 +70,7 @@ pub fn implement_pointer(
|
|||
if let Some(wid) = mouse_focus {
|
||||
sink.send_event(
|
||||
WindowEvent::CursorMoved {
|
||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
position: (surface_x, surface_y).into(),
|
||||
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||
},
|
||||
|
|
@ -94,7 +94,7 @@ pub fn implement_pointer(
|
|||
};
|
||||
sink.send_event(
|
||||
WindowEvent::MouseInput {
|
||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
state: state,
|
||||
button: button,
|
||||
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||
|
|
@ -116,7 +116,7 @@ pub fn implement_pointer(
|
|||
}
|
||||
sink.send_event(
|
||||
WindowEvent::MouseWheel {
|
||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
delta: MouseScrollDelta::PixelDelta((x as f64, y as f64).into()),
|
||||
phase: TouchPhase::Moved,
|
||||
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||
|
|
@ -146,7 +146,7 @@ pub fn implement_pointer(
|
|||
if let Some((x, y)) = axis_discrete_buffer {
|
||||
sink.send_event(
|
||||
WindowEvent::MouseWheel {
|
||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
delta: MouseScrollDelta::LineDelta(x as f32, y as f32),
|
||||
phase: axis_state,
|
||||
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||
|
|
@ -156,7 +156,7 @@ pub fn implement_pointer(
|
|||
} else if let Some((x, y)) = axis_buffer {
|
||||
sink.send_event(
|
||||
WindowEvent::MouseWheel {
|
||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
delta: MouseScrollDelta::PixelDelta((x as f64, y as f64).into()),
|
||||
phase: axis_state,
|
||||
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use event::{TouchPhase, WindowEvent};
|
||||
use crate::event::{TouchPhase, WindowEvent};
|
||||
|
||||
use super::{DeviceId, WindowId};
|
||||
use super::event_loop::WindowEventsSink;
|
||||
use super::window::WindowStore;
|
||||
|
||||
use sctk::reexports::client::protocol::wl_touch::{Event as TouchEvent, WlTouch};
|
||||
use sctk::reexports::client::protocol::wl_seat;
|
||||
use smithay_client_toolkit::reexports::client::protocol::wl_touch::{Event as TouchEvent, WlTouch};
|
||||
use smithay_client_toolkit::reexports::client::protocol::wl_seat;
|
||||
|
||||
struct TouchPoint {
|
||||
wid: WindowId,
|
||||
|
|
@ -32,8 +32,8 @@ pub(crate) fn implement_touch(
|
|||
let wid = store.find_wid(&surface);
|
||||
if let Some(wid) = wid {
|
||||
sink.send_event(
|
||||
WindowEvent::Touch(::event::Touch {
|
||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
WindowEvent::Touch(crate::event::Touch {
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
phase: TouchPhase::Started,
|
||||
location: (x, y).into(),
|
||||
id: id as u64,
|
||||
|
|
@ -52,8 +52,8 @@ pub(crate) fn implement_touch(
|
|||
if let Some(idx) = idx {
|
||||
let pt = pending_ids.remove(idx);
|
||||
sink.send_event(
|
||||
WindowEvent::Touch(::event::Touch {
|
||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
WindowEvent::Touch(crate::event::Touch {
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
phase: TouchPhase::Ended,
|
||||
location: pt.location.into(),
|
||||
id: id as u64,
|
||||
|
|
@ -67,8 +67,8 @@ pub(crate) fn implement_touch(
|
|||
if let Some(pt) = pt {
|
||||
pt.location = (x, y);
|
||||
sink.send_event(
|
||||
WindowEvent::Touch(::event::Touch {
|
||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
WindowEvent::Touch(crate::event::Touch {
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
phase: TouchPhase::Moved,
|
||||
location: (x, y).into(),
|
||||
id: id as u64,
|
||||
|
|
@ -80,8 +80,8 @@ pub(crate) fn implement_touch(
|
|||
TouchEvent::Frame => (),
|
||||
TouchEvent::Cancel => for pt in pending_ids.drain(..) {
|
||||
sink.send_event(
|
||||
WindowEvent::Touch(::event::Touch {
|
||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
WindowEvent::Touch(crate::event::Touch {
|
||||
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||
phase: TouchPhase::Cancelled,
|
||||
location: pt.location.into(),
|
||||
id: pt.id as u64,
|
||||
|
|
|
|||
|
|
@ -2,20 +2,20 @@ use std::collections::VecDeque;
|
|||
use std::io::{Seek, SeekFrom, Write};
|
||||
use std::sync::{Arc, Mutex, Weak};
|
||||
|
||||
use dpi::{LogicalPosition, LogicalSize};
|
||||
use error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
||||
use platform_impl::{MonitorHandle as PlatformMonitorHandle, PlatformSpecificWindowBuilderAttributes as PlAttributes};
|
||||
use monitor::MonitorHandle as RootMonitorHandle;
|
||||
use window::{WindowAttributes, CursorIcon};
|
||||
use crate::dpi::{LogicalPosition, LogicalSize};
|
||||
use crate::error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
||||
use crate::platform_impl::{MonitorHandle as PlatformMonitorHandle, PlatformSpecificWindowBuilderAttributes as PlAttributes};
|
||||
use crate::monitor::MonitorHandle as RootMonitorHandle;
|
||||
use crate::window::{WindowAttributes, CursorIcon};
|
||||
|
||||
use sctk::surface::{get_dpi_factor, get_outputs};
|
||||
use sctk::window::{ConceptFrame, Event as WEvent, State as WState, Window as SWindow, Theme};
|
||||
use sctk::reexports::client::{Display, NewProxy};
|
||||
use sctk::reexports::client::protocol::{wl_seat, wl_surface, wl_subsurface, wl_shm};
|
||||
use sctk::output::OutputMgr;
|
||||
use smithay_client_toolkit::surface::{get_dpi_factor, get_outputs};
|
||||
use smithay_client_toolkit::window::{ConceptFrame, Event as WEvent, State as WState, Window as SWindow, Theme};
|
||||
use smithay_client_toolkit::reexports::client::{Display, NewProxy};
|
||||
use smithay_client_toolkit::reexports::client::protocol::{wl_seat, wl_surface, wl_subsurface, wl_shm};
|
||||
use smithay_client_toolkit::output::OutputMgr;
|
||||
|
||||
use super::{make_wid, EventLoopWindowTarget, MonitorHandle, WindowId};
|
||||
use platform_impl::platform::wayland::event_loop::{available_monitors, primary_monitor};
|
||||
use crate::platform_impl::platform::wayland::event_loop::{available_monitors, primary_monitor};
|
||||
|
||||
pub struct Window {
|
||||
_bg_surface: wl_surface::WlSurface,
|
||||
|
|
@ -60,7 +60,7 @@ impl Window {
|
|||
let my_bg_surface = bg_surface.clone();
|
||||
|
||||
// prepare a 1px buffer to display on the root window
|
||||
let mut pool = sctk::utils::MemPool::new(&evlp.env.shm, || {}).unwrap();
|
||||
let mut pool = smithay_client_toolkit::utils::MemPool::new(&evlp.env.shm, || {}).unwrap();
|
||||
pool.resize(4).unwrap();
|
||||
pool.seek(SeekFrom::Start(0)).unwrap();
|
||||
pool.write(&[0, 0, 0, 0]).unwrap();
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ use super::{
|
|||
events, util, DndState, Dnd, DeviceInfo
|
||||
};
|
||||
|
||||
use event_loop::EventLoopWindowTarget as RootELW;
|
||||
use event::{DeviceEvent, Event, KeyboardInput, ModifiersState, WindowEvent};
|
||||
use dpi::{LogicalPosition,LogicalSize};
|
||||
use crate::event_loop::EventLoopWindowTarget as RootELW;
|
||||
use crate::event::{DeviceEvent, Event, KeyboardInput, ModifiersState, WindowEvent};
|
||||
use crate::dpi::{LogicalPosition,LogicalSize};
|
||||
|
||||
pub(super) struct EventProcessor<T: 'static> {
|
||||
pub(super) dnd: Dnd,
|
||||
|
|
@ -440,7 +440,7 @@ impl<T: 'static> EventProcessor<T> {
|
|||
}
|
||||
|
||||
ffi::KeyPress | ffi::KeyRelease => {
|
||||
use event::ElementState::{Pressed, Released};
|
||||
use crate::event::ElementState::{Pressed, Released};
|
||||
|
||||
// Note that in compose/pre-edit sequences, this will always be Released.
|
||||
let state = if xev.get_type() == ffi::KeyPress {
|
||||
|
|
@ -521,11 +521,11 @@ impl<T: 'static> EventProcessor<T> {
|
|||
return;
|
||||
}
|
||||
|
||||
use event::WindowEvent::{Focused, CursorEntered, MouseInput, CursorLeft, CursorMoved, MouseWheel, AxisMotion};
|
||||
use event::ElementState::{Pressed, Released};
|
||||
use event::MouseButton::{Left, Right, Middle, Other};
|
||||
use event::MouseScrollDelta::LineDelta;
|
||||
use event::{Touch, TouchPhase};
|
||||
use crate::event::WindowEvent::{Focused, CursorEntered, MouseInput, CursorLeft, CursorMoved, MouseWheel, AxisMotion};
|
||||
use crate::event::ElementState::{Pressed, Released};
|
||||
use crate::event::MouseButton::{Left, Right, Middle, Other};
|
||||
use crate::event::MouseScrollDelta::LineDelta;
|
||||
use crate::event::{Touch, TouchPhase};
|
||||
|
||||
match xev.evtype {
|
||||
ffi::XI_ButtonPress | ffi::XI_ButtonRelease => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use libc;
|
||||
use super::ffi;
|
||||
use event::VirtualKeyCode;
|
||||
use crate::event::VirtualKeyCode;
|
||||
|
||||
pub fn keysym_to_element(keysym: libc::c_uint) -> Option<VirtualKeyCode> {
|
||||
Some(match keysym {
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ impl InputMethodName {
|
|||
}
|
||||
|
||||
impl fmt::Debug for InputMethodName {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.string.fmt(f)
|
||||
}
|
||||
}
|
||||
|
|
@ -254,7 +254,7 @@ impl PotentialInputMethods {
|
|||
pub fn open_im(
|
||||
&mut self,
|
||||
xconn: &Arc<XConnection>,
|
||||
callback: Option<&Fn() -> ()>,
|
||||
callback: Option<&dyn Fn() -> ()>,
|
||||
) -> InputMethodResult {
|
||||
use self::InputMethodResult::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ use std::sync::{Arc, mpsc, Weak, Mutex};
|
|||
|
||||
use libc::{self, setlocale, LC_CTYPE};
|
||||
|
||||
use error::OsError as RootOsError;
|
||||
use event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootELW};
|
||||
use event::{WindowEvent, Event};
|
||||
use platform_impl::PlatformSpecificWindowBuilderAttributes;
|
||||
use platform_impl::platform::sticky_exit_callback;
|
||||
use window::{WindowAttributes};
|
||||
use crate::error::OsError as RootOsError;
|
||||
use crate::event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootELW};
|
||||
use crate::event::{WindowEvent, Event};
|
||||
use crate::platform_impl::PlatformSpecificWindowBuilderAttributes;
|
||||
use crate::platform_impl::platform::sticky_exit_callback;
|
||||
use crate::window::{WindowAttributes};
|
||||
use self::dnd::{Dnd, DndState};
|
||||
use self::ime::{ImeReceiver, ImeSender, ImeCreationError, Ime};
|
||||
use self::event_processor::EventProcessor;
|
||||
|
|
@ -243,7 +243,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
let mut guard = self.pending_user_events.borrow_mut();
|
||||
for evt in guard.drain(..) {
|
||||
sticky_exit_callback(
|
||||
::event::Event::UserEvent(evt),
|
||||
crate::event::Event::UserEvent(evt),
|
||||
&self.target,
|
||||
&mut control_flow,
|
||||
&mut callback
|
||||
|
|
@ -256,7 +256,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
for wid in guard.drain() {
|
||||
sticky_exit_callback(
|
||||
Event::WindowEvent {
|
||||
window_id: ::window::WindowId(super::WindowId::X(wid)),
|
||||
window_id: crate::window::WindowId(super::WindowId::X(wid)),
|
||||
event: WindowEvent::RedrawRequested
|
||||
},
|
||||
&self.target,
|
||||
|
|
@ -268,7 +268,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
// send Events cleared
|
||||
{
|
||||
sticky_exit_callback(
|
||||
::event::Event::EventsCleared,
|
||||
crate::event::Event::EventsCleared,
|
||||
&self.target,
|
||||
&mut control_flow,
|
||||
&mut callback
|
||||
|
|
@ -283,12 +283,12 @@ impl<T: 'static> EventLoop<T> {
|
|||
ControlFlow::Poll => {
|
||||
// non-blocking dispatch
|
||||
self.inner_loop.dispatch(Some(::std::time::Duration::from_millis(0)), &mut ()).unwrap();
|
||||
callback(::event::Event::NewEvents(::event::StartCause::Poll), &self.target, &mut control_flow);
|
||||
callback(crate::event::Event::NewEvents(crate::event::StartCause::Poll), &self.target, &mut control_flow);
|
||||
},
|
||||
ControlFlow::Wait => {
|
||||
self.inner_loop.dispatch(None, &mut ()).unwrap();
|
||||
callback(
|
||||
::event::Event::NewEvents(::event::StartCause::WaitCancelled {
|
||||
crate::event::Event::NewEvents(crate::event::StartCause::WaitCancelled {
|
||||
start: ::std::time::Instant::now(),
|
||||
requested_resume: None
|
||||
}),
|
||||
|
|
@ -308,7 +308,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
let now = std::time::Instant::now();
|
||||
if now < deadline {
|
||||
callback(
|
||||
::event::Event::NewEvents(::event::StartCause::WaitCancelled {
|
||||
crate::event::Event::NewEvents(crate::event::StartCause::WaitCancelled {
|
||||
start,
|
||||
requested_resume: Some(deadline)
|
||||
}),
|
||||
|
|
@ -317,7 +317,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
);
|
||||
} else {
|
||||
callback(
|
||||
::event::Event::NewEvents(::event::StartCause::ResumeTimeReached {
|
||||
crate::event::Event::NewEvents(crate::event::StartCause::ResumeTimeReached {
|
||||
start,
|
||||
requested_resume: deadline
|
||||
}),
|
||||
|
|
@ -329,7 +329,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
}
|
||||
}
|
||||
|
||||
callback(::event::Event::LoopDestroyed, &self.target, &mut control_flow);
|
||||
callback(crate::event::Event::LoopDestroyed, &self.target, &mut control_flow);
|
||||
}
|
||||
|
||||
pub fn run<F>(mut self, callback: F) -> !
|
||||
|
|
@ -485,8 +485,8 @@ struct XExtension {
|
|||
first_error_id: c_int,
|
||||
}
|
||||
|
||||
fn mkwid(w: ffi::Window) -> ::window::WindowId { ::window::WindowId(::platform_impl::WindowId::X(WindowId(w))) }
|
||||
fn mkdid(w: c_int) -> ::event::DeviceId { ::event::DeviceId(::platform_impl::DeviceId::X(DeviceId(w))) }
|
||||
fn mkwid(w: ffi::Window) -> crate::window::WindowId { crate::window::WindowId(crate::platform_impl::WindowId::X(WindowId(w))) }
|
||||
fn mkdid(w: c_int) -> crate::event::DeviceId { crate::event::DeviceId(crate::platform_impl::DeviceId::X(DeviceId(w))) }
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Device {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ use std::os::raw::*;
|
|||
|
||||
use parking_lot::Mutex;
|
||||
|
||||
use dpi::{PhysicalPosition, PhysicalSize};
|
||||
use monitor::VideoMode;
|
||||
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
||||
use crate::monitor::VideoMode;
|
||||
use super::{util, XConnection, XError};
|
||||
use super::ffi::{
|
||||
RRCrtcChangeNotifyMask,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ impl XConnection {
|
|||
target_window: c_ulong,
|
||||
event_mask: Option<c_long>,
|
||||
event: T,
|
||||
) -> Flusher {
|
||||
) -> Flusher<'_> {
|
||||
let event_mask = event_mask.unwrap_or(ffi::NoEventMask);
|
||||
unsafe {
|
||||
(self.xlib.XSendEvent)(
|
||||
|
|
@ -29,7 +29,7 @@ impl XConnection {
|
|||
message_type: ffi::Atom,
|
||||
event_mask: Option<c_long>,
|
||||
data: ClientMsgPayload,
|
||||
) -> Flusher {
|
||||
) -> Flusher<'_> {
|
||||
let mut event: ffi::XClientMessageEvent = unsafe { mem::uninitialized() };
|
||||
event.type_ = ffi::ClientMessage;
|
||||
event.display = self.display;
|
||||
|
|
@ -50,7 +50,7 @@ impl XConnection {
|
|||
message_type: ffi::Atom,
|
||||
event_mask: Option<c_long>,
|
||||
data: &[T],
|
||||
) -> Flusher {
|
||||
) -> Flusher<'_> {
|
||||
let format = T::FORMAT;
|
||||
let size_of_t = mem::size_of::<T>();
|
||||
debug_assert_eq!(size_of_t, format.get_actual_size());
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::cmp;
|
||||
|
||||
use super::*;
|
||||
use dpi::{LogicalPosition, LogicalSize};
|
||||
use crate::dpi::{LogicalPosition, LogicalSize};
|
||||
|
||||
// Friendly neighborhood axis-aligned rectangle
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ impl<'a> NormalHints<'a> {
|
|||
}
|
||||
|
||||
impl XConnection {
|
||||
pub fn get_wm_hints(&self, window: ffi::Window) -> Result<XSmartPointer<ffi::XWMHints>, XError> {
|
||||
pub fn get_wm_hints(&self, window: ffi::Window) -> Result<XSmartPointer<'_, ffi::XWMHints>, XError> {
|
||||
let wm_hints = unsafe { (self.xlib.XGetWMHints)(self.display, window) };
|
||||
self.check_errors()?;
|
||||
let wm_hints = if wm_hints.is_null() {
|
||||
|
|
@ -198,7 +198,7 @@ impl XConnection {
|
|||
Ok(wm_hints)
|
||||
}
|
||||
|
||||
pub fn set_wm_hints(&self, window: ffi::Window, wm_hints: XSmartPointer<ffi::XWMHints>) -> Flusher {
|
||||
pub fn set_wm_hints(&self, window: ffi::Window, wm_hints: XSmartPointer<'_, ffi::XWMHints>) -> Flusher<'_> {
|
||||
unsafe {
|
||||
(self.xlib.XSetWMHints)(
|
||||
self.display,
|
||||
|
|
@ -209,7 +209,7 @@ impl XConnection {
|
|||
Flusher::new(self)
|
||||
}
|
||||
|
||||
pub fn get_normal_hints(&self, window: ffi::Window) -> Result<NormalHints, XError> {
|
||||
pub fn get_normal_hints(&self, window: ffi::Window) -> Result<NormalHints<'_>, XError> {
|
||||
let size_hints = self.alloc_size_hints();
|
||||
let mut supplied_by_user: c_long = unsafe { mem::uninitialized() };
|
||||
unsafe {
|
||||
|
|
@ -223,7 +223,7 @@ impl XConnection {
|
|||
self.check_errors().map(|_| NormalHints { size_hints })
|
||||
}
|
||||
|
||||
pub fn set_normal_hints(&self, window: ffi::Window, normal_hints: NormalHints) -> Flusher {
|
||||
pub fn set_normal_hints(&self, window: ffi::Window, normal_hints: NormalHints<'_>) -> Flusher<'_> {
|
||||
unsafe {
|
||||
(self.xlib.XSetWMNormalHints)(
|
||||
self.display,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use window::{Icon, Pixel, PIXEL_SIZE};
|
||||
use crate::window::{Icon, Pixel, PIXEL_SIZE};
|
||||
use super::*;
|
||||
|
||||
impl Pixel {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::str;
|
||||
|
||||
use super::*;
|
||||
use event::ModifiersState;
|
||||
use crate::event::ModifiersState;
|
||||
|
||||
pub const VIRTUAL_CORE_POINTER: c_int = 2;
|
||||
pub const VIRTUAL_CORE_KEYBOARD: c_int = 3;
|
||||
|
|
@ -55,7 +55,7 @@ impl<'a> Drop for PointerState<'a> {
|
|||
}
|
||||
|
||||
impl XConnection {
|
||||
pub fn select_xinput_events(&self, window: c_ulong, device_id: c_int, mask: i32) -> Flusher {
|
||||
pub fn select_xinput_events(&self, window: c_ulong, device_id: c_int, mask: i32) -> Flusher<'_> {
|
||||
let mut event_mask = ffi::XIEventMask {
|
||||
deviceid: device_id,
|
||||
mask: &mask as *const _ as *mut c_uchar,
|
||||
|
|
@ -73,7 +73,7 @@ impl XConnection {
|
|||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn select_xkb_events(&self, device_id: c_uint, mask: c_ulong) -> Option<Flusher> {
|
||||
pub fn select_xkb_events(&self, device_id: c_uint, mask: c_ulong) -> Option<Flusher<'_>> {
|
||||
let status = unsafe {
|
||||
(self.xlib.XkbSelectEvents)(
|
||||
self.display,
|
||||
|
|
@ -89,9 +89,9 @@ impl XConnection {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn query_pointer(&self, window: ffi::Window, device_id: c_int) -> Result<PointerState, XError> {
|
||||
pub fn query_pointer(&self, window: ffi::Window, device_id: c_int) -> Result<PointerState<'_>, XError> {
|
||||
unsafe {
|
||||
let mut pointer_state: PointerState = mem::uninitialized();
|
||||
let mut pointer_state: PointerState<'_> = mem::uninitialized();
|
||||
pointer_state.xconn = self;
|
||||
pointer_state.relative_to_window = (self.xinput2.XIQueryPointer)(
|
||||
self.display,
|
||||
|
|
|
|||
|
|
@ -45,17 +45,17 @@ impl<'a, T> Drop for XSmartPointer<'a, T> {
|
|||
}
|
||||
|
||||
impl XConnection {
|
||||
pub fn alloc_class_hint(&self) -> XSmartPointer<ffi::XClassHint> {
|
||||
pub fn alloc_class_hint(&self) -> XSmartPointer<'_, ffi::XClassHint> {
|
||||
XSmartPointer::new(self, unsafe { (self.xlib.XAllocClassHint)() })
|
||||
.expect("`XAllocClassHint` returned null; out of memory")
|
||||
}
|
||||
|
||||
pub fn alloc_size_hints(&self) -> XSmartPointer<ffi::XSizeHints> {
|
||||
pub fn alloc_size_hints(&self) -> XSmartPointer<'_, ffi::XSizeHints> {
|
||||
XSmartPointer::new(self, unsafe { (self.xlib.XAllocSizeHints)() })
|
||||
.expect("`XAllocSizeHints` returned null; out of memory")
|
||||
}
|
||||
|
||||
pub fn alloc_wm_hints(&self) -> XSmartPointer<ffi::XWMHints> {
|
||||
pub fn alloc_wm_hints(&self) -> XSmartPointer<'_, ffi::XWMHints> {
|
||||
XSmartPointer::new(self, unsafe { (self.xlib.XAllocWMHints)() })
|
||||
.expect("`XAllocWMHints` returned null; out of memory")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use std::{env, slice};
|
||||
use std::str::FromStr;
|
||||
|
||||
use monitor::VideoMode;
|
||||
use dpi::validate_hidpi_factor;
|
||||
use crate::monitor::VideoMode;
|
||||
use crate::dpi::validate_hidpi_factor;
|
||||
use super::*;
|
||||
|
||||
pub fn calc_dpi_factor(
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@ use std::sync::Arc;
|
|||
use libc;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
use error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
||||
use window::{Icon, CursorIcon, WindowAttributes};
|
||||
use dpi::{LogicalPosition, LogicalSize};
|
||||
use platform_impl::MonitorHandle as PlatformMonitorHandle;
|
||||
use platform_impl::{OsError, PlatformSpecificWindowBuilderAttributes};
|
||||
use platform_impl::x11::ime::ImeContextCreationError;
|
||||
use platform_impl::x11::MonitorHandle as X11MonitorHandle;
|
||||
use monitor::MonitorHandle as RootMonitorHandle;
|
||||
use crate::error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
||||
use crate::window::{Icon, CursorIcon, WindowAttributes};
|
||||
use crate::dpi::{LogicalPosition, LogicalSize};
|
||||
use crate::platform_impl::MonitorHandle as PlatformMonitorHandle;
|
||||
use crate::platform_impl::{OsError, PlatformSpecificWindowBuilderAttributes};
|
||||
use crate::platform_impl::x11::ime::ImeContextCreationError;
|
||||
use crate::platform_impl::x11::MonitorHandle as X11MonitorHandle;
|
||||
use crate::monitor::MonitorHandle as RootMonitorHandle;
|
||||
|
||||
use super::{ffi, util, ImeSender, XConnection, XError, WindowId, EventLoopWindowTarget};
|
||||
|
||||
|
|
@ -429,7 +429,7 @@ impl UnownedWindow {
|
|||
LogicalSize::from_physical((width, height), dpi)
|
||||
}
|
||||
|
||||
fn set_pid(&self) -> Option<util::Flusher> {
|
||||
fn set_pid(&self) -> Option<util::Flusher<'_>> {
|
||||
let pid_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_PID\0") };
|
||||
let client_machine_atom = unsafe { self.xconn.get_atom_unchecked(b"WM_CLIENT_MACHINE\0") };
|
||||
unsafe {
|
||||
|
|
@ -462,7 +462,7 @@ impl UnownedWindow {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_window_type(&self, window_type: util::WindowType) -> util::Flusher {
|
||||
fn set_window_type(&self, window_type: util::WindowType) -> util::Flusher<'_> {
|
||||
let hint_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_WINDOW_TYPE\0") };
|
||||
let window_type_atom = window_type.as_atom(&self.xconn);
|
||||
self.xconn.change_property(
|
||||
|
|
@ -474,7 +474,7 @@ impl UnownedWindow {
|
|||
)
|
||||
}
|
||||
|
||||
fn set_gtk_theme_variant(&self, variant: String) -> util::Flusher {
|
||||
fn set_gtk_theme_variant(&self, variant: String) -> util::Flusher<'_> {
|
||||
let hint_atom = unsafe { self.xconn.get_atom_unchecked(b"_GTK_THEME_VARIANT\0") };
|
||||
let utf8_atom = unsafe { self.xconn.get_atom_unchecked(b"UTF8_STRING\0") };
|
||||
let variant = CString::new(variant).expect("`_GTK_THEME_VARIANT` contained null byte");
|
||||
|
|
@ -502,7 +502,7 @@ impl UnownedWindow {
|
|||
&self,
|
||||
operation: util::StateOperation,
|
||||
properties: (c_long, c_long, c_long, c_long),
|
||||
) -> util::Flusher {
|
||||
) -> util::Flusher<'_> {
|
||||
let state_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_STATE\0") };
|
||||
self.xconn.send_client_msg(
|
||||
self.xwindow,
|
||||
|
|
@ -519,12 +519,12 @@ impl UnownedWindow {
|
|||
)
|
||||
}
|
||||
|
||||
fn set_fullscreen_hint(&self, fullscreen: bool) -> util::Flusher {
|
||||
fn set_fullscreen_hint(&self, fullscreen: bool) -> util::Flusher<'_> {
|
||||
let fullscreen_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_STATE_FULLSCREEN\0") };
|
||||
self.set_netwm(fullscreen.into(), (fullscreen_atom as c_long, 0, 0, 0))
|
||||
}
|
||||
|
||||
fn set_fullscreen_inner(&self, monitor: Option<RootMonitorHandle>) -> util::Flusher {
|
||||
fn set_fullscreen_inner(&self, monitor: Option<RootMonitorHandle>) -> util::Flusher<'_> {
|
||||
match monitor {
|
||||
None => {
|
||||
let flusher = self.set_fullscreen_hint(false);
|
||||
|
|
@ -588,7 +588,7 @@ impl UnownedWindow {
|
|||
self.xconn.primary_monitor()
|
||||
}
|
||||
|
||||
fn set_maximized_inner(&self, maximized: bool) -> util::Flusher {
|
||||
fn set_maximized_inner(&self, maximized: bool) -> util::Flusher<'_> {
|
||||
let horz_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_STATE_MAXIMIZED_HORZ\0") };
|
||||
let vert_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_STATE_MAXIMIZED_VERT\0") };
|
||||
self.set_netwm(maximized.into(), (horz_atom as c_long, vert_atom as c_long, 0, 0))
|
||||
|
|
@ -602,7 +602,7 @@ impl UnownedWindow {
|
|||
self.invalidate_cached_frame_extents();
|
||||
}
|
||||
|
||||
fn set_title_inner(&self, title: &str) -> util::Flusher {
|
||||
fn set_title_inner(&self, title: &str) -> util::Flusher<'_> {
|
||||
let wm_name_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_NAME\0") };
|
||||
let utf8_atom = unsafe { self.xconn.get_atom_unchecked(b"UTF8_STRING\0") };
|
||||
let title = CString::new(title).expect("Window title contained null byte");
|
||||
|
|
@ -629,7 +629,7 @@ impl UnownedWindow {
|
|||
.expect("Failed to set window title");
|
||||
}
|
||||
|
||||
fn set_decorations_inner(&self, decorations: bool) -> util::Flusher {
|
||||
fn set_decorations_inner(&self, decorations: bool) -> util::Flusher<'_> {
|
||||
let wm_hints = unsafe { self.xconn.get_atom_unchecked(b"_MOTIF_WM_HINTS\0") };
|
||||
self.xconn.change_property(
|
||||
self.xwindow,
|
||||
|
|
@ -654,7 +654,7 @@ impl UnownedWindow {
|
|||
self.invalidate_cached_frame_extents();
|
||||
}
|
||||
|
||||
fn set_always_on_top_inner(&self, always_on_top: bool) -> util::Flusher {
|
||||
fn set_always_on_top_inner(&self, always_on_top: bool) -> util::Flusher<'_> {
|
||||
let above_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_STATE_ABOVE\0") };
|
||||
self.set_netwm(always_on_top.into(), (above_atom as c_long, 0, 0, 0))
|
||||
}
|
||||
|
|
@ -666,7 +666,7 @@ impl UnownedWindow {
|
|||
.expect("Failed to set always-on-top state");
|
||||
}
|
||||
|
||||
fn set_icon_inner(&self, icon: Icon) -> util::Flusher {
|
||||
fn set_icon_inner(&self, icon: Icon) -> util::Flusher<'_> {
|
||||
let icon_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_ICON\0") };
|
||||
let data = icon.to_cardinals();
|
||||
self.xconn.change_property(
|
||||
|
|
@ -678,7 +678,7 @@ impl UnownedWindow {
|
|||
)
|
||||
}
|
||||
|
||||
fn unset_icon_inner(&self) -> util::Flusher {
|
||||
fn unset_icon_inner(&self) -> util::Flusher<'_> {
|
||||
let icon_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_ICON\0") };
|
||||
let empty_data: [util::Cardinal; 0] = [];
|
||||
self.xconn.change_property(
|
||||
|
|
@ -759,7 +759,7 @@ impl UnownedWindow {
|
|||
Ok(self.logicalize_coords(self.inner_position_physical()))
|
||||
}
|
||||
|
||||
pub(crate) fn set_position_inner(&self, mut x: i32, mut y: i32) -> util::Flusher {
|
||||
pub(crate) fn set_position_inner(&self, mut x: i32, mut y: i32) -> util::Flusher<'_> {
|
||||
// There are a few WMs that set client area position rather than window position, so
|
||||
// we'll translate for consistency.
|
||||
if util::wm_name_is_one_of(&["Enlightenment", "FVWM"]) {
|
||||
|
|
@ -851,7 +851,7 @@ impl UnownedWindow {
|
|||
}
|
||||
|
||||
fn update_normal_hints<F>(&self, callback: F) -> Result<(), XError>
|
||||
where F: FnOnce(&mut util::NormalHints) -> ()
|
||||
where F: FnOnce(&mut util::NormalHints<'_>) -> ()
|
||||
{
|
||||
let mut normal_hints = self.xconn.get_normal_hints(self.xwindow)?;
|
||||
callback(&mut normal_hints);
|
||||
|
|
@ -892,7 +892,7 @@ impl UnownedWindow {
|
|||
new_dpi_factor: f64,
|
||||
width: f64,
|
||||
height: f64,
|
||||
) -> (f64, f64, util::Flusher) {
|
||||
) -> (f64, f64, util::Flusher<'_>) {
|
||||
let scale_factor = new_dpi_factor / old_dpi_factor;
|
||||
let new_width = width * scale_factor;
|
||||
let new_height = height * scale_factor;
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ impl XConnection {
|
|||
}
|
||||
|
||||
impl fmt::Debug for XConnection {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.display.fmt(f)
|
||||
}
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ impl Error for XError {
|
|||
}
|
||||
|
||||
impl fmt::Display for XError {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
write!(formatter, "X error: {} (code: {}, request code: {}, minor code: {})",
|
||||
self.description, self.error_code, self.request_code, self.minor_code)
|
||||
}
|
||||
|
|
@ -151,7 +151,7 @@ impl Error for XNotSupported {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn cause(&self) -> Option<&Error> {
|
||||
fn cause(&self) -> Option<&dyn Error> {
|
||||
match *self {
|
||||
XNotSupported::LibraryOpenError(ref err) => Some(err),
|
||||
_ => None
|
||||
|
|
@ -160,7 +160,7 @@ impl Error for XNotSupported {
|
|||
}
|
||||
|
||||
impl fmt::Display for XNotSupported {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
formatter.write_str(self.description())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue