1 Commits

View File

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