Skip to content

Commit

Permalink
fix tray module no working on different languages
Browse files Browse the repository at this point in the history
  • Loading branch information
eythaann committed Jun 13, 2024
1 parent 4a7c00c commit dcf75a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- toolbar no initialized correctly sometimes, now will retry if fails.
- battery no updating level.
- battery showing as always charging on default toolbar templates.
- tray overflow module no working on different languages.

### refactor
- refactor on window_api and AppBar structures.
Expand Down
8 changes: 5 additions & 3 deletions src/background/modules/tray/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
pcstr,
seelen::get_app_handle,
seelen_weg::icon_extractor::extract_and_save_icon,
utils::{is_windows_11_22h2, resolve_guid_path},
utils::{is_windows_11_22h2, resolve_guid_path, sleep_millis},
windows_api::{AppBarData, AppBarDataState, WindowsApi},
};

Expand All @@ -50,7 +50,8 @@ pub fn get_tray_overflow_handle() -> HWND {
unsafe {
// https://learn.microsoft.com/en-us/answers/questions/1483214/win11-22h2-(10-0-22621)-cant-support-tb-buttoncount
if is_windows_11_22h2() {
let tray_overflow_hwnd = FindWindowA(None, pcstr!("System tray overflow window."));
let tray_overflow_hwnd =
FindWindowA(pcstr!("TopLevelWindowForOverflowXamlIsland"), None);
let tray_overflow_list_hwnd = FindWindowExA(
tray_overflow_hwnd,
HWND(0),
Expand All @@ -73,7 +74,7 @@ pub fn get_tray_overflow_handle() -> HWND {

pub fn try_force_tray_overflow_creation() -> Result<()> {
unsafe {
let tray_overflow_hwnd = FindWindowA(None, pcstr!("System tray overflow window."));
let tray_overflow_hwnd = FindWindowA(pcstr!("TopLevelWindowForOverflowXamlIsland"), None);
if tray_overflow_hwnd.0 != 0 {
return Ok(());
}
Expand Down Expand Up @@ -101,6 +102,7 @@ pub fn try_force_tray_overflow_creation() -> Result<()> {
.GetCurrentPatternAs::<IUIAutomationInvokePattern>(UIA_InvokePatternId)?;
// open and close the tray to force the creation of the overflow list
invoker.Invoke()?;
sleep_millis(10);
invoker.Invoke()?;

tray_bar.set_state(tray_bar_state);
Expand Down

0 comments on commit dcf75a5

Please sign in to comment.