diff --git a/src/main.rs b/src/main.rs index 5d2deb4..bc01a2c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use crossbeam_channel::unbounded; +use tray_icon::TrayIcon; use std::{io::Read, thread, time::Duration}; use modules::{ @@ -73,12 +74,12 @@ fn main() { let tick_update = state.tick(); handle_instructions(tick_update, &mut state, &socket, &hotkeys); - println!("{:?}", messages.recv()); + TrayIcon::handle_tray_messages(&messages); } socket.close(); }); while !stop_flag.get() { - tray_icon.process_tray_messages(); + tray_icon.check_tray_icon_messages(); //tray_icon.check_tray_messages(); } diff --git a/src/modules/tray_icon.rs b/src/modules/tray_icon.rs index 5f25565..2afccfa 100644 --- a/src/modules/tray_icon.rs +++ b/src/modules/tray_icon.rs @@ -1,7 +1,9 @@ use core::mem::MaybeUninit; use std::time::Duration; +use crossbeam_channel::Receiver; use trayicon::*; use winapi::um::winuser; +use workctl::sync_flag::SyncFlagRx; #[derive(Copy, Clone, Eq, PartialEq, Debug)] pub enum Events { @@ -71,7 +73,7 @@ impl TrayIcon { } } - pub fn process_tray_messages(&self) { + pub fn check_tray_icon_messages(&self) { unsafe { let mut msg = MaybeUninit::uninit(); let bret = winuser::PeekMessageA(msg.as_mut_ptr(), 0 as _, 0, 0, 1); @@ -85,8 +87,8 @@ impl TrayIcon { } } - pub fn check_tray_messages(&self) { - let message = self.message_channel.recv_timeout(Duration::from_millis(10)); + pub fn handle_tray_messages(message_channel: &Receiver) { + let message = message_channel.recv_timeout(Duration::from_millis(10)); match message { Err(_) => return, Ok(message) => {