x11: port to evl2 with stubs

This commit is contained in:
Victor Berger
2019-04-16 10:42:04 +02:00
parent be372898dd
commit f64edb60cc
10 changed files with 1337 additions and 1279 deletions

View File

@@ -15,15 +15,15 @@ use platform_impl::{
EventLoop as LinuxEventLoop,
Window as LinuxWindow,
};
//use platform_impl::x11::XConnection;
//use platform_impl::x11::ffi::XVisualInfo;
//
use platform_impl::x11::XConnection;
use platform_impl::x11::ffi::XVisualInfo;
// TODO: stupid hack so that glutin can do its work
//#[doc(hidden)]
//pub use platform_impl::x11;
//
//pub use platform_impl::XNotSupported;
//pub use platform_impl::x11::util::WindowType as XWindowType;
#[doc(hidden)]
pub use platform_impl::x11;
pub use platform_impl::XNotSupported;
pub use platform_impl::x11::util::WindowType as XWindowType;
/// Theme for wayland client side decorations
///
@@ -96,8 +96,8 @@ impl Theme for WaylandThemeObject {
/// Additional methods on `EventLoop` that are specific to Unix.
pub trait EventLoopExtUnix {
/// Builds a new `EventLoops` that is forced to use X11.
//fn new_x11() -> Result<Self, XNotSupported>
// where Self: Sized;
fn new_x11() -> Result<Self, XNotSupported>
where Self: Sized;
/// Builds a new `EventLoop` that is forced to use Wayland.
fn new_wayland() -> Self
@@ -109,8 +109,8 @@ pub trait EventLoopExtUnix {
/// True if the `EventLoop` uses X11.
fn is_x11(&self) -> bool;
//#[doc(hidden)]
//fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>>;
#[doc(hidden)]
fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>>;
/// Returns a pointer to the `wl_display` object of wayland that is used by this `EventsLoop`.
///
@@ -121,15 +121,15 @@ pub trait EventLoopExtUnix {
}
impl<T> EventLoopExtUnix for EventLoop<T> {
//#[inline]
//fn new_x11() -> Result<Self, XNotSupported> {
// LinuxEventLoop::new_x11().map(|ev|
// EventLoop {
// event_loop: ev,
// _marker: ::std::marker::PhantomData,
// }
// )
//}
#[inline]
fn new_x11() -> Result<Self, XNotSupported> {
LinuxEventLoop::new_x11().map(|ev|
EventLoop {
event_loop: ev,
_marker: ::std::marker::PhantomData,
}
)
}
#[inline]
fn new_wayland() -> Self {
@@ -152,11 +152,14 @@ impl<T> EventLoopExtUnix for EventLoop<T> {
!self.event_loop.is_wayland()
}
//#[inline]
//#[doc(hidden)]
//fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>> {
// self.event_loop.x_connection().cloned()
//}
#[inline]
#[doc(hidden)]
fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>> {
match self.event_loop {
LinuxEventLoop::X(ref e) => Some(e.x_connection().clone()),
_ => None
}
}
#[inline]
fn get_wayland_display(&self) -> Option<*mut raw::c_void> {
@@ -183,8 +186,8 @@ pub trait WindowExtUnix {
fn get_xlib_screen_id(&self) -> Option<raw::c_int>;
//#[doc(hidden)]
//fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>>;
#[doc(hidden)]
fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>>;
/// Set window urgency hint (`XUrgencyHint`). Only relevant on X.
fn set_urgent(&self, is_urgent: bool);
@@ -227,7 +230,7 @@ impl WindowExtUnix for Window {
#[inline]
fn get_xlib_window(&self) -> Option<raw::c_ulong> {
match self.window {
//LinuxWindow::X(ref w) => Some(w.get_xlib_window()),
LinuxWindow::X(ref w) => Some(w.get_xlib_window()),
_ => None
}
}
@@ -235,7 +238,7 @@ impl WindowExtUnix for Window {
#[inline]
fn get_xlib_display(&self) -> Option<*mut raw::c_void> {
match self.window {
//LinuxWindow::X(ref w) => Some(w.get_xlib_display()),
LinuxWindow::X(ref w) => Some(w.get_xlib_display()),
_ => None
}
}
@@ -243,33 +246,33 @@ impl WindowExtUnix for Window {
#[inline]
fn get_xlib_screen_id(&self) -> Option<raw::c_int> {
match self.window {
//LinuxWindow::X(ref w) => Some(w.get_xlib_screen_id()),
LinuxWindow::X(ref w) => Some(w.get_xlib_screen_id()),
_ => None
}
}
//#[inline]
//#[doc(hidden)]
//fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>> {
// match self.window {
// //LinuxWindow::X(ref w) => Some(w.get_xlib_xconnection()),
// _ => None
// }
//}
#[inline]
#[doc(hidden)]
fn get_xlib_xconnection(&self) -> Option<Arc<XConnection>> {
match self.window {
LinuxWindow::X(ref w) => Some(w.get_xlib_xconnection()),
_ => None
}
}
#[inline]
fn get_xcb_connection(&self) -> Option<*mut raw::c_void> {
match self.window {
//LinuxWindow::X(ref w) => Some(w.get_xcb_connection()),
LinuxWindow::X(ref w) => Some(w.get_xcb_connection()),
_ => None
}
}
#[inline]
fn set_urgent(&self, is_urgent: bool) {
//if let LinuxWindow::X(ref w) = self.window {
// w.set_urgent(is_urgent);
//}
if let LinuxWindow::X(ref w) = self.window {
w.set_urgent(is_urgent);
}
}
#[inline]
@@ -312,7 +315,7 @@ pub trait WindowBuilderExtUnix {
/// Build window with override-redirect flag; defaults to false. Only relevant on X11.
fn with_override_redirect(self, override_redirect: bool) -> WindowBuilder;
/// Build window with `_NET_WM_WINDOW_TYPE` hint; defaults to `Normal`. Only relevant on X11.
//fn with_x11_window_type(self, x11_window_type: XWindowType) -> WindowBuilder;
fn with_x11_window_type(self, x11_window_type: XWindowType) -> WindowBuilder;
/// Build window with `_GTK_THEME_VARIANT` hint set to the specified value. Currently only relevant on X11.
fn with_gtk_theme_variant(self, variant: String) -> WindowBuilder;
/// Build window with resize increment hint. Only implemented on X11.
@@ -331,9 +334,9 @@ pub trait WindowBuilderExtUnix {
impl WindowBuilderExtUnix for WindowBuilder {
#[inline]
fn with_x11_visual<T>(mut self, visual_infos: *const T) -> WindowBuilder {
//self.platform_specific.visual_infos = Some(
// unsafe { ptr::read(visual_infos as *const XVisualInfo) }
//);
self.platform_specific.visual_infos = Some(
unsafe { ptr::read(visual_infos as *const XVisualInfo) }
);
self
}
@@ -355,11 +358,11 @@ impl WindowBuilderExtUnix for WindowBuilder {
self
}
//#[inline]
//fn with_x11_window_type(mut self, x11_window_type: XWindowType) -> WindowBuilder {
// self.platform_specific.x11_window_type = x11_window_type;
// self
//}
#[inline]
fn with_x11_window_type(mut self, x11_window_type: XWindowType) -> WindowBuilder {
self.platform_specific.x11_window_type = x11_window_type;
self
}
#[inline]
fn with_resize_increments(mut self, increments: LogicalSize) -> WindowBuilder {

View File

@@ -14,13 +14,13 @@ use icon::Icon;
use event_loop::{EventLoopClosed, ControlFlow, EventLoopWindowTarget as RootELW};
use monitor::MonitorHandle as RootMonitorHandle;
use window::{WindowAttributes, CreationError, MouseCursor};
//use self::x11::{XConnection, XError};
//use self::x11::ffi::XVisualInfo;
//pub use self::x11::XNotSupported;
use self::x11::{XConnection, XError};
use self::x11::ffi::XVisualInfo;
pub use self::x11::XNotSupported;
mod dlopen;
pub mod wayland;
//pub mod x11;
pub mod x11;
/// Environment variable specifying which backend should be used on unix platform.
///
@@ -33,31 +33,31 @@ const BACKEND_PREFERENCE_ENV_VAR: &str = "WINIT_UNIX_BACKEND";
#[derive(Clone, Default)]
pub struct PlatformSpecificWindowBuilderAttributes {
//pub visual_infos: Option<XVisualInfo>,
pub visual_infos: Option<XVisualInfo>,
pub screen_id: Option<i32>,
pub resize_increments: Option<(u32, u32)>,
pub base_size: Option<(u32, u32)>,
pub class: Option<(String, String)>,
pub override_redirect: bool,
//pub x11_window_type: x11::util::WindowType,
pub x11_window_type: x11::util::WindowType,
pub gtk_theme_variant: Option<String>,
pub app_id: Option<String>
}
//lazy_static!(
// pub static ref X11_BACKEND: Mutex<Result<Arc<XConnection>, XNotSupported>> = {
// Mutex::new(XConnection::new(Some(x_error_callback)).map(Arc::new))
// };
//);
lazy_static!(
pub static ref X11_BACKEND: Mutex<Result<Arc<XConnection>, XNotSupported>> = {
Mutex::new(XConnection::new(Some(x_error_callback)).map(Arc::new))
};
);
pub enum Window {
//X(x11::Window),
X(x11::Window),
Wayland(wayland::Window),
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum WindowId {
//X(x11::WindowId),
X(x11::WindowId),
Wayland(wayland::WindowId),
}
@@ -69,7 +69,7 @@ impl WindowId {
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum DeviceId {
//X(x11::DeviceId),
X(x11::DeviceId),
Wayland(wayland::DeviceId),
}
@@ -81,7 +81,7 @@ impl DeviceId {
#[derive(Debug, Clone)]
pub enum MonitorHandle {
//X(x11::MonitorHandle),
X(x11::MonitorHandle),
Wayland(wayland::MonitorHandle),
}
@@ -89,7 +89,7 @@ impl MonitorHandle {
#[inline]
pub fn get_name(&self) -> Option<String> {
match self {
//&MonitorHandle::X(ref m) => m.get_name(),
&MonitorHandle::X(ref m) => m.get_name(),
&MonitorHandle::Wayland(ref m) => m.get_name(),
}
}
@@ -97,7 +97,7 @@ impl MonitorHandle {
#[inline]
pub fn get_native_identifier(&self) -> u32 {
match self {
//&MonitorHandle::X(ref m) => m.get_native_identifier(),
&MonitorHandle::X(ref m) => m.get_native_identifier(),
&MonitorHandle::Wayland(ref m) => m.get_native_identifier(),
}
}
@@ -105,7 +105,7 @@ impl MonitorHandle {
#[inline]
pub fn get_dimensions(&self) -> PhysicalSize {
match self {
//&MonitorHandle::X(ref m) => m.get_dimensions(),
&MonitorHandle::X(ref m) => m.get_dimensions(),
&MonitorHandle::Wayland(ref m) => m.get_dimensions(),
}
}
@@ -113,7 +113,7 @@ impl MonitorHandle {
#[inline]
pub fn get_position(&self) -> PhysicalPosition {
match self {
//&MonitorHandle::X(ref m) => m.get_position(),
&MonitorHandle::X(ref m) => m.get_position(),
&MonitorHandle::Wayland(ref m) => m.get_position(),
}
}
@@ -121,7 +121,7 @@ impl MonitorHandle {
#[inline]
pub fn get_hidpi_factor(&self) -> f64 {
match self {
//&MonitorHandle::X(ref m) => m.get_hidpi_factor(),
&MonitorHandle::X(ref m) => m.get_hidpi_factor(),
&MonitorHandle::Wayland(ref m) => m.get_hidpi_factor() as f64,
}
}
@@ -138,16 +138,16 @@ impl Window {
EventLoopWindowTarget::Wayland(ref window_target) => {
wayland::Window::new(window_target, attribs, pl_attribs).map(Window::Wayland)
},
//EventLoop::X(ref event_loop) => {
// x11::Window::new(event_loop, attribs, pl_attribs).map(Window::X)
//},
EventLoopWindowTarget::X(ref window_target) => {
x11::Window::new(window_target, attribs, pl_attribs).map(Window::X)
},
}
}
#[inline]
pub fn id(&self) -> WindowId {
match self {
//&Window::X(ref w) => WindowId::X(w.id()),
&Window::X(ref w) => WindowId::X(w.id()),
&Window::Wayland(ref w) => WindowId::Wayland(w.id()),
}
}
@@ -155,7 +155,7 @@ impl Window {
#[inline]
pub fn set_title(&self, title: &str) {
match self {
//&Window::X(ref w) => w.set_title(title),
&Window::X(ref w) => w.set_title(title),
&Window::Wayland(ref w) => w.set_title(title),
}
}
@@ -163,7 +163,7 @@ impl Window {
#[inline]
pub fn show(&self) {
match self {
//&Window::X(ref w) => w.show(),
&Window::X(ref w) => w.show(),
&Window::Wayland(ref w) => w.show(),
}
}
@@ -171,7 +171,7 @@ impl Window {
#[inline]
pub fn hide(&self) {
match self {
//&Window::X(ref w) => w.hide(),
&Window::X(ref w) => w.hide(),
&Window::Wayland(ref w) => w.hide(),
}
}
@@ -179,7 +179,7 @@ impl Window {
#[inline]
pub fn get_position(&self) -> Option<LogicalPosition> {
match self {
//&Window::X(ref w) => w.get_position(),
&Window::X(ref w) => w.get_position(),
&Window::Wayland(ref w) => w.get_position(),
}
}
@@ -187,7 +187,7 @@ impl Window {
#[inline]
pub fn get_inner_position(&self) -> Option<LogicalPosition> {
match self {
//&Window::X(ref m) => m.get_inner_position(),
&Window::X(ref m) => m.get_inner_position(),
&Window::Wayland(ref m) => m.get_inner_position(),
}
}
@@ -195,7 +195,7 @@ impl Window {
#[inline]
pub fn set_position(&self, position: LogicalPosition) {
match self {
//&Window::X(ref w) => w.set_position(position),
&Window::X(ref w) => w.set_position(position),
&Window::Wayland(ref w) => w.set_position(position),
}
}
@@ -203,7 +203,7 @@ impl Window {
#[inline]
pub fn get_inner_size(&self) -> Option<LogicalSize> {
match self {
//&Window::X(ref w) => w.get_inner_size(),
&Window::X(ref w) => w.get_inner_size(),
&Window::Wayland(ref w) => w.get_inner_size(),
}
}
@@ -211,7 +211,7 @@ impl Window {
#[inline]
pub fn get_outer_size(&self) -> Option<LogicalSize> {
match self {
//&Window::X(ref w) => w.get_outer_size(),
&Window::X(ref w) => w.get_outer_size(),
&Window::Wayland(ref w) => w.get_outer_size(),
}
}
@@ -219,7 +219,7 @@ impl Window {
#[inline]
pub fn set_inner_size(&self, size: LogicalSize) {
match self {
//&Window::X(ref w) => w.set_inner_size(size),
&Window::X(ref w) => w.set_inner_size(size),
&Window::Wayland(ref w) => w.set_inner_size(size),
}
}
@@ -227,7 +227,7 @@ impl Window {
#[inline]
pub fn set_min_dimensions(&self, dimensions: Option<LogicalSize>) {
match self {
//&Window::X(ref w) => w.set_min_dimensions(dimensions),
&Window::X(ref w) => w.set_min_dimensions(dimensions),
&Window::Wayland(ref w) => w.set_min_dimensions(dimensions),
}
}
@@ -235,7 +235,7 @@ impl Window {
#[inline]
pub fn set_max_dimensions(&self, dimensions: Option<LogicalSize>) {
match self {
//&Window::X(ref w) => w.set_max_dimensions(dimensions),
&Window::X(ref w) => w.set_max_dimensions(dimensions),
&Window::Wayland(ref w) => w.set_max_dimensions(dimensions),
}
}
@@ -243,7 +243,7 @@ impl Window {
#[inline]
pub fn set_resizable(&self, resizable: bool) {
match self {
//&Window::X(ref w) => w.set_resizable(resizable),
&Window::X(ref w) => w.set_resizable(resizable),
&Window::Wayland(ref w) => w.set_resizable(resizable),
}
}
@@ -251,7 +251,7 @@ impl Window {
#[inline]
pub fn set_cursor(&self, cursor: MouseCursor) {
match self {
//&Window::X(ref w) => w.set_cursor(cursor),
&Window::X(ref w) => w.set_cursor(cursor),
&Window::Wayland(ref w) => w.set_cursor(cursor)
}
}
@@ -259,7 +259,7 @@ impl Window {
#[inline]
pub fn grab_cursor(&self, grab: bool) -> Result<(), String> {
match self {
//&Window::X(ref window) => window.grab_cursor(grab),
&Window::X(ref window) => window.grab_cursor(grab),
&Window::Wayland(ref window) => window.grab_cursor(grab),
}
}
@@ -267,7 +267,7 @@ impl Window {
#[inline]
pub fn hide_cursor(&self, hide: bool) {
match self {
//&Window::X(ref window) => window.hide_cursor(hide),
&Window::X(ref window) => window.hide_cursor(hide),
&Window::Wayland(ref window) => window.hide_cursor(hide),
}
}
@@ -275,7 +275,7 @@ impl Window {
#[inline]
pub fn get_hidpi_factor(&self) -> f64 {
match self {
//&Window::X(ref w) => w.get_hidpi_factor(),
&Window::X(ref w) => w.get_hidpi_factor(),
&Window::Wayland(ref w) => w.hidpi_factor() as f64,
}
}
@@ -283,7 +283,7 @@ impl Window {
#[inline]
pub fn set_cursor_position(&self, position: LogicalPosition) -> Result<(), String> {
match self {
//&Window::X(ref w) => w.set_cursor_position(position),
&Window::X(ref w) => w.set_cursor_position(position),
&Window::Wayland(ref w) => w.set_cursor_position(position),
}
}
@@ -291,7 +291,7 @@ impl Window {
#[inline]
pub fn set_maximized(&self, maximized: bool) {
match self {
//&Window::X(ref w) => w.set_maximized(maximized),
&Window::X(ref w) => w.set_maximized(maximized),
&Window::Wayland(ref w) => w.set_maximized(maximized),
}
}
@@ -299,7 +299,7 @@ impl Window {
#[inline]
pub fn set_fullscreen(&self, monitor: Option<RootMonitorHandle>) {
match self {
//&Window::X(ref w) => w.set_fullscreen(monitor),
&Window::X(ref w) => w.set_fullscreen(monitor),
&Window::Wayland(ref w) => w.set_fullscreen(monitor)
}
}
@@ -307,7 +307,7 @@ impl Window {
#[inline]
pub fn set_decorations(&self, decorations: bool) {
match self {
//&Window::X(ref w) => w.set_decorations(decorations),
&Window::X(ref w) => w.set_decorations(decorations),
&Window::Wayland(ref w) => w.set_decorations(decorations)
}
}
@@ -315,7 +315,7 @@ impl Window {
#[inline]
pub fn set_always_on_top(&self, always_on_top: bool) {
match self {
//&Window::X(ref w) => w.set_always_on_top(always_on_top),
&Window::X(ref w) => w.set_always_on_top(always_on_top),
&Window::Wayland(_) => (),
}
}
@@ -323,7 +323,7 @@ impl Window {
#[inline]
pub fn set_window_icon(&self, window_icon: Option<Icon>) {
match self {
//&Window::X(ref w) => w.set_window_icon(window_icon),
&Window::X(ref w) => w.set_window_icon(window_icon),
&Window::Wayland(_) => (),
}
}
@@ -331,7 +331,7 @@ impl Window {
#[inline]
pub fn set_ime_spot(&self, position: LogicalPosition) {
match self {
//&Window::X(ref w) => w.set_ime_spot(position),
&Window::X(ref w) => w.set_ime_spot(position),
&Window::Wayland(_) => (),
}
}
@@ -339,7 +339,7 @@ impl Window {
#[inline]
pub fn request_redraw(&self) {
match self {
//&Window::X(ref w) => w.request_redraw(),
&Window::X(ref w) => w.request_redraw(),
&Window::Wayland(ref w) => w.request_redraw(),
}
}
@@ -347,7 +347,7 @@ impl Window {
#[inline]
pub fn get_current_monitor(&self) -> RootMonitorHandle {
match self {
//&Window::X(ref window) => RootMonitorHandle { inner: MonitorHandle::X(window.get_current_monitor()) },
&Window::X(ref window) => RootMonitorHandle { inner: MonitorHandle::X(window.get_current_monitor()) },
&Window::Wayland(ref window) => RootMonitorHandle { inner: MonitorHandle::Wayland(window.get_current_monitor()) },
}
}
@@ -355,10 +355,10 @@ impl Window {
#[inline]
pub fn get_available_monitors(&self) -> VecDeque<MonitorHandle> {
match self {
//&Window::X(ref window) => window.get_available_monitors()
// .into_iter()
// .map(MonitorHandle::X)
// .collect(),
&Window::X(ref window) => window.get_available_monitors()
.into_iter()
.map(MonitorHandle::X)
.collect(),
&Window::Wayland(ref window) => window.get_available_monitors()
.into_iter()
.map(MonitorHandle::Wayland)
@@ -369,13 +369,13 @@ impl Window {
#[inline]
pub fn get_primary_monitor(&self) -> MonitorHandle {
match self {
//&Window::X(ref window) => MonitorHandle::X(window.get_primary_monitor()),
&Window::X(ref window) => MonitorHandle::X(window.get_primary_monitor()),
&Window::Wayland(ref window) => MonitorHandle::Wayland(window.get_primary_monitor()),
}
}
}
/*
unsafe extern "C" fn x_error_callback(
display: *mut x11::ffi::Display,
event: *mut x11::ffi::XErrorEvent,
@@ -405,16 +405,16 @@ unsafe extern "C" fn x_error_callback(
// Fun fact: this return value is completely ignored.
0
}
*/
pub enum EventLoop<T: 'static> {
Wayland(wayland::EventLoop<T>),
//X(x11::EventLoop)
X(x11::EventLoop<T>)
}
#[derive(Clone)]
pub enum EventLoopProxy<T: 'static> {
//X(x11::EventLoopProxy),
X(x11::EventLoopProxy<T>),
Wayland(wayland::EventLoopProxy<T>),
}
@@ -460,15 +460,14 @@ impl<T:'static> EventLoop<T> {
.map(EventLoop::Wayland)
}
pub fn new_x11() -> Result<EventLoop<T>, () /*XNotSupported*/> {
//X11_BACKEND
// .lock()
// .as_ref()
// .map(Arc::clone)
// .map(x11::EventLoop::new)
// .map(EventLoop::X)
// .map_err(|err| err.clone())
unimplemented!()
pub fn new_x11() -> Result<EventLoop<T>, XNotSupported> {
X11_BACKEND
.lock()
.as_ref()
.map(Arc::clone)
.map(x11::EventLoop::new)
.map(EventLoop::X)
.map_err(|err| err.clone())
}
#[inline]
@@ -479,12 +478,12 @@ impl<T:'static> EventLoop<T> {
.into_iter()
.map(MonitorHandle::Wayland)
.collect(),
//EventLoop::X(ref evlp) => evlp
// .x_connection()
// .get_available_monitors()
// .into_iter()
// .map(MonitorHandle::X)
// .collect(),
EventLoop::X(ref evlp) => evlp
.x_connection()
.get_available_monitors()
.into_iter()
.map(MonitorHandle::X)
.collect(),
}
}
@@ -492,14 +491,14 @@ impl<T:'static> EventLoop<T> {
pub fn get_primary_monitor(&self) -> MonitorHandle {
match *self {
EventLoop::Wayland(ref evlp) => MonitorHandle::Wayland(evlp.get_primary_monitor()),
//EventLoop::X(ref evlp) => MonitorHandle::X(evlp.x_connection().get_primary_monitor()),
EventLoop::X(ref evlp) => MonitorHandle::X(evlp.x_connection().get_primary_monitor()),
}
}
pub fn create_proxy(&self) -> EventLoopProxy<T> {
match *self {
EventLoop::Wayland(ref evlp) => EventLoopProxy::Wayland(evlp.create_proxy()),
//EventLoop::X(ref evlp) => EventLoopProxy::X(evlp.create_proxy()),
EventLoop::X(ref evlp) => EventLoopProxy::X(evlp.create_proxy()),
}
}
@@ -508,7 +507,7 @@ impl<T:'static> EventLoop<T> {
{
match *self {
EventLoop::Wayland(ref mut evlp) => evlp.run_return(callback),
//EventLoop::X(ref mut evlp) => evlp.run_return(callback)
EventLoop::X(ref mut evlp) => evlp.run_return(callback)
}
}
@@ -517,7 +516,7 @@ impl<T:'static> EventLoop<T> {
{
match self {
EventLoop::Wayland(evlp) => evlp.run(callback),
//EventLoop::X(ref mut evlp) => evlp.run(callback)
EventLoop::X(evlp) => evlp.run(callback)
}
}
@@ -525,36 +524,28 @@ impl<T:'static> EventLoop<T> {
pub fn is_wayland(&self) -> bool {
match *self {
EventLoop::Wayland(_) => true,
//EventLoop::X(_) => false,
EventLoop::X(_) => false,
}
}
pub fn window_target(&self) -> &::event_loop::EventLoopWindowTarget<T> {
match *self {
EventLoop::Wayland(ref evl) => evl.window_target(),
//EventLoop::X(ref evl) => evl.window_target()
EventLoop::X(ref evl) => evl.window_target()
}
}
//#[inline]
//pub fn x_connection(&self) -> Option<&Arc<XConnection>> {
// match *self {
// EventLoop::Wayland(_) => None,
// EventLoop::X(ref ev) => Some(ev.x_connection()),
// }
//}
}
impl<T: 'static> EventLoopProxy<T> {
pub fn send_event(&self, event: T) -> Result<(), EventLoopClosed> {
match *self {
EventLoopProxy::Wayland(ref proxy) => proxy.send_event(event),
//EventLoopProxy::X(ref proxy) => proxy.wakeup(),
EventLoopProxy::X(ref proxy) => proxy.send_event(event),
}
}
}
pub enum EventLoopWindowTarget<T> {
Wayland(wayland::EventLoopWindowTarget<T>),
//X(x11::EventLoopWIndowTarget<T>)
X(x11::EventLoopWindowTarget<T>)
}

File diff suppressed because it is too large Load Diff

View File

@@ -31,50 +31,47 @@ use std::sync::atomic::{self, AtomicBool};
use libc::{self, setlocale, LC_CTYPE};
use {
ControlFlow,
CreationError,
DeviceEvent,
Event,
EventLoopClosed,
KeyboardInput,
LogicalPosition,
LogicalSize,
WindowAttributes,
WindowEvent,
};
use events::ModifiersState;
use event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootELW};
use event::{DeviceEvent, Event, KeyboardInput, ModifiersState, WindowEvent};
use platform_impl::PlatformSpecificWindowBuilderAttributes;
use dpi::{LogicalPosition,LogicalSize};
use window::{CreationError, WindowAttributes};
use self::dnd::{Dnd, DndState};
use self::ime::{ImeReceiver, ImeSender, ImeCreationError, Ime};
pub struct EventLoop {
pub struct EventLoopWindowTarget<T> {
xconn: Arc<XConnection>,
wm_delete_window: ffi::Atom,
ime_sender: ImeSender,
root: ffi::Window,
ime: RefCell<Ime>,
windows: RefCell<HashMap<WindowId, Weak<UnownedWindow>>>,
_marker: ::std::marker::PhantomData<T>
}
pub struct EventLoop<T: 'static> {
dnd: Dnd,
ime_receiver: ImeReceiver,
ime_sender: ImeSender,
ime: RefCell<Ime>,
randr_event_offset: c_int,
windows: RefCell<HashMap<WindowId, Weak<UnownedWindow>>>,
devices: RefCell<HashMap<DeviceId, Device>>,
xi2ext: XExtension,
pending_wakeup: Arc<AtomicBool>,
root: ffi::Window,
// A dummy, `InputOnly` window that we can use to receive wakeup events and interrupt blocking
// `XNextEvent` calls.
wakeup_dummy_window: ffi::Window,
target: RootELW<T>
}
#[derive(Clone)]
pub struct EventLoopProxy {
pub struct EventLoopProxy<T: 'static> {
pending_wakeup: Weak<AtomicBool>,
xconn: Weak<XConnection>,
wakeup_dummy_window: ffi::Window,
_marker: ::std::marker::PhantomData<T>
}
impl EventLoop {
pub fn new(xconn: Arc<XConnection>) -> EventLoop {
impl<T: 'static> EventLoop<T> {
pub fn new(xconn: Arc<XConnection>) -> EventLoop<T> {
let root = unsafe { (xconn.xlib.XDefaultRootWindow)(xconn.display) };
let wm_delete_window = unsafe { xconn.get_atom_unchecked(b"WM_DELETE_WINDOW\0") };
@@ -150,24 +147,30 @@ impl EventLoop {
};
let result = EventLoop {
xconn,
wm_delete_window,
dnd,
ime_receiver,
ime_sender,
ime,
randr_event_offset,
windows: Default::default(),
devices: Default::default(),
xi2ext,
pending_wakeup: Default::default(),
root,
wakeup_dummy_window,
target: RootELW{
p: super::EventLoopWindowTarget::X(EventLoopWindowTarget {
ime,
root,
windows: Default::default(),
_marker: ::std::marker::PhantomData,
ime_sender,
xconn,
wm_delete_window,
}),
_marker: ::std::marker::PhantomData
}
};
// Register for device hotplug events
// (The request buffer is flushed during `init_device`)
result.xconn.select_xinput_events(
get_xtarget(&result.target).xconn.select_xinput_events(
root,
ffi::XIAllDevices,
ffi::XI_HierarchyChangedMask,
@@ -181,18 +184,21 @@ impl EventLoop {
/// Returns the `XConnection` of this events loop.
#[inline]
pub fn x_connection(&self) -> &Arc<XConnection> {
&self.xconn
&get_xtarget(&self.target).xconn
}
pub fn create_proxy(&self) -> EventLoopProxy {
pub fn create_proxy(&self) -> EventLoopProxy<T> {
let wt = get_xtarget(&self.target);
EventLoopProxy {
pending_wakeup: Arc::downgrade(&self.pending_wakeup),
xconn: Arc::downgrade(&self.xconn),
xconn: Arc::downgrade(&wt.xconn),
wakeup_dummy_window: self.wakeup_dummy_window,
_marker: ::std::marker::PhantomData
}
}
unsafe fn poll_one_event(&mut self, event_ptr : *mut ffi::XEvent) -> bool {
let wt = get_xtarget(&self.target);
// This function is used to poll and remove a single event
// from the Xlib event queue in a non-blocking, atomic way.
// XCheckIfEvent is non-blocking and removes events from queue.
@@ -207,8 +213,8 @@ impl EventLoop {
1
}
let result = (self.xconn.xlib.XCheckIfEvent)(
self.xconn.display,
let result = (wt.xconn.xlib.XCheckIfEvent)(
wt.xconn.display,
event_ptr,
Some(predicate),
std::ptr::null_mut());
@@ -217,6 +223,7 @@ impl EventLoop {
}
unsafe fn wait_for_input(&mut self) {
let wt = get_xtarget(&self.target);
// XNextEvent can not be used in multi-threaded applications
// because it is blocking for input while holding the global
// Xlib mutex.
@@ -224,14 +231,14 @@ impl EventLoop {
// use select(2) to wait for input to arrive
loop {
// First use XFlush to flush any buffered x11 requests
(self.xconn.xlib.XFlush)(self.xconn.display);
(wt.xconn.xlib.XFlush)(wt.xconn.display);
// Then use select(2) to wait for input data
let mut fds : fd_set = mem::uninitialized();
FD_ZERO(&mut fds);
FD_SET(self.xconn.x11_fd, &mut fds);
FD_SET(wt.xconn.x11_fd, &mut fds);
let err = select(
self.xconn.x11_fd + 1,
wt.xconn.x11_fd + 1,
&mut fds, // read fds
std::ptr::null_mut(), // write fds
std::ptr::null_mut(), // except fds (could be used to detect errors)
@@ -250,67 +257,21 @@ impl EventLoop {
panic!("select(2) returned fatal error condition");
}
if FD_ISSET(self.xconn.x11_fd, &mut fds) {
break;
}
}
}
pub fn poll_events<F>(&mut self, mut callback: F)
where F: FnMut(Event)
{
let mut xev = unsafe { mem::uninitialized() };
loop {
// Get next event
unsafe {
if !self.poll_one_event(&mut xev) {
break;
}
}
self.process_event(&mut xev, &mut callback);
}
}
pub fn run_forever<F>(&mut self, mut callback: F)
where F: FnMut(Event) -> ControlFlow
{
let mut xev = unsafe { mem::uninitialized() };
loop {
unsafe {
while !self.poll_one_event(&mut xev) {
// block until input is available
self.wait_for_input();
}
};
let mut control_flow = ControlFlow::Continue;
// Track whether or not `Break` was returned when processing the event.
{
let mut cb = |event| {
if let ControlFlow::Break = callback(event) {
control_flow = ControlFlow::Break;
}
};
self.process_event(&mut xev, &mut cb);
}
if let ControlFlow::Break = control_flow {
if FD_ISSET(wt.xconn.x11_fd, &mut fds) {
break;
}
}
}
fn process_event<F>(&mut self, xev: &mut ffi::XEvent, mut callback: F)
where F: FnMut(Event)
where F: FnMut(Event<T>)
{
let wt = get_xtarget(&self.target);
// XFilterEvent tells us when an event has been discarded by the input method.
// Specifically, this involves all of the KeyPress events in compose/pre-edit sequences,
// along with an extra copy of the KeyRelease events. This also prevents backspace and
// arrow keys from being detected twice.
if ffi::True == unsafe { (self.xconn.xlib.XFilterEvent)(
if ffi::True == unsafe { (wt.xconn.xlib.XFilterEvent)(
xev,
{ let xev: &ffi::XAnyEvent = xev.as_ref(); xev.window }
) } {
@@ -320,8 +281,8 @@ impl EventLoop {
let event_type = xev.get_type();
match event_type {
ffi::MappingNotify => {
unsafe { (self.xconn.xlib.XRefreshKeyboardMapping)(xev.as_mut()); }
self.xconn.check_errors().expect("Failed to call XRefreshKeyboardMapping");
unsafe { (wt.xconn.xlib.XRefreshKeyboardMapping)(xev.as_mut()); }
wt.xconn.check_errors().expect("Failed to call XRefreshKeyboardMapping");
}
ffi::ClientMessage => {
@@ -330,7 +291,7 @@ impl EventLoop {
let window = client_msg.window;
let window_id = mkwid(window);
if client_msg.data.get_long(0) as ffi::Atom == self.wm_delete_window {
if client_msg.data.get_long(0) as ffi::Atom == wt.wm_delete_window {
callback(Event::WindowEvent { window_id, event: WindowEvent::CloseRequested });
} else if client_msg.message_type == self.dnd.atoms.enter {
let source_window = client_msg.data.get_long(0) as c_ulong;
@@ -433,7 +394,8 @@ impl EventLoop {
});
} else if self.pending_wakeup.load(atomic::Ordering::Relaxed) {
self.pending_wakeup.store(false, atomic::Ordering::Relaxed);
callback(Event::Awakened);
// TODO: User event
// callback(Event::Awakened);
}
}
@@ -519,7 +481,7 @@ impl EventLoop {
.as_ref()
.cloned()
.unwrap_or_else(|| {
let frame_extents = self.xconn.get_frame_extents_heuristic(xwindow, self.root);
let frame_extents = wt.xconn.get_frame_extents_heuristic(xwindow, wt.root);
shared_state_lock.frame_extents = Some(frame_extents.clone());
frame_extents
});
@@ -549,7 +511,7 @@ impl EventLoop {
});
let new_hidpi_factor = {
let window_rect = util::AaRect::new(new_outer_position, new_inner_size);
monitor = self.xconn.get_monitor_for_window(Some(window_rect));
monitor = wt.xconn.get_monitor_for_window(Some(window_rect));
let new_hidpi_factor = monitor.hidpi_factor;
shared_state_lock.last_monitor = Some(monitor.clone());
new_hidpi_factor
@@ -581,8 +543,8 @@ impl EventLoop {
shared_state_lock.dpi_adjusted = None;
} else {
unsafe {
(self.xconn.xlib.XResizeWindow)(
self.xconn.display,
(wt.xconn.xlib.XResizeWindow)(
wt.xconn.display,
xwindow,
rounded_size.0 as c_uint,
rounded_size.1 as c_uint,
@@ -621,7 +583,7 @@ impl EventLoop {
// (which is almost all of them). Failing to correctly update WM info doesn't
// really have much impact, since on the WMs affected (xmonad, dwm, etc.) the only
// effect is that we waste some time trying to query unsupported properties.
self.xconn.update_cached_wm_info(self.root);
wt.xconn.update_cached_wm_info(wt.root);
self.with_window(xev.window, |window| {
window.invalidate_cached_frame_extents();
@@ -636,11 +598,11 @@ impl EventLoop {
// In the event that the window's been destroyed without being dropped first, we
// cleanup again here.
self.windows.borrow_mut().remove(&WindowId(window));
wt.windows.borrow_mut().remove(&WindowId(window));
// Since all XIM stuff needs to happen from the same thread, we destroy the input
// context here instead of when dropping the window.
self.ime
wt.ime
.borrow_mut()
.remove_context(window)
.expect("Failed to destroy input context");
@@ -654,11 +616,11 @@ impl EventLoop {
let window = xev.window;
let window_id = mkwid(window);
callback(Event::WindowEvent { window_id, event: WindowEvent::Redraw });
callback(Event::WindowEvent { window_id, event: WindowEvent::RedrawRequested });
}
ffi::KeyPress | ffi::KeyRelease => {
use events::ElementState::{Pressed, Released};
use event::ElementState::{Pressed, Released};
// Note that in compose/pre-edit sequences, this will always be Released.
let state = if xev.get_type() == ffi::KeyPress {
@@ -689,14 +651,14 @@ impl EventLoop {
let keysym = unsafe {
let mut keysym = 0;
(self.xconn.xlib.XLookupString)(
(wt.xconn.xlib.XLookupString)(
xkev,
ptr::null_mut(),
0,
&mut keysym,
ptr::null_mut(),
);
self.xconn.check_errors().expect("Failed to lookup keysym");
wt.xconn.check_errors().expect("Failed to lookup keysym");
keysym
};
let virtual_keycode = events::keysym_to_element(keysym as c_uint);
@@ -716,8 +678,8 @@ impl EventLoop {
}
if state == Pressed {
let written = if let Some(ic) = self.ime.borrow().get_context(window) {
self.xconn.lookup_utf8(ic, xkev)
let written = if let Some(ic) = wt.ime.borrow().get_context(window) {
wt.xconn.lookup_utf8(ic, xkev)
} else {
return;
};
@@ -733,17 +695,17 @@ impl EventLoop {
}
ffi::GenericEvent => {
let guard = if let Some(e) = GenericEventCookie::from_event(&self.xconn, *xev) { e } else { return };
let guard = if let Some(e) = GenericEventCookie::from_event(&wt.xconn, *xev) { e } else { return };
let xev = &guard.cookie;
if self.xi2ext.opcode != xev.extension {
return;
}
use events::WindowEvent::{Focused, CursorEntered, MouseInput, CursorLeft, CursorMoved, MouseWheel, AxisMotion};
use events::ElementState::{Pressed, Released};
use events::MouseButton::{Left, Right, Middle, Other};
use events::MouseScrollDelta::LineDelta;
use events::{Touch, TouchPhase};
use event::WindowEvent::{Focused, CursorEntered, MouseInput, CursorLeft, CursorMoved, MouseWheel, AxisMotion};
use event::ElementState::{Pressed, Released};
use event::MouseButton::{Left, Right, Middle, Other};
use event::MouseScrollDelta::LineDelta;
use event::{Touch, TouchPhase};
match xev.evtype {
ffi::XI_ButtonPress | ffi::XI_ButtonRelease => {
@@ -917,7 +879,7 @@ impl EventLoop {
let window_id = mkwid(xev.event);
let device_id = mkdid(xev.deviceid);
if let Some(all_info) = DeviceInfo::get(&self.xconn, ffi::XIAllDevices) {
if let Some(all_info) = DeviceInfo::get(&wt.xconn, ffi::XIAllDevices) {
let mut devices = self.devices.borrow_mut();
for device_info in all_info.iter() {
if device_info.deviceid == xev.sourceid
@@ -953,7 +915,7 @@ impl EventLoop {
// This needs to only be done after confirming the window still exists,
// since otherwise we risk getting a `BadWindow` error if the window was
// dropped with queued events.
let modifiers = self.xconn
let modifiers = wt.xconn
.query_pointer(xev.event, xev.deviceid)
.expect("Failed to query pointer device")
.get_modifier_state();
@@ -992,7 +954,7 @@ impl EventLoop {
};
let window_id = mkwid(xev.event);
self.ime
wt.ime
.borrow_mut()
.focus(xev.event)
.expect("Failed to focus input context");
@@ -1023,7 +985,7 @@ impl EventLoop {
ffi::XI_FocusOut => {
let xev: &ffi::XIFocusOutEvent = unsafe { &*(xev.data as *const _) };
if !self.window_exists(xev.event) { return; }
self.ime
wt.ime
.borrow_mut()
.unfocus(xev.event)
.expect("Failed to unfocus input context");
@@ -1130,13 +1092,13 @@ impl EventLoop {
let scancode = (keycode - 8) as u32;
let keysym = unsafe {
(self.xconn.xlib.XKeycodeToKeysym)(
self.xconn.display,
(wt.xconn.xlib.XKeycodeToKeysym)(
wt.xconn.display,
xev.detail as ffi::KeyCode,
0,
)
};
self.xconn.check_errors().expect("Failed to lookup raw keysym");
wt.xconn.check_errors().expect("Failed to lookup raw keysym");
let virtual_keycode = events::keysym_to_element(keysym as c_uint);
@@ -1178,14 +1140,14 @@ impl EventLoop {
// In the future, it would be quite easy to emit monitor hotplug events.
let prev_list = monitor::invalidate_cached_monitor_list();
if let Some(prev_list) = prev_list {
let new_list = self.xconn.get_available_monitors();
let new_list = wt.xconn.get_available_monitors();
for new_monitor in new_list {
prev_list
.iter()
.find(|prev_monitor| prev_monitor.name == new_monitor.name)
.map(|prev_monitor| {
if new_monitor.hidpi_factor != prev_monitor.hidpi_factor {
for (window_id, window) in self.windows.borrow().iter() {
for (window_id, window) in wt.windows.borrow().iter() {
if let Some(window) = window.upgrade() {
// Check if the window is on this monitor
let monitor = window.get_current_monitor();
@@ -1220,27 +1182,29 @@ impl EventLoop {
match self.ime_receiver.try_recv() {
Ok((window_id, x, y)) => {
self.ime.borrow_mut().send_xim_spot(window_id, x, y);
wt.ime.borrow_mut().send_xim_spot(window_id, x, y);
},
Err(_) => (),
}
}
fn init_device(&self, device: c_int) {
let wt = get_xtarget(&self.target);
let mut devices = self.devices.borrow_mut();
if let Some(info) = DeviceInfo::get(&self.xconn, device) {
if let Some(info) = DeviceInfo::get(&wt.xconn, device) {
for info in info.iter() {
devices.insert(DeviceId(info.deviceid), Device::new(&self, info));
}
}
}
fn with_window<F, T>(&self, window_id: ffi::Window, callback: F) -> Option<T>
where F: Fn(&UnownedWindow) -> T
fn with_window<F, Ret>(&self, window_id: ffi::Window, callback: F) -> Option<Ret>
where F: Fn(&UnownedWindow) -> Ret
{
let mut deleted = false;
let window_id = WindowId(window_id);
let result = self.windows
let wt = get_xtarget(&self.target);
let result = wt.windows
.borrow()
.get(&window_id)
.and_then(|window| {
@@ -1251,7 +1215,7 @@ impl EventLoop {
.map(|window| callback(&*window));
if deleted {
// Garbage collection
self.windows.borrow_mut().remove(&window_id);
wt.windows.borrow_mut().remove(&window_id);
}
result
}
@@ -1259,9 +1223,102 @@ impl EventLoop {
fn window_exists(&self, window_id: ffi::Window) -> bool {
self.with_window(window_id, |_| ()).is_some()
}
pub(crate) fn window_target(&self) -> &RootELW<T> {
&self.target
}
pub fn run_return<F>(&mut self, mut callback: F)
where F: FnMut(Event<T>, &RootELW<T>, &mut ControlFlow)
{
let mut control_flow = ControlFlow::default();
loop {
match control_flow {
ControlFlow::Exit => return,
ControlFlow::Poll => {
},
ControlFlow::Wait => {
},
ControlFlow::WaitUntil(deadline) => {
}
}
}
}
pub fn run<F>(mut self, callback: F) -> !
where F: 'static + FnMut(Event<T>, &RootELW<T>, &mut ControlFlow)
{
self.run_return(callback);
::std::process::exit(0);
}
/*
pub fn poll_events<F>(&mut self, mut callback: F)
where F: FnMut(Event<T>)
{
let mut xev = unsafe { mem::uninitialized() };
loop {
// Get next event
unsafe {
if !self.poll_one_event(&mut xev) {
break;
}
}
self.process_event(&mut xev, &mut callback);
}
}
pub fn run_forever<F>(&mut self, mut callback: F)
where F: FnMut(Event<T>) -> ControlFlow
{
let mut xev = unsafe { mem::uninitialized() };
loop {
unsafe {
while !self.poll_one_event(&mut xev) {
// block until input is available
self.wait_for_input();
}
};
let mut control_flow = ControlFlow::Poll;
// Track whether or not `Break` was returned when processing the event.
{
let mut cb = |event| {
if let ControlFlow::Exit = callback(event) {
control_flow = ControlFlow::Exit;
}
};
self.process_event(&mut xev, &mut cb);
}
if let ControlFlow::Exit = control_flow {
break;
}
}
}
*/
}
impl EventLoopProxy {
fn get_xtarget<T>(rt: &RootELW<T>) -> &EventLoopWindowTarget<T> {
if let super::EventLoopWindowTarget::X(ref target) = rt.p {
target
} else {
unreachable!();
}
}
impl<T: 'static> EventLoopProxy<T> {
pub fn send_event(&self, evt: T) -> Result<(), EventLoopClosed> {
unimplemented!();
}
pub fn wakeup(&self) -> Result<(), EventLoopClosed> {
// Update the `EventLoop`'s `pending_wakeup` flag.
let display = match (self.pending_wakeup.upgrade(), self.xconn.upgrade()) {
@@ -1360,8 +1417,8 @@ impl Deref for Window {
}
impl Window {
pub fn new(
event_loop: &EventLoop,
pub fn new<T>(
event_loop: &EventLoopWindowTarget<T>,
attribs: WindowAttributes,
pl_attribs: PlatformSpecificWindowBuilderAttributes
) -> Result<Self, CreationError> {
@@ -1420,8 +1477,8 @@ struct XExtension {
first_error_id: c_int,
}
fn mkwid(w: ffi::Window) -> ::WindowId { ::WindowId(::platform::WindowId::X(WindowId(w))) }
fn mkdid(w: c_int) -> ::DeviceId { ::DeviceId(::platform::DeviceId::X(DeviceId(w))) }
fn mkwid(w: ffi::Window) -> ::window::WindowId { ::window::WindowId(::platform_impl::WindowId::X(WindowId(w))) }
fn mkdid(w: c_int) -> ::event::DeviceId { ::event::DeviceId(::platform_impl::DeviceId::X(DeviceId(w))) }
#[derive(Debug)]
struct Device {
@@ -1446,10 +1503,12 @@ enum ScrollOrientation {
}
impl Device {
fn new(el: &EventLoop, info: &ffi::XIDeviceInfo) -> Self {
fn new<T: 'static>(el: &EventLoop<T>, info: &ffi::XIDeviceInfo) -> Self {
let name = unsafe { CStr::from_ptr(info.name).to_string_lossy() };
let mut scroll_axes = Vec::new();
let wt = get_xtarget(&el.target);
if Device::physical_device(info) {
// Register for global raw events
let mask = ffi::XI_RawMotionMask
@@ -1458,7 +1517,7 @@ impl Device {
| ffi::XI_RawKeyPressMask
| ffi::XI_RawKeyReleaseMask;
// The request buffer is flushed when we poll for events
el.xconn.select_xinput_events(el.root, info.deviceid, mask).queue();
wt.xconn.select_xinput_events(wt.root, info.deviceid, mask).queue();
// Identify scroll axes
for class_ptr in Device::classes(info) {

View File

@@ -2,7 +2,7 @@ use std::os::raw::*;
use parking_lot::Mutex;
use {PhysicalPosition, PhysicalSize};
use dpi::{PhysicalPosition, PhysicalSize};
use super::{util, XConnection, XError};
use super::ffi::{
RRCrtcChangeNotifyMask,

View File

@@ -1,7 +1,7 @@
use std::cmp;
use super::*;
use {LogicalPosition, LogicalSize};
use dpi::{LogicalPosition, LogicalSize};
// Friendly neighborhood axis-aligned rectangle
#[derive(Debug, Clone, PartialEq, Eq)]

View File

@@ -1,4 +1,4 @@
use {Icon, Pixel, PIXEL_SIZE};
use window::{Icon, Pixel, PIXEL_SIZE};
use super::*;
impl Pixel {

View File

@@ -1,7 +1,7 @@
use std::str;
use super::*;
use events::ModifiersState;
use event::ModifiersState;
pub const VIRTUAL_CORE_POINTER: c_int = 2;
pub const VIRTUAL_CORE_KEYBOARD: c_int = 3;

View File

@@ -1,7 +1,7 @@
use std::{env, slice};
use std::str::FromStr;
use validate_hidpi_factor;
use dpi::validate_hidpi_factor;
use super::*;
pub fn calc_dpi_factor(

View File

@@ -7,15 +7,15 @@ use std::sync::Arc;
use libc;
use parking_lot::Mutex;
use {Icon, MouseCursor, WindowAttributes};
use CreationError::{self, OsError};
use window::{Icon, MouseCursor, WindowAttributes};
use window::CreationError::{self, OsError};
use dpi::{LogicalPosition, LogicalSize};
use platform_impl::MonitorHandle as PlatformMonitorHandle;
use platform_impl::PlatformSpecificWindowBuilderAttributes;
use platform_impl::x11::MonitorHandle as X11MonitorHandle;
use window::MonitorHandle as RootMonitorHandle;
use monitor::MonitorHandle as RootMonitorHandle;
use super::{ffi, util, ImeSender, XConnection, XError, WindowId, EventLoop};
use super::{ffi, util, ImeSender, XConnection, XError, WindowId, EventLoopWindowTarget};
unsafe extern "C" fn visibility_predicate(
_display: *mut ffi::Display,
@@ -69,8 +69,8 @@ pub struct UnownedWindow {
}
impl UnownedWindow {
pub fn new(
event_loop: &EventLoop,
pub fn new<T>(
event_loop: &EventLoopWindowTarget<T>,
window_attrs: WindowAttributes,
pl_attribs: PlatformSpecificWindowBuilderAttributes,
) -> Result<UnownedWindow, CreationError> {
@@ -1210,4 +1210,9 @@ impl UnownedWindow {
#[inline]
pub fn id(&self) -> WindowId { WindowId(self.xwindow) }
#[inline]
pub fn request_redraw(&self) {
unimplemented!();
}
}