Upgrade anvil to wayland-server 0.23
This commit is contained in:
parent
c238770a1b
commit
f34cf4b068
|
@ -18,10 +18,7 @@ use smithay::{
|
|||
egl::{BufferAccessError, EGLImages, Format},
|
||||
graphics::{gl::GLGraphicsBackend, glium::GliumGraphicsBackend},
|
||||
},
|
||||
reexports::wayland_server::{
|
||||
protocol::{wl_buffer, wl_surface},
|
||||
Resource,
|
||||
},
|
||||
reexports::wayland_server::protocol::{wl_buffer, wl_surface},
|
||||
wayland::{
|
||||
compositor::{roles::Role, SubsurfaceRole, TraversalAction},
|
||||
data_device::DnDIconRole,
|
||||
|
@ -148,7 +145,7 @@ impl<T: Into<GliumGraphicsBackend<T>> + GLGraphicsBackend + 'static> GliumDrawer
|
|||
|
||||
impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
|
||||
#[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
|
||||
let images = if let Some(display) = &self.egl_display.borrow().as_ref() {
|
||||
display.egl_buffer_contents(buffer)
|
||||
|
@ -199,11 +196,11 @@ impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
|
|||
}
|
||||
|
||||
#[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)
|
||||
}
|
||||
|
||||
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| {
|
||||
crate::shm_load::load_shm_buffer(data, slice)
|
||||
.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(
|
||||
&self,
|
||||
frame: &mut Frame,
|
||||
root: &Resource<wl_surface::WlSurface>,
|
||||
root: &wl_surface::WlSurface,
|
||||
location: (i32, i32),
|
||||
compositor_token: MyCompositorToken,
|
||||
screen_dimensions: (u32, u32),
|
||||
|
@ -307,7 +304,7 @@ impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
|
|||
}
|
||||
// notify the client that we have finished reading the
|
||||
// buffer
|
||||
buffer.send(wl_buffer::Event::Release);
|
||||
buffer.release();
|
||||
}
|
||||
}
|
||||
if let Some(ref metadata) = attributes.user_data.texture {
|
||||
|
@ -371,7 +368,7 @@ impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
|
|||
pub fn draw_cursor(
|
||||
&self,
|
||||
frame: &mut Frame,
|
||||
surface: &Resource<wl_surface::WlSurface>,
|
||||
surface: &wl_surface::WlSurface,
|
||||
(x, y): (i32, i32),
|
||||
token: MyCompositorToken,
|
||||
) {
|
||||
|
@ -392,7 +389,7 @@ impl<F: GLGraphicsBackend + 'static> GliumDrawer<F> {
|
|||
pub fn draw_dnd_icon(
|
||||
&self,
|
||||
frame: &mut Frame,
|
||||
surface: &Resource<wl_surface::WlSurface>,
|
||||
surface: &wl_surface::WlSurface,
|
||||
(x, y): (i32, i32),
|
||||
token: MyCompositorToken,
|
||||
) {
|
||||
|
|
|
@ -8,8 +8,8 @@ use rand;
|
|||
|
||||
use smithay::{
|
||||
reexports::wayland_server::{
|
||||
protocol::{wl_buffer, wl_callback, wl_shell_surface, wl_surface},
|
||||
Display, Resource,
|
||||
protocol::{wl_buffer, wl_shell_surface, wl_surface},
|
||||
Display,
|
||||
},
|
||||
wayland::{
|
||||
compositor::{compositor_init, CompositorToken, SurfaceAttributes, SurfaceEvent},
|
||||
|
@ -56,8 +56,8 @@ pub fn init_shell(
|
|||
move |request, surface, ctoken| match request {
|
||||
SurfaceEvent::Commit => surface_commit(&surface, ctoken),
|
||||
SurfaceEvent::Frame { callback } => callback
|
||||
.implement(|e, _| match e {}, None::<fn(_)>, ())
|
||||
.send(wl_callback::Event::Done { callback_data: 0 }),
|
||||
.implement_closure(|_, _| unreachable!(), None::<fn(_)>, ())
|
||||
.done(0),
|
||||
},
|
||||
log.clone(),
|
||||
);
|
||||
|
@ -131,11 +131,11 @@ pub fn init_shell(
|
|||
|
||||
#[derive(Default)]
|
||||
pub struct SurfaceData {
|
||||
pub buffer: Option<Resource<wl_buffer::WlBuffer>>,
|
||||
pub buffer: Option<wl_buffer::WlBuffer>,
|
||||
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
|
||||
token.with_surface_data(surface, |attributes| {
|
||||
match attributes.buffer.take() {
|
||||
|
|
|
@ -49,7 +49,7 @@ use smithay::{
|
|||
EventLoop, LoopHandle, Source,
|
||||
},
|
||||
protocol::{wl_output, wl_surface},
|
||||
Display, Resource,
|
||||
Display,
|
||||
},
|
||||
},
|
||||
wayland::{
|
||||
|
@ -175,7 +175,7 @@ pub fn run_udev(mut display: Display, mut event_loop: EventLoop<()>, log: Logger
|
|||
});
|
||||
let keyboard = w_seat
|
||||
.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");
|
||||
|
||||
|
@ -290,7 +290,7 @@ struct UdevHandlerImpl<S: SessionNotifier, Data: 'static> {
|
|||
pointer_location: Rc<RefCell<(f64, f64)>>,
|
||||
pointer_image: ImageBuffer<Rgba<u8>, Vec<u8>>,
|
||||
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>,
|
||||
notifier: S,
|
||||
logger: ::slog::Logger,
|
||||
|
@ -527,7 +527,7 @@ pub struct DrmHandlerImpl {
|
|||
window_map: Rc<RefCell<MyWindowMap>>,
|
||||
pointer_location: Rc<RefCell<(f64, f64)>>,
|
||||
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,
|
||||
}
|
||||
|
||||
|
@ -553,7 +553,7 @@ impl DeviceHandler for DrmHandlerImpl {
|
|||
{
|
||||
let guard = self.dnd_icon.lock().unwrap();
|
||||
if let Some(ref surface) = *guard {
|
||||
if surface.is_alive() {
|
||||
if surface.as_ref().is_alive() {
|
||||
drawer.draw_dnd_icon(
|
||||
&mut frame,
|
||||
surface,
|
||||
|
@ -569,7 +569,7 @@ impl DeviceHandler for DrmHandlerImpl {
|
|||
// reset the cursor if the surface is no longer alive
|
||||
let mut reset = false;
|
||||
if let CursorImageStatus::Image(ref surface) = *guard {
|
||||
reset = !surface.is_alive();
|
||||
reset = !surface.as_ref().is_alive();
|
||||
}
|
||||
if reset {
|
||||
*guard = CursorImageStatus::Default;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use smithay::{
|
||||
reexports::wayland_server::{protocol::wl_surface, Resource},
|
||||
reexports::wayland_server::protocol::wl_surface,
|
||||
utils::Rectangle,
|
||||
wayland::{
|
||||
compositor::{roles::Role, CompositorToken, SubsurfaceRole, SurfaceAttributes, TraversalAction},
|
||||
|
@ -28,7 +28,7 @@ where
|
|||
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 {
|
||||
Kind::Xdg(ref t) => t.get_surface(),
|
||||
Kind::Wl(ref t) => t.get_surface(),
|
||||
|
@ -55,7 +55,7 @@ where
|
|||
point: (f64, f64),
|
||||
ctoken: CompositorToken<U, R>,
|
||||
get_size: F,
|
||||
) -> Option<(Resource<wl_surface::WlSurface>, (f64, f64))>
|
||||
) -> Option<(wl_surface::WlSurface, (f64, f64))>
|
||||
where
|
||||
F: Fn(&SurfaceAttributes<U>) -> Option<(i32, i32)>,
|
||||
{
|
||||
|
@ -177,10 +177,7 @@ where
|
|||
self.windows.insert(0, window);
|
||||
}
|
||||
|
||||
pub fn get_surface_under(
|
||||
&self,
|
||||
point: (f64, f64),
|
||||
) -> Option<(Resource<wl_surface::WlSurface>, (f64, f64))> {
|
||||
pub fn get_surface_under(&self, point: (f64, f64)) -> Option<(wl_surface::WlSurface, (f64, f64))> {
|
||||
for w in &self.windows {
|
||||
if let Some(surface) = w.matching(point, self.ctoken, &self.get_size) {
|
||||
return Some(surface);
|
||||
|
@ -192,7 +189,7 @@ where
|
|||
pub fn get_surface_and_bring_to_top(
|
||||
&mut self,
|
||||
point: (f64, f64),
|
||||
) -> Option<(Resource<wl_surface::WlSurface>, (f64, f64))> {
|
||||
) -> Option<(wl_surface::WlSurface, (f64, f64))> {
|
||||
let mut found = None;
|
||||
for (i, w) in self.windows.iter().enumerate() {
|
||||
if let Some(surface) = w.matching(point, self.ctoken, &self.get_size) {
|
||||
|
|
|
@ -88,7 +88,7 @@ pub fn run_winit(display: &mut Display, event_loop: &mut EventLoop<()>, log: Log
|
|||
|
||||
let keyboard = seat
|
||||
.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");
|
||||
|
||||
|
@ -151,7 +151,7 @@ pub fn run_winit(display: &mut Display, event_loop: &mut EventLoop<()>, log: Log
|
|||
{
|
||||
let guard = dnd_icon.lock().unwrap();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
let mut reset = false;
|
||||
if let CursorImageStatus::Image(ref surface) = *guard {
|
||||
reset = !surface.is_alive();
|
||||
reset = !surface.as_ref().is_alive();
|
||||
}
|
||||
if reset {
|
||||
*guard = CursorImageStatus::Default;
|
||||
|
|
|
@ -27,10 +27,7 @@ use std::{
|
|||
rc::{Rc, Weak},
|
||||
};
|
||||
#[cfg(feature = "wayland_frontend")]
|
||||
use wayland_server::{
|
||||
protocol::wl_buffer::{self, WlBuffer},
|
||||
Display, Resource,
|
||||
};
|
||||
use wayland_server::{protocol::wl_buffer::WlBuffer, Display};
|
||||
#[cfg(feature = "native_lib")]
|
||||
use wayland_sys::server::wl_display;
|
||||
|
||||
|
@ -78,7 +75,7 @@ pub enum BufferAccessError {
|
|||
/// The corresponding Context is not alive anymore
|
||||
ContextLost,
|
||||
/// This buffer is not managed by the EGL buffer
|
||||
NotManaged(Resource<WlBuffer>),
|
||||
NotManaged(WlBuffer),
|
||||
/// Failed to create `EGLImages` from the buffer
|
||||
EGLImageCreationFailed,
|
||||
/// The required EGL extension is not supported by the underlying EGL implementation
|
||||
|
@ -239,7 +236,7 @@ pub struct EGLImages {
|
|||
/// Format of these images
|
||||
pub format: Format,
|
||||
images: Vec<EGLImage>,
|
||||
buffer: Resource<WlBuffer>,
|
||||
buffer: WlBuffer,
|
||||
#[cfg(feature = "renderer_gl")]
|
||||
gl: gl_ffi::Gles2,
|
||||
#[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.
|
||||
pub fn egl_buffer_contents(
|
||||
&self,
|
||||
buffer: Resource<WlBuffer>,
|
||||
buffer: WlBuffer,
|
||||
) -> ::std::result::Result<EGLImages, BufferAccessError> {
|
||||
if let Some(display) = self.egl.upgrade() {
|
||||
let mut format: i32 = 0;
|
||||
if unsafe {
|
||||
ffi::egl::QueryWaylandBufferWL(
|
||||
*display,
|
||||
buffer.c_ptr() as *mut _,
|
||||
buffer.as_ref().c_ptr() as *mut _,
|
||||
ffi::egl::EGL_TEXTURE_FORMAT,
|
||||
&mut format as *mut _,
|
||||
) == 0
|
||||
|
@ -401,7 +398,7 @@ impl EGLDisplay {
|
|||
if unsafe {
|
||||
ffi::egl::QueryWaylandBufferWL(
|
||||
*display,
|
||||
buffer.c_ptr() as *mut _,
|
||||
buffer.as_ref().c_ptr() as *mut _,
|
||||
ffi::egl::WIDTH as i32,
|
||||
&mut width as *mut _,
|
||||
) == 0
|
||||
|
@ -413,7 +410,7 @@ impl EGLDisplay {
|
|||
if unsafe {
|
||||
ffi::egl::QueryWaylandBufferWL(
|
||||
*display,
|
||||
buffer.c_ptr() as *mut _,
|
||||
buffer.as_ref().c_ptr() as *mut _,
|
||||
ffi::egl::HEIGHT as i32,
|
||||
&mut height as *mut _,
|
||||
) == 0
|
||||
|
@ -425,7 +422,7 @@ impl EGLDisplay {
|
|||
if unsafe {
|
||||
ffi::egl::QueryWaylandBufferWL(
|
||||
*display,
|
||||
buffer.c_ptr() as *mut _,
|
||||
buffer.as_ref().c_ptr() as *mut _,
|
||||
ffi::egl::WAYLAND_Y_INVERTED_WL,
|
||||
&mut inverted as *mut _,
|
||||
) != 0
|
||||
|
@ -446,7 +443,7 @@ impl EGLDisplay {
|
|||
*display,
|
||||
ffi::egl::NO_CONTEXT,
|
||||
ffi::egl::WAYLAND_BUFFER_WL,
|
||||
buffer.c_ptr() as *mut _,
|
||||
buffer.as_ref().c_ptr() as *mut _,
|
||||
out.as_ptr(),
|
||||
)
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue