Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ features = [
]

[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))'.dependencies]
wayland-client = { version = "0.21", features = [ "dlopen", "egl", "cursor"] }
smithay-client-toolkit = "0.4.3"
wayland-client = { version = "0.23.0", features = [ "dlopen", "egl", "cursor", "eventloop"] }
calloop = "0.4.2"
smithay-client-toolkit = "0.6"
x11-dl = "2.18.3"
parking_lot = "0.7"
percent-encoding = "1.0"
Expand Down
6 changes: 3 additions & 3 deletions src/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ impl<T> Deref for EventLoop<T> {

/// Used to send custom events to `EventLoop`.
#[derive(Clone)]
pub struct EventLoopProxy<T> {
pub struct EventLoopProxy<T: 'static> {
event_loop_proxy: platform_impl::EventLoopProxy<T>,
}

impl<T> EventLoopProxy<T> {
impl<T: 'static> EventLoopProxy<T> {
/// Send an event to the `EventLoop` from which this proxy was created. This emits a
/// `UserEvent(event)` event in the event loop, where `event` is the value passed to this
/// function.
Expand All @@ -178,7 +178,7 @@ impl<T> EventLoopProxy<T> {
}
}

impl<T> fmt::Debug for EventLoopProxy<T> {
impl<T: 'static> fmt::Debug for EventLoopProxy<T> {
fn fmt(&self, fmtr: &mut fmt::Formatter) -> fmt::Result {
fmtr.pad("EventLoopProxy { .. }")
}
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ extern crate parking_lot;
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 event;
Expand Down
124 changes: 61 additions & 63 deletions src/platform/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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.
Expand All @@ -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);
Expand Down Expand Up @@ -214,63 +212,63 @@ 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
}
}

#[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
}
}

#[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
}
}

#[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
}
}
Expand Down Expand Up @@ -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.
Expand All @@ -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
}

Expand All @@ -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 {
Expand Down
Loading