Upgrade backends to calloop 0.4 and renamed gl-traits

This commit is contained in:
Victor Brekenfeld 2018-11-21 09:37:57 +01:00
parent 38ec44f70c
commit 505791e336
3 changed files with 46 additions and 46 deletions

View File

@ -10,8 +10,8 @@ repository = "https://github.com/Smithay/smithay"
members = [ "anvil" ]
[dependencies]
wayland-server = "0.21.1"
wayland-sys = "0.21.1"
wayland-server = "0.21.4"
wayland-sys = "0.21.3"
wayland-commons = "0.21.1"
nix = "0.11"
xkbcommon = "0.2.1"
@ -28,7 +28,7 @@ input = { version = "0.4.0", optional = true }
udev = { version = "0.2.0", optional = true }
dbus = { version = "0.6.1", optional = true }
systemd = { version = "^0.2.0", optional = true }
wayland-protocols = { version = "0.21.1", features = ["unstable_protocols", "native_server"] }
wayland-protocols = { version = "0.21.3", features = ["unstable_protocols", "native_server"] }
image = "0.17.0"
error-chain = "0.11.0"
lazy_static = "1.0.0"

View File

@ -7,25 +7,22 @@ use input as libinput;
use input::event;
use std::{
cell::RefCell,
collections::hash_map::{DefaultHasher, Entry, HashMap},
hash::{Hash, Hasher},
io::Error as IoError,
os::unix::io::RawFd,
path::Path,
rc::Rc,
os::unix::io::{AsRawFd, RawFd},
};
use wayland_server::calloop::{
generic::{EventedRawFd, Generic},
generic::{EventedFd, Generic},
mio::Ready,
LoopHandle, Source,
LoopHandle, Source, InsertError,
};
// No idea if this is the same across unix platforms
// Lets make this linux exclusive for now, once someone tries to build it for
// any BSD-like system, they can verify if this is right and make a PR to change this.
#[cfg(any(target_os = "linux", target_os = "android"))]
#[cfg(all(any(target_os = "linux", target_os = "android"), feature = "backend_session"))]
const INPUT_MAJOR: u32 = 13;
/// Libinput based `InputBackend`.
@ -590,6 +587,12 @@ impl<S: Session> libinput::LibinputInterface for LibinputSessionInterface<S> {
}
}
impl AsRawFd for LibinputInputBackend {
fn as_raw_fd(&self) -> RawFd {
unsafe { self.context.fd() }
}
}
/// Binds a `LibinputInputBackend` to a given `EventLoop`.
///
/// Automatically feeds the backend with incoming events without any manual calls to
@ -597,22 +600,16 @@ impl<S: Session> libinput::LibinputInterface for LibinputSessionInterface<S> {
pub fn libinput_bind<Data: 'static>(
backend: LibinputInputBackend,
handle: LoopHandle<Data>,
) -> ::std::result::Result<Source<Generic<EventedRawFd>>, (IoError, LibinputInputBackend)> {
let mut source = Generic::from_raw_fd(unsafe { backend.context.fd() });
) -> ::std::result::Result<Source<Generic<EventedFd<LibinputInputBackend>>>, InsertError<Generic<EventedFd<LibinputInputBackend>>>> {
let mut source = Generic::from_fd_source(backend);
source.set_interest(Ready::readable());
let backend = Rc::new(RefCell::new(backend));
let fail_backend = backend.clone();
handle
.insert_source(source, move |_, _| {
handle.insert_source(source, move |evt, _| {
use backend::input::InputBackend;
if let Err(error) = backend.borrow_mut().dispatch_new_events() {
warn!(backend.borrow().logger, "Libinput errored: {}", error);
let mut backend = evt.source.borrow_mut();
if let Err(error) = backend.0.dispatch_new_events() {
warn!(backend.0.logger, "Libinput errored: {}", error);
}
}).map_err(move |e| {
// the backend in the closure should already have been dropped
let backend = Rc::try_unwrap(fail_backend)
.unwrap_or_else(|_| unreachable!())
.into_inner();
(e.into(), backend)
})
}

View File

@ -2,15 +2,16 @@
use backend::{
graphics::{
gl::{GLGraphicsBackend, PixelFormat},
CursorBackend,
SwapBuffersError,
},
egl::{
context::GlAttributes,
error as egl_error,
error::Result as EGLResult,
native,
wayland::{EGLDisplay, EGLWaylandExtensions},
EGLContext, EGLGraphicsBackend, EGLSurface, PixelFormat, SwapBuffersError,
},
GraphicsBackend,
EGLDisplay, EGLContext, EGLGraphicsBackend, EGLSurface,
},
input::{
Axis, AxisSource, Event as BackendEvent, InputBackend, InputHandler, KeyState, KeyboardKeyEvent,
@ -156,12 +157,12 @@ where
let reqs = Default::default();
let window = Rc::new(
if native::NativeDisplay::<native::Wayland>::is_backend(&winit_window) {
let context =
let mut context =
EGLContext::<native::Wayland, WinitWindow>::new(winit_window, attributes, reqs, log.clone())?;
let surface = context.create_surface(())?;
Window::Wayland { context, surface }
} else if native::NativeDisplay::<native::X11>::is_backend(&winit_window) {
let context =
let mut context =
EGLContext::<native::X11, WinitWindow>::new(winit_window, attributes, reqs, log.clone())?;
let surface = context.create_surface(())?;
Window::X11 { context, surface }
@ -226,8 +227,8 @@ impl WinitGraphicsBackend {
}
}
impl GraphicsBackend for WinitGraphicsBackend {
type CursorFormat = MouseCursor;
impl<'a> CursorBackend<'a> for WinitGraphicsBackend {
type CursorFormat = &'a MouseCursor;
type Error = ();
fn set_cursor_position(&self, x: u32, y: u32) -> ::std::result::Result<(), ()> {
@ -240,11 +241,13 @@ impl GraphicsBackend for WinitGraphicsBackend {
})
}
fn set_cursor_representation(
&self,
cursor: &Self::CursorFormat,
fn set_cursor_representation<'b>(
&'b self,
cursor: Self::CursorFormat,
_hotspot: (u32, u32),
) -> ::std::result::Result<(), ()> {
) -> ::std::result::Result<(), ()>
where 'a: 'b
{
// Cannot log this one, as `CursorFormat` is not `Debug` and should not be
debug!(self.logger, "Changing cursor representation");
self.window.window().set_cursor(*cursor);
@ -252,7 +255,7 @@ impl GraphicsBackend for WinitGraphicsBackend {
}
}
impl EGLGraphicsBackend for WinitGraphicsBackend {
impl GLGraphicsBackend for WinitGraphicsBackend {
fn swap_buffers(&self) -> ::std::result::Result<(), SwapBuffersError> {
trace!(self.logger, "Swapping buffers");
match *self.window {
@ -303,7 +306,7 @@ impl EGLGraphicsBackend for WinitGraphicsBackend {
}
}
impl EGLWaylandExtensions for WinitGraphicsBackend {
impl EGLGraphicsBackend for WinitGraphicsBackend {
fn bind_wl_display(&self, display: &Display) -> EGLResult<EGLDisplay> {
match *self.window {
Window::Wayland { ref context, .. } => context.bind_wl_display(display),