check miximized
parent
5a48735f36
commit
31fcf4ea83
|
|
@ -33,3 +33,7 @@ playerInstance* player_instance = NULL;
|
|||
extern "C" __declspec(dllexport) BOOL set_wallpaper(const char* window_title) {
|
||||
return set_as_wallpaper(window_title);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) BOOL anyMaximized() {
|
||||
return !detectWindowMaximized();
|
||||
}
|
||||
|
|
@ -87,3 +87,13 @@ BOOL set_as_wallpaper(const char* window_title) {
|
|||
EnumWindows(EnumWindowsProc, 0);// 找到第二个workerw窗口并隐藏它
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL CALLBACK CheckMaximized(_In_ HWND hwnd, _In_ LPARAM Lparam) {
|
||||
BOOL isMaximized = IsZoomed(hwnd);
|
||||
if (isMaximized) return FALSE;
|
||||
else return TRUE;
|
||||
}
|
||||
|
||||
BOOL detectWindowMaximized() {
|
||||
return EnumWindows(CheckMaximized, 0);
|
||||
}
|
||||
|
|
@ -14,3 +14,4 @@ public:
|
|||
};
|
||||
|
||||
BOOL set_as_wallpaper(const char* window_title);
|
||||
BOOL detectWindowMaximized();
|
||||
|
|
@ -1,5 +1,30 @@
|
|||
use std::ffi::CString;
|
||||
use libloading::{Library, Symbol};
|
||||
use std::{ffi::CString, rc::Rc, sync::Arc};
|
||||
|
||||
struct CoreModule<'a>{
|
||||
module:Arc<Library>,
|
||||
set_wallpaper:Arc<Symbol<'a,unsafe extern "C" fn(*const i8) -> i8>>,
|
||||
any_maximized:Arc<Symbol<'a,unsafe extern "C" fn() -> i8>>
|
||||
}
|
||||
|
||||
impl<'a> CoreModule<'a> {
|
||||
fn new(library_path: &str) -> Result<Self, libloading::Error> {
|
||||
let lib = Arc::new(unsafe { Library::new(library_path).unwrap() });
|
||||
|
||||
let set_fn:&Symbol<'a,unsafe extern "C" fn(*const i8) -> i8> = unsafe {
|
||||
&lib.get::<unsafe extern "C" fn(*const i8) -> i8>(b"set_wallpaper\0")?
|
||||
};
|
||||
let any_fn:&Symbol<'a,unsafe extern "C" fn() -> i8> = unsafe {
|
||||
&lib.get::<unsafe extern "C" fn() -> i8>(b"any_maximized\0")?
|
||||
};
|
||||
|
||||
Ok(CoreModule {
|
||||
module: Arc::clone(&lib),
|
||||
set_wallpaper:Arc::new(set_fn),
|
||||
any_maximized:Arc::new(any_fn),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn set_wallpaper(title: String) -> bool {
|
||||
|
|
@ -10,8 +35,15 @@ pub async fn set_wallpaper(title: String) -> bool {
|
|||
unsafe {
|
||||
let res = set(title.as_ptr());
|
||||
if res == 0 {
|
||||
drop(lib);
|
||||
return false;
|
||||
};
|
||||
}
|
||||
drop(lib);
|
||||
return true;
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn anyZoomed()->bool{
|
||||
let Library
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue