Skip to content

Commit

Permalink
fix system events
Browse files Browse the repository at this point in the history
  • Loading branch information
eythaann committed Jun 26, 2024
1 parent d5e14ef commit 0d7412a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog

## [Unreleased]
### fix
- no registering system events (battery/network/etc)

## [1.7.6]
### enhancements
- improve logging on dev mode and fix missing target on production logged errors.
Expand Down
2 changes: 2 additions & 0 deletions src/background/hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ pub extern "system" fn win_event_hook(
}

pub fn register_win_hook() -> Result<()> {
log::trace!("Registering Windows and Virtual Desktop Hooks");

std::thread::spawn(move || unsafe {
SetWinEventHook(EVENT_MIN, EVENT_MAX, None, Some(win_event_hook), 0, 0, 0);

Expand Down
5 changes: 2 additions & 3 deletions src/background/seelen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
seelen_weg::SeelenWeg,
seelen_wm::WindowManager,
state::State,
system::register_system_events,
system::declare_system_events_handlers,
utils::{ahk::AutoHotKey, sleep_millis},
windows_api::WindowsApi,
};
Expand Down Expand Up @@ -131,6 +131,7 @@ impl Seelen {
}

self.start_ahk_shortcuts()?;
declare_system_events_handlers()?;

std::thread::spawn(|| -> Result<()> {
log::trace!("Enumerating Monitors");
Expand All @@ -147,9 +148,7 @@ impl Seelen {
WindowsApi::enum_windows(Some(Self::enum_windows_proc), 0)
.expect("Failed to enum windows");

log::trace!("Registering Windows and System Events");
register_win_hook()?;
register_system_events()?;
Ok(())
});

Expand Down
2 changes: 1 addition & 1 deletion src/background/system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
seelen::get_app_handle,
};

pub fn register_system_events() -> Result<()> {
pub fn declare_system_events_handlers() -> Result<()> {
let handle = get_app_handle();

handle.once("register-power-events", move |_| {
Expand Down

0 comments on commit 0d7412a

Please sign in to comment.