removed the unused hotkey_stop flag

This commit is contained in:
Nickiel12 2022-07-16 22:18:51 -07:00
parent 3962a48843
commit 970eabdda8
2 changed files with 5 additions and 8 deletions

View file

@ -31,7 +31,7 @@ const SERVER_ADDRESS: &str = "10.0.0.168:5000";
fn main() { fn main() {
let icon = include_bytes!("icon1.ico"); let icon = include_bytes!("icon1.ico");
let mut tray_icon = tray_icon::TrayIcon::setup(icon); let tray_icon = tray_icon::TrayIcon::setup(icon);
let settings_json = load_json(); let settings_json = load_json();
let hotkeys = Hotkeys::new(settings_json); let hotkeys = Hotkeys::new(settings_json);
@ -42,12 +42,11 @@ fn main() {
let mut socket = let mut socket =
Socket::handle_connections(Socket::make_listener(SERVER_ADDRESS), from_socket_tx); Socket::handle_connections(Socket::make_listener(SERVER_ADDRESS), from_socket_tx);
let (hotkey_close_flag_tx, hotkey_close_flag_rx) = sync_flag::new_syncflag(true); let control_c_called_flag_rx = setup_control_c();
let control_c_called_flag_rx = setup_control_c(hotkey_close_flag_tx);
let hotkey_handle = thread::spawn(move || { let hotkey_handle = thread::spawn(move || {
println!("starting hotkey thread"); println!("starting hotkey thread");
modules::external_interface::create_keyboard_hooks(hotkey_channel_tx, hotkey_close_flag_rx); modules::external_interface::create_keyboard_hooks(hotkey_channel_tx);
println!("closing hotkey thread"); println!("closing hotkey thread");
}); });
@ -106,12 +105,11 @@ fn handle_instructions(
} }
} }
fn setup_control_c(mut hotkey_close_flag_tx: sync_flag::SyncFlagTx) -> sync_flag::SyncFlagRx { fn setup_control_c() -> sync_flag::SyncFlagRx {
let (mut control_c_flag_tx, control_c_called_flag_rx) = sync_flag::new_syncflag(false); let (mut control_c_flag_tx, control_c_called_flag_rx) = sync_flag::new_syncflag(false);
ctrlc::set_handler(move || { ctrlc::set_handler(move || {
println!("ctrl c caught"); println!("ctrl c caught");
control_c_flag_tx.set(true); control_c_flag_tx.set(true);
hotkey_close_flag_tx.set(false);
}) })
.expect("control C handler failed!"); .expect("control C handler failed!");
control_c_called_flag_rx control_c_called_flag_rx

View file

@ -21,7 +21,6 @@ pub const OPTIONS_PATH: &str = "./options.json";
pub fn create_keyboard_hooks( pub fn create_keyboard_hooks(
channel_tx: crossbeam_channel::Sender<String>, channel_tx: crossbeam_channel::Sender<String>,
close_flag: workctl::sync_flag::SyncFlagRx,
) { ) {
let tx_1 = channel_tx.clone(); let tx_1 = channel_tx.clone();
inputbot::KeybdKey::PageUpKey.bind(move || { inputbot::KeybdKey::PageUpKey.bind(move || {
@ -44,7 +43,7 @@ pub fn create_keyboard_hooks(
}); });
#[cfg(feature = "default")] #[cfg(feature = "default")]
inputbot::handle_input_events(close_flag); inputbot::handle_input_events();
} }
#[cfg(feature = "no_hotkeys")] #[cfg(feature = "no_hotkeys")]