Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
refresh_panel_style
Browse files Browse the repository at this point in the history
  • Loading branch information
ruihe774 committed Dec 1, 2023
1 parent 296df7c commit 753a157
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn main() {
monitors::get_monitor_feature,
monitors::set_monitor_feature,
colors::get_accent_colors,
wm::refresh_mica,
wm::refresh_panel_style,
wm::get_workarea_corner,
tray::set_tray_icon,
])
Expand Down
21 changes: 18 additions & 3 deletions src-tauri/src/wm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::mem::{size_of, MaybeUninit};

use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
use tauri::{PhysicalPosition, Theme, Window};
use windows::core::Error;
use windows::core::{Error, PCSTR};
use windows::Win32::Foundation::{BOOL, HWND, POINT};
use windows::Win32::Graphics::Dwm::{
DwmExtendFrameIntoClientArea, DwmSetWindowAttribute, DWMSBT_MAINWINDOW,
Expand All @@ -14,13 +14,14 @@ use windows::Win32::Graphics::Gdi::{
};
use windows::Win32::UI::Controls::MARGINS;
use windows::Win32::UI::WindowsAndMessaging::{
GetWindowLongW, SetWindowLongW, GWL_STYLE, WS_SYSMENU,
FindWindowA, GetWindowLongW, SetWindowLongW, SetWindowPos, GWL_STYLE, SWP_ASYNCWINDOWPOS,
SWP_NOMOVE, SWP_NOSIZE, WS_SYSMENU,
};

use crate::util::JSResult;

#[tauri::command]
pub fn refresh_mica(window: Window) -> JSResult<()> {
pub fn refresh_panel_style(window: Window) -> JSResult<()> {
let handle = window.raw_window_handle();
let RawWindowHandle::Win32(handle) = handle else {
panic!("failed to get HWND");
Expand Down Expand Up @@ -62,6 +63,20 @@ pub fn refresh_mica(window: Window) -> JSResult<()> {
size_of::<DWM_SYSTEMBACKDROP_TYPE>() as u32,
)
}?;

let tray_wnd = unsafe { FindWindowA(PCSTR::from_raw(b"Shell_TrayWnd\0".as_ptr()), None) };
unsafe {
SetWindowPos(
hwnd,
tray_wnd,
0,
0,
0,
0,
SWP_ASYNCWINDOWPOS | SWP_NOMOVE | SWP_NOSIZE,
)
}?;

Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion src/wm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ async function showWindow(clickPosition?: RawPosition): Promise<void> {
await locatePanel(clickPosition, !preferReducedMotion());
await appWindow.show();
await appWindow.setFocus();
await invoke("refresh_mica");
await invoke("refresh_panel_style");
}

async function hideWindow(): Promise<void> {
Expand Down

0 comments on commit 753a157

Please sign in to comment.