From 8934bf19dc6fa26e7fe3b00ef876a985776b3cb8 Mon Sep 17 00:00:00 2001 From: Victor Berger Date: Sun, 1 Oct 2017 19:14:25 +0200 Subject: [PATCH] examples: add output to winit example --- examples/winit.rs | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/examples/winit.rs b/examples/winit.rs index 057ec46..0148c07 100644 --- a/examples/winit.rs +++ b/examples/winit.rs @@ -20,11 +20,12 @@ use smithay::backend::input::{self, Event, InputBackend, InputHandler, KeyboardK use smithay::backend::winit; use smithay::wayland::compositor::{SubsurfaceRole, TraversalAction}; use smithay::wayland::compositor::roles::Role; +use smithay::wayland::output::{Mode, Output, PhysicalProperties}; use smithay::wayland::seat::{KeyboardHandle, PointerHandle, Seat}; use smithay::wayland::shm::init_shm_global; use std::cell::RefCell; use std::rc::Rc; -use wayland_server::protocol::wl_pointer; +use wayland_server::protocol::{wl_output, wl_pointer}; struct WinitInputHandler { log: Logger, @@ -148,6 +149,41 @@ fn main() { .add_keyboard("", "fr", "oss", None, 1000, 500) .expect("Failed to initialize the keyboard"); + let (output_token, _output_global) = Output::new( + &mut event_loop, + "Winit".into(), + PhysicalProperties { + width: 0, + height: 0, + subpixel: wl_output::Subpixel::Unknown, + maker: "Smithay".into(), + model: "Winit".into(), + }, + log.clone(), + ); + + let (w, h) = renderer.get_framebuffer_dimensions(); + event_loop + .state() + .get_mut(&output_token) + .change_current_state( + Some(Mode { + width: w as i32, + height: h as i32, + refresh: 60_000, + }), + None, + None, + ); + event_loop + .state() + .get_mut(&output_token) + .set_preferred(Mode { + width: w as i32, + height: h as i32, + refresh: 60_000, + }); + /* * Initialize glium */