mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 05:21:31 +11:00
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
|
@ -3,6 +3,7 @@ name = "winit"
|
||||||
version = "0.19.1"
|
version = "0.19.1"
|
||||||
authors = ["The winit contributors", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
|
authors = ["The winit contributors", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
|
||||||
description = "Cross-platform window creation library."
|
description = "Cross-platform window creation library."
|
||||||
|
edition = "2018"
|
||||||
keywords = ["windowing"]
|
keywords = ["windowing"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
|
@ -43,7 +43,7 @@ fn main() {
|
||||||
match event {
|
match event {
|
||||||
CloseRequested => *control_flow = ControlFlow::Exit,
|
CloseRequested => *control_flow = ControlFlow::Exit,
|
||||||
DroppedFile(path) => {
|
DroppedFile(path) => {
|
||||||
use image::GenericImageView;
|
|
||||||
|
|
||||||
window.set_window_icon(Some(load_icon(&path)));
|
window.set_window_icon(Some(load_icon(&path)));
|
||||||
},
|
},
|
||||||
|
|
10
src/error.rs
10
src/error.rs
|
@ -1,7 +1,7 @@
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::error;
|
use std::error;
|
||||||
|
|
||||||
use platform_impl;
|
use crate::platform_impl;
|
||||||
|
|
||||||
/// An error whose cause it outside Winit's control.
|
/// An error whose cause it outside Winit's control.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -55,13 +55,13 @@ macro_rules! os_error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for 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> {
|
||||||
formatter.pad(&format!("os error at {}:{}: {}", self.file, self.line, self.error))
|
formatter.pad(&format!("os error at {}:{}: {}", self.file, self.line, self.error))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for ExternalError {
|
impl fmt::Display for ExternalError {
|
||||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||||
match self {
|
match self {
|
||||||
ExternalError::NotSupported(e) => e.fmt(formatter),
|
ExternalError::NotSupported(e) => e.fmt(formatter),
|
||||||
ExternalError::Os(e) => e.fmt(formatter),
|
ExternalError::Os(e) => e.fmt(formatter),
|
||||||
|
@ -70,13 +70,13 @@ impl fmt::Display for ExternalError {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for NotSupportedError {
|
impl fmt::Debug for NotSupportedError {
|
||||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||||
formatter.debug_struct("NotSupportedError").finish()
|
formatter.debug_struct("NotSupportedError").finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for NotSupportedError {
|
impl fmt::Display for NotSupportedError {
|
||||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||||
formatter.pad("the requested operation is not supported by Winit")
|
formatter.pad("the requested operation is not supported by Winit")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use dpi::{LogicalPosition, LogicalSize};
|
use crate::dpi::{LogicalPosition, LogicalSize};
|
||||||
use window::WindowId;
|
use crate::window::WindowId;
|
||||||
use platform_impl;
|
use crate::platform_impl;
|
||||||
|
|
||||||
/// Describes a generic event.
|
/// Describes a generic event.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
|
|
|
@ -13,9 +13,9 @@ use std::{fmt, error};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
use platform_impl;
|
use crate::platform_impl;
|
||||||
use event::Event;
|
use crate::event::Event;
|
||||||
use monitor::{AvailableMonitorsIter, MonitorHandle};
|
use crate::monitor::{AvailableMonitorsIter, MonitorHandle};
|
||||||
|
|
||||||
/// Provides a way to retrieve events from the system and from the windows that were registered to
|
/// Provides a way to retrieve events from the system and from the windows that were registered to
|
||||||
/// the events loop.
|
/// the events loop.
|
||||||
|
@ -46,13 +46,13 @@ pub struct EventLoopWindowTarget<T: 'static> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> fmt::Debug for EventLoop<T> {
|
impl<T> fmt::Debug for EventLoop<T> {
|
||||||
fn fmt(&self, fmtr: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmtr: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
fmtr.pad("EventLoop { .. }")
|
fmtr.pad("EventLoop { .. }")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> fmt::Debug for EventLoopWindowTarget<T> {
|
impl<T> fmt::Debug for EventLoopWindowTarget<T> {
|
||||||
fn fmt(&self, fmtr: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmtr: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
fmtr.pad("EventLoopWindowTarget { .. }")
|
fmtr.pad("EventLoopWindowTarget { .. }")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,10 +146,8 @@ impl<T> EventLoop<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the list of all the monitors available on the system.
|
/// Returns the list of all the monitors available on the system.
|
||||||
///
|
|
||||||
// Note: should be replaced with `-> impl Iterator` once stable.
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn available_monitors(&self) -> AvailableMonitorsIter {
|
pub fn available_monitors(&self) -> impl Iterator<Item = MonitorHandle> {
|
||||||
let data = self.event_loop.available_monitors();
|
let data = self.event_loop.available_monitors();
|
||||||
AvailableMonitorsIter{ data: data.into_iter() }
|
AvailableMonitorsIter{ data: data.into_iter() }
|
||||||
}
|
}
|
||||||
|
@ -186,7 +184,7 @@ impl<T: 'static> EventLoopProxy<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: 'static> fmt::Debug for EventLoopProxy<T> {
|
impl<T: 'static> fmt::Debug for EventLoopProxy<T> {
|
||||||
fn fmt(&self, fmtr: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmtr: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
fmtr.pad("EventLoopProxy { .. }")
|
fmtr.pad("EventLoopProxy { .. }")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,7 +195,7 @@ impl<T: 'static> fmt::Debug for EventLoopProxy<T> {
|
||||||
pub struct EventLoopClosed;
|
pub struct EventLoopClosed;
|
||||||
|
|
||||||
impl fmt::Display for EventLoopClosed {
|
impl fmt::Display for EventLoopClosed {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}", error::Error::description(self))
|
write!(f, "{}", error::Error::description(self))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub enum BadIcon {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for BadIcon {
|
impl fmt::Display for BadIcon {
|
||||||
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let msg = match self {
|
let msg = match self {
|
||||||
&BadIcon::ByteCountNotDivisibleBy4 { byte_count } => format!(
|
&BadIcon::ByteCountNotDivisibleBy4 { byte_count } => format!(
|
||||||
"The length of the `rgba` argument ({:?}) isn't divisible by 4, making it impossible to interpret as 32bpp RGBA pixels.",
|
"The length of the `rgba` argument ({:?}) isn't divisible by 4, making it impossible to interpret as 32bpp RGBA pixels.",
|
||||||
|
@ -56,7 +56,7 @@ impl Error for BadIcon {
|
||||||
"A valid icon cannot be created from these arguments"
|
"A valid icon cannot be created from these arguments"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cause(&self) -> Option<&Error> {
|
fn cause(&self) -> Option<&dyn Error> {
|
||||||
Some(self)
|
Some(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
26
src/lib.rs
26
src/lib.rs
|
@ -75,10 +75,11 @@
|
||||||
//! [`LoopDestroyed`]: ./event/enum.Event.html#variant.LoopDestroyed
|
//! [`LoopDestroyed`]: ./event/enum.Event.html#variant.LoopDestroyed
|
||||||
//! [`platform`]: ./platform/index.html
|
//! [`platform`]: ./platform/index.html
|
||||||
|
|
||||||
|
#![deny(rust_2018_idioms)]
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
extern crate libc;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
|
@ -86,35 +87,12 @@ extern crate log;
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate derivative;
|
extern crate derivative;
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
extern crate winapi;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate objc;
|
extern crate objc;
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
extern crate cocoa;
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
extern crate dispatch;
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
extern crate core_foundation;
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
extern crate core_graphics;
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
extern crate core_video_sys;
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))]
|
|
||||||
extern crate x11_dl;
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd", target_os = "windows"))]
|
|
||||||
extern crate parking_lot;
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))]
|
|
||||||
extern crate percent_encoding;
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))]
|
|
||||||
extern crate smithay_client_toolkit as sctk;
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))]
|
|
||||||
extern crate calloop;
|
|
||||||
|
|
||||||
pub mod dpi;
|
pub mod dpi;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
//! [window_get]: ../window/struct.Window.html#method.available_monitors
|
//! [window_get]: ../window/struct.Window.html#method.available_monitors
|
||||||
use std::collections::vec_deque::IntoIter as VecDequeIter;
|
use std::collections::vec_deque::IntoIter as VecDequeIter;
|
||||||
|
|
||||||
use platform_impl;
|
use crate::platform_impl;
|
||||||
use dpi::{PhysicalPosition, PhysicalSize};
|
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
||||||
|
|
||||||
/// An iterator over all available monitors.
|
/// An iterator over all available monitors.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
#![cfg(any(target_os = "android"))]
|
#![cfg(any(target_os = "android"))]
|
||||||
|
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
use EventLoop;
|
use crate::EventLoop;
|
||||||
use Window;
|
use crate::Window;
|
||||||
use WindowBuilder;
|
use crate::WindowBuilder;
|
||||||
|
|
||||||
/// Additional methods on `EventLoop` that are specific to Android.
|
/// Additional methods on `EventLoop` that are specific to Android.
|
||||||
pub trait EventLoopExtAndroid {
|
pub trait EventLoopExtAndroid {
|
||||||
/// Makes it possible for glutin to register a callback when a suspend event happens on Android
|
/// Makes it possible for glutin to register a callback when a suspend event happens on Android
|
||||||
fn set_suspend_callback(&self, cb: Option<Box<Fn(bool) -> ()>>);
|
fn set_suspend_callback(&self, cb: Option<Box<dyn Fn(bool) -> ()>>);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventLoopExtAndroid for EventLoop {
|
impl EventLoopExtAndroid for EventLoop {
|
||||||
fn set_suspend_callback(&self, cb: Option<Box<Fn(bool) -> ()>>) {
|
fn set_suspend_callback(&self, cb: Option<Box<dyn Fn(bool) -> ()>>) {
|
||||||
self.event_loop.set_suspend_callback(cb);
|
self.event_loop.set_suspend_callback(cb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"
|
target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"
|
||||||
))]
|
))]
|
||||||
|
|
||||||
use event::Event;
|
use crate::event::Event;
|
||||||
use event_loop::{EventLoop, EventLoopWindowTarget, ControlFlow};
|
use crate::event_loop::{EventLoop, EventLoopWindowTarget, ControlFlow};
|
||||||
|
|
||||||
/// Additional methods on `EventLoop` that are specific to desktop platforms.
|
/// Additional methods on `EventLoop` that are specific to desktop platforms.
|
||||||
pub trait EventLoopExtDesktop {
|
pub trait EventLoopExtDesktop {
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
|
|
||||||
use event_loop::EventLoop;
|
use crate::event_loop::EventLoop;
|
||||||
use monitor::MonitorHandle;
|
use crate::monitor::MonitorHandle;
|
||||||
use window::{Window, WindowBuilder};
|
use crate::window::{Window, WindowBuilder};
|
||||||
|
|
||||||
/// Additional methods on `EventLoop` that are specific to iOS.
|
/// Additional methods on `EventLoop` that are specific to iOS.
|
||||||
pub trait EventLoopExtIOS {
|
pub trait EventLoopExtIOS {
|
||||||
|
|
|
@ -4,26 +4,26 @@ use std::os::raw;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use sctk::window::{ButtonState, Theme};
|
use smithay_client_toolkit::window::{ButtonState, Theme};
|
||||||
|
|
||||||
use dpi::LogicalSize;
|
use crate::dpi::LogicalSize;
|
||||||
use event_loop::EventLoop;
|
use crate::event_loop::EventLoop;
|
||||||
use monitor::MonitorHandle;
|
use crate::monitor::MonitorHandle;
|
||||||
use window::{Window, WindowBuilder};
|
use crate::window::{Window, WindowBuilder};
|
||||||
|
|
||||||
use platform_impl::{
|
use crate::platform_impl::{
|
||||||
EventLoop as LinuxEventLoop,
|
EventLoop as LinuxEventLoop,
|
||||||
Window as LinuxWindow,
|
Window as LinuxWindow,
|
||||||
};
|
};
|
||||||
use platform_impl::x11::XConnection;
|
use crate::platform_impl::x11::XConnection;
|
||||||
use platform_impl::x11::ffi::XVisualInfo;
|
use crate::platform_impl::x11::ffi::XVisualInfo;
|
||||||
|
|
||||||
// TODO: stupid hack so that glutin can do its work
|
// TODO: stupid hack so that glutin can do its work
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use platform_impl::x11;
|
pub use crate::platform_impl::x11;
|
||||||
|
|
||||||
pub use platform_impl::XNotSupported;
|
pub use crate::platform_impl::XNotSupported;
|
||||||
pub use platform_impl::x11::util::WindowType as XWindowType;
|
pub use crate::platform_impl::x11::util::WindowType as XWindowType;
|
||||||
|
|
||||||
/// Theme for wayland client side decorations
|
/// Theme for wayland client side decorations
|
||||||
///
|
///
|
||||||
|
|
|
@ -5,11 +5,11 @@ use std::os::raw::c_void;
|
||||||
use libc;
|
use libc;
|
||||||
use winapi::shared::windef::HWND;
|
use winapi::shared::windef::HWND;
|
||||||
|
|
||||||
use event::DeviceId;
|
use crate::event::DeviceId;
|
||||||
use monitor::MonitorHandle;
|
use crate::monitor::MonitorHandle;
|
||||||
use event_loop::EventLoop;
|
use crate::event_loop::EventLoop;
|
||||||
use window::{Icon, Window, WindowBuilder};
|
use crate::window::{Icon, Window, WindowBuilder};
|
||||||
use platform_impl::EventLoop as WindowsEventLoop;
|
use crate::platform_impl::EventLoop as WindowsEventLoop;
|
||||||
|
|
||||||
/// Additional methods on `EventLoop` that are specific to Windows.
|
/// Additional methods on `EventLoop` that are specific to Windows.
|
||||||
pub trait EventLoopExtWindows {
|
pub trait EventLoopExtWindows {
|
||||||
|
|
|
@ -11,27 +11,27 @@ use std::os::raw::c_void;
|
||||||
use std::sync::mpsc::{Receiver, channel};
|
use std::sync::mpsc::{Receiver, channel};
|
||||||
|
|
||||||
use {
|
use {
|
||||||
CreationError,
|
crate::CreationError,
|
||||||
Event,
|
crate::Event,
|
||||||
LogicalPosition,
|
crate::LogicalPosition,
|
||||||
LogicalSize,
|
crate::LogicalSize,
|
||||||
CursorIcon,
|
crate::CursorIcon,
|
||||||
PhysicalPosition,
|
crate::PhysicalPosition,
|
||||||
PhysicalSize,
|
crate::PhysicalSize,
|
||||||
WindowAttributes,
|
crate::WindowAttributes,
|
||||||
WindowEvent,
|
crate::WindowEvent,
|
||||||
WindowId as RootWindowId,
|
crate::WindowId as RootWindowId,
|
||||||
};
|
};
|
||||||
use CreationError::OsError;
|
use CreationError::OsError;
|
||||||
use error::{ExternalError, NotSupportedError};
|
use crate::error::{ExternalError, NotSupportedError};
|
||||||
use events::{Touch, TouchPhase};
|
use crate::events::{Touch, TouchPhase};
|
||||||
use window::MonitorHandle as RootMonitorHandle;
|
use crate::window::MonitorHandle as RootMonitorHandle;
|
||||||
|
|
||||||
pub type OsError = std::io::Error;
|
pub type OsError = std::io::Error;
|
||||||
|
|
||||||
pub struct EventLoop {
|
pub struct EventLoop {
|
||||||
event_rx: Receiver<android_glue::Event>,
|
event_rx: Receiver<android_glue::Event>,
|
||||||
suspend_callback: RefCell<Option<Box<Fn(bool) -> ()>>>,
|
suspend_callback: RefCell<Option<Box<dyn Fn(bool) -> ()>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -136,7 +136,7 @@ impl EventLoop {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_suspend_callback(&self, cb: Option<Box<Fn(bool) -> ()>>) {
|
pub fn set_suspend_callback(&self, cb: Option<Box<dyn Fn(bool) -> ()>>) {
|
||||||
*self.suspend_callback.borrow_mut() = cb;
|
*self.suspend_callback.borrow_mut() = cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ pub struct Window {
|
||||||
pub struct MonitorHandle;
|
pub struct MonitorHandle;
|
||||||
|
|
||||||
impl fmt::Debug 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)]
|
#[derive(Debug)]
|
||||||
struct MonitorHandle {
|
struct MonitorHandle {
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
|
|
|
@ -9,9 +9,9 @@ use std::os::raw::{c_char, c_void, c_double, c_ulong, c_int};
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::sync::{Mutex, Arc};
|
use std::sync::{Mutex, Arc};
|
||||||
|
|
||||||
use dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize};
|
use crate::dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize};
|
||||||
use error::{ExternalError, NotSupportedError};
|
use crate::error::{ExternalError, NotSupportedError};
|
||||||
use window::MonitorHandle as RootMonitorHandle;
|
use crate::window::MonitorHandle as RootMonitorHandle;
|
||||||
|
|
||||||
const DOCUMENT_NAME: &'static str = "#document\0";
|
const DOCUMENT_NAME: &'static str = "#document\0";
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@ use std::mem::ManuallyDrop;
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use event::{Event, StartCause};
|
use crate::event::{Event, StartCause};
|
||||||
use event_loop::ControlFlow;
|
use crate::event_loop::ControlFlow;
|
||||||
|
|
||||||
use platform_impl::platform::event_loop::{EventHandler, Never};
|
use crate::platform_impl::platform::event_loop::{EventHandler, Never};
|
||||||
use platform_impl::platform::ffi::{
|
use crate::platform_impl::platform::ffi::{
|
||||||
id,
|
id,
|
||||||
CFAbsoluteTimeGetCurrent,
|
CFAbsoluteTimeGetCurrent,
|
||||||
CFRelease,
|
CFRelease,
|
||||||
|
@ -39,10 +39,10 @@ enum AppStateImpl {
|
||||||
Launching {
|
Launching {
|
||||||
queued_windows: Vec<id>,
|
queued_windows: Vec<id>,
|
||||||
queued_events: Vec<Event<Never>>,
|
queued_events: Vec<Event<Never>>,
|
||||||
queued_event_handler: Box<EventHandler>,
|
queued_event_handler: Box<dyn EventHandler>,
|
||||||
},
|
},
|
||||||
ProcessingEvents {
|
ProcessingEvents {
|
||||||
event_handler: Box<EventHandler>,
|
event_handler: Box<dyn EventHandler>,
|
||||||
active_control_flow: ControlFlow,
|
active_control_flow: ControlFlow,
|
||||||
},
|
},
|
||||||
// special state to deal with reentrancy and prevent mutable aliasing.
|
// special state to deal with reentrancy and prevent mutable aliasing.
|
||||||
|
@ -50,11 +50,11 @@ enum AppStateImpl {
|
||||||
queued_events: Vec<Event<Never>>,
|
queued_events: Vec<Event<Never>>,
|
||||||
},
|
},
|
||||||
Waiting {
|
Waiting {
|
||||||
waiting_event_handler: Box<EventHandler>,
|
waiting_event_handler: Box<dyn EventHandler>,
|
||||||
start: Instant,
|
start: Instant,
|
||||||
},
|
},
|
||||||
PollFinished {
|
PollFinished {
|
||||||
waiting_event_handler: Box<EventHandler>,
|
waiting_event_handler: Box<dyn EventHandler>,
|
||||||
},
|
},
|
||||||
Terminated,
|
Terminated,
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ impl AppState {
|
||||||
}
|
}
|
||||||
|
|
||||||
// requires main thread
|
// requires main thread
|
||||||
pub unsafe fn will_launch(queued_event_handler: Box<EventHandler>) {
|
pub unsafe fn will_launch(queued_event_handler: Box<dyn EventHandler>) {
|
||||||
let mut this = AppState::get_mut();
|
let mut this = AppState::get_mut();
|
||||||
let (queued_windows, queued_events) = match &mut this.app_state {
|
let (queued_windows, queued_events) = match &mut this.app_state {
|
||||||
&mut AppStateImpl::NotLaunched {
|
&mut AppStateImpl::NotLaunched {
|
||||||
|
|
|
@ -5,16 +5,16 @@ use std::fmt::{self, Debug, Formatter};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::sync::mpsc::{self, Sender, Receiver};
|
use std::sync::mpsc::{self, Sender, Receiver};
|
||||||
|
|
||||||
use event::Event;
|
use crate::event::Event;
|
||||||
use event_loop::{
|
use crate::event_loop::{
|
||||||
ControlFlow,
|
ControlFlow,
|
||||||
EventLoopWindowTarget as RootEventLoopWindowTarget,
|
EventLoopWindowTarget as RootEventLoopWindowTarget,
|
||||||
EventLoopClosed,
|
EventLoopClosed,
|
||||||
};
|
};
|
||||||
use platform::ios::Idiom;
|
use crate::platform::ios::Idiom;
|
||||||
|
|
||||||
use platform_impl::platform::app_state::AppState;
|
use crate::platform_impl::platform::app_state::AppState;
|
||||||
use platform_impl::platform::ffi::{
|
use crate::platform_impl::platform::ffi::{
|
||||||
id,
|
id,
|
||||||
nil,
|
nil,
|
||||||
CFIndex,
|
CFIndex,
|
||||||
|
@ -42,9 +42,9 @@ use platform_impl::platform::ffi::{
|
||||||
UIApplicationMain,
|
UIApplicationMain,
|
||||||
UIUserInterfaceIdiom,
|
UIUserInterfaceIdiom,
|
||||||
};
|
};
|
||||||
use platform_impl::platform::monitor;
|
use crate::platform_impl::platform::monitor;
|
||||||
use platform_impl::platform::MonitorHandle;
|
use crate::platform_impl::platform::MonitorHandle;
|
||||||
use platform_impl::platform::view;
|
use crate::platform_impl::platform::view;
|
||||||
|
|
||||||
pub struct EventLoopWindowTarget<T: 'static> {
|
pub struct EventLoopWindowTarget<T: 'static> {
|
||||||
receiver: Receiver<T>,
|
receiver: Receiver<T>,
|
||||||
|
@ -281,7 +281,7 @@ struct EventLoopHandler<F, T: 'static> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F, T: 'static> Debug for EventLoopHandler<F, T> {
|
impl<F, T: 'static> Debug for EventLoopHandler<F, T> {
|
||||||
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
formatter.debug_struct("EventLoopHandler")
|
formatter.debug_struct("EventLoopHandler")
|
||||||
.field("event_loop", &self.event_loop)
|
.field("event_loop", &self.event_loop)
|
||||||
.finish()
|
.finish()
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::os::raw::*;
|
||||||
use objc::{Encode, Encoding};
|
use objc::{Encode, Encoding};
|
||||||
use objc::runtime::Object;
|
use objc::runtime::Object;
|
||||||
|
|
||||||
use platform::ios::{Idiom, ValidOrientations};
|
use crate::platform::ios::{Idiom, ValidOrientations};
|
||||||
|
|
||||||
pub type id = *mut Object;
|
pub type id = *mut Object;
|
||||||
pub const nil: id = 0 as id;
|
pub const nil: id = 0 as id;
|
||||||
|
|
|
@ -106,7 +106,7 @@ unsafe impl Sync for DeviceId {}
|
||||||
pub enum OsError {}
|
pub enum OsError {}
|
||||||
|
|
||||||
impl fmt::Display for OsError {
|
impl fmt::Display for OsError {
|
||||||
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
_ => unreachable!()
|
_ => unreachable!()
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,10 @@ use std::{
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
};
|
};
|
||||||
|
|
||||||
use dpi::{PhysicalPosition, PhysicalSize};
|
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
||||||
use monitor::VideoMode;
|
use crate::monitor::VideoMode;
|
||||||
|
|
||||||
use platform_impl::platform::ffi::{id, nil, CGFloat, CGRect, CGSize, NSInteger, NSUInteger};
|
use crate::platform_impl::platform::ffi::{id, nil, CGFloat, CGRect, CGSize, NSInteger, NSUInteger};
|
||||||
|
|
||||||
pub struct Inner {
|
pub struct Inner {
|
||||||
uiscreen: id,
|
uiscreen: id,
|
||||||
|
@ -63,7 +63,7 @@ impl Drop for MonitorHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug 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)]
|
#[derive(Debug)]
|
||||||
struct MonitorHandle {
|
struct MonitorHandle {
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
|
|
|
@ -3,20 +3,20 @@ use std::collections::HashMap;
|
||||||
use objc::declare::ClassDecl;
|
use objc::declare::ClassDecl;
|
||||||
use objc::runtime::{BOOL, Class, NO, Object, Sel, YES};
|
use objc::runtime::{BOOL, Class, NO, Object, Sel, YES};
|
||||||
|
|
||||||
use event::{
|
use crate::event::{
|
||||||
DeviceId as RootDeviceId,
|
DeviceId as RootDeviceId,
|
||||||
Event,
|
Event,
|
||||||
Touch,
|
Touch,
|
||||||
TouchPhase,
|
TouchPhase,
|
||||||
WindowEvent
|
WindowEvent
|
||||||
};
|
};
|
||||||
use platform::ios::MonitorHandleExtIOS;
|
use crate::platform::ios::MonitorHandleExtIOS;
|
||||||
use window::{WindowAttributes, WindowId as RootWindowId};
|
use crate::window::{WindowAttributes, WindowId as RootWindowId};
|
||||||
|
|
||||||
use platform_impl::platform::app_state::AppState;
|
use crate::platform_impl::platform::app_state::AppState;
|
||||||
use platform_impl::platform::DeviceId;
|
use crate::platform_impl::platform::DeviceId;
|
||||||
use platform_impl::platform::event_loop;
|
use crate::platform_impl::platform::event_loop;
|
||||||
use platform_impl::platform::ffi::{
|
use crate::platform_impl::platform::ffi::{
|
||||||
id,
|
id,
|
||||||
nil,
|
nil,
|
||||||
CGFloat,
|
CGFloat,
|
||||||
|
@ -25,7 +25,7 @@ use platform_impl::platform::ffi::{
|
||||||
UIInterfaceOrientationMask,
|
UIInterfaceOrientationMask,
|
||||||
UITouchPhase,
|
UITouchPhase,
|
||||||
};
|
};
|
||||||
use platform_impl::platform::window::{PlatformSpecificWindowBuilderAttributes};
|
use crate::platform_impl::platform::window::{PlatformSpecificWindowBuilderAttributes};
|
||||||
|
|
||||||
// requires main thread
|
// requires main thread
|
||||||
unsafe fn get_view_class(root_view_class: &'static Class) -> &'static Class {
|
unsafe fn get_view_class(root_view_class: &'static Class) -> &'static Class {
|
||||||
|
|
|
@ -5,16 +5,16 @@ use std::{
|
||||||
|
|
||||||
use objc::runtime::{Class, NO, Object, YES};
|
use objc::runtime::{Class, NO, Object, YES};
|
||||||
|
|
||||||
use dpi::{self, LogicalPosition, LogicalSize};
|
use crate::dpi::{self, LogicalPosition, LogicalSize};
|
||||||
use error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
use crate::error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
||||||
use icon::Icon;
|
use crate::icon::Icon;
|
||||||
use monitor::MonitorHandle as RootMonitorHandle;
|
use crate::monitor::MonitorHandle as RootMonitorHandle;
|
||||||
use platform::ios::{MonitorHandleExtIOS, ValidOrientations};
|
use crate::platform::ios::{MonitorHandleExtIOS, ValidOrientations};
|
||||||
use window::{
|
use crate::window::{
|
||||||
CursorIcon,
|
CursorIcon,
|
||||||
WindowAttributes,
|
WindowAttributes,
|
||||||
};
|
};
|
||||||
use platform_impl::{
|
use crate::platform_impl::{
|
||||||
platform::{
|
platform::{
|
||||||
app_state::AppState,
|
app_state::AppState,
|
||||||
event_loop,
|
event_loop,
|
||||||
|
|
|
@ -7,15 +7,15 @@ use std::os::raw::*;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use sctk::reexports::client::ConnectError;
|
use smithay_client_toolkit::reexports::client::ConnectError;
|
||||||
|
|
||||||
use dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize};
|
use crate::dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize};
|
||||||
use icon::Icon;
|
use crate::icon::Icon;
|
||||||
use error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
use crate::error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
||||||
use event::Event;
|
use crate::event::Event;
|
||||||
use event_loop::{EventLoopClosed, ControlFlow, EventLoopWindowTarget as RootELW};
|
use crate::event_loop::{EventLoopClosed, ControlFlow, EventLoopWindowTarget as RootELW};
|
||||||
use monitor::{MonitorHandle as RootMonitorHandle, VideoMode};
|
use crate::monitor::{MonitorHandle as RootMonitorHandle, VideoMode};
|
||||||
use window::{WindowAttributes, CursorIcon};
|
use crate::window::{WindowAttributes, CursorIcon};
|
||||||
use self::x11::{XConnection, XError};
|
use self::x11::{XConnection, XError};
|
||||||
use self::x11::ffi::XVisualInfo;
|
use self::x11::ffi::XVisualInfo;
|
||||||
pub use self::x11::XNotSupported;
|
pub use self::x11::XNotSupported;
|
||||||
|
@ -59,7 +59,7 @@ pub enum OsError {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for 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 {
|
match self {
|
||||||
OsError::XError(e) => formatter.pad(&e.description),
|
OsError::XError(e) => formatter.pad(&e.description),
|
||||||
OsError::XMisc(e) => formatter.pad(e),
|
OsError::XMisc(e) => formatter.pad(e),
|
||||||
|
@ -529,7 +529,7 @@ impl<T:'static> EventLoop<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_return<F>(&mut self, callback: F)
|
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 {
|
match *self {
|
||||||
EventLoop::Wayland(ref mut evlp) => evlp.run_return(callback),
|
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) -> !
|
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 {
|
match self {
|
||||||
EventLoop::Wayland(evlp) => evlp.run(callback),
|
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 {
|
match *self {
|
||||||
EventLoop::Wayland(ref evl) => evl.window_target(),
|
EventLoop::Wayland(ref evl) => evl.window_target(),
|
||||||
EventLoop::X(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::sync::{Arc, Mutex};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootELW};
|
use crate::event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootELW};
|
||||||
use event::ModifiersState;
|
use crate::event::ModifiersState;
|
||||||
use dpi::{PhysicalPosition, PhysicalSize};
|
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
||||||
use platform_impl::platform::sticky_exit_callback;
|
use crate::platform_impl::platform::sticky_exit_callback;
|
||||||
use monitor::VideoMode;
|
use crate::monitor::VideoMode;
|
||||||
|
|
||||||
use super::window::WindowStore;
|
use super::window::WindowStore;
|
||||||
use super::WindowId;
|
use super::WindowId;
|
||||||
|
|
||||||
use sctk::output::OutputMgr;
|
use smithay_client_toolkit::output::OutputMgr;
|
||||||
use sctk::reexports::client::protocol::{
|
use smithay_client_toolkit::reexports::client::protocol::{
|
||||||
wl_keyboard, wl_output, wl_pointer, wl_registry, wl_seat, wl_touch,
|
wl_keyboard, wl_output, wl_pointer, wl_registry, wl_seat, wl_touch,
|
||||||
};
|
};
|
||||||
use sctk::reexports::client::{ConnectError, Display, EventQueue, GlobalEvent};
|
use smithay_client_toolkit::reexports::client::{ConnectError, Display, EventQueue, GlobalEvent};
|
||||||
use sctk::Environment;
|
use smithay_client_toolkit::Environment;
|
||||||
|
|
||||||
pub struct WindowEventsSink {
|
pub struct WindowEventsSink {
|
||||||
buffer: VecDeque<(::event::WindowEvent, ::window::WindowId)>,
|
buffer: VecDeque<(crate::event::WindowEvent, crate::window::WindowId)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowEventsSink {
|
impl WindowEventsSink {
|
||||||
|
@ -32,16 +32,16 @@ impl WindowEventsSink {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_event(&mut self, evt: ::event::WindowEvent, wid: WindowId) {
|
pub fn send_event(&mut self, evt: crate::event::WindowEvent, wid: WindowId) {
|
||||||
self.buffer.push_back((evt, ::window::WindowId(::platform_impl::WindowId::Wayland(wid))));
|
self.buffer.push_back((evt, crate::window::WindowId(crate::platform_impl::WindowId::Wayland(wid))));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn empty_with<F, T>(&mut self, mut callback: F)
|
fn empty_with<F, T>(&mut self, mut callback: F)
|
||||||
where
|
where
|
||||||
F: FnMut(::event::Event<T>),
|
F: FnMut(crate::event::Event<T>),
|
||||||
{
|
{
|
||||||
for (evt, wid) in self.buffer.drain(..) {
|
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>>>,
|
pending_user_events: Rc<RefCell<VecDeque<T>>>,
|
||||||
_user_source: ::calloop::Source<::calloop::channel::Channel<T>>,
|
_user_source: ::calloop::Source<::calloop::channel::Channel<T>>,
|
||||||
user_sender: ::calloop::channel::Sender<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>
|
window_target: RootELW<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ impl<T: 'static> EventLoop<T> {
|
||||||
user_sender,
|
user_sender,
|
||||||
_kbd_source: kbd_source,
|
_kbd_source: kbd_source,
|
||||||
window_target: RootELW {
|
window_target: RootELW {
|
||||||
p: ::platform_impl::EventLoopWindowTarget::Wayland(EventLoopWindowTarget {
|
p: crate::platform_impl::EventLoopWindowTarget::Wayland(EventLoopWindowTarget {
|
||||||
evq: RefCell::new(source),
|
evq: RefCell::new(source),
|
||||||
store,
|
store,
|
||||||
env,
|
env,
|
||||||
|
@ -181,14 +181,14 @@ impl<T: 'static> EventLoop<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run<F>(mut self, callback: F) -> !
|
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);
|
self.run_return(callback);
|
||||||
::std::process::exit(0);
|
::std::process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_return<F>(&mut self, mut callback: F)
|
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
|
// send pending events to the server
|
||||||
self.display.flush().expect("Wayland connection lost.");
|
self.display.flush().expect("Wayland connection lost.");
|
||||||
|
@ -198,7 +198,7 @@ impl<T: 'static> EventLoop<T> {
|
||||||
let sink = self.sink.clone();
|
let sink = self.sink.clone();
|
||||||
let user_events = self.pending_user_events.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 {
|
loop {
|
||||||
self.post_dispatch_triggers();
|
self.post_dispatch_triggers();
|
||||||
|
@ -215,7 +215,7 @@ impl<T: 'static> EventLoop<T> {
|
||||||
let mut guard = user_events.borrow_mut();
|
let mut guard = user_events.borrow_mut();
|
||||||
for evt in guard.drain(..) {
|
for evt in guard.drain(..) {
|
||||||
sticky_exit_callback(
|
sticky_exit_callback(
|
||||||
::event::Event::UserEvent(evt),
|
crate::event::Event::UserEvent(evt),
|
||||||
&self.window_target,
|
&self.window_target,
|
||||||
&mut control_flow,
|
&mut control_flow,
|
||||||
&mut callback
|
&mut callback
|
||||||
|
@ -234,7 +234,7 @@ impl<T: 'static> EventLoop<T> {
|
||||||
// send Events cleared
|
// send Events cleared
|
||||||
{
|
{
|
||||||
sticky_exit_callback(
|
sticky_exit_callback(
|
||||||
::event::Event::EventsCleared,
|
crate::event::Event::EventsCleared,
|
||||||
&self.window_target,
|
&self.window_target,
|
||||||
&mut control_flow,
|
&mut control_flow,
|
||||||
&mut callback
|
&mut callback
|
||||||
|
@ -249,12 +249,12 @@ impl<T: 'static> EventLoop<T> {
|
||||||
ControlFlow::Poll => {
|
ControlFlow::Poll => {
|
||||||
// non-blocking dispatch
|
// non-blocking dispatch
|
||||||
self.inner_loop.dispatch(Some(::std::time::Duration::from_millis(0)), &mut ()).unwrap();
|
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 => {
|
ControlFlow::Wait => {
|
||||||
self.inner_loop.dispatch(None, &mut ()).unwrap();
|
self.inner_loop.dispatch(None, &mut ()).unwrap();
|
||||||
callback(
|
callback(
|
||||||
::event::Event::NewEvents(::event::StartCause::WaitCancelled {
|
crate::event::Event::NewEvents(crate::event::StartCause::WaitCancelled {
|
||||||
start: Instant::now(),
|
start: Instant::now(),
|
||||||
requested_resume: None
|
requested_resume: None
|
||||||
}),
|
}),
|
||||||
|
@ -274,7 +274,7 @@ impl<T: 'static> EventLoop<T> {
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
if now < deadline {
|
if now < deadline {
|
||||||
callback(
|
callback(
|
||||||
::event::Event::NewEvents(::event::StartCause::WaitCancelled {
|
crate::event::Event::NewEvents(crate::event::StartCause::WaitCancelled {
|
||||||
start,
|
start,
|
||||||
requested_resume: Some(deadline)
|
requested_resume: Some(deadline)
|
||||||
}),
|
}),
|
||||||
|
@ -283,7 +283,7 @@ impl<T: 'static> EventLoop<T> {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
callback(
|
callback(
|
||||||
::event::Event::NewEvents(::event::StartCause::ResumeTimeReached {
|
crate::event::Event::NewEvents(crate::event::StartCause::ResumeTimeReached {
|
||||||
start,
|
start,
|
||||||
requested_resume: deadline
|
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 {
|
pub fn primary_monitor(&self) -> MonitorHandle {
|
||||||
|
@ -323,7 +323,7 @@ impl<T> EventLoop<T> {
|
||||||
fn post_dispatch_triggers(&mut self) {
|
fn post_dispatch_triggers(&mut self) {
|
||||||
let mut sink = self.sink.lock().unwrap();
|
let mut sink = self.sink.lock().unwrap();
|
||||||
let window_target = match self.window_target.p {
|
let window_target = match self.window_target.p {
|
||||||
::platform_impl::EventLoopWindowTarget::Wayland(ref wt) => wt,
|
crate::platform_impl::EventLoopWindowTarget::Wayland(ref wt) => wt,
|
||||||
_ => unreachable!()
|
_ => unreachable!()
|
||||||
};
|
};
|
||||||
// prune possible dead windows
|
// prune possible dead windows
|
||||||
|
@ -333,7 +333,7 @@ impl<T> EventLoop<T> {
|
||||||
let pruned = window_target.store.lock().unwrap().cleanup();
|
let pruned = window_target.store.lock().unwrap().cleanup();
|
||||||
*cleanup_needed = false;
|
*cleanup_needed = false;
|
||||||
for wid in pruned {
|
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 {
|
if let Some((w, h)) = newsize {
|
||||||
frame.resize(w, h);
|
frame.resize(w, h);
|
||||||
frame.refresh();
|
frame.refresh();
|
||||||
let logical_size = ::dpi::LogicalSize::new(w as f64, h as f64);
|
let logical_size = crate::dpi::LogicalSize::new(w as f64, h as f64);
|
||||||
sink.send_event(::event::WindowEvent::Resized(logical_size), wid);
|
sink.send_event(crate::event::WindowEvent::Resized(logical_size), wid);
|
||||||
*size = (w, h);
|
*size = (w, h);
|
||||||
} else if frame_refresh {
|
} else if frame_refresh {
|
||||||
frame.refresh();
|
frame.refresh();
|
||||||
|
@ -355,13 +355,13 @@ impl<T> EventLoop<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(dpi) = new_dpi {
|
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 {
|
if refresh {
|
||||||
sink.send_event(::event::WindowEvent::RedrawRequested, wid);
|
sink.send_event(crate::event::WindowEvent::RedrawRequested, wid);
|
||||||
}
|
}
|
||||||
if closed {
|
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>>,
|
sink: Arc<Mutex<WindowEventsSink>>,
|
||||||
store: Arc<Mutex<WindowStore>>,
|
store: Arc<Mutex<WindowStore>>,
|
||||||
seats: Arc<Mutex<Vec<(u32, wl_seat::WlSeat)>>>,
|
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 {
|
impl SeatManager {
|
||||||
|
@ -417,7 +417,7 @@ impl SeatManager {
|
||||||
struct SeatData {
|
struct SeatData {
|
||||||
sink: Arc<Mutex<WindowEventsSink>>,
|
sink: Arc<Mutex<WindowEventsSink>>,
|
||||||
store: Arc<Mutex<WindowStore>>,
|
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>,
|
pointer: Option<wl_pointer::WlPointer>,
|
||||||
keyboard: Option<wl_keyboard::WlKeyboard>,
|
keyboard: Option<wl_keyboard::WlKeyboard>,
|
||||||
touch: Option<wl_touch::WlTouch>,
|
touch: Option<wl_touch::WlTouch>,
|
||||||
|
@ -523,7 +523,7 @@ impl Clone for MonitorHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug 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)]
|
#[derive(Debug)]
|
||||||
struct MonitorHandle {
|
struct MonitorHandle {
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use super::{make_wid, DeviceId};
|
use super::{make_wid, DeviceId};
|
||||||
use sctk::keyboard::{
|
use smithay_client_toolkit::keyboard::{
|
||||||
self, map_keyboard_auto_with_repeat, Event as KbEvent, KeyRepeatEvent, KeyRepeatKind,
|
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(
|
pub fn init_keyboard(
|
||||||
seat: &wl_seat::WlSeat,
|
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>>,
|
modifiers_tracker: Arc<Mutex<ModifiersState>>,
|
||||||
) -> wl_keyboard::WlKeyboard {
|
) -> wl_keyboard::WlKeyboard {
|
||||||
// { variables to be captured by the closures
|
// { variables to be captured by the closures
|
||||||
|
@ -23,7 +23,7 @@ pub fn init_keyboard(
|
||||||
let ret = map_keyboard_auto_with_repeat(
|
let ret = map_keyboard_auto_with_repeat(
|
||||||
seat,
|
seat,
|
||||||
KeyRepeatKind::System,
|
KeyRepeatKind::System,
|
||||||
move |evt: KbEvent, _| match evt {
|
move |evt: KbEvent<'_>, _| match evt {
|
||||||
KbEvent::Enter { surface, .. } => {
|
KbEvent::Enter { surface, .. } => {
|
||||||
let wid = make_wid(&surface);
|
let wid = make_wid(&surface);
|
||||||
my_sink.send((WindowEvent::Focused(true), wid)).unwrap();
|
my_sink.send((WindowEvent::Focused(true), wid)).unwrap();
|
||||||
|
@ -50,7 +50,7 @@ pub fn init_keyboard(
|
||||||
let vkcode = key_to_vkey(rawkey, keysym);
|
let vkcode = key_to_vkey(rawkey, keysym);
|
||||||
my_sink.send(
|
my_sink.send(
|
||||||
(WindowEvent::KeyboardInput {
|
(WindowEvent::KeyboardInput {
|
||||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||||
input: KeyboardInput {
|
input: KeyboardInput {
|
||||||
state: state,
|
state: state,
|
||||||
scancode: rawkey,
|
scancode: rawkey,
|
||||||
|
@ -82,7 +82,7 @@ pub fn init_keyboard(
|
||||||
let vkcode = key_to_vkey(repeat_event.rawkey, repeat_event.keysym);
|
let vkcode = key_to_vkey(repeat_event.rawkey, repeat_event.keysym);
|
||||||
repeat_sink.send((
|
repeat_sink.send((
|
||||||
WindowEvent::KeyboardInput {
|
WindowEvent::KeyboardInput {
|
||||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||||
input: KeyboardInput {
|
input: KeyboardInput {
|
||||||
state: state,
|
state: state,
|
||||||
scancode: repeat_event.rawkey,
|
scancode: repeat_event.rawkey,
|
||||||
|
@ -136,7 +136,7 @@ pub fn init_keyboard(
|
||||||
};
|
};
|
||||||
my_sink.send((
|
my_sink.send((
|
||||||
WindowEvent::KeyboardInput {
|
WindowEvent::KeyboardInput {
|
||||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||||
input: KeyboardInput {
|
input: KeyboardInput {
|
||||||
state: state,
|
state: state,
|
||||||
scancode: key,
|
scancode: key,
|
||||||
|
@ -173,7 +173,7 @@ fn key_to_vkey(rawkey: u32, keysym: u32) -> Option<VirtualKeyCode> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn keysym_to_vkey(keysym: u32) -> Option<VirtualKeyCode> {
|
fn keysym_to_vkey(keysym: u32) -> Option<VirtualKeyCode> {
|
||||||
use sctk::keyboard::keysyms;
|
use smithay_client_toolkit::keyboard::keysyms;
|
||||||
match keysym {
|
match keysym {
|
||||||
// letters
|
// letters
|
||||||
keysyms::XKB_KEY_A | keysyms::XKB_KEY_a => Some(VirtualKeyCode::A),
|
keysyms::XKB_KEY_A | keysyms::XKB_KEY_a => Some(VirtualKeyCode::A),
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
pub use self::window::Window;
|
pub use self::window::Window;
|
||||||
pub use self::event_loop::{EventLoop, EventLoopWindowTarget, EventLoopProxy, WindowEventsSink, MonitorHandle};
|
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 event_loop;
|
||||||
mod pointer;
|
mod pointer;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
use std::sync::{Arc, Mutex};
|
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::DeviceId;
|
||||||
use super::event_loop::WindowEventsSink;
|
use super::event_loop::WindowEventsSink;
|
||||||
use super::window::WindowStore;
|
use super::window::WindowStore;
|
||||||
|
|
||||||
use sctk::reexports::client::protocol::wl_pointer::{self, Event as PtrEvent, WlPointer};
|
use smithay_client_toolkit::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_seat;
|
||||||
|
|
||||||
pub fn implement_pointer(
|
pub fn implement_pointer(
|
||||||
seat: &wl_seat::WlSeat,
|
seat: &wl_seat::WlSeat,
|
||||||
|
@ -36,13 +36,13 @@ pub fn implement_pointer(
|
||||||
mouse_focus = Some(wid);
|
mouse_focus = Some(wid);
|
||||||
sink.send_event(
|
sink.send_event(
|
||||||
WindowEvent::CursorEntered {
|
WindowEvent::CursorEntered {
|
||||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||||
},
|
},
|
||||||
wid,
|
wid,
|
||||||
);
|
);
|
||||||
sink.send_event(
|
sink.send_event(
|
||||||
WindowEvent::CursorMoved {
|
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(),
|
position: (surface_x, surface_y).into(),
|
||||||
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||||
},
|
},
|
||||||
|
@ -56,7 +56,7 @@ pub fn implement_pointer(
|
||||||
if let Some(wid) = wid {
|
if let Some(wid) = wid {
|
||||||
sink.send_event(
|
sink.send_event(
|
||||||
WindowEvent::CursorLeft {
|
WindowEvent::CursorLeft {
|
||||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||||
},
|
},
|
||||||
wid,
|
wid,
|
||||||
);
|
);
|
||||||
|
@ -70,7 +70,7 @@ pub fn implement_pointer(
|
||||||
if let Some(wid) = mouse_focus {
|
if let Some(wid) = mouse_focus {
|
||||||
sink.send_event(
|
sink.send_event(
|
||||||
WindowEvent::CursorMoved {
|
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(),
|
position: (surface_x, surface_y).into(),
|
||||||
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||||
},
|
},
|
||||||
|
@ -94,7 +94,7 @@ pub fn implement_pointer(
|
||||||
};
|
};
|
||||||
sink.send_event(
|
sink.send_event(
|
||||||
WindowEvent::MouseInput {
|
WindowEvent::MouseInput {
|
||||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||||
state: state,
|
state: state,
|
||||||
button: button,
|
button: button,
|
||||||
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||||
|
@ -116,7 +116,7 @@ pub fn implement_pointer(
|
||||||
}
|
}
|
||||||
sink.send_event(
|
sink.send_event(
|
||||||
WindowEvent::MouseWheel {
|
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()),
|
delta: MouseScrollDelta::PixelDelta((x as f64, y as f64).into()),
|
||||||
phase: TouchPhase::Moved,
|
phase: TouchPhase::Moved,
|
||||||
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||||
|
@ -146,7 +146,7 @@ pub fn implement_pointer(
|
||||||
if let Some((x, y)) = axis_discrete_buffer {
|
if let Some((x, y)) = axis_discrete_buffer {
|
||||||
sink.send_event(
|
sink.send_event(
|
||||||
WindowEvent::MouseWheel {
|
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),
|
delta: MouseScrollDelta::LineDelta(x as f32, y as f32),
|
||||||
phase: axis_state,
|
phase: axis_state,
|
||||||
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||||
|
@ -156,7 +156,7 @@ pub fn implement_pointer(
|
||||||
} else if let Some((x, y)) = axis_buffer {
|
} else if let Some((x, y)) = axis_buffer {
|
||||||
sink.send_event(
|
sink.send_event(
|
||||||
WindowEvent::MouseWheel {
|
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()),
|
delta: MouseScrollDelta::PixelDelta((x as f64, y as f64).into()),
|
||||||
phase: axis_state,
|
phase: axis_state,
|
||||||
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
modifiers: modifiers_tracker.lock().unwrap().clone(),
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use event::{TouchPhase, WindowEvent};
|
use crate::event::{TouchPhase, WindowEvent};
|
||||||
|
|
||||||
use super::{DeviceId, WindowId};
|
use super::{DeviceId, WindowId};
|
||||||
use super::event_loop::WindowEventsSink;
|
use super::event_loop::WindowEventsSink;
|
||||||
use super::window::WindowStore;
|
use super::window::WindowStore;
|
||||||
|
|
||||||
use sctk::reexports::client::protocol::wl_touch::{Event as TouchEvent, WlTouch};
|
use smithay_client_toolkit::reexports::client::protocol::wl_touch::{Event as TouchEvent, WlTouch};
|
||||||
use sctk::reexports::client::protocol::wl_seat;
|
use smithay_client_toolkit::reexports::client::protocol::wl_seat;
|
||||||
|
|
||||||
struct TouchPoint {
|
struct TouchPoint {
|
||||||
wid: WindowId,
|
wid: WindowId,
|
||||||
|
@ -32,8 +32,8 @@ pub(crate) fn implement_touch(
|
||||||
let wid = store.find_wid(&surface);
|
let wid = store.find_wid(&surface);
|
||||||
if let Some(wid) = wid {
|
if let Some(wid) = wid {
|
||||||
sink.send_event(
|
sink.send_event(
|
||||||
WindowEvent::Touch(::event::Touch {
|
WindowEvent::Touch(crate::event::Touch {
|
||||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||||
phase: TouchPhase::Started,
|
phase: TouchPhase::Started,
|
||||||
location: (x, y).into(),
|
location: (x, y).into(),
|
||||||
id: id as u64,
|
id: id as u64,
|
||||||
|
@ -52,8 +52,8 @@ pub(crate) fn implement_touch(
|
||||||
if let Some(idx) = idx {
|
if let Some(idx) = idx {
|
||||||
let pt = pending_ids.remove(idx);
|
let pt = pending_ids.remove(idx);
|
||||||
sink.send_event(
|
sink.send_event(
|
||||||
WindowEvent::Touch(::event::Touch {
|
WindowEvent::Touch(crate::event::Touch {
|
||||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||||
phase: TouchPhase::Ended,
|
phase: TouchPhase::Ended,
|
||||||
location: pt.location.into(),
|
location: pt.location.into(),
|
||||||
id: id as u64,
|
id: id as u64,
|
||||||
|
@ -67,8 +67,8 @@ pub(crate) fn implement_touch(
|
||||||
if let Some(pt) = pt {
|
if let Some(pt) = pt {
|
||||||
pt.location = (x, y);
|
pt.location = (x, y);
|
||||||
sink.send_event(
|
sink.send_event(
|
||||||
WindowEvent::Touch(::event::Touch {
|
WindowEvent::Touch(crate::event::Touch {
|
||||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||||
phase: TouchPhase::Moved,
|
phase: TouchPhase::Moved,
|
||||||
location: (x, y).into(),
|
location: (x, y).into(),
|
||||||
id: id as u64,
|
id: id as u64,
|
||||||
|
@ -80,8 +80,8 @@ pub(crate) fn implement_touch(
|
||||||
TouchEvent::Frame => (),
|
TouchEvent::Frame => (),
|
||||||
TouchEvent::Cancel => for pt in pending_ids.drain(..) {
|
TouchEvent::Cancel => for pt in pending_ids.drain(..) {
|
||||||
sink.send_event(
|
sink.send_event(
|
||||||
WindowEvent::Touch(::event::Touch {
|
WindowEvent::Touch(crate::event::Touch {
|
||||||
device_id: ::event::DeviceId(::platform_impl::DeviceId::Wayland(DeviceId)),
|
device_id: crate::event::DeviceId(crate::platform_impl::DeviceId::Wayland(DeviceId)),
|
||||||
phase: TouchPhase::Cancelled,
|
phase: TouchPhase::Cancelled,
|
||||||
location: pt.location.into(),
|
location: pt.location.into(),
|
||||||
id: pt.id as u64,
|
id: pt.id as u64,
|
||||||
|
|
|
@ -2,20 +2,20 @@ use std::collections::VecDeque;
|
||||||
use std::io::{Seek, SeekFrom, Write};
|
use std::io::{Seek, SeekFrom, Write};
|
||||||
use std::sync::{Arc, Mutex, Weak};
|
use std::sync::{Arc, Mutex, Weak};
|
||||||
|
|
||||||
use dpi::{LogicalPosition, LogicalSize};
|
use crate::dpi::{LogicalPosition, LogicalSize};
|
||||||
use error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
use crate::error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
||||||
use platform_impl::{MonitorHandle as PlatformMonitorHandle, PlatformSpecificWindowBuilderAttributes as PlAttributes};
|
use crate::platform_impl::{MonitorHandle as PlatformMonitorHandle, PlatformSpecificWindowBuilderAttributes as PlAttributes};
|
||||||
use monitor::MonitorHandle as RootMonitorHandle;
|
use crate::monitor::MonitorHandle as RootMonitorHandle;
|
||||||
use window::{WindowAttributes, CursorIcon};
|
use crate::window::{WindowAttributes, CursorIcon};
|
||||||
|
|
||||||
use sctk::surface::{get_dpi_factor, get_outputs};
|
use smithay_client_toolkit::surface::{get_dpi_factor, get_outputs};
|
||||||
use sctk::window::{ConceptFrame, Event as WEvent, State as WState, Window as SWindow, Theme};
|
use smithay_client_toolkit::window::{ConceptFrame, Event as WEvent, State as WState, Window as SWindow, Theme};
|
||||||
use sctk::reexports::client::{Display, NewProxy};
|
use smithay_client_toolkit::reexports::client::{Display, NewProxy};
|
||||||
use sctk::reexports::client::protocol::{wl_seat, wl_surface, wl_subsurface, wl_shm};
|
use smithay_client_toolkit::reexports::client::protocol::{wl_seat, wl_surface, wl_subsurface, wl_shm};
|
||||||
use sctk::output::OutputMgr;
|
use smithay_client_toolkit::output::OutputMgr;
|
||||||
|
|
||||||
use super::{make_wid, EventLoopWindowTarget, MonitorHandle, WindowId};
|
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 {
|
pub struct Window {
|
||||||
_bg_surface: wl_surface::WlSurface,
|
_bg_surface: wl_surface::WlSurface,
|
||||||
|
@ -60,7 +60,7 @@ impl Window {
|
||||||
let my_bg_surface = bg_surface.clone();
|
let my_bg_surface = bg_surface.clone();
|
||||||
|
|
||||||
// prepare a 1px buffer to display on the root window
|
// 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.resize(4).unwrap();
|
||||||
pool.seek(SeekFrom::Start(0)).unwrap();
|
pool.seek(SeekFrom::Start(0)).unwrap();
|
||||||
pool.write(&[0, 0, 0, 0]).unwrap();
|
pool.write(&[0, 0, 0, 0]).unwrap();
|
||||||
|
|
|
@ -12,9 +12,9 @@ use super::{
|
||||||
events, util, DndState, Dnd, DeviceInfo
|
events, util, DndState, Dnd, DeviceInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
use event_loop::EventLoopWindowTarget as RootELW;
|
use crate::event_loop::EventLoopWindowTarget as RootELW;
|
||||||
use event::{DeviceEvent, Event, KeyboardInput, ModifiersState, WindowEvent};
|
use crate::event::{DeviceEvent, Event, KeyboardInput, ModifiersState, WindowEvent};
|
||||||
use dpi::{LogicalPosition,LogicalSize};
|
use crate::dpi::{LogicalPosition,LogicalSize};
|
||||||
|
|
||||||
pub(super) struct EventProcessor<T: 'static> {
|
pub(super) struct EventProcessor<T: 'static> {
|
||||||
pub(super) dnd: Dnd,
|
pub(super) dnd: Dnd,
|
||||||
|
@ -440,7 +440,7 @@ impl<T: 'static> EventProcessor<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
ffi::KeyPress | ffi::KeyRelease => {
|
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.
|
// Note that in compose/pre-edit sequences, this will always be Released.
|
||||||
let state = if xev.get_type() == ffi::KeyPress {
|
let state = if xev.get_type() == ffi::KeyPress {
|
||||||
|
@ -521,11 +521,11 @@ impl<T: 'static> EventProcessor<T> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
use event::WindowEvent::{Focused, CursorEntered, MouseInput, CursorLeft, CursorMoved, MouseWheel, AxisMotion};
|
use crate::event::WindowEvent::{Focused, CursorEntered, MouseInput, CursorLeft, CursorMoved, MouseWheel, AxisMotion};
|
||||||
use event::ElementState::{Pressed, Released};
|
use crate::event::ElementState::{Pressed, Released};
|
||||||
use event::MouseButton::{Left, Right, Middle, Other};
|
use crate::event::MouseButton::{Left, Right, Middle, Other};
|
||||||
use event::MouseScrollDelta::LineDelta;
|
use crate::event::MouseScrollDelta::LineDelta;
|
||||||
use event::{Touch, TouchPhase};
|
use crate::event::{Touch, TouchPhase};
|
||||||
|
|
||||||
match xev.evtype {
|
match xev.evtype {
|
||||||
ffi::XI_ButtonPress | ffi::XI_ButtonRelease => {
|
ffi::XI_ButtonPress | ffi::XI_ButtonRelease => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use libc;
|
use libc;
|
||||||
use super::ffi;
|
use super::ffi;
|
||||||
use event::VirtualKeyCode;
|
use crate::event::VirtualKeyCode;
|
||||||
|
|
||||||
pub fn keysym_to_element(keysym: libc::c_uint) -> Option<VirtualKeyCode> {
|
pub fn keysym_to_element(keysym: libc::c_uint) -> Option<VirtualKeyCode> {
|
||||||
Some(match keysym {
|
Some(match keysym {
|
||||||
|
|
|
@ -152,7 +152,7 @@ impl InputMethodName {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for 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)
|
self.string.fmt(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ impl PotentialInputMethods {
|
||||||
pub fn open_im(
|
pub fn open_im(
|
||||||
&mut self,
|
&mut self,
|
||||||
xconn: &Arc<XConnection>,
|
xconn: &Arc<XConnection>,
|
||||||
callback: Option<&Fn() -> ()>,
|
callback: Option<&dyn Fn() -> ()>,
|
||||||
) -> InputMethodResult {
|
) -> InputMethodResult {
|
||||||
use self::InputMethodResult::*;
|
use self::InputMethodResult::*;
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,12 @@ use std::sync::{Arc, mpsc, Weak, Mutex};
|
||||||
|
|
||||||
use libc::{self, setlocale, LC_CTYPE};
|
use libc::{self, setlocale, LC_CTYPE};
|
||||||
|
|
||||||
use error::OsError as RootOsError;
|
use crate::error::OsError as RootOsError;
|
||||||
use event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootELW};
|
use crate::event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootELW};
|
||||||
use event::{WindowEvent, Event};
|
use crate::event::{WindowEvent, Event};
|
||||||
use platform_impl::PlatformSpecificWindowBuilderAttributes;
|
use crate::platform_impl::PlatformSpecificWindowBuilderAttributes;
|
||||||
use platform_impl::platform::sticky_exit_callback;
|
use crate::platform_impl::platform::sticky_exit_callback;
|
||||||
use window::{WindowAttributes};
|
use crate::window::{WindowAttributes};
|
||||||
use self::dnd::{Dnd, DndState};
|
use self::dnd::{Dnd, DndState};
|
||||||
use self::ime::{ImeReceiver, ImeSender, ImeCreationError, Ime};
|
use self::ime::{ImeReceiver, ImeSender, ImeCreationError, Ime};
|
||||||
use self::event_processor::EventProcessor;
|
use self::event_processor::EventProcessor;
|
||||||
|
@ -243,7 +243,7 @@ impl<T: 'static> EventLoop<T> {
|
||||||
let mut guard = self.pending_user_events.borrow_mut();
|
let mut guard = self.pending_user_events.borrow_mut();
|
||||||
for evt in guard.drain(..) {
|
for evt in guard.drain(..) {
|
||||||
sticky_exit_callback(
|
sticky_exit_callback(
|
||||||
::event::Event::UserEvent(evt),
|
crate::event::Event::UserEvent(evt),
|
||||||
&self.target,
|
&self.target,
|
||||||
&mut control_flow,
|
&mut control_flow,
|
||||||
&mut callback
|
&mut callback
|
||||||
|
@ -256,7 +256,7 @@ impl<T: 'static> EventLoop<T> {
|
||||||
for wid in guard.drain() {
|
for wid in guard.drain() {
|
||||||
sticky_exit_callback(
|
sticky_exit_callback(
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
window_id: ::window::WindowId(super::WindowId::X(wid)),
|
window_id: crate::window::WindowId(super::WindowId::X(wid)),
|
||||||
event: WindowEvent::RedrawRequested
|
event: WindowEvent::RedrawRequested
|
||||||
},
|
},
|
||||||
&self.target,
|
&self.target,
|
||||||
|
@ -268,7 +268,7 @@ impl<T: 'static> EventLoop<T> {
|
||||||
// send Events cleared
|
// send Events cleared
|
||||||
{
|
{
|
||||||
sticky_exit_callback(
|
sticky_exit_callback(
|
||||||
::event::Event::EventsCleared,
|
crate::event::Event::EventsCleared,
|
||||||
&self.target,
|
&self.target,
|
||||||
&mut control_flow,
|
&mut control_flow,
|
||||||
&mut callback
|
&mut callback
|
||||||
|
@ -283,12 +283,12 @@ impl<T: 'static> EventLoop<T> {
|
||||||
ControlFlow::Poll => {
|
ControlFlow::Poll => {
|
||||||
// non-blocking dispatch
|
// non-blocking dispatch
|
||||||
self.inner_loop.dispatch(Some(::std::time::Duration::from_millis(0)), &mut ()).unwrap();
|
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 => {
|
ControlFlow::Wait => {
|
||||||
self.inner_loop.dispatch(None, &mut ()).unwrap();
|
self.inner_loop.dispatch(None, &mut ()).unwrap();
|
||||||
callback(
|
callback(
|
||||||
::event::Event::NewEvents(::event::StartCause::WaitCancelled {
|
crate::event::Event::NewEvents(crate::event::StartCause::WaitCancelled {
|
||||||
start: ::std::time::Instant::now(),
|
start: ::std::time::Instant::now(),
|
||||||
requested_resume: None
|
requested_resume: None
|
||||||
}),
|
}),
|
||||||
|
@ -308,7 +308,7 @@ impl<T: 'static> EventLoop<T> {
|
||||||
let now = std::time::Instant::now();
|
let now = std::time::Instant::now();
|
||||||
if now < deadline {
|
if now < deadline {
|
||||||
callback(
|
callback(
|
||||||
::event::Event::NewEvents(::event::StartCause::WaitCancelled {
|
crate::event::Event::NewEvents(crate::event::StartCause::WaitCancelled {
|
||||||
start,
|
start,
|
||||||
requested_resume: Some(deadline)
|
requested_resume: Some(deadline)
|
||||||
}),
|
}),
|
||||||
|
@ -317,7 +317,7 @@ impl<T: 'static> EventLoop<T> {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
callback(
|
callback(
|
||||||
::event::Event::NewEvents(::event::StartCause::ResumeTimeReached {
|
crate::event::Event::NewEvents(crate::event::StartCause::ResumeTimeReached {
|
||||||
start,
|
start,
|
||||||
requested_resume: deadline
|
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) -> !
|
pub fn run<F>(mut self, callback: F) -> !
|
||||||
|
@ -485,8 +485,8 @@ struct XExtension {
|
||||||
first_error_id: c_int,
|
first_error_id: c_int,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mkwid(w: ffi::Window) -> ::window::WindowId { ::window::WindowId(::platform_impl::WindowId::X(WindowId(w))) }
|
fn mkwid(w: ffi::Window) -> crate::window::WindowId { crate::window::WindowId(crate::platform_impl::WindowId::X(WindowId(w))) }
|
||||||
fn mkdid(w: c_int) -> ::event::DeviceId { ::event::DeviceId(::platform_impl::DeviceId::X(DeviceId(w))) }
|
fn mkdid(w: c_int) -> crate::event::DeviceId { crate::event::DeviceId(crate::platform_impl::DeviceId::X(DeviceId(w))) }
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Device {
|
struct Device {
|
||||||
|
|
|
@ -2,8 +2,8 @@ use std::os::raw::*;
|
||||||
|
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
|
||||||
use dpi::{PhysicalPosition, PhysicalSize};
|
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
||||||
use monitor::VideoMode;
|
use crate::monitor::VideoMode;
|
||||||
use super::{util, XConnection, XError};
|
use super::{util, XConnection, XError};
|
||||||
use super::ffi::{
|
use super::ffi::{
|
||||||
RRCrtcChangeNotifyMask,
|
RRCrtcChangeNotifyMask,
|
||||||
|
|
|
@ -8,7 +8,7 @@ impl XConnection {
|
||||||
target_window: c_ulong,
|
target_window: c_ulong,
|
||||||
event_mask: Option<c_long>,
|
event_mask: Option<c_long>,
|
||||||
event: T,
|
event: T,
|
||||||
) -> Flusher {
|
) -> Flusher<'_> {
|
||||||
let event_mask = event_mask.unwrap_or(ffi::NoEventMask);
|
let event_mask = event_mask.unwrap_or(ffi::NoEventMask);
|
||||||
unsafe {
|
unsafe {
|
||||||
(self.xlib.XSendEvent)(
|
(self.xlib.XSendEvent)(
|
||||||
|
@ -29,7 +29,7 @@ impl XConnection {
|
||||||
message_type: ffi::Atom,
|
message_type: ffi::Atom,
|
||||||
event_mask: Option<c_long>,
|
event_mask: Option<c_long>,
|
||||||
data: ClientMsgPayload,
|
data: ClientMsgPayload,
|
||||||
) -> Flusher {
|
) -> Flusher<'_> {
|
||||||
let mut event: ffi::XClientMessageEvent = unsafe { mem::uninitialized() };
|
let mut event: ffi::XClientMessageEvent = unsafe { mem::uninitialized() };
|
||||||
event.type_ = ffi::ClientMessage;
|
event.type_ = ffi::ClientMessage;
|
||||||
event.display = self.display;
|
event.display = self.display;
|
||||||
|
@ -50,7 +50,7 @@ impl XConnection {
|
||||||
message_type: ffi::Atom,
|
message_type: ffi::Atom,
|
||||||
event_mask: Option<c_long>,
|
event_mask: Option<c_long>,
|
||||||
data: &[T],
|
data: &[T],
|
||||||
) -> Flusher {
|
) -> Flusher<'_> {
|
||||||
let format = T::FORMAT;
|
let format = T::FORMAT;
|
||||||
let size_of_t = mem::size_of::<T>();
|
let size_of_t = mem::size_of::<T>();
|
||||||
debug_assert_eq!(size_of_t, format.get_actual_size());
|
debug_assert_eq!(size_of_t, format.get_actual_size());
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use dpi::{LogicalPosition, LogicalSize};
|
use crate::dpi::{LogicalPosition, LogicalSize};
|
||||||
|
|
||||||
// Friendly neighborhood axis-aligned rectangle
|
// Friendly neighborhood axis-aligned rectangle
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
|
|
@ -187,7 +187,7 @@ impl<'a> NormalHints<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XConnection {
|
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) };
|
let wm_hints = unsafe { (self.xlib.XGetWMHints)(self.display, window) };
|
||||||
self.check_errors()?;
|
self.check_errors()?;
|
||||||
let wm_hints = if wm_hints.is_null() {
|
let wm_hints = if wm_hints.is_null() {
|
||||||
|
@ -198,7 +198,7 @@ impl XConnection {
|
||||||
Ok(wm_hints)
|
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 {
|
unsafe {
|
||||||
(self.xlib.XSetWMHints)(
|
(self.xlib.XSetWMHints)(
|
||||||
self.display,
|
self.display,
|
||||||
|
@ -209,7 +209,7 @@ impl XConnection {
|
||||||
Flusher::new(self)
|
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 size_hints = self.alloc_size_hints();
|
||||||
let mut supplied_by_user: c_long = unsafe { mem::uninitialized() };
|
let mut supplied_by_user: c_long = unsafe { mem::uninitialized() };
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -223,7 +223,7 @@ impl XConnection {
|
||||||
self.check_errors().map(|_| NormalHints { size_hints })
|
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 {
|
unsafe {
|
||||||
(self.xlib.XSetWMNormalHints)(
|
(self.xlib.XSetWMNormalHints)(
|
||||||
self.display,
|
self.display,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use window::{Icon, Pixel, PIXEL_SIZE};
|
use crate::window::{Icon, Pixel, PIXEL_SIZE};
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
impl Pixel {
|
impl Pixel {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use event::ModifiersState;
|
use crate::event::ModifiersState;
|
||||||
|
|
||||||
pub const VIRTUAL_CORE_POINTER: c_int = 2;
|
pub const VIRTUAL_CORE_POINTER: c_int = 2;
|
||||||
pub const VIRTUAL_CORE_KEYBOARD: c_int = 3;
|
pub const VIRTUAL_CORE_KEYBOARD: c_int = 3;
|
||||||
|
@ -55,7 +55,7 @@ impl<'a> Drop for PointerState<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XConnection {
|
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 {
|
let mut event_mask = ffi::XIEventMask {
|
||||||
deviceid: device_id,
|
deviceid: device_id,
|
||||||
mask: &mask as *const _ as *mut c_uchar,
|
mask: &mask as *const _ as *mut c_uchar,
|
||||||
|
@ -73,7 +73,7 @@ impl XConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[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 {
|
let status = unsafe {
|
||||||
(self.xlib.XkbSelectEvents)(
|
(self.xlib.XkbSelectEvents)(
|
||||||
self.display,
|
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 {
|
unsafe {
|
||||||
let mut pointer_state: PointerState = mem::uninitialized();
|
let mut pointer_state: PointerState<'_> = mem::uninitialized();
|
||||||
pointer_state.xconn = self;
|
pointer_state.xconn = self;
|
||||||
pointer_state.relative_to_window = (self.xinput2.XIQueryPointer)(
|
pointer_state.relative_to_window = (self.xinput2.XIQueryPointer)(
|
||||||
self.display,
|
self.display,
|
||||||
|
|
|
@ -45,17 +45,17 @@ impl<'a, T> Drop for XSmartPointer<'a, T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XConnection {
|
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)() })
|
XSmartPointer::new(self, unsafe { (self.xlib.XAllocClassHint)() })
|
||||||
.expect("`XAllocClassHint` returned null; out of memory")
|
.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)() })
|
XSmartPointer::new(self, unsafe { (self.xlib.XAllocSizeHints)() })
|
||||||
.expect("`XAllocSizeHints` returned null; out of memory")
|
.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)() })
|
XSmartPointer::new(self, unsafe { (self.xlib.XAllocWMHints)() })
|
||||||
.expect("`XAllocWMHints` returned null; out of memory")
|
.expect("`XAllocWMHints` returned null; out of memory")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use std::{env, slice};
|
use std::{env, slice};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use monitor::VideoMode;
|
use crate::monitor::VideoMode;
|
||||||
use dpi::validate_hidpi_factor;
|
use crate::dpi::validate_hidpi_factor;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
pub fn calc_dpi_factor(
|
pub fn calc_dpi_factor(
|
||||||
|
|
|
@ -8,14 +8,14 @@ use std::sync::Arc;
|
||||||
use libc;
|
use libc;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
|
||||||
use error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
use crate::error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
||||||
use window::{Icon, CursorIcon, WindowAttributes};
|
use crate::window::{Icon, CursorIcon, WindowAttributes};
|
||||||
use dpi::{LogicalPosition, LogicalSize};
|
use crate::dpi::{LogicalPosition, LogicalSize};
|
||||||
use platform_impl::MonitorHandle as PlatformMonitorHandle;
|
use crate::platform_impl::MonitorHandle as PlatformMonitorHandle;
|
||||||
use platform_impl::{OsError, PlatformSpecificWindowBuilderAttributes};
|
use crate::platform_impl::{OsError, PlatformSpecificWindowBuilderAttributes};
|
||||||
use platform_impl::x11::ime::ImeContextCreationError;
|
use crate::platform_impl::x11::ime::ImeContextCreationError;
|
||||||
use platform_impl::x11::MonitorHandle as X11MonitorHandle;
|
use crate::platform_impl::x11::MonitorHandle as X11MonitorHandle;
|
||||||
use monitor::MonitorHandle as RootMonitorHandle;
|
use crate::monitor::MonitorHandle as RootMonitorHandle;
|
||||||
|
|
||||||
use super::{ffi, util, ImeSender, XConnection, XError, WindowId, EventLoopWindowTarget};
|
use super::{ffi, util, ImeSender, XConnection, XError, WindowId, EventLoopWindowTarget};
|
||||||
|
|
||||||
|
@ -429,7 +429,7 @@ impl UnownedWindow {
|
||||||
LogicalSize::from_physical((width, height), dpi)
|
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 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") };
|
let client_machine_atom = unsafe { self.xconn.get_atom_unchecked(b"WM_CLIENT_MACHINE\0") };
|
||||||
unsafe {
|
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 hint_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_WINDOW_TYPE\0") };
|
||||||
let window_type_atom = window_type.as_atom(&self.xconn);
|
let window_type_atom = window_type.as_atom(&self.xconn);
|
||||||
self.xconn.change_property(
|
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 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 utf8_atom = unsafe { self.xconn.get_atom_unchecked(b"UTF8_STRING\0") };
|
||||||
let variant = CString::new(variant).expect("`_GTK_THEME_VARIANT` contained null byte");
|
let variant = CString::new(variant).expect("`_GTK_THEME_VARIANT` contained null byte");
|
||||||
|
@ -502,7 +502,7 @@ impl UnownedWindow {
|
||||||
&self,
|
&self,
|
||||||
operation: util::StateOperation,
|
operation: util::StateOperation,
|
||||||
properties: (c_long, c_long, c_long, c_long),
|
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") };
|
let state_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_STATE\0") };
|
||||||
self.xconn.send_client_msg(
|
self.xconn.send_client_msg(
|
||||||
self.xwindow,
|
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") };
|
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))
|
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 {
|
match monitor {
|
||||||
None => {
|
None => {
|
||||||
let flusher = self.set_fullscreen_hint(false);
|
let flusher = self.set_fullscreen_hint(false);
|
||||||
|
@ -588,7 +588,7 @@ impl UnownedWindow {
|
||||||
self.xconn.primary_monitor()
|
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 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") };
|
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))
|
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();
|
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 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 utf8_atom = unsafe { self.xconn.get_atom_unchecked(b"UTF8_STRING\0") };
|
||||||
let title = CString::new(title).expect("Window title contained null byte");
|
let title = CString::new(title).expect("Window title contained null byte");
|
||||||
|
@ -629,7 +629,7 @@ impl UnownedWindow {
|
||||||
.expect("Failed to set window title");
|
.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") };
|
let wm_hints = unsafe { self.xconn.get_atom_unchecked(b"_MOTIF_WM_HINTS\0") };
|
||||||
self.xconn.change_property(
|
self.xconn.change_property(
|
||||||
self.xwindow,
|
self.xwindow,
|
||||||
|
@ -654,7 +654,7 @@ impl UnownedWindow {
|
||||||
self.invalidate_cached_frame_extents();
|
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") };
|
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))
|
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");
|
.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 icon_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_ICON\0") };
|
||||||
let data = icon.to_cardinals();
|
let data = icon.to_cardinals();
|
||||||
self.xconn.change_property(
|
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 icon_atom = unsafe { self.xconn.get_atom_unchecked(b"_NET_WM_ICON\0") };
|
||||||
let empty_data: [util::Cardinal; 0] = [];
|
let empty_data: [util::Cardinal; 0] = [];
|
||||||
self.xconn.change_property(
|
self.xconn.change_property(
|
||||||
|
@ -759,7 +759,7 @@ impl UnownedWindow {
|
||||||
Ok(self.logicalize_coords(self.inner_position_physical()))
|
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
|
// There are a few WMs that set client area position rather than window position, so
|
||||||
// we'll translate for consistency.
|
// we'll translate for consistency.
|
||||||
if util::wm_name_is_one_of(&["Enlightenment", "FVWM"]) {
|
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>
|
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)?;
|
let mut normal_hints = self.xconn.get_normal_hints(self.xwindow)?;
|
||||||
callback(&mut normal_hints);
|
callback(&mut normal_hints);
|
||||||
|
@ -892,7 +892,7 @@ impl UnownedWindow {
|
||||||
new_dpi_factor: f64,
|
new_dpi_factor: f64,
|
||||||
width: f64,
|
width: f64,
|
||||||
height: f64,
|
height: f64,
|
||||||
) -> (f64, f64, util::Flusher) {
|
) -> (f64, f64, util::Flusher<'_>) {
|
||||||
let scale_factor = new_dpi_factor / old_dpi_factor;
|
let scale_factor = new_dpi_factor / old_dpi_factor;
|
||||||
let new_width = width * scale_factor;
|
let new_width = width * scale_factor;
|
||||||
let new_height = height * scale_factor;
|
let new_height = height * scale_factor;
|
||||||
|
|
|
@ -90,7 +90,7 @@ impl XConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for 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)
|
self.display.fmt(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ impl Error for XError {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display 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: {})",
|
write!(formatter, "X error: {} (code: {}, request code: {}, minor code: {})",
|
||||||
self.description, self.error_code, self.request_code, self.minor_code)
|
self.description, self.error_code, self.request_code, self.minor_code)
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ impl Error for XNotSupported {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cause(&self) -> Option<&Error> {
|
fn cause(&self) -> Option<&dyn Error> {
|
||||||
match *self {
|
match *self {
|
||||||
XNotSupported::LibraryOpenError(ref err) => Some(err),
|
XNotSupported::LibraryOpenError(ref err) => Some(err),
|
||||||
_ => None
|
_ => None
|
||||||
|
@ -160,7 +160,7 @@ impl Error for XNotSupported {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display 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())
|
formatter.write_str(self.description())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@ use std::collections::VecDeque;
|
||||||
use cocoa::{appkit::{self, NSEvent}, base::id};
|
use cocoa::{appkit::{self, NSEvent}, base::id};
|
||||||
use objc::{declare::ClassDecl, runtime::{Class, Object, Sel}};
|
use objc::{declare::ClassDecl, runtime::{Class, Object, Sel}};
|
||||||
|
|
||||||
use event::{DeviceEvent, Event};
|
use crate::event::{DeviceEvent, Event};
|
||||||
use platform_impl::platform::{app_state::AppState, DEVICE_ID, util};
|
use crate::platform_impl::platform::{app_state::AppState, DEVICE_ID, util};
|
||||||
|
|
||||||
pub struct AppClass(pub *const Class);
|
pub struct AppClass(pub *const Class);
|
||||||
unsafe impl Send for AppClass {}
|
unsafe impl Send for AppClass {}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use cocoa::base::id;
|
use cocoa::base::id;
|
||||||
use objc::{runtime::{Class, Object, Sel, BOOL, YES}, declare::ClassDecl};
|
use objc::{runtime::{Class, Object, Sel, BOOL, YES}, declare::ClassDecl};
|
||||||
|
|
||||||
use platform_impl::platform::app_state::AppState;
|
use crate::platform_impl::platform::app_state::AppState;
|
||||||
|
|
||||||
pub struct AppDelegateClass(pub *const Class);
|
pub struct AppDelegateClass(pub *const Class);
|
||||||
unsafe impl Send for AppDelegateClass {}
|
unsafe impl Send for AppDelegateClass {}
|
||||||
|
|
|
@ -6,12 +6,12 @@ use std::{
|
||||||
|
|
||||||
use cocoa::{appkit::NSApp, base::nil};
|
use cocoa::{appkit::NSApp, base::nil};
|
||||||
|
|
||||||
use {
|
use crate::{
|
||||||
event::{Event, StartCause, WindowEvent},
|
event::{Event, StartCause, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoopWindowTarget as RootWindowTarget},
|
event_loop::{ControlFlow, EventLoopWindowTarget as RootWindowTarget},
|
||||||
window::WindowId,
|
window::WindowId,
|
||||||
};
|
};
|
||||||
use platform_impl::platform::{observer::EventLoopWaker, util::Never};
|
use crate::platform_impl::platform::{observer::EventLoopWaker, util::Never};
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref HANDLER: Handler = Default::default();
|
static ref HANDLER: Handler = Default::default();
|
||||||
|
@ -38,7 +38,7 @@ struct EventLoopHandler<F, T: 'static> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F, T> Debug for EventLoopHandler<F, T> {
|
impl<F, T> Debug for EventLoopHandler<F, T> {
|
||||||
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
formatter.debug_struct("EventLoopHandler")
|
formatter.debug_struct("EventLoopHandler")
|
||||||
.field("window_target", &self.window_target)
|
.field("window_target", &self.window_target)
|
||||||
.finish()
|
.finish()
|
||||||
|
|
|
@ -2,11 +2,11 @@ use std::os::raw::c_ushort;
|
||||||
|
|
||||||
use cocoa::{appkit::{NSEvent, NSEventModifierFlags}, base::id};
|
use cocoa::{appkit::{NSEvent, NSEventModifierFlags}, base::id};
|
||||||
|
|
||||||
use event::{
|
use crate::event::{
|
||||||
ElementState, KeyboardInput,
|
ElementState, KeyboardInput,
|
||||||
ModifiersState, VirtualKeyCode, WindowEvent,
|
ModifiersState, VirtualKeyCode, WindowEvent,
|
||||||
};
|
};
|
||||||
use platform_impl::platform::DEVICE_ID;
|
use crate::platform_impl::platform::DEVICE_ID;
|
||||||
|
|
||||||
pub fn char_to_keycode(c: char) -> Option<VirtualKeyCode> {
|
pub fn char_to_keycode(c: char) -> Option<VirtualKeyCode> {
|
||||||
// We only translate keys that are affected by keyboard layout.
|
// We only translate keys that are affected by keyboard layout.
|
||||||
|
|
|
@ -4,11 +4,11 @@ use std::{
|
||||||
|
|
||||||
use cocoa::{appkit::NSApp, base::{id, nil}, foundation::NSAutoreleasePool};
|
use cocoa::{appkit::NSApp, base::{id, nil}, foundation::NSAutoreleasePool};
|
||||||
|
|
||||||
use {
|
use crate::{
|
||||||
event::Event,
|
event::Event,
|
||||||
event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootWindowTarget},
|
event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootWindowTarget},
|
||||||
};
|
};
|
||||||
use platform_impl::platform::{
|
use crate::platform_impl::platform::{
|
||||||
app::APP_CLASS, app_delegate::APP_DELEGATE_CLASS,
|
app::APP_CLASS, app_delegate::APP_DELEGATE_CLASS,
|
||||||
app_state::AppState, monitor::{self, MonitorHandle},
|
app_state::AppState, monitor::{self, MonitorHandle},
|
||||||
observer::*, util::IdRef,
|
observer::*, util::IdRef,
|
||||||
|
|
|
@ -15,7 +15,7 @@ mod window_delegate;
|
||||||
|
|
||||||
use std::{fmt, ops::Deref, sync::Arc};
|
use std::{fmt, ops::Deref, sync::Arc};
|
||||||
|
|
||||||
use {
|
use crate::{
|
||||||
event::DeviceId as RootDeviceId, window::WindowAttributes,
|
event::DeviceId as RootDeviceId, window::WindowAttributes,
|
||||||
error::OsError as RootOsError,
|
error::OsError as RootOsError,
|
||||||
};
|
};
|
||||||
|
@ -74,7 +74,7 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for OsError {
|
impl fmt::Display for OsError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
OsError::CGError(e) => f.pad(&format!("CGError {}", e)),
|
OsError::CGError(e) => f.pad(&format!("CGError {}", e)),
|
||||||
OsError::CreationError(e) => f.pad(e),
|
OsError::CreationError(e) => f.pad(e),
|
||||||
|
|
|
@ -11,9 +11,9 @@ use core_video_sys::{
|
||||||
CVDisplayLinkGetNominalOutputVideoRefreshPeriod, CVDisplayLinkRelease,
|
CVDisplayLinkGetNominalOutputVideoRefreshPeriod, CVDisplayLinkRelease,
|
||||||
};
|
};
|
||||||
|
|
||||||
use dpi::{PhysicalPosition, PhysicalSize};
|
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
||||||
use monitor::VideoMode;
|
use crate::monitor::VideoMode;
|
||||||
use platform_impl::platform::util::IdRef;
|
use crate::platform_impl::platform::util::IdRef;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
pub struct MonitorHandle(CGDirectDisplayID);
|
pub struct MonitorHandle(CGDirectDisplayID);
|
||||||
|
@ -35,7 +35,7 @@ pub fn primary_monitor() -> MonitorHandle {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug 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 {
|
||||||
// TODO: Do this using the proper fmt API
|
// TODO: Do this using the proper fmt API
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct MonitorHandle {
|
struct MonitorHandle {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::{self, ptr, os::raw::*, time::Instant};
|
use std::{self, ptr, os::raw::*, time::Instant};
|
||||||
|
|
||||||
use platform_impl::platform::app_state::AppState;
|
use crate::platform_impl::platform::app_state::AppState;
|
||||||
|
|
||||||
#[link(name = "CoreFoundation", kind = "framework")]
|
#[link(name = "CoreFoundation", kind = "framework")]
|
||||||
extern {
|
extern {
|
||||||
|
|
|
@ -7,8 +7,8 @@ use cocoa::{
|
||||||
};
|
};
|
||||||
use dispatch::ffi::{dispatch_async_f, dispatch_get_main_queue, dispatch_sync_f};
|
use dispatch::ffi::{dispatch_async_f, dispatch_get_main_queue, dispatch_sync_f};
|
||||||
|
|
||||||
use dpi::LogicalSize;
|
use crate::dpi::LogicalSize;
|
||||||
use platform_impl::platform::{ffi, window::SharedState};
|
use crate::platform_impl::platform::{ffi, window::SharedState};
|
||||||
|
|
||||||
unsafe fn set_style_mask(ns_window: id, ns_view: id, mask: NSWindowStyleMask) {
|
unsafe fn set_style_mask(ns_window: id, ns_view: id, mask: NSWindowStyleMask) {
|
||||||
ns_window.setStyleMask_(mask);
|
ns_window.setStyleMask_(mask);
|
||||||
|
|
|
@ -4,7 +4,7 @@ use cocoa::{
|
||||||
};
|
};
|
||||||
use objc::runtime::Sel;
|
use objc::runtime::Sel;
|
||||||
|
|
||||||
use window::CursorIcon;
|
use crate::window::CursorIcon;
|
||||||
|
|
||||||
pub enum Cursor {
|
pub enum Cursor {
|
||||||
Native(&'static str),
|
Native(&'static str),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
mod async;
|
mod r#async;
|
||||||
mod cursor;
|
mod cursor;
|
||||||
|
|
||||||
pub use self::{async::*, cursor::*};
|
pub use self::{r#async::*, cursor::*};
|
||||||
|
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::ops::BitAnd;
|
use std::ops::BitAnd;
|
||||||
|
@ -14,7 +14,7 @@ use cocoa::{
|
||||||
use core_graphics::display::CGDisplay;
|
use core_graphics::display::CGDisplay;
|
||||||
use objc::runtime::{BOOL, Class, Object, Sel, YES};
|
use objc::runtime::{BOOL, Class, Object, Sel, YES};
|
||||||
|
|
||||||
use platform_impl::platform::ffi;
|
use crate::platform_impl::platform::ffi;
|
||||||
|
|
||||||
// Replace with `!` once stable
|
// Replace with `!` once stable
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -9,14 +9,14 @@ use cocoa::{
|
||||||
};
|
};
|
||||||
use objc::{declare::ClassDecl, runtime::{BOOL, Class, NO, Object, Protocol, Sel, YES}};
|
use objc::{declare::ClassDecl, runtime::{BOOL, Class, NO, Object, Protocol, Sel, YES}};
|
||||||
|
|
||||||
use {
|
use crate::{
|
||||||
event::{
|
event::{
|
||||||
DeviceEvent, ElementState, Event, KeyboardInput, MouseButton,
|
DeviceEvent, ElementState, Event, KeyboardInput, MouseButton,
|
||||||
MouseScrollDelta, TouchPhase, VirtualKeyCode, WindowEvent,
|
MouseScrollDelta, TouchPhase, VirtualKeyCode, WindowEvent,
|
||||||
},
|
},
|
||||||
window::WindowId,
|
window::WindowId,
|
||||||
};
|
};
|
||||||
use platform_impl::platform::{
|
use crate::platform_impl::platform::{
|
||||||
app_state::AppState, DEVICE_ID,
|
app_state::AppState, DEVICE_ID,
|
||||||
event::{check_function_keys, event_mods, modifier_event, char_to_keycode, get_scancode, scancode_to_keycode},
|
event::{check_function_keys, event_mods, modifier_event, char_to_keycode, get_scancode, scancode_to_keycode},
|
||||||
util::{self, IdRef}, ffi::*, window::get_window_id,
|
util::{self, IdRef}, ffi::*, window::get_window_id,
|
||||||
|
|
|
@ -15,7 +15,7 @@ use cocoa::{
|
||||||
use core_graphics::display::CGDisplay;
|
use core_graphics::display::CGDisplay;
|
||||||
use objc::{runtime::{Class, Object, Sel, BOOL, YES, NO}, declare::ClassDecl};
|
use objc::{runtime::{Class, Object, Sel, BOOL, YES, NO}, declare::ClassDecl};
|
||||||
|
|
||||||
use {
|
use crate::{
|
||||||
dpi::{LogicalPosition, LogicalSize}, icon::Icon,
|
dpi::{LogicalPosition, LogicalSize}, icon::Icon,
|
||||||
error::{ExternalError, NotSupportedError, OsError as RootOsError},
|
error::{ExternalError, NotSupportedError, OsError as RootOsError},
|
||||||
monitor::MonitorHandle as RootMonitorHandle,
|
monitor::MonitorHandle as RootMonitorHandle,
|
||||||
|
@ -23,8 +23,8 @@ use {
|
||||||
CursorIcon, WindowAttributes, WindowId as RootWindowId,
|
CursorIcon, WindowAttributes, WindowId as RootWindowId,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use platform::macos::{ActivationPolicy, WindowExtMacOS};
|
use crate::platform::macos::{ActivationPolicy, WindowExtMacOS};
|
||||||
use platform_impl::platform::{
|
use crate::platform_impl::platform::{
|
||||||
OsError,
|
OsError,
|
||||||
app_state::AppState, ffi, monitor::{self, MonitorHandle},
|
app_state::AppState, ffi, monitor::{self, MonitorHandle},
|
||||||
util::{self, IdRef}, view::{self, new_view},
|
util::{self, IdRef}, view::{self, new_view},
|
||||||
|
|
|
@ -6,8 +6,8 @@ use cocoa::{
|
||||||
};
|
};
|
||||||
use objc::{runtime::{Class, Object, Sel, BOOL, YES, NO}, declare::ClassDecl};
|
use objc::{runtime::{Class, Object, Sel, BOOL, YES, NO}, declare::ClassDecl};
|
||||||
|
|
||||||
use {dpi::LogicalSize, event::{Event, WindowEvent}, window::WindowId};
|
use crate::{dpi::LogicalSize, event::{Event, WindowEvent}, window::WindowId};
|
||||||
use platform_impl::platform::{
|
use crate::platform_impl::platform::{
|
||||||
app_state::AppState, util::{self, IdRef},
|
app_state::AppState, util::{self, IdRef},
|
||||||
window::{get_window_id, UnownedWindow},
|
window::{get_window_id, UnownedWindow},
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,17 +14,17 @@ use winapi::um::oleidl::{DROPEFFECT_COPY, DROPEFFECT_NONE, IDropTarget, IDropTar
|
||||||
use winapi::um::winnt::HRESULT;
|
use winapi::um::winnt::HRESULT;
|
||||||
use winapi::um::{shellapi, unknwnbase};
|
use winapi::um::{shellapi, unknwnbase};
|
||||||
|
|
||||||
use platform_impl::platform::WindowId;
|
use crate::platform_impl::platform::WindowId;
|
||||||
|
|
||||||
use event::Event;
|
use crate::event::Event;
|
||||||
use window::WindowId as SuperWindowId;
|
use crate::window::WindowId as SuperWindowId;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct FileDropHandlerData {
|
pub struct FileDropHandlerData {
|
||||||
pub interface: IDropTarget,
|
pub interface: IDropTarget,
|
||||||
refcount: AtomicUsize,
|
refcount: AtomicUsize,
|
||||||
window: HWND,
|
window: HWND,
|
||||||
send_event: Box<Fn(Event<()>)>,
|
send_event: Box<dyn Fn(Event<()>)>,
|
||||||
cursor_effect: DWORD,
|
cursor_effect: DWORD,
|
||||||
hovered_is_valid: bool, // If the currently hovered item is not valid there must not be any `HoveredFileCancelled` emitted
|
hovered_is_valid: bool, // If the currently hovered item is not valid there must not be any `HoveredFileCancelled` emitted
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ pub struct FileDropHandler {
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
impl FileDropHandler {
|
impl FileDropHandler {
|
||||||
pub fn new(window: HWND, send_event: Box<Fn(Event<()>)>) -> FileDropHandler {
|
pub fn new(window: HWND, send_event: Box<dyn Fn(Event<()>)>) -> FileDropHandler {
|
||||||
let data = Box::new(FileDropHandlerData {
|
let data = Box::new(FileDropHandlerData {
|
||||||
interface: IDropTarget {
|
interface: IDropTarget {
|
||||||
lpVtbl: &DROP_TARGET_VTBL as *const IDropTargetVtbl,
|
lpVtbl: &DROP_TARGET_VTBL as *const IDropTargetVtbl,
|
||||||
|
@ -85,7 +85,7 @@ impl FileDropHandler {
|
||||||
_pt: *const POINTL,
|
_pt: *const POINTL,
|
||||||
pdwEffect: *mut DWORD,
|
pdwEffect: *mut DWORD,
|
||||||
) -> HRESULT {
|
) -> HRESULT {
|
||||||
use event::WindowEvent::HoveredFile;
|
use crate::event::WindowEvent::HoveredFile;
|
||||||
let drop_handler = Self::from_interface(this);
|
let drop_handler = Self::from_interface(this);
|
||||||
let hdrop = Self::iterate_filenames(pDataObj, |filename| {
|
let hdrop = Self::iterate_filenames(pDataObj, |filename| {
|
||||||
drop_handler.send_event(Event::WindowEvent {
|
drop_handler.send_event(Event::WindowEvent {
|
||||||
|
@ -117,7 +117,7 @@ impl FileDropHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe extern "system" fn DragLeave(this: *mut IDropTarget) -> HRESULT {
|
pub unsafe extern "system" fn DragLeave(this: *mut IDropTarget) -> HRESULT {
|
||||||
use event::WindowEvent::HoveredFileCancelled;
|
use crate::event::WindowEvent::HoveredFileCancelled;
|
||||||
let drop_handler = Self::from_interface(this);
|
let drop_handler = Self::from_interface(this);
|
||||||
if drop_handler.hovered_is_valid {
|
if drop_handler.hovered_is_valid {
|
||||||
drop_handler.send_event(Event::WindowEvent {
|
drop_handler.send_event(Event::WindowEvent {
|
||||||
|
@ -136,7 +136,7 @@ impl FileDropHandler {
|
||||||
_pt: *const POINTL,
|
_pt: *const POINTL,
|
||||||
_pdwEffect: *mut DWORD,
|
_pdwEffect: *mut DWORD,
|
||||||
) -> HRESULT {
|
) -> HRESULT {
|
||||||
use event::WindowEvent::DroppedFile;
|
use crate::event::WindowEvent::DroppedFile;
|
||||||
let drop_handler = Self::from_interface(this);
|
let drop_handler = Self::from_interface(this);
|
||||||
let hdrop = Self::iterate_filenames(pDataObj, |filename| {
|
let hdrop = Self::iterate_filenames(pDataObj, |filename| {
|
||||||
drop_handler.send_event(Event::WindowEvent {
|
drop_handler.send_event(Event::WindowEvent {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::{char, ptr};
|
||||||
use std::os::raw::c_int;
|
use std::os::raw::c_int;
|
||||||
use std::sync::atomic::{AtomicBool, AtomicPtr, Ordering};
|
use std::sync::atomic::{AtomicBool, AtomicPtr, Ordering};
|
||||||
|
|
||||||
use event::{ScanCode, ModifiersState, VirtualKeyCode};
|
use crate::event::{ScanCode, ModifiersState, VirtualKeyCode};
|
||||||
|
|
||||||
use winapi::shared::minwindef::{WPARAM, LPARAM, UINT, HKL, HKL__};
|
use winapi::shared::minwindef::{WPARAM, LPARAM, UINT, HKL, HKL__};
|
||||||
use winapi::um::winuser;
|
use winapi::um::winuser;
|
||||||
|
|
|
@ -43,22 +43,22 @@ use winapi::shared::{windowsx, winerror};
|
||||||
use winapi::um::{winuser, winbase, ole2, processthreadsapi, commctrl, libloaderapi};
|
use winapi::um::{winuser, winbase, ole2, processthreadsapi, commctrl, libloaderapi};
|
||||||
use winapi::um::winnt::{LONG, LPCSTR, SHORT};
|
use winapi::um::winnt::{LONG, LPCSTR, SHORT};
|
||||||
|
|
||||||
use window::WindowId as RootWindowId;
|
use crate::window::WindowId as RootWindowId;
|
||||||
use event_loop::{ControlFlow, EventLoopWindowTarget as RootELW, EventLoopClosed};
|
use crate::event_loop::{ControlFlow, EventLoopWindowTarget as RootELW, EventLoopClosed};
|
||||||
use dpi::{LogicalPosition, LogicalSize, PhysicalSize};
|
use crate::dpi::{LogicalPosition, LogicalSize, PhysicalSize};
|
||||||
use event::{DeviceEvent, Touch, TouchPhase, StartCause, KeyboardInput, Event, WindowEvent};
|
use crate::event::{DeviceEvent, Touch, TouchPhase, StartCause, KeyboardInput, Event, WindowEvent};
|
||||||
use platform_impl::platform::{event, WindowId, DEVICE_ID, wrap_device_id, util};
|
use crate::platform_impl::platform::{event, WindowId, DEVICE_ID, wrap_device_id, util};
|
||||||
use platform_impl::platform::dpi::{
|
use crate::platform_impl::platform::dpi::{
|
||||||
become_dpi_aware,
|
become_dpi_aware,
|
||||||
dpi_to_scale_factor,
|
dpi_to_scale_factor,
|
||||||
enable_non_client_dpi_scaling,
|
enable_non_client_dpi_scaling,
|
||||||
hwnd_scale_factor,
|
hwnd_scale_factor,
|
||||||
};
|
};
|
||||||
use platform_impl::platform::drop_handler::FileDropHandler;
|
use crate::platform_impl::platform::drop_handler::FileDropHandler;
|
||||||
use platform_impl::platform::event::{handle_extended_keys, process_key_params, vkey_to_winit_vkey};
|
use crate::platform_impl::platform::event::{handle_extended_keys, process_key_params, vkey_to_winit_vkey};
|
||||||
use platform_impl::platform::raw_input::{get_raw_input_data, get_raw_mouse_button_state};
|
use crate::platform_impl::platform::raw_input::{get_raw_input_data, get_raw_mouse_button_state};
|
||||||
use platform_impl::platform::window::adjust_size;
|
use crate::platform_impl::platform::window::adjust_size;
|
||||||
use platform_impl::platform::window_state::{CursorFlags, WindowFlags, WindowState};
|
use crate::platform_impl::platform::window_state::{CursorFlags, WindowFlags, WindowState};
|
||||||
|
|
||||||
pub(crate) struct SubclassInput<T> {
|
pub(crate) struct SubclassInput<T> {
|
||||||
pub window_state: Arc<Mutex<WindowState>>,
|
pub window_state: Arc<Mutex<WindowState>>,
|
||||||
|
@ -237,10 +237,10 @@ pub(crate) struct EventLoopRunner<T> {
|
||||||
runner_state: RunnerState,
|
runner_state: RunnerState,
|
||||||
modal_redraw_window: HWND,
|
modal_redraw_window: HWND,
|
||||||
in_modal_loop: bool,
|
in_modal_loop: bool,
|
||||||
event_handler: Box<FnMut(Event<T>, &mut ControlFlow)>,
|
event_handler: Box<dyn FnMut(Event<T>, &mut ControlFlow)>,
|
||||||
panic_error: Option<PanicError>,
|
panic_error: Option<PanicError>,
|
||||||
}
|
}
|
||||||
type PanicError = Box<Any + Send + 'static>;
|
type PanicError = Box<dyn Any + Send + 'static>;
|
||||||
|
|
||||||
impl<T> ELRShared<T> {
|
impl<T> ELRShared<T> {
|
||||||
pub(crate) unsafe fn send_event(&self, event: Event<T>) {
|
pub(crate) unsafe fn send_event(&self, event: Event<T>) {
|
||||||
|
@ -297,8 +297,8 @@ impl<T> EventLoopRunner<T> {
|
||||||
in_modal_loop: false,
|
in_modal_loop: false,
|
||||||
modal_redraw_window: event_loop.window_target.p.thread_msg_target,
|
modal_redraw_window: event_loop.window_target.p.thread_msg_target,
|
||||||
event_handler: mem::transmute::<
|
event_handler: mem::transmute::<
|
||||||
Box<FnMut(Event<T>, &mut ControlFlow)>,
|
Box<dyn FnMut(Event<T>, &mut ControlFlow)>,
|
||||||
Box<FnMut(Event<T>, &mut ControlFlow)>
|
Box<dyn FnMut(Event<T>, &mut ControlFlow)>
|
||||||
>(Box::new(f)),
|
>(Box::new(f)),
|
||||||
panic_error: None,
|
panic_error: None,
|
||||||
}
|
}
|
||||||
|
@ -583,7 +583,7 @@ impl EventLoopThreadExecutor {
|
||||||
function();
|
function();
|
||||||
} else {
|
} else {
|
||||||
// We double-box because the first box is a fat pointer.
|
// We double-box because the first box is a fat pointer.
|
||||||
let boxed = Box::new(function) as Box<FnMut()>;
|
let boxed = Box::new(function) as Box<dyn FnMut()>;
|
||||||
let boxed2: ThreadExecFn = Box::new(boxed);
|
let boxed2: ThreadExecFn = Box::new(boxed);
|
||||||
|
|
||||||
let raw = Box::into_raw(boxed2);
|
let raw = Box::into_raw(boxed2);
|
||||||
|
@ -598,7 +598,7 @@ impl EventLoopThreadExecutor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ThreadExecFn = Box<Box<FnMut()>>;
|
type ThreadExecFn = Box<Box<dyn FnMut()>>;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct EventLoopProxy<T: 'static> {
|
pub struct EventLoopProxy<T: 'static> {
|
||||||
|
@ -629,7 +629,7 @@ lazy_static! {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Message sent when we want to execute a closure in the thread.
|
// Message sent when we want to execute a closure in the thread.
|
||||||
// WPARAM contains a Box<Box<FnMut()>> that must be retrieved with `Box::from_raw`,
|
// WPARAM contains a Box<Box<dyn FnMut()>> that must be retrieved with `Box::from_raw`,
|
||||||
// and LPARAM is unused.
|
// and LPARAM is unused.
|
||||||
static ref EXEC_MSG_ID: u32 = {
|
static ref EXEC_MSG_ID: u32 = {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -814,7 +814,7 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_CLOSE => {
|
winuser::WM_CLOSE => {
|
||||||
use event::WindowEvent::CloseRequested;
|
use crate::event::WindowEvent::CloseRequested;
|
||||||
subclass_input.send_event(Event::WindowEvent {
|
subclass_input.send_event(Event::WindowEvent {
|
||||||
window_id: RootWindowId(WindowId(window)),
|
window_id: RootWindowId(WindowId(window)),
|
||||||
event: CloseRequested,
|
event: CloseRequested,
|
||||||
|
@ -823,7 +823,7 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_DESTROY => {
|
winuser::WM_DESTROY => {
|
||||||
use event::WindowEvent::Destroyed;
|
use crate::event::WindowEvent::Destroyed;
|
||||||
ole2::RevokeDragDrop(window);
|
ole2::RevokeDragDrop(window);
|
||||||
subclass_input.send_event(Event::WindowEvent {
|
subclass_input.send_event(Event::WindowEvent {
|
||||||
window_id: RootWindowId(WindowId(window)),
|
window_id: RootWindowId(WindowId(window)),
|
||||||
|
@ -836,7 +836,7 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
_ if msg == *REQUEST_REDRAW_NO_NEWEVENTS_MSG_ID => {
|
_ if msg == *REQUEST_REDRAW_NO_NEWEVENTS_MSG_ID => {
|
||||||
use event::WindowEvent::RedrawRequested;
|
use crate::event::WindowEvent::RedrawRequested;
|
||||||
let mut runner = subclass_input.event_loop_runner.runner.borrow_mut();
|
let mut runner = subclass_input.event_loop_runner.runner.borrow_mut();
|
||||||
if let Some(ref mut runner) = *runner {
|
if let Some(ref mut runner) = *runner {
|
||||||
// This check makes sure that calls to `request_redraw()` during `EventsCleared`
|
// This check makes sure that calls to `request_redraw()` during `EventsCleared`
|
||||||
|
@ -871,7 +871,7 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
0
|
0
|
||||||
},
|
},
|
||||||
winuser::WM_PAINT => {
|
winuser::WM_PAINT => {
|
||||||
use event::WindowEvent::RedrawRequested;
|
use crate::event::WindowEvent::RedrawRequested;
|
||||||
subclass_input.send_event(Event::WindowEvent {
|
subclass_input.send_event(Event::WindowEvent {
|
||||||
window_id: RootWindowId(WindowId(window)),
|
window_id: RootWindowId(WindowId(window)),
|
||||||
event: RedrawRequested,
|
event: RedrawRequested,
|
||||||
|
@ -881,7 +881,7 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
|
|
||||||
// WM_MOVE supplies client area positions, so we send Moved here instead.
|
// WM_MOVE supplies client area positions, so we send Moved here instead.
|
||||||
winuser::WM_WINDOWPOSCHANGED => {
|
winuser::WM_WINDOWPOSCHANGED => {
|
||||||
use event::WindowEvent::Moved;
|
use crate::event::WindowEvent::Moved;
|
||||||
|
|
||||||
let windowpos = lparam as *const winuser::WINDOWPOS;
|
let windowpos = lparam as *const winuser::WINDOWPOS;
|
||||||
if (*windowpos).flags & winuser::SWP_NOMOVE != winuser::SWP_NOMOVE {
|
if (*windowpos).flags & winuser::SWP_NOMOVE != winuser::SWP_NOMOVE {
|
||||||
|
@ -901,7 +901,7 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_SIZE => {
|
winuser::WM_SIZE => {
|
||||||
use event::WindowEvent::Resized;
|
use crate::event::WindowEvent::Resized;
|
||||||
let w = LOWORD(lparam as DWORD) as u32;
|
let w = LOWORD(lparam as DWORD) as u32;
|
||||||
let h = HIWORD(lparam as DWORD) as u32;
|
let h = HIWORD(lparam as DWORD) as u32;
|
||||||
|
|
||||||
|
@ -926,7 +926,7 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_CHAR => {
|
winuser::WM_CHAR => {
|
||||||
use event::WindowEvent::ReceivedCharacter;
|
use crate::event::WindowEvent::ReceivedCharacter;
|
||||||
let chr: char = mem::transmute(wparam as u32);
|
let chr: char = mem::transmute(wparam as u32);
|
||||||
subclass_input.send_event(Event::WindowEvent {
|
subclass_input.send_event(Event::WindowEvent {
|
||||||
window_id: RootWindowId(WindowId(window)),
|
window_id: RootWindowId(WindowId(window)),
|
||||||
|
@ -944,7 +944,7 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
}
|
}
|
||||||
|
|
||||||
winuser::WM_MOUSEMOVE => {
|
winuser::WM_MOUSEMOVE => {
|
||||||
use event::WindowEvent::{CursorEntered, CursorMoved};
|
use crate::event::WindowEvent::{CursorEntered, CursorMoved};
|
||||||
let mouse_was_outside_window = {
|
let mouse_was_outside_window = {
|
||||||
let mut w = subclass_input.window_state.lock();
|
let mut w = subclass_input.window_state.lock();
|
||||||
|
|
||||||
|
@ -982,7 +982,7 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_MOUSELEAVE => {
|
winuser::WM_MOUSELEAVE => {
|
||||||
use event::WindowEvent::CursorLeft;
|
use crate::event::WindowEvent::CursorLeft;
|
||||||
{
|
{
|
||||||
let mut w = subclass_input.window_state.lock();
|
let mut w = subclass_input.window_state.lock();
|
||||||
w.mouse.set_cursor_flags(window, |f| f.set(CursorFlags::IN_WINDOW, false)).ok();
|
w.mouse.set_cursor_flags(window, |f| f.set(CursorFlags::IN_WINDOW, false)).ok();
|
||||||
|
@ -997,7 +997,7 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_MOUSEWHEEL => {
|
winuser::WM_MOUSEWHEEL => {
|
||||||
use event::MouseScrollDelta::LineDelta;
|
use crate::event::MouseScrollDelta::LineDelta;
|
||||||
|
|
||||||
let value = (wparam >> 16) as i16;
|
let value = (wparam >> 16) as i16;
|
||||||
let value = value as i32;
|
let value = value as i32;
|
||||||
|
@ -1012,7 +1012,7 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_MOUSEHWHEEL => {
|
winuser::WM_MOUSEHWHEEL => {
|
||||||
use event::MouseScrollDelta::LineDelta;
|
use crate::event::MouseScrollDelta::LineDelta;
|
||||||
|
|
||||||
let value = (wparam >> 16) as i16;
|
let value = (wparam >> 16) as i16;
|
||||||
let value = value as i32;
|
let value = value as i32;
|
||||||
|
@ -1027,8 +1027,8 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_KEYDOWN | winuser::WM_SYSKEYDOWN => {
|
winuser::WM_KEYDOWN | winuser::WM_SYSKEYDOWN => {
|
||||||
use event::ElementState::Pressed;
|
use crate::event::ElementState::Pressed;
|
||||||
use event::VirtualKeyCode;
|
use crate::event::VirtualKeyCode;
|
||||||
if msg == winuser::WM_SYSKEYDOWN && wparam as i32 == winuser::VK_F4 {
|
if msg == winuser::WM_SYSKEYDOWN && wparam as i32 == winuser::VK_F4 {
|
||||||
commctrl::DefSubclassProc(window, msg, wparam, lparam)
|
commctrl::DefSubclassProc(window, msg, wparam, lparam)
|
||||||
} else {
|
} else {
|
||||||
|
@ -1059,7 +1059,7 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_KEYUP | winuser::WM_SYSKEYUP => {
|
winuser::WM_KEYUP | winuser::WM_SYSKEYUP => {
|
||||||
use event::ElementState::Released;
|
use crate::event::ElementState::Released;
|
||||||
if let Some((scancode, vkey)) = process_key_params(wparam, lparam) {
|
if let Some((scancode, vkey)) = process_key_params(wparam, lparam) {
|
||||||
subclass_input.send_event(Event::WindowEvent {
|
subclass_input.send_event(Event::WindowEvent {
|
||||||
window_id: RootWindowId(WindowId(window)),
|
window_id: RootWindowId(WindowId(window)),
|
||||||
|
@ -1078,9 +1078,9 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_LBUTTONDOWN => {
|
winuser::WM_LBUTTONDOWN => {
|
||||||
use event::WindowEvent::MouseInput;
|
use crate::event::WindowEvent::MouseInput;
|
||||||
use event::MouseButton::Left;
|
use crate::event::MouseButton::Left;
|
||||||
use event::ElementState::Pressed;
|
use crate::event::ElementState::Pressed;
|
||||||
|
|
||||||
capture_mouse(window, &mut *subclass_input.window_state.lock());
|
capture_mouse(window, &mut *subclass_input.window_state.lock());
|
||||||
|
|
||||||
|
@ -1092,9 +1092,9 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_LBUTTONUP => {
|
winuser::WM_LBUTTONUP => {
|
||||||
use event::WindowEvent::MouseInput;
|
use crate::event::WindowEvent::MouseInput;
|
||||||
use event::MouseButton::Left;
|
use crate::event::MouseButton::Left;
|
||||||
use event::ElementState::Released;
|
use crate::event::ElementState::Released;
|
||||||
|
|
||||||
release_mouse(&mut *subclass_input.window_state.lock());
|
release_mouse(&mut *subclass_input.window_state.lock());
|
||||||
|
|
||||||
|
@ -1106,9 +1106,9 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_RBUTTONDOWN => {
|
winuser::WM_RBUTTONDOWN => {
|
||||||
use event::WindowEvent::MouseInput;
|
use crate::event::WindowEvent::MouseInput;
|
||||||
use event::MouseButton::Right;
|
use crate::event::MouseButton::Right;
|
||||||
use event::ElementState::Pressed;
|
use crate::event::ElementState::Pressed;
|
||||||
|
|
||||||
capture_mouse(window, &mut *subclass_input.window_state.lock());
|
capture_mouse(window, &mut *subclass_input.window_state.lock());
|
||||||
|
|
||||||
|
@ -1120,9 +1120,9 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_RBUTTONUP => {
|
winuser::WM_RBUTTONUP => {
|
||||||
use event::WindowEvent::MouseInput;
|
use crate::event::WindowEvent::MouseInput;
|
||||||
use event::MouseButton::Right;
|
use crate::event::MouseButton::Right;
|
||||||
use event::ElementState::Released;
|
use crate::event::ElementState::Released;
|
||||||
|
|
||||||
release_mouse(&mut *subclass_input.window_state.lock());
|
release_mouse(&mut *subclass_input.window_state.lock());
|
||||||
|
|
||||||
|
@ -1134,9 +1134,9 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_MBUTTONDOWN => {
|
winuser::WM_MBUTTONDOWN => {
|
||||||
use event::WindowEvent::MouseInput;
|
use crate::event::WindowEvent::MouseInput;
|
||||||
use event::MouseButton::Middle;
|
use crate::event::MouseButton::Middle;
|
||||||
use event::ElementState::Pressed;
|
use crate::event::ElementState::Pressed;
|
||||||
|
|
||||||
capture_mouse(window, &mut *subclass_input.window_state.lock());
|
capture_mouse(window, &mut *subclass_input.window_state.lock());
|
||||||
|
|
||||||
|
@ -1148,9 +1148,9 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_MBUTTONUP => {
|
winuser::WM_MBUTTONUP => {
|
||||||
use event::WindowEvent::MouseInput;
|
use crate::event::WindowEvent::MouseInput;
|
||||||
use event::MouseButton::Middle;
|
use crate::event::MouseButton::Middle;
|
||||||
use event::ElementState::Released;
|
use crate::event::ElementState::Released;
|
||||||
|
|
||||||
release_mouse(&mut *subclass_input.window_state.lock());
|
release_mouse(&mut *subclass_input.window_state.lock());
|
||||||
|
|
||||||
|
@ -1162,9 +1162,9 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_XBUTTONDOWN => {
|
winuser::WM_XBUTTONDOWN => {
|
||||||
use event::WindowEvent::MouseInput;
|
use crate::event::WindowEvent::MouseInput;
|
||||||
use event::MouseButton::Other;
|
use crate::event::MouseButton::Other;
|
||||||
use event::ElementState::Pressed;
|
use crate::event::ElementState::Pressed;
|
||||||
let xbutton = winuser::GET_XBUTTON_WPARAM(wparam);
|
let xbutton = winuser::GET_XBUTTON_WPARAM(wparam);
|
||||||
|
|
||||||
capture_mouse(window, &mut *subclass_input.window_state.lock());
|
capture_mouse(window, &mut *subclass_input.window_state.lock());
|
||||||
|
@ -1177,9 +1177,9 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_XBUTTONUP => {
|
winuser::WM_XBUTTONUP => {
|
||||||
use event::WindowEvent::MouseInput;
|
use crate::event::WindowEvent::MouseInput;
|
||||||
use event::MouseButton::Other;
|
use crate::event::MouseButton::Other;
|
||||||
use event::ElementState::Released;
|
use crate::event::ElementState::Released;
|
||||||
let xbutton = winuser::GET_XBUTTON_WPARAM(wparam);
|
let xbutton = winuser::GET_XBUTTON_WPARAM(wparam);
|
||||||
|
|
||||||
release_mouse(&mut *subclass_input.window_state.lock());
|
release_mouse(&mut *subclass_input.window_state.lock());
|
||||||
|
@ -1207,9 +1207,9 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_INPUT => {
|
winuser::WM_INPUT => {
|
||||||
use event::DeviceEvent::{Motion, MouseMotion, MouseWheel, Button, Key};
|
use crate::event::DeviceEvent::{Motion, MouseMotion, MouseWheel, Button, Key};
|
||||||
use event::MouseScrollDelta::LineDelta;
|
use crate::event::MouseScrollDelta::LineDelta;
|
||||||
use event::ElementState::{Pressed, Released};
|
use crate::event::ElementState::{Pressed, Released};
|
||||||
|
|
||||||
if let Some(data) = get_raw_input_data(lparam as _) {
|
if let Some(data) = get_raw_input_data(lparam as _) {
|
||||||
let device_id = wrap_device_id(data.header.hDevice as _);
|
let device_id = wrap_device_id(data.header.hDevice as _);
|
||||||
|
@ -1351,7 +1351,7 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
}
|
}
|
||||||
|
|
||||||
winuser::WM_SETFOCUS => {
|
winuser::WM_SETFOCUS => {
|
||||||
use event::WindowEvent::Focused;
|
use crate::event::WindowEvent::Focused;
|
||||||
subclass_input.send_event(Event::WindowEvent {
|
subclass_input.send_event(Event::WindowEvent {
|
||||||
window_id: RootWindowId(WindowId(window)),
|
window_id: RootWindowId(WindowId(window)),
|
||||||
event: Focused(true),
|
event: Focused(true),
|
||||||
|
@ -1361,7 +1361,7 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
},
|
},
|
||||||
|
|
||||||
winuser::WM_KILLFOCUS => {
|
winuser::WM_KILLFOCUS => {
|
||||||
use event::WindowEvent::Focused;
|
use crate::event::WindowEvent::Focused;
|
||||||
subclass_input.send_event(Event::WindowEvent {
|
subclass_input.send_event(Event::WindowEvent {
|
||||||
window_id: RootWindowId(WindowId(window)),
|
window_id: RootWindowId(WindowId(window)),
|
||||||
event: Focused(false),
|
event: Focused(false),
|
||||||
|
@ -1423,7 +1423,7 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
// Only sent on Windows 8.1 or newer. On Windows 7 and older user has to log out to change
|
// Only sent on Windows 8.1 or newer. On Windows 7 and older user has to log out to change
|
||||||
// DPI, therefore all applications are closed while DPI is changing.
|
// DPI, therefore all applications are closed while DPI is changing.
|
||||||
winuser::WM_DPICHANGED => {
|
winuser::WM_DPICHANGED => {
|
||||||
use event::WindowEvent::HiDpiFactorChanged;
|
use crate::event::WindowEvent::HiDpiFactorChanged;
|
||||||
|
|
||||||
// This message actually provides two DPI values - x and y. However MSDN says that
|
// This message actually provides two DPI values - x and y. However MSDN says that
|
||||||
// "you only need to use either the X-axis or the Y-axis value when scaling your
|
// "you only need to use either the X-axis or the Y-axis value when scaling your
|
||||||
|
@ -1473,7 +1473,7 @@ unsafe extern "system" fn public_window_callback<T>(
|
||||||
window_state.set_window_flags_in_place(|f| f.set(WindowFlags::MARKER_RETAIN_STATE_ON_SIZE, wparam != 0));
|
window_state.set_window_flags_in_place(|f| f.set(WindowFlags::MARKER_RETAIN_STATE_ON_SIZE, wparam != 0));
|
||||||
0
|
0
|
||||||
} else if msg == *INITIAL_DPI_MSG_ID {
|
} else if msg == *INITIAL_DPI_MSG_ID {
|
||||||
use event::WindowEvent::HiDpiFactorChanged;
|
use crate::event::WindowEvent::HiDpiFactorChanged;
|
||||||
let scale_factor = dpi_to_scale_factor(wparam as u32);
|
let scale_factor = dpi_to_scale_factor(wparam as u32);
|
||||||
subclass_input.send_event(Event::WindowEvent {
|
subclass_input.send_event(Event::WindowEvent {
|
||||||
window_id: RootWindowId(WindowId(window)),
|
window_id: RootWindowId(WindowId(window)),
|
||||||
|
|
|
@ -7,7 +7,7 @@ use winapi::shared::minwindef::{BYTE, LPARAM, WPARAM};
|
||||||
use winapi::shared::windef::{HICON, HWND};
|
use winapi::shared::windef::{HICON, HWND};
|
||||||
use winapi::um::winuser;
|
use winapi::um::winuser;
|
||||||
|
|
||||||
use icon::{Pixel, PIXEL_SIZE, Icon};
|
use crate::icon::{Pixel, PIXEL_SIZE, Icon};
|
||||||
|
|
||||||
impl Pixel {
|
impl Pixel {
|
||||||
fn to_bgra(&mut self) {
|
fn to_bgra(&mut self) {
|
||||||
|
|
|
@ -7,8 +7,8 @@ pub use self::event_loop::{EventLoop, EventLoopWindowTarget, EventLoopProxy};
|
||||||
pub use self::monitor::MonitorHandle;
|
pub use self::monitor::MonitorHandle;
|
||||||
pub use self::window::Window;
|
pub use self::window::Window;
|
||||||
|
|
||||||
use window::Icon;
|
use crate::window::Icon;
|
||||||
use event::DeviceId as RootDeviceId;
|
use crate::event::DeviceId as RootDeviceId;
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
pub struct PlatformSpecificWindowBuilderAttributes {
|
pub struct PlatformSpecificWindowBuilderAttributes {
|
||||||
|
|
|
@ -7,10 +7,10 @@ use std::collections::{HashSet, VecDeque};
|
||||||
use std::{io, mem, ptr};
|
use std::{io, mem, ptr};
|
||||||
|
|
||||||
use super::{util, EventLoop};
|
use super::{util, EventLoop};
|
||||||
use dpi::{PhysicalPosition, PhysicalSize};
|
use crate::dpi::{PhysicalPosition, PhysicalSize};
|
||||||
use monitor::VideoMode;
|
use crate::monitor::VideoMode;
|
||||||
use platform_impl::platform::dpi::{dpi_to_scale_factor, get_monitor_dpi};
|
use crate::platform_impl::platform::dpi::{dpi_to_scale_factor, get_monitor_dpi};
|
||||||
use platform_impl::platform::window::Window;
|
use crate::platform_impl::platform::window::Window;
|
||||||
|
|
||||||
/// Win32 implementation of the main `MonitorHandle` object.
|
/// Win32 implementation of the main `MonitorHandle` object.
|
||||||
#[derive(Derivative)]
|
#[derive(Derivative)]
|
||||||
|
|
|
@ -31,8 +31,8 @@ use winapi::um::winuser::{
|
||||||
RID_INPUT,
|
RID_INPUT,
|
||||||
};
|
};
|
||||||
|
|
||||||
use platform_impl::platform::util;
|
use crate::platform_impl::platform::util;
|
||||||
use event::ElementState;
|
use crate::event::ElementState;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn get_raw_input_device_list() -> Option<Vec<RAWINPUTDEVICELIST>> {
|
pub fn get_raw_input_device_list() -> Option<Vec<RAWINPUTDEVICELIST>> {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::{mem, ptr, slice, io};
|
||||||
use std::ops::BitAnd;
|
use std::ops::BitAnd;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
|
||||||
use window::CursorIcon;
|
use crate::window::CursorIcon;
|
||||||
use winapi::ctypes::wchar_t;
|
use winapi::ctypes::wchar_t;
|
||||||
use winapi::shared::minwindef::{BOOL, DWORD};
|
use winapi::shared::minwindef::{BOOL, DWORD};
|
||||||
use winapi::shared::windef::{HWND, POINT, RECT};
|
use winapi::shared::windef::{HWND, POINT, RECT};
|
||||||
|
|
|
@ -18,11 +18,11 @@ use winapi::um::wingdi::{CreateRectRgn, DeleteObject};
|
||||||
use winapi::um::oleidl::LPDROPTARGET;
|
use winapi::um::oleidl::LPDROPTARGET;
|
||||||
use winapi::um::winnt::{LONG, LPCWSTR};
|
use winapi::um::winnt::{LONG, LPCWSTR};
|
||||||
|
|
||||||
use window::{Icon, CursorIcon, WindowAttributes};
|
use crate::window::{Icon, CursorIcon, WindowAttributes};
|
||||||
use error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
use crate::error::{ExternalError, NotSupportedError, OsError as RootOsError};
|
||||||
use dpi::{LogicalPosition, LogicalSize, PhysicalSize};
|
use crate::dpi::{LogicalPosition, LogicalSize, PhysicalSize};
|
||||||
use monitor::MonitorHandle as RootMonitorHandle;
|
use crate::monitor::MonitorHandle as RootMonitorHandle;
|
||||||
use platform_impl::platform::{
|
use crate::platform_impl::platform::{
|
||||||
{PlatformSpecificWindowBuilderAttributes, WindowId},
|
{PlatformSpecificWindowBuilderAttributes, WindowId},
|
||||||
dpi::{dpi_to_scale_factor, hwnd_dpi},
|
dpi::{dpi_to_scale_factor, hwnd_dpi},
|
||||||
drop_handler::FileDropHandler,
|
drop_handler::FileDropHandler,
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use monitor::MonitorHandle;
|
use crate::monitor::MonitorHandle;
|
||||||
use window::{CursorIcon, WindowAttributes};
|
use crate::window::{CursorIcon, WindowAttributes};
|
||||||
use std::{io, ptr};
|
use std::{io, ptr};
|
||||||
use parking_lot::MutexGuard;
|
use parking_lot::MutexGuard;
|
||||||
use dpi::LogicalSize;
|
use crate::dpi::LogicalSize;
|
||||||
use platform_impl::platform::{util, event_loop};
|
use crate::platform_impl::platform::{util, event_loop};
|
||||||
use platform_impl::platform::icon::WinIcon;
|
use crate::platform_impl::platform::icon::WinIcon;
|
||||||
use winapi::shared::windef::{RECT, HWND};
|
use winapi::shared::windef::{RECT, HWND};
|
||||||
use winapi::shared::minwindef::DWORD;
|
use winapi::shared::minwindef::DWORD;
|
||||||
use winapi::um::winuser;
|
use winapi::um::winuser;
|
||||||
|
@ -113,7 +113,7 @@ impl WindowState {
|
||||||
self.window_flags
|
self.window_flags
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_window_flags<F>(mut this: MutexGuard<Self>, window: HWND, set_client_rect: Option<RECT>, f: F)
|
pub fn set_window_flags<F>(mut this: MutexGuard<'_, Self>, window: HWND, set_client_rect: Option<RECT>, f: F)
|
||||||
where F: FnOnce(&mut WindowFlags)
|
where F: FnOnce(&mut WindowFlags)
|
||||||
{
|
{
|
||||||
let old_flags = this.window_flags;
|
let old_flags = this.window_flags;
|
||||||
|
@ -127,7 +127,7 @@ impl WindowState {
|
||||||
old_flags.apply_diff(window, new_flags, set_client_rect);
|
old_flags.apply_diff(window, new_flags, set_client_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn refresh_window_state(this: MutexGuard<Self>, window: HWND, set_client_rect: Option<RECT>) {
|
pub fn refresh_window_state(this: MutexGuard<'_, Self>, window: HWND, set_client_rect: Option<RECT>) {
|
||||||
Self::set_window_flags(this, window, set_client_rect, |_| ());
|
Self::set_window_flags(this, window, set_client_rect, |_| ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
//! The `Window` struct and associated types.
|
//! The `Window` struct and associated types.
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use platform_impl;
|
use crate::platform_impl;
|
||||||
use error::{ExternalError, NotSupportedError, OsError};
|
use crate::error::{ExternalError, NotSupportedError, OsError};
|
||||||
use event_loop::EventLoopWindowTarget;
|
use crate::event_loop::EventLoopWindowTarget;
|
||||||
use monitor::{AvailableMonitorsIter, MonitorHandle};
|
use crate::monitor::{AvailableMonitorsIter, MonitorHandle};
|
||||||
use dpi::{LogicalPosition, LogicalSize};
|
use crate::dpi::{LogicalPosition, LogicalSize};
|
||||||
|
|
||||||
pub use icon::*;
|
pub use crate::icon::*;
|
||||||
|
|
||||||
/// Represents a window.
|
/// Represents a window.
|
||||||
///
|
///
|
||||||
|
@ -35,7 +35,7 @@ pub struct Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for Window {
|
impl fmt::Debug for Window {
|
||||||
fn fmt(&self, fmtr: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmtr: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
fmtr.pad("Window { .. }")
|
fmtr.pad("Window { .. }")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ pub struct WindowBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for WindowBuilder {
|
impl fmt::Debug for WindowBuilder {
|
||||||
fn fmt(&self, fmtr: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmtr: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
fmtr.debug_struct("WindowBuilder")
|
fmtr.debug_struct("WindowBuilder")
|
||||||
.field("window", &self.window)
|
.field("window", &self.window)
|
||||||
.finish()
|
.finish()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
extern crate winit;
|
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn needs_send<T:Send>() {}
|
fn needs_send<T:Send>() {}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
#![cfg(feature = "serde")]
|
#![cfg(feature = "serde")]
|
||||||
|
|
||||||
extern crate serde;
|
|
||||||
extern crate winit;
|
|
||||||
|
|
||||||
use winit::window::{CursorIcon};
|
use winit::window::{CursorIcon};
|
||||||
use winit::event::{
|
use winit::event::{
|
||||||
KeyboardInput, TouchPhase, ElementState, MouseButton, MouseScrollDelta, VirtualKeyCode,
|
KeyboardInput, TouchPhase, ElementState, MouseButton, MouseScrollDelta, VirtualKeyCode,
|
||||||
|
@ -11,6 +8,7 @@ use winit::event::{
|
||||||
use winit::dpi::{LogicalPosition, PhysicalPosition, LogicalSize, PhysicalSize};
|
use winit::dpi::{LogicalPosition, PhysicalPosition, LogicalSize, PhysicalSize};
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn needs_serde<S: Serialize + Deserialize<'static>>() {}
|
fn needs_serde<S: Serialize + Deserialize<'static>>() {}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
extern crate winit;
|
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
fn needs_sync<T:Sync>() {}
|
fn needs_sync<T:Sync>() {}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue