Skip to content

Commit

Permalink
Merge pull request #88 from Smithay/wayland_rs_20
Browse files Browse the repository at this point in the history
Upgrade to wayland-rs 0.20
  • Loading branch information
vberger authored Apr 24, 2018
2 parents 2d7d01e + 4fda0be commit 60fc479
Show file tree
Hide file tree
Showing 45 changed files with 4,940 additions and 3,735 deletions.
9 changes: 0 additions & 9 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
error_on_line_overflow = false
fn_args_density = "Compressed"
fn_args_layout = "Visual"
fn_arg_intent = "Tabbed"
reorder_imports = true
reorder_imported_names = true
report_todo = "Never"
report_fixme = "Never"
use_try_shorthand = true
max_width = 110
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ rust:

sudo: required

branches:
only:
- master

dist: trusty

# We cannot cache .vagga, because we actually do not have read permissions
Expand Down
13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ description = "Smithay is a library for writing wayland compositors."
repository = "https://github.com/Smithay/smithay"

[dependencies]
wayland-server = "0.14.0"
wayland-sys = "0.14.0"
nix = "0.9.0"
wayland-server = "0.20.1"
wayland-sys = "0.20.1"
nix = "0.10.0"
xkbcommon = "0.2.1"
tempfile = "2.1.5"
slog = { version = "2.1.1" }
slog-stdlog = "3.0.2"
libloading = "0.4.0"
wayland-client = { version = "0.12.5", optional = true }
wayland-client = { version = "0.20.1", optional = true }
winit = { version = "0.10.0", optional = true }
drm = { version = "^0.3.1", optional = true }
gbm = { version = "^0.4.0", optional = true, default-features = false, features = ["drm-support"] }
Expand All @@ -24,7 +24,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.14.0", features = ["unstable_protocols", "server"] }
wayland-protocols = { version = "0.20.1", features = ["unstable_protocols", "server"] }
image = "0.17.0"
error-chain = "0.11.0"
lazy_static = "1.0.0"
Expand All @@ -38,7 +38,7 @@ slog-async = "2.2"
rand = "0.3"

[features]
default = ["backend_winit", "backend_drm", "backend_libinput", "backend_udev", "renderer_glium", "backend_session_logind"]
default = ["backend_winit", "backend_drm", "backend_libinput", "backend_udev", "renderer_glium"]
backend_winit = ["winit", "wayland-server/dlopen", "wayland-client/dlopen"]
backend_drm = ["drm", "gbm"]
backend_libinput = ["input"]
Expand All @@ -47,3 +47,4 @@ backend_session_udev = ["udev", "backend_session"]
backend_session_logind = ["dbus", "systemd", "backend_session"]
backend_udev = ["udev", "backend_drm", "backend_session_udev"]
renderer_glium = ["glium"]

26 changes: 14 additions & 12 deletions examples/drm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use std::os::unix::io::AsRawFd;
use std::os::unix::io::RawFd;
use std::rc::Rc;
use std::time::Duration;
use wayland_server::EventLoopHandle;

#[derive(Debug)]
pub struct Card(File);
Expand All @@ -56,7 +55,7 @@ fn main() {
);

// Initialize the wayland server
let (mut display, mut event_loop) = wayland_server::create_display();
let (mut display, mut event_loop) = wayland_server::Display::new();

/*
* Initialize the drm backend
Expand Down Expand Up @@ -124,10 +123,10 @@ fn main() {
* Initialize the globals
*/

init_shm_global(&mut event_loop, vec![], log.clone());
init_shm_global(&mut display, event_loop.token(), vec![], log.clone());

let (compositor_token, _shell_state_token, window_map) =
init_shell(&mut event_loop, log.clone(), egl_display.clone());
let (compositor_token, _, _, window_map) =
init_shell(&mut display, event_loop.token(), log.clone(), egl_display);

/*
* Add a listening socket:
Expand All @@ -139,7 +138,7 @@ fn main() {
* Register the DrmDevice on the EventLoop
*/
let _source = drm_device_bind(
&mut event_loop,
&event_loop.token(),
device,
DrmHandlerImpl {
compositor_token,
Expand All @@ -159,16 +158,19 @@ fn main() {
}

pub struct DrmHandlerImpl {
compositor_token: CompositorToken<SurfaceData, Roles, Rc<RefCell<Option<EGLDisplay>>>>,
compositor_token: CompositorToken<SurfaceData, Roles>,
window_map: Rc<RefCell<MyWindowMap>>,
drawer: GliumDrawer<DrmBackend<Card>>,
logger: ::slog::Logger,
}

impl DrmHandler<Card> for DrmHandlerImpl {
fn ready(
&mut self, _evlh: &mut EventLoopHandle, _device: &mut DrmDevice<Card>, _crtc: crtc::Handle,
_frame: u32, _duration: Duration,
&mut self,
_device: &mut DrmDevice<Card>,
_crtc: crtc::Handle,
_frame: u32,
_duration: Duration,
) {
let mut frame = self.drawer.draw();
frame.clear_color(0.8, 0.8, 0.9, 1.0);
Expand Down Expand Up @@ -215,8 +217,8 @@ impl DrmHandler<Card> for DrmHandlerImpl {

if let Some(ref texture) = attributes.user_data.texture {
if let Ok(subdata) = Role::<SubsurfaceRole>::data(role) {
x += subdata.x;
y += subdata.y;
x += subdata.location.0;
y += subdata.location.1;
}
info!(self.logger, "Render window");
self.drawer.render_texture(
Expand Down Expand Up @@ -248,7 +250,7 @@ impl DrmHandler<Card> for DrmHandlerImpl {
frame.finish().unwrap();
}

fn error(&mut self, _evlh: &mut EventLoopHandle, _device: &mut DrmDevice<Card>, error: DrmError) {
fn error(&mut self, _device: &mut DrmDevice<Card>, error: DrmError) {
panic!("{:?}", error);
}
}
9 changes: 7 additions & 2 deletions examples/helpers/glium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,13 @@ impl<F: EGLGraphicsBackend + 'static> GliumDrawer<F> {
}

pub fn render_texture(
&self, target: &mut glium::Frame, texture: &Texture2d, y_inverted: bool,
surface_dimensions: (u32, u32), surface_location: (i32, i32), screen_size: (u32, u32),
&self,
target: &mut glium::Frame,
texture: &Texture2d,
y_inverted: bool,
surface_dimensions: (u32, u32),
surface_location: (i32, i32),
screen_size: (u32, u32),
blending: glium::Blend,
) {
let xscale = 2.0 * (surface_dimensions.0 as f32) / (screen_size.0 as f32);
Expand Down
Loading

0 comments on commit 60fc479

Please sign in to comment.