Upgrade anvil to wayland-server 0.23

This commit is contained in:
Jonas Platte 2019-02-22 22:50:46 +01:00 committed by Victor Berger
parent c238770a1b
commit f34cf4b068
6 changed files with 38 additions and 47 deletions

View File

@ -18,10 +18,7 @@ use smithay::{
egl::{BufferAccessError, EGLImages, Format}, egl::{BufferAccessError, EGLImages, Format},
graphics::{gl::GLGraphicsBackend, glium::GliumGraphicsBackend}, graphics::{gl::GLGraphicsBackend, glium::GliumGraphicsBackend},
}, },
reexports::wayland_server::{ reexports::wayland_server::protocol::{wl_buffer, wl_surface},
protocol::{wl_buffer, wl_surface},
Resource,
},
wayland::{ wayland::{
compositor::{roles::Role, SubsurfaceRole, TraversalAction}, compositor::{roles::Role, SubsurfaceRole, TraversalAction},
data_device::DnDIconRole, data_device::DnDIconRole,
@ -148,7 +145,7 @@ impl<T: Into<GliumGraphicsBackend<T>> + GLGraphicsBackend + 'static> GliumDrawer
impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> { impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
#[cfg(feature = "egl")] #[cfg(feature = "egl")]
pub fn texture_from_buffer(&self, buffer: Resource<wl_buffer::WlBuffer>) -> Result<TextureMetadata, ()> { pub fn texture_from_buffer(&self, buffer: wl_buffer::WlBuffer) -> Result<TextureMetadata, ()> {
// try to retrieve the egl contents of this buffer // try to retrieve the egl contents of this buffer
let images = if let Some(display) = &self.egl_display.borrow().as_ref() { let images = if let Some(display) = &self.egl_display.borrow().as_ref() {
display.egl_buffer_contents(buffer) display.egl_buffer_contents(buffer)
@ -199,11 +196,11 @@ impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
} }
#[cfg(not(feature = "egl"))] #[cfg(not(feature = "egl"))]
pub fn texture_from_buffer(&self, buffer: Resource<wl_buffer::WlBuffer>) -> Result<TextureMetadata, ()> { pub fn texture_from_buffer(&self, buffer: wl_buffer::WlBuffer) -> Result<TextureMetadata, ()> {
self.texture_from_shm_buffer(buffer) self.texture_from_shm_buffer(buffer)
} }
fn texture_from_shm_buffer(&self, buffer: Resource<wl_buffer::WlBuffer>) -> Result<TextureMetadata, ()> { fn texture_from_shm_buffer(&self, buffer: wl_buffer::WlBuffer) -> Result<TextureMetadata, ()> {
match shm_buffer_contents(&buffer, |slice, data| { match shm_buffer_contents(&buffer, |slice, data| {
crate::shm_load::load_shm_buffer(data, slice) crate::shm_load::load_shm_buffer(data, slice)
.map(|(image, kind)| (Texture2d::new(&self.display, image).unwrap(), kind, data)) .map(|(image, kind)| (Texture2d::new(&self.display, image).unwrap(), kind, data))
@ -292,7 +289,7 @@ impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
fn draw_surface_tree( fn draw_surface_tree(
&self, &self,
frame: &mut Frame, frame: &mut Frame,
root: &Resource<wl_surface::WlSurface>, root: &wl_surface::WlSurface,
location: (i32, i32), location: (i32, i32),
compositor_token: MyCompositorToken, compositor_token: MyCompositorToken,
screen_dimensions: (u32, u32), screen_dimensions: (u32, u32),
@ -307,7 +304,7 @@ impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
} }
// notify the client that we have finished reading the // notify the client that we have finished reading the
// buffer // buffer
buffer.send(wl_buffer::Event::Release); buffer.release();
} }
} }
if let Some(ref metadata) = attributes.user_data.texture { if let Some(ref metadata) = attributes.user_data.texture {
@ -371,7 +368,7 @@ impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
pub fn draw_cursor( pub fn draw_cursor(
&self, &self,
frame: &mut Frame, frame: &mut Frame,
surface: &Resource<wl_surface::WlSurface>, surface: &wl_surface::WlSurface,
(x, y): (i32, i32), (x, y): (i32, i32),
token: MyCompositorToken, token: MyCompositorToken,
) { ) {
@ -392,7 +389,7 @@ impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
pub fn draw_dnd_icon( pub fn draw_dnd_icon(
&self, &self,
frame: &mut Frame, frame: &mut Frame,
surface: &Resource<wl_surface::WlSurface>, surface: &wl_surface::WlSurface,
(x, y): (i32, i32), (x, y): (i32, i32),
token: MyCompositorToken, token: MyCompositorToken,
) { ) {

View File

@ -8,8 +8,8 @@ use rand;
use smithay::{ use smithay::{
reexports::wayland_server::{ reexports::wayland_server::{
protocol::{wl_buffer, wl_callback, wl_shell_surface, wl_surface}, protocol::{wl_buffer, wl_shell_surface, wl_surface},
Display, Resource, Display,
}, },
wayland::{ wayland::{
compositor::{compositor_init, CompositorToken, SurfaceAttributes, SurfaceEvent}, compositor::{compositor_init, CompositorToken, SurfaceAttributes, SurfaceEvent},
@ -56,8 +56,8 @@ pub fn init_shell(
move |request, surface, ctoken| match request { move |request, surface, ctoken| match request {
SurfaceEvent::Commit => surface_commit(&surface, ctoken), SurfaceEvent::Commit => surface_commit(&surface, ctoken),
SurfaceEvent::Frame { callback } => callback SurfaceEvent::Frame { callback } => callback
.implement(|e, _| match e {}, None::<fn(_)>, ()) .implement_closure(|_, _| unreachable!(), None::<fn(_)>, ())
.send(wl_callback::Event::Done { callback_data: 0 }), .done(0),
}, },
log.clone(), log.clone(),
); );
@ -131,11 +131,11 @@ pub fn init_shell(
#[derive(Default)] #[derive(Default)]
pub struct SurfaceData { pub struct SurfaceData {
pub buffer: Option<Resource<wl_buffer::WlBuffer>>, pub buffer: Option<wl_buffer::WlBuffer>,
pub texture: Option<crate::glium_drawer::TextureMetadata>, pub texture: Option<crate::glium_drawer::TextureMetadata>,
} }
fn surface_commit(surface: &Resource<wl_surface::WlSurface>, token: CompositorToken<SurfaceData, Roles>) { fn surface_commit(surface: &wl_surface::WlSurface, token: CompositorToken<SurfaceData, Roles>) {
// we retrieve the contents of the associated buffer and copy it // we retrieve the contents of the associated buffer and copy it
token.with_surface_data(surface, |attributes| { token.with_surface_data(surface, |attributes| {
match attributes.buffer.take() { match attributes.buffer.take() {

View File

@ -49,7 +49,7 @@ use smithay::{
EventLoop, LoopHandle, Source, EventLoop, LoopHandle, Source,
}, },
protocol::{wl_output, wl_surface}, protocol::{wl_output, wl_surface},
Display, Resource, Display,
}, },
}, },
wayland::{ wayland::{
@ -175,7 +175,7 @@ pub fn run_udev(mut display: Display, mut event_loop: EventLoop<()>, log: Logger
}); });
let keyboard = w_seat let keyboard = w_seat
.add_keyboard(XkbConfig::default(), 1000, 500, |seat, focus| { .add_keyboard(XkbConfig::default(), 1000, 500, |seat, focus| {
set_data_device_focus(seat, focus.and_then(|s| s.client())) set_data_device_focus(seat, focus.and_then(|s| s.as_ref().client()))
}) })
.expect("Failed to initialize the keyboard"); .expect("Failed to initialize the keyboard");
@ -290,7 +290,7 @@ struct UdevHandlerImpl<S: SessionNotifier, Data: 'static> {
pointer_location: Rc<RefCell<(f64, f64)>>, pointer_location: Rc<RefCell<(f64, f64)>>,
pointer_image: ImageBuffer<Rgba<u8>, Vec<u8>>, pointer_image: ImageBuffer<Rgba<u8>, Vec<u8>>,
cursor_status: Arc<Mutex<CursorImageStatus>>, cursor_status: Arc<Mutex<CursorImageStatus>>,
dnd_icon: Arc<Mutex<Option<Resource<wl_surface::WlSurface>>>>, dnd_icon: Arc<Mutex<Option<wl_surface::WlSurface>>>,
loop_handle: LoopHandle<Data>, loop_handle: LoopHandle<Data>,
notifier: S, notifier: S,
logger: ::slog::Logger, logger: ::slog::Logger,
@ -527,7 +527,7 @@ pub struct DrmHandlerImpl {
window_map: Rc<RefCell<MyWindowMap>>, window_map: Rc<RefCell<MyWindowMap>>,
pointer_location: Rc<RefCell<(f64, f64)>>, pointer_location: Rc<RefCell<(f64, f64)>>,
cursor_status: Arc<Mutex<CursorImageStatus>>, cursor_status: Arc<Mutex<CursorImageStatus>>,
dnd_icon: Arc<Mutex<Option<Resource<wl_surface::WlSurface>>>>, dnd_icon: Arc<Mutex<Option<wl_surface::WlSurface>>>,
logger: ::slog::Logger, logger: ::slog::Logger,
} }
@ -553,7 +553,7 @@ impl DeviceHandler for DrmHandlerImpl {
{ {
let guard = self.dnd_icon.lock().unwrap(); let guard = self.dnd_icon.lock().unwrap();
if let Some(ref surface) = *guard { if let Some(ref surface) = *guard {
if surface.is_alive() { if surface.as_ref().is_alive() {
drawer.draw_dnd_icon( drawer.draw_dnd_icon(
&mut frame, &mut frame,
surface, surface,
@ -569,7 +569,7 @@ impl DeviceHandler for DrmHandlerImpl {
// reset the cursor if the surface is no longer alive // reset the cursor if the surface is no longer alive
let mut reset = false; let mut reset = false;
if let CursorImageStatus::Image(ref surface) = *guard { if let CursorImageStatus::Image(ref surface) = *guard {
reset = !surface.is_alive(); reset = !surface.as_ref().is_alive();
} }
if reset { if reset {
*guard = CursorImageStatus::Default; *guard = CursorImageStatus::Default;

View File

@ -1,5 +1,5 @@
use smithay::{ use smithay::{
reexports::wayland_server::{protocol::wl_surface, Resource}, reexports::wayland_server::protocol::wl_surface,
utils::Rectangle, utils::Rectangle,
wayland::{ wayland::{
compositor::{roles::Role, CompositorToken, SubsurfaceRole, SurfaceAttributes, TraversalAction}, compositor::{roles::Role, CompositorToken, SubsurfaceRole, SurfaceAttributes, TraversalAction},
@ -28,7 +28,7 @@ where
Kind::Wl(ref t) => t.alive(), Kind::Wl(ref t) => t.alive(),
} }
} }
pub fn get_surface(&self) -> Option<&Resource<wl_surface::WlSurface>> { pub fn get_surface(&self) -> Option<&wl_surface::WlSurface> {
match *self { match *self {
Kind::Xdg(ref t) => t.get_surface(), Kind::Xdg(ref t) => t.get_surface(),
Kind::Wl(ref t) => t.get_surface(), Kind::Wl(ref t) => t.get_surface(),
@ -55,7 +55,7 @@ where
point: (f64, f64), point: (f64, f64),
ctoken: CompositorToken<U, R>, ctoken: CompositorToken<U, R>,
get_size: F, get_size: F,
) -> Option<(Resource<wl_surface::WlSurface>, (f64, f64))> ) -> Option<(wl_surface::WlSurface, (f64, f64))>
where where
F: Fn(&SurfaceAttributes<U>) -> Option<(i32, i32)>, F: Fn(&SurfaceAttributes<U>) -> Option<(i32, i32)>,
{ {
@ -177,10 +177,7 @@ where
self.windows.insert(0, window); self.windows.insert(0, window);
} }
pub fn get_surface_under( pub fn get_surface_under(&self, point: (f64, f64)) -> Option<(wl_surface::WlSurface, (f64, f64))> {
&self,
point: (f64, f64),
) -> Option<(Resource<wl_surface::WlSurface>, (f64, f64))> {
for w in &self.windows { for w in &self.windows {
if let Some(surface) = w.matching(point, self.ctoken, &self.get_size) { if let Some(surface) = w.matching(point, self.ctoken, &self.get_size) {
return Some(surface); return Some(surface);
@ -192,7 +189,7 @@ where
pub fn get_surface_and_bring_to_top( pub fn get_surface_and_bring_to_top(
&mut self, &mut self,
point: (f64, f64), point: (f64, f64),
) -> Option<(Resource<wl_surface::WlSurface>, (f64, f64))> { ) -> Option<(wl_surface::WlSurface, (f64, f64))> {
let mut found = None; let mut found = None;
for (i, w) in self.windows.iter().enumerate() { for (i, w) in self.windows.iter().enumerate() {
if let Some(surface) = w.matching(point, self.ctoken, &self.get_size) { if let Some(surface) = w.matching(point, self.ctoken, &self.get_size) {

View File

@ -88,7 +88,7 @@ pub fn run_winit(display: &mut Display, event_loop: &mut EventLoop<()>, log: Log
let keyboard = seat let keyboard = seat
.add_keyboard(XkbConfig::default(), 1000, 500, |seat, focus| { .add_keyboard(XkbConfig::default(), 1000, 500, |seat, focus| {
set_data_device_focus(seat, focus.and_then(|s| s.client())) set_data_device_focus(seat, focus.and_then(|s| s.as_ref().client()))
}) })
.expect("Failed to initialize the keyboard"); .expect("Failed to initialize the keyboard");
@ -151,7 +151,7 @@ pub fn run_winit(display: &mut Display, event_loop: &mut EventLoop<()>, log: Log
{ {
let guard = dnd_icon.lock().unwrap(); let guard = dnd_icon.lock().unwrap();
if let Some(ref surface) = *guard { if let Some(ref surface) = *guard {
if surface.is_alive() { if surface.as_ref().is_alive() {
drawer.draw_dnd_icon(&mut frame, surface, (x as i32, y as i32), compositor_token); drawer.draw_dnd_icon(&mut frame, surface, (x as i32, y as i32), compositor_token);
} }
} }
@ -162,7 +162,7 @@ pub fn run_winit(display: &mut Display, event_loop: &mut EventLoop<()>, log: Log
// reset the cursor if the surface is no longer alive // reset the cursor if the surface is no longer alive
let mut reset = false; let mut reset = false;
if let CursorImageStatus::Image(ref surface) = *guard { if let CursorImageStatus::Image(ref surface) = *guard {
reset = !surface.is_alive(); reset = !surface.as_ref().is_alive();
} }
if reset { if reset {
*guard = CursorImageStatus::Default; *guard = CursorImageStatus::Default;

View File

@ -27,10 +27,7 @@ use std::{
rc::{Rc, Weak}, rc::{Rc, Weak},
}; };
#[cfg(feature = "wayland_frontend")] #[cfg(feature = "wayland_frontend")]
use wayland_server::{ use wayland_server::{protocol::wl_buffer::WlBuffer, Display};
protocol::wl_buffer::{self, WlBuffer},
Display, Resource,
};
#[cfg(feature = "native_lib")] #[cfg(feature = "native_lib")]
use wayland_sys::server::wl_display; use wayland_sys::server::wl_display;
@ -78,7 +75,7 @@ pub enum BufferAccessError {
/// The corresponding Context is not alive anymore /// The corresponding Context is not alive anymore
ContextLost, ContextLost,
/// This buffer is not managed by the EGL buffer /// This buffer is not managed by the EGL buffer
NotManaged(Resource<WlBuffer>), NotManaged(WlBuffer),
/// Failed to create `EGLImages` from the buffer /// Failed to create `EGLImages` from the buffer
EGLImageCreationFailed, EGLImageCreationFailed,
/// The required EGL extension is not supported by the underlying EGL implementation /// The required EGL extension is not supported by the underlying EGL implementation
@ -239,7 +236,7 @@ pub struct EGLImages {
/// Format of these images /// Format of these images
pub format: Format, pub format: Format,
images: Vec<EGLImage>, images: Vec<EGLImage>,
buffer: Resource<WlBuffer>, buffer: WlBuffer,
#[cfg(feature = "renderer_gl")] #[cfg(feature = "renderer_gl")]
gl: gl_ffi::Gles2, gl: gl_ffi::Gles2,
#[cfg(feature = "renderer_gl")] #[cfg(feature = "renderer_gl")]
@ -303,7 +300,7 @@ impl Drop for EGLImages {
} }
} }
} }
self.buffer.send(wl_buffer::Event::Release); self.buffer.release();
} }
} }
@ -373,14 +370,14 @@ impl EGLDisplay {
/// to render it another way. /// to render it another way.
pub fn egl_buffer_contents( pub fn egl_buffer_contents(
&self, &self,
buffer: Resource<WlBuffer>, buffer: WlBuffer,
) -> ::std::result::Result<EGLImages, BufferAccessError> { ) -> ::std::result::Result<EGLImages, BufferAccessError> {
if let Some(display) = self.egl.upgrade() { if let Some(display) = self.egl.upgrade() {
let mut format: i32 = 0; let mut format: i32 = 0;
if unsafe { if unsafe {
ffi::egl::QueryWaylandBufferWL( ffi::egl::QueryWaylandBufferWL(
*display, *display,
buffer.c_ptr() as *mut _, buffer.as_ref().c_ptr() as *mut _,
ffi::egl::EGL_TEXTURE_FORMAT, ffi::egl::EGL_TEXTURE_FORMAT,
&mut format as *mut _, &mut format as *mut _,
) == 0 ) == 0
@ -401,7 +398,7 @@ impl EGLDisplay {
if unsafe { if unsafe {
ffi::egl::QueryWaylandBufferWL( ffi::egl::QueryWaylandBufferWL(
*display, *display,
buffer.c_ptr() as *mut _, buffer.as_ref().c_ptr() as *mut _,
ffi::egl::WIDTH as i32, ffi::egl::WIDTH as i32,
&mut width as *mut _, &mut width as *mut _,
) == 0 ) == 0
@ -413,7 +410,7 @@ impl EGLDisplay {
if unsafe { if unsafe {
ffi::egl::QueryWaylandBufferWL( ffi::egl::QueryWaylandBufferWL(
*display, *display,
buffer.c_ptr() as *mut _, buffer.as_ref().c_ptr() as *mut _,
ffi::egl::HEIGHT as i32, ffi::egl::HEIGHT as i32,
&mut height as *mut _, &mut height as *mut _,
) == 0 ) == 0
@ -425,7 +422,7 @@ impl EGLDisplay {
if unsafe { if unsafe {
ffi::egl::QueryWaylandBufferWL( ffi::egl::QueryWaylandBufferWL(
*display, *display,
buffer.c_ptr() as *mut _, buffer.as_ref().c_ptr() as *mut _,
ffi::egl::WAYLAND_Y_INVERTED_WL, ffi::egl::WAYLAND_Y_INVERTED_WL,
&mut inverted as *mut _, &mut inverted as *mut _,
) != 0 ) != 0
@ -446,7 +443,7 @@ impl EGLDisplay {
*display, *display,
ffi::egl::NO_CONTEXT, ffi::egl::NO_CONTEXT,
ffi::egl::WAYLAND_BUFFER_WL, ffi::egl::WAYLAND_BUFFER_WL,
buffer.c_ptr() as *mut _, buffer.as_ref().c_ptr() as *mut _,
out.as_ptr(), out.as_ptr(),
) )
}; };