Wayland's eventloop 2.0 (#790)
* match unix common API to evl 2.0 * wayland: eventloop2.0 * make EventLoopProxy require T: 'static * Fix linux build and tests * wayland: update sctk & small fixes
This commit is contained in:
parent
9602716ed2
commit
6513351e0c
13 changed files with 532 additions and 592 deletions
|
|
@ -6,26 +6,24 @@ use std::sync::Arc;
|
|||
|
||||
use sctk::window::{ButtonState, Theme};
|
||||
|
||||
use {
|
||||
EventLoop,
|
||||
LogicalSize,
|
||||
MonitorHandle,
|
||||
Window,
|
||||
WindowBuilder,
|
||||
};
|
||||
use dpi::LogicalSize;
|
||||
use event_loop::EventLoop;
|
||||
use monitor::MonitorHandle;
|
||||
use window::{Window, WindowBuilder};
|
||||
|
||||
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
|
||||
///
|
||||
|
|
@ -97,9 +95,9 @@ impl Theme for WaylandThemeObject {
|
|||
|
||||
/// Additional methods on `EventLoop` that are specific to Unix.
|
||||
pub trait EventLoopExtUnix {
|
||||
/// Builds a new `EventsLoop` that is forced to use X11.
|
||||
fn new_x11() -> Result<Self, XNotSupported>
|
||||
where Self: Sized;
|
||||
/// Builds a new `EventLoops` that is forced to use X11.
|
||||
//fn new_x11() -> Result<Self, XNotSupported>
|
||||
// where Self: Sized;
|
||||
|
||||
/// Builds a new `EventLoop` that is forced to use Wayland.
|
||||
fn new_wayland() -> Self
|
||||
|
|
@ -111,20 +109,20 @@ 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>>;
|
||||
}
|
||||
|
||||
impl EventLoopExtUnix for EventLoop {
|
||||
#[inline]
|
||||
fn new_x11() -> Result<Self, XNotSupported> {
|
||||
LinuxEventLoop::new_x11().map(|ev|
|
||||
EventLoop {
|
||||
event_loop: ev,
|
||||
_marker: ::std::marker::PhantomData,
|
||||
}
|
||||
)
|
||||
}
|
||||
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_wayland() -> Self {
|
||||
|
|
@ -147,11 +145,11 @@ impl EventLoopExtUnix for EventLoop {
|
|||
!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>> {
|
||||
// self.event_loop.x_connection().cloned()
|
||||
//}
|
||||
}
|
||||
|
||||
/// Additional methods on `Window` that are specific to Unix.
|
||||
|
|
@ -170,8 +168,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);
|
||||
|
|
@ -214,7 +212,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
|
||||
}
|
||||
}
|
||||
|
|
@ -222,7 +220,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
|
||||
}
|
||||
}
|
||||
|
|
@ -230,39 +228,39 @@ 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]
|
||||
fn get_wayland_surface(&self) -> Option<*mut raw::c_void> {
|
||||
match self.window {
|
||||
LinuxWindow::Wayland(ref w) => Some(w.get_surface().c_ptr() as *mut _),
|
||||
LinuxWindow::Wayland(ref w) => Some(w.get_surface().as_ref().c_ptr() as *mut _),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
|
@ -270,7 +268,7 @@ impl WindowExtUnix for Window {
|
|||
#[inline]
|
||||
fn get_wayland_display(&self) -> Option<*mut raw::c_void> {
|
||||
match self.window {
|
||||
LinuxWindow::Wayland(ref w) => Some(w.get_display().c_ptr() as *mut _),
|
||||
LinuxWindow::Wayland(ref w) => Some(w.get_display().as_ref().c_ptr() as *mut _),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
|
|
@ -299,7 +297,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.
|
||||
|
|
@ -318,9 +316,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
|
||||
}
|
||||
|
||||
|
|
@ -342,11 +340,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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue