Slight cleanup

This commit is contained in:
Kenny Levinsen
2019-08-01 11:07:33 +02:00
parent 14a1611e9e
commit 9ac29b2a94
3 changed files with 7 additions and 17 deletions
+1 -1
View File
@@ -116,7 +116,7 @@ impl ModuleImpl for Backlight {
384, 384,
24, 24,
self.brightness() / 100.0, self.brightness() / 100.0,
); )?;
Ok(vec![buf.get_signed_bounds()]) Ok(vec![buf.get_signed_bounds()])
} }
+1 -1
View File
@@ -112,7 +112,7 @@ pub fn draw_bar(
) -> Result<(), ::std::io::Error> { ) -> Result<(), ::std::io::Error> {
let mut buf = buf.subdimensions((0, 0, length, height)); let mut buf = buf.subdimensions((0, 0, length, height));
let mut fill_pos = (((length as f32) * fill) as u32); let mut fill_pos = ((length as f32) * fill) as u32;
if fill_pos > length { if fill_pos > length {
fill_pos = length; fill_pos = length;
} }
+5 -15
View File
@@ -46,7 +46,6 @@ struct App {
display: Display, display: Display,
event_queue: EventQueue, event_queue: EventQueue,
surface: wl_surface::WlSurface, surface: wl_surface::WlSurface,
shell_surface: zwlr_layer_surface_v1::ZwlrLayerSurfaceV1,
cmd_queue: Arc<Mutex<VecDeque<Cmd>>>, cmd_queue: Arc<Mutex<VecDeque<Cmd>>>,
dimensions: (u32, u32), dimensions: (u32, u32),
modules: Vec<Module>, modules: Vec<Module>,
@@ -101,10 +100,6 @@ impl App {
Ok(()) Ok(())
} }
fn shell_surface(&mut self) -> &mut zwlr_layer_surface_v1::ZwlrLayerSurfaceV1 {
&mut self.shell_surface
}
fn cmd_queue(&self) -> Arc<Mutex<VecDeque<Cmd>>> { fn cmd_queue(&self) -> Arc<Mutex<VecDeque<Cmd>>> {
self.cmd_queue.clone() self.cmd_queue.clone()
} }
@@ -113,10 +108,6 @@ impl App {
self.display.flush().expect("unable to flush display"); self.display.flush().expect("unable to flush display");
} }
fn dimensions(&self) -> (u32, u32) {
self.dimensions
}
fn event_queue(&mut self) -> &mut EventQueue { fn event_queue(&mut self) -> &mut EventQueue {
&mut self.event_queue &mut self.event_queue
} }
@@ -221,6 +212,7 @@ impl App {
|_, _| {}, |_, _| {},
) )
.expect("Failed to map keyboard"); .expect("Failed to map keyboard");
event_queue.sync_roundtrip().unwrap();
// //
// Prepare shell so that we can create our shell surface // Prepare shell so that we can create our shell surface
@@ -236,9 +228,6 @@ impl App {
panic!("server didn't advertise `zwlr_layer_shell_v1`"); panic!("server didn't advertise `zwlr_layer_shell_v1`");
}; };
// sync to retrieve the global events
event_queue.sync_roundtrip().unwrap();
let surface = compositor let surface = compositor
.create_surface(NewProxy::implement_dummy) .create_surface(NewProxy::implement_dummy)
.unwrap(); .unwrap();
@@ -270,9 +259,11 @@ impl App {
.unwrap(); .unwrap();
shell_surface.set_keyboard_interactivity(1); shell_surface.set_keyboard_interactivity(1);
shell_surface.set_size(dimensions.0, dimensions.1);
surface.commit(); surface.commit();
event_queue.sync_roundtrip().unwrap(); event_queue.sync_roundtrip().unwrap();
// //
// Cursor processing // Cursor processing
// //
@@ -372,9 +363,10 @@ impl App {
modules.push(Module::new(Box::new(m), (720, 0, 512, 32))); modules.push(Module::new(Box::new(m), (720, 0, 512, 32)));
} }
event_queue.sync_roundtrip().unwrap();
App { App {
surface: surface, surface: surface,
shell_surface: shell_surface,
display: display, display: display,
event_queue: event_queue, event_queue: event_queue,
cmd_queue: cmd_queue, cmd_queue: cmd_queue,
@@ -417,8 +409,6 @@ fn main() {
match cmd { match cmd {
Some(cmd) => match cmd { Some(cmd) => match cmd {
Cmd::Configure => { Cmd::Configure => {
let d = app.dimensions();
app.shell_surface().set_size(d.0, d.1);
app.wipe(); app.wipe();
app.redraw(true).expect("Failed to draw"); app.redraw(true).expect("Failed to draw");
app.flush_display(); app.flush_display();