Merge pull request #40 from Smithay/fix/borrow
Fix examples and expand travis
This commit is contained in:
commit
c5048fea71
22
.travis.yml
22
.travis.yml
|
@ -2,7 +2,7 @@ language: rust
|
|||
|
||||
cache: cargo
|
||||
|
||||
sudo: false
|
||||
sudo: required
|
||||
|
||||
rust:
|
||||
- stable
|
||||
|
@ -21,8 +21,16 @@ dist: trusty
|
|||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libwayland-dev
|
||||
- libssl-dev
|
||||
- libudev-dev
|
||||
- libgbm-dev
|
||||
- libxkbcommon-dev
|
||||
- libegl1-mesa-dev
|
||||
|
||||
before_install:
|
||||
- sudo add-apt-repository -y ppa:wayland.admin/daily-builds
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -y libwayland-dev libinput-dev
|
||||
|
||||
branches:
|
||||
only:
|
||||
|
@ -38,13 +46,13 @@ before_script:
|
|||
- export XDG_RUNTIME_DIR="$(pwd)/socket"
|
||||
|
||||
script:
|
||||
- travis-cargo --only nightly fmt -- -- --write-mode=diff
|
||||
- travis-cargo --skip nightly build
|
||||
- travis-cargo --only nightly build -- --features "clippy"
|
||||
- travis-cargo --only stable doc -- --no-deps
|
||||
- travis-cargo -q --only nightly fmt -- -- --write-mode=diff
|
||||
- travis-cargo -q --skip nightly test
|
||||
- travis-cargo -q --only nightly test -- --features "clippy"
|
||||
- travis-cargo -q --only stable doc -- --no-deps
|
||||
|
||||
after_success:
|
||||
- travis-cargo --only stable doc-upload
|
||||
- travis-cargo -q --only stable doc-upload
|
||||
|
||||
env:
|
||||
global:
|
||||
|
|
|
@ -25,7 +25,6 @@ use smithay::compositor::{compositor_init, CompositorToken, SubsurfaceRole, Trav
|
|||
use smithay::compositor::roles::Role;
|
||||
use smithay::shell::{shell_init, ShellState};
|
||||
use smithay::shm::init_shm_global;
|
||||
use std::borrow::Borrow;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::Error as IoError;
|
||||
use std::time::Duration;
|
||||
|
@ -148,7 +147,7 @@ impl DrmHandler<GliumDrawer<DrmBackend>> for DrmHandlerImpl {
|
|||
frame.clear_color(0.8, 0.8, 0.9, 1.0);
|
||||
// redraw the frame, in a simple but inneficient way
|
||||
{
|
||||
let screen_dimensions = (drawer.borrow() as &DrmBackend).get_framebuffer_dimensions();
|
||||
let screen_dimensions = drawer.get_framebuffer_dimensions();
|
||||
for toplevel_surface in state.get(&self.shell_state_token).toplevel_surfaces() {
|
||||
if let Some(wl_surface) = toplevel_surface.get_surface() {
|
||||
// this surface is a root of a subsurface tree that needs to be drawn
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use glium;
|
||||
use glium::Surface;
|
||||
use glium::{Frame, Surface};
|
||||
use glium::index::PrimitiveType;
|
||||
use smithay::backend::graphics::egl::EGLGraphicsBackend;
|
||||
use smithay::backend::graphics::glium::GliumGraphicsBackend;
|
||||
use std::ops::Deref;
|
||||
use std::borrow::Borrow;
|
||||
use std::ops::Deref;
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct Vertex {
|
||||
|
@ -22,10 +22,10 @@ pub struct GliumDrawer<F: EGLGraphicsBackend + 'static> {
|
|||
}
|
||||
|
||||
impl<F: EGLGraphicsBackend + 'static> Deref for GliumDrawer<F> {
|
||||
type Target = GliumGraphicsBackend<F>;
|
||||
type Target = F;
|
||||
|
||||
fn deref(&self) -> &GliumGraphicsBackend<F> {
|
||||
&self.display
|
||||
fn deref(&self) -> &F {
|
||||
self.borrow()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,4 +142,9 @@ impl<F: EGLGraphicsBackend + 'static> GliumDrawer<F> {
|
|||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn draw(&self) -> Frame {
|
||||
self.display.draw()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,9 +26,8 @@ pub fn surface_implementation() -> SurfaceUserImplementation<SurfaceData, Roles,
|
|||
let height = data.height as usize;
|
||||
let mut new_vec = Vec::with_capacity(width * height * 4);
|
||||
for i in 0..height {
|
||||
new_vec.extend(
|
||||
&slice[(offset + i * stride)..(offset + i * stride + width * 4)],
|
||||
);
|
||||
new_vec
|
||||
.extend(&slice[(offset + i * stride)..(offset + i * stride + width * 4)]);
|
||||
}
|
||||
attributes.user_data.buffer =
|
||||
Some((new_vec, (data.width as u32, data.height as u32)));
|
||||
|
|
|
@ -491,12 +491,7 @@ where
|
|||
|
||||
let &mut (ref mut dev, ref mut handler) = id;
|
||||
|
||||
struct PageFlipHandler<
|
||||
'a,
|
||||
'b,
|
||||
B: Borrow<DrmBackend> + 'static,
|
||||
H: DrmHandler<B> + 'static,
|
||||
> {
|
||||
struct PageFlipHandler<'a, 'b, B: Borrow<DrmBackend> + 'static, H: DrmHandler<B> + 'static> {
|
||||
handler: &'a mut H,
|
||||
evlh: &'b mut EventLoopHandle,
|
||||
_marker: PhantomData<B>,
|
||||
|
|
|
@ -619,11 +619,11 @@ impl<'a, T: NativeSurface> EGLContext<'a, T> {
|
|||
};
|
||||
|
||||
let desc = PixelFormat {
|
||||
hardware_accelerated: attrib!(egl, display, config_id, ffi::egl::CONFIG_CAVEAT) !=
|
||||
ffi::egl::SLOW_CONFIG as i32,
|
||||
color_bits: attrib!(egl, display, config_id, ffi::egl::RED_SIZE) as u8 +
|
||||
attrib!(egl, display, config_id, ffi::egl::BLUE_SIZE) as u8 +
|
||||
attrib!(egl, display, config_id, ffi::egl::GREEN_SIZE) as u8,
|
||||
hardware_accelerated: attrib!(egl, display, config_id, ffi::egl::CONFIG_CAVEAT)
|
||||
!= ffi::egl::SLOW_CONFIG as i32,
|
||||
color_bits: attrib!(egl, display, config_id, ffi::egl::RED_SIZE) as u8
|
||||
+ attrib!(egl, display, config_id, ffi::egl::BLUE_SIZE) as u8
|
||||
+ attrib!(egl, display, config_id, ffi::egl::GREEN_SIZE) as u8,
|
||||
alpha_bits: attrib!(egl, display, config_id, ffi::egl::ALPHA_SIZE) as u8,
|
||||
depth_bits: attrib!(egl, display, config_id, ffi::egl::DEPTH_SIZE) as u8,
|
||||
stencil_bits: attrib!(egl, display, config_id, ffi::egl::STENCIL_SIZE) as u8,
|
||||
|
|
|
@ -308,8 +308,8 @@ impl PointerMotionAbsoluteEvent for WinitMouseMovedEvent {
|
|||
|
||||
fn x_transformed(&self, width: u32) -> u32 {
|
||||
cmp::min(
|
||||
(self.x * width as f64 /
|
||||
self.window
|
||||
(self.x * width as f64
|
||||
/ self.window
|
||||
.head()
|
||||
.get_inner_size_points()
|
||||
.unwrap_or((width, 0))
|
||||
|
@ -320,8 +320,8 @@ impl PointerMotionAbsoluteEvent for WinitMouseMovedEvent {
|
|||
|
||||
fn y_transformed(&self, height: u32) -> u32 {
|
||||
cmp::min(
|
||||
(self.y * height as f64 /
|
||||
self.window
|
||||
(self.y * height as f64
|
||||
/ self.window
|
||||
.head()
|
||||
.get_inner_size_points()
|
||||
.unwrap_or((0, height))
|
||||
|
@ -421,8 +421,8 @@ impl TouchDownEvent for WinitTouchStartedEvent {
|
|||
|
||||
fn x_transformed(&self, width: u32) -> u32 {
|
||||
cmp::min(
|
||||
self.location.0 as i32 * width as i32 /
|
||||
self.window
|
||||
self.location.0 as i32 * width as i32
|
||||
/ self.window
|
||||
.head()
|
||||
.get_inner_size_points()
|
||||
.unwrap_or((width, 0))
|
||||
|
@ -433,8 +433,8 @@ impl TouchDownEvent for WinitTouchStartedEvent {
|
|||
|
||||
fn y_transformed(&self, height: u32) -> u32 {
|
||||
cmp::min(
|
||||
self.location.1 as i32 * height as i32 /
|
||||
self.window
|
||||
self.location.1 as i32 * height as i32
|
||||
/ self.window
|
||||
.head()
|
||||
.get_inner_size_points()
|
||||
.unwrap_or((0, height))
|
||||
|
@ -473,8 +473,8 @@ impl TouchMotionEvent for WinitTouchMovedEvent {
|
|||
}
|
||||
|
||||
fn x_transformed(&self, width: u32) -> u32 {
|
||||
self.location.0 as u32 * width /
|
||||
self.window
|
||||
self.location.0 as u32 * width
|
||||
/ self.window
|
||||
.head()
|
||||
.get_inner_size_points()
|
||||
.unwrap_or((width, 0))
|
||||
|
@ -482,8 +482,8 @@ impl TouchMotionEvent for WinitTouchMovedEvent {
|
|||
}
|
||||
|
||||
fn y_transformed(&self, height: u32) -> u32 {
|
||||
self.location.1 as u32 * height /
|
||||
self.window
|
||||
self.location.1 as u32 * height
|
||||
/ self.window
|
||||
.head()
|
||||
.get_inner_size_points()
|
||||
.unwrap_or((0, height))
|
||||
|
@ -619,9 +619,10 @@ impl InputBackend for WinitInputBackend {
|
|||
}
|
||||
(
|
||||
WindowEvent::KeyboardInput {
|
||||
input: KeyboardInput {
|
||||
scancode, state, ..
|
||||
},
|
||||
input:
|
||||
KeyboardInput {
|
||||
scancode, state, ..
|
||||
},
|
||||
..
|
||||
},
|
||||
Some(handler),
|
||||
|
|
|
@ -227,9 +227,7 @@ where
|
|||
);
|
||||
return;
|
||||
}
|
||||
subsurface.set_user_data(
|
||||
Box::into_raw(Box::new(unsafe { surface.clone_unchecked() })) as *mut _,
|
||||
);
|
||||
subsurface.set_user_data(Box::into_raw(Box::new(unsafe { surface.clone_unchecked() })) as *mut _);
|
||||
evlh.register(
|
||||
&subsurface,
|
||||
subsurface_implementation::<U, R>(),
|
||||
|
@ -253,9 +251,8 @@ where
|
|||
{
|
||||
let ptr = subsurface.get_user_data();
|
||||
let surface = &*(ptr as *mut wl_surface::WlSurface);
|
||||
SurfaceData::<U, R>::with_role_data::<SubsurfaceRole, _, _>(surface, |d| f(d)).expect(
|
||||
"The surface does not have a subsurface role while it has a wl_subsurface?!",
|
||||
);
|
||||
SurfaceData::<U, R>::with_role_data::<SubsurfaceRole, _, _>(surface, |d| f(d))
|
||||
.expect("The surface does not have a subsurface role while it has a wl_subsurface?!");
|
||||
}
|
||||
|
||||
fn subsurface_implementation<U, R>() -> wl_subsurface::Implementation<()>
|
||||
|
|
|
@ -11,9 +11,8 @@ pub struct RegionData {
|
|||
impl RegionData {
|
||||
/// Initialize the user_data of a region, must be called right when the surface is created
|
||||
pub unsafe fn init(region: &wl_region::WlRegion) {
|
||||
region.set_user_data(
|
||||
Box::into_raw(Box::new(Mutex::new(RegionData::default()))) as *mut _,
|
||||
)
|
||||
region.set_user_data(Box::into_raw(Box::new(Mutex::new(RegionData::default())))
|
||||
as *mut _)
|
||||
}
|
||||
|
||||
/// Cleans the user_data of that surface, must be called when it is destroyed
|
||||
|
|
|
@ -57,9 +57,7 @@ impl<U: Default, R: Default> SurfaceData<U, R> {
|
|||
|
||||
/// Initialize the user_data of a surface, must be called right when the surface is created
|
||||
pub unsafe fn init(surface: &wl_surface::WlSurface) {
|
||||
surface.set_user_data(
|
||||
Box::into_raw(Box::new(Mutex::new(SurfaceData::<U, R>::new()))) as *mut _,
|
||||
)
|
||||
surface.set_user_data(Box::into_raw(Box::new(Mutex::new(SurfaceData::<U, R>::new()))) as *mut _)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -596,9 +596,7 @@ where
|
|||
}
|
||||
let configured = self.token
|
||||
.with_role_data::<ShellSurfaceRole, _, _>(&self.wl_surface, |data| data.configured)
|
||||
.expect(
|
||||
"A shell surface object exists but the surface does not have the shell_surface role ?!",
|
||||
);
|
||||
.expect("A shell surface object exists but the surface does not have the shell_surface role ?!");
|
||||
if !configured {
|
||||
if let SurfaceKind::XdgToplevel(ref s) = self.shell_surface {
|
||||
let ptr = s.get_user_data();
|
||||
|
@ -733,9 +731,7 @@ where
|
|||
}
|
||||
let configured = self.token
|
||||
.with_role_data::<ShellSurfaceRole, _, _>(&self.wl_surface, |data| data.configured)
|
||||
.expect(
|
||||
"A shell surface object exists but the surface does not have the shell_surface role ?!",
|
||||
);
|
||||
.expect("A shell surface object exists but the surface does not have the shell_surface role ?!");
|
||||
if !configured {
|
||||
if let SurfaceKind::XdgPopup(ref s) = self.shell_surface {
|
||||
let ptr = s.get_user_data();
|
||||
|
|
|
@ -78,9 +78,8 @@ where
|
|||
);
|
||||
return;
|
||||
}
|
||||
shell_surface.set_user_data(
|
||||
Box::into_raw(Box::new(unsafe { surface.clone_unchecked() })) as *mut _,
|
||||
);
|
||||
shell_surface
|
||||
.set_user_data(Box::into_raw(Box::new(unsafe { surface.clone_unchecked() })) as *mut _);
|
||||
evlh.register(
|
||||
&shell_surface,
|
||||
shell_surface_implementation(),
|
||||
|
@ -243,9 +242,7 @@ where
|
|||
});
|
||||
return true;
|
||||
})
|
||||
.expect(
|
||||
"xdg_surface exists but surface has not shell_surface role?!",
|
||||
);
|
||||
.expect("xdg_surface exists but surface has not shell_surface role?!");
|
||||
// we need to notify about this new toplevel surface
|
||||
if need_send {
|
||||
evlh.state()
|
||||
|
|
|
@ -19,9 +19,7 @@ where
|
|||
SID: 'static,
|
||||
SD: Default + 'static,
|
||||
{
|
||||
shell.set_user_data(
|
||||
Box::into_raw(Box::new(Mutex::new(make_shell_client_data::<SD>()))) as *mut _,
|
||||
);
|
||||
shell.set_user_data(Box::into_raw(Box::new(Mutex::new(make_shell_client_data::<SD>()))) as *mut _);
|
||||
evlh.register(
|
||||
&shell,
|
||||
shell_implementation(),
|
||||
|
@ -222,11 +220,8 @@ fn destroy_surface(surface: &zxdg_surface_v6::ZxdgSurfaceV6) {
|
|||
let ptr = surface.get_user_data();
|
||||
surface.set_user_data(::std::ptr::null_mut());
|
||||
// drop the state
|
||||
let data = unsafe {
|
||||
Box::from_raw(
|
||||
ptr as *mut (zxdg_surface_v6::ZxdgSurfaceV6, zxdg_shell_v6::ZxdgShellV6),
|
||||
)
|
||||
};
|
||||
let data =
|
||||
unsafe { Box::from_raw(ptr as *mut (zxdg_surface_v6::ZxdgSurfaceV6, zxdg_shell_v6::ZxdgShellV6)) };
|
||||
// explicit call to drop to not forget what we're doing here
|
||||
::std::mem::drop(data);
|
||||
}
|
||||
|
@ -258,9 +253,7 @@ where
|
|||
);
|
||||
}
|
||||
})
|
||||
.expect(
|
||||
"xdg_surface exists but surface has not shell_surface role?!",
|
||||
);
|
||||
.expect("xdg_surface exists but surface has not shell_surface role?!");
|
||||
},
|
||||
get_toplevel: |evlh, idata, _, xdg_surface, toplevel| {
|
||||
let ptr = xdg_surface.get_user_data();
|
||||
|
@ -277,9 +270,7 @@ where
|
|||
max_size: (0, 0),
|
||||
});
|
||||
})
|
||||
.expect(
|
||||
"xdg_surface exists but surface has not shell_surface role?!",
|
||||
);
|
||||
.expect("xdg_surface exists but surface has not shell_surface role?!");
|
||||
|
||||
toplevel.set_user_data(Box::into_raw(Box::new(unsafe {
|
||||
(
|
||||
|
@ -326,9 +317,7 @@ where
|
|||
positioner: positioner_data.clone(),
|
||||
});
|
||||
})
|
||||
.expect(
|
||||
"xdg_surface exists but surface has not shell_surface role?!",
|
||||
);
|
||||
.expect("xdg_surface exists but surface has not shell_surface role?!");
|
||||
|
||||
popup.set_user_data(Box::into_raw(Box::new(unsafe {
|
||||
(
|
||||
|
@ -370,9 +359,7 @@ where
|
|||
height,
|
||||
});
|
||||
})
|
||||
.expect(
|
||||
"xdg_surface exists but surface has not shell_surface role?!",
|
||||
);
|
||||
.expect("xdg_surface exists but surface has not shell_surface role?!");
|
||||
},
|
||||
ack_configure: |_, idata, _, surface, serial| {
|
||||
let ptr = surface.get_user_data();
|
||||
|
@ -397,9 +384,7 @@ where
|
|||
}
|
||||
data.configured = true;
|
||||
})
|
||||
.expect(
|
||||
"xdg_surface exists but surface has not shell_surface role?!",
|
||||
);
|
||||
.expect("xdg_surface exists but surface has not shell_surface role?!");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -442,9 +427,7 @@ where
|
|||
ShellSurfacePendingState::Toplevel(ref mut toplevel_data) => f(toplevel_data),
|
||||
_ => unreachable!(),
|
||||
})
|
||||
.expect(
|
||||
"xdg_toplevel exists but surface has not shell_surface role?!",
|
||||
);
|
||||
.expect("xdg_toplevel exists but surface has not shell_surface role?!");
|
||||
}
|
||||
|
||||
fn xdg_handle_display_state_change<U, R, CID, SID, SD>(evlh: &mut EventLoopHandle,
|
||||
|
@ -503,9 +486,7 @@ where
|
|||
// Add the configure as pending
|
||||
token
|
||||
.with_role_data::<ShellSurfaceRole, _, _>(surface, |data| data.pending_configures.push(serial))
|
||||
.expect(
|
||||
"xdg_toplevel exists but surface has not shell_surface role?!",
|
||||
);
|
||||
.expect("xdg_toplevel exists but surface has not shell_surface role?!");
|
||||
}
|
||||
|
||||
fn make_toplevel_handle<U, R, H, SD>(token: CompositorToken<U, R, H>,
|
||||
|
@ -541,9 +522,7 @@ where
|
|||
data.pending_state = ShellSurfacePendingState::None;
|
||||
data.configured = false;
|
||||
})
|
||||
.expect(
|
||||
"xdg_toplevel exists but surface has not shell_surface role?!",
|
||||
);
|
||||
.expect("xdg_toplevel exists but surface has not shell_surface role?!");
|
||||
// remove this surface from the known ones (as well as any leftover dead surface)
|
||||
evlh.state()
|
||||
.get_mut(&idata.state_token)
|
||||
|
@ -651,9 +630,7 @@ where
|
|||
// Add the configure as pending
|
||||
token
|
||||
.with_role_data::<ShellSurfaceRole, _, _>(surface, |data| data.pending_configures.push(serial))
|
||||
.expect(
|
||||
"xdg_toplevel exists but surface has not shell_surface role?!",
|
||||
);
|
||||
.expect("xdg_toplevel exists but surface has not shell_surface role?!");
|
||||
}
|
||||
|
||||
fn make_popup_handle<U, R, H, SD>(token: CompositorToken<U, R, H>, resource: &zxdg_popup_v6::ZxdgPopupV6)
|
||||
|
@ -682,8 +659,8 @@ where
|
|||
destroy: |evlh, idata, _, popup| {
|
||||
let ptr = popup.get_user_data();
|
||||
let &(ref surface, _, _) = unsafe {
|
||||
&*(ptr as
|
||||
*mut (
|
||||
&*(ptr
|
||||
as *mut (
|
||||
wl_surface::WlSurface,
|
||||
zxdg_shell_v6::ZxdgShellV6,
|
||||
zxdg_surface_v6::ZxdgSurfaceV6,
|
||||
|
@ -695,9 +672,7 @@ where
|
|||
data.pending_state = ShellSurfacePendingState::None;
|
||||
data.configured = false;
|
||||
})
|
||||
.expect(
|
||||
"xdg_toplevel exists but surface has not shell_surface role?!",
|
||||
);
|
||||
.expect("xdg_toplevel exists but surface has not shell_surface role?!");
|
||||
// remove this surface from the known ones (as well as any leftover dead surface)
|
||||
evlh.state()
|
||||
.get_mut(&idata.state_token)
|
||||
|
|
Loading…
Reference in New Issue