Use calloop

This commit is contained in:
Ian Douglas Scott 2024-10-17 18:09:10 -07:00
parent 315bc8cd90
commit 6d15d0f3c9
3 changed files with 13 additions and 4 deletions

2
Cargo.lock generated
View file

@ -170,6 +170,8 @@ dependencies = [
name = "cosmic-idle"
version = "0.1.0"
dependencies = [
"calloop",
"calloop-wayland-source",
"cosmic-config",
"cosmic-idle-config",
"keyframe",

View file

@ -11,6 +11,8 @@ wayland-protocols = { version = "0.32.3", features = ["client", "staging"] }
wayland-protocols-wlr = { version = "0.3.3", features = ["client"] }
cosmic-config = { git = "https://github.com/pop-os/libcosmic" }
cosmic-idle-config = { path = "./cosmic-idle-config" }
calloop = "0.13.0"
calloop-wayland-source = "0.3.0"
[workspace]
members = [

View file

@ -1,5 +1,7 @@
#![allow(clippy::single_match)]
use calloop::EventLoop;
use calloop_wayland_source::WaylandSource;
use keyframe::{ease, functions::EaseInOut};
use std::time::{Duration, Instant};
use wayland_client::{
@ -132,7 +134,7 @@ impl State {
fn main() {
let connection = Connection::connect_to_env().unwrap();
let (globals, mut event_queue) = registry_queue_init::<State>(&connection).unwrap();
let (globals, event_queue) = registry_queue_init::<State>(&connection).unwrap();
let qh = event_queue.handle();
let output_power_manager = globals
@ -200,9 +202,12 @@ fn main() {
_idle_notification,
outputs,
};
loop {
event_queue.blocking_dispatch(&mut state).unwrap();
}
let mut event_loop: EventLoop<State> = EventLoop::try_new().unwrap();
WaylandSource::new(connection, event_queue)
.insert(event_loop.handle())
.unwrap();
while let Ok(_) = event_loop.dispatch(None, &mut state) {}
}
impl Dispatch<wl_registry::WlRegistry, GlobalListContents> for State {