1 Commits

View File

@@ -3,7 +3,7 @@ extern crate smithay_client_toolkit as sctk;
use std::fmt; use std::fmt;
use std::fs; use std::fs;
use calloop::{timer::{Timer, TimerHandle}, EventLoop}; use calloop::{timer::Timer, EventLoop};
use chrono::prelude::{Local, Utc}; use chrono::prelude::{Local, Utc};
use chrono::TimeZone; use chrono::TimeZone;
use chrono::Timelike; use chrono::Timelike;
@@ -685,20 +685,25 @@ fn main() {
let timer_handle = source.handle(); let timer_handle = source.handle();
timer_handle.add_timeout(std::time::Duration::from_secs(1), ""); timer_handle.add_timeout(std::time::Duration::from_secs(1), "");
handle.insert_source(source, |_, timer_handle, _| { handle
println!("Redraw!"); .insert_source(source, |_, timer_handle, event| {
redraw(&mut pool, window.surface(), dimensions).expect("Failed to draw");
window.refresh();
timer_handle.add_timeout(std::time::Duration::from_secs(1), ""); timer_handle.add_timeout(std::time::Duration::from_secs(1), "");
}); if event.is_none() {
*event = Some(sctk::window::Event::Refresh);
}
})
.unwrap();
sctk::WaylandSource::new(queue).quick_insert(handle).unwrap(); sctk::WaylandSource::new(queue)
.quick_insert(handle)
.unwrap();
loop { loop {
// Update every second // Update every second
match next_action.take() { match next_action.take() {
Some(WEvent::Close) => break, Some(WEvent::Close) => break,
Some(WEvent::Refresh) => { Some(WEvent::Refresh) => {
redraw(&mut pool, window.surface(), dimensions, &config).expect("Failed to draw");
window.refresh(); window.refresh();
window.surface().commit(); window.surface().commit();
} }