Add option to hide icon from Windows. Fix #95
This commit is contained in:
parent
4adedbae43
commit
88f0618b67
|
@ -39,6 +39,7 @@
|
|||
const long refreshKeyboardLayoutInterval = 2000;
|
||||
|
||||
void * manager_instance;
|
||||
int32_t show_icon;
|
||||
|
||||
// Keyboard listening
|
||||
|
||||
|
@ -298,14 +299,17 @@ LRESULT CALLBACK window_procedure(HWND window, unsigned int msg, WPARAM wp, LPAR
|
|||
}
|
||||
default:
|
||||
if (msg == WM_TASKBARCREATED) { // Explorer crashed, recreate the icon
|
||||
Shell_NotifyIcon(NIM_ADD, &nid);
|
||||
if (show_icon) {
|
||||
Shell_NotifyIcon(NIM_ADD, &nid);
|
||||
}
|
||||
}
|
||||
return DefWindowProc(window, msg, wp, lp);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t initialize(void * self, wchar_t * ico_path, wchar_t * bmp_path) {
|
||||
int32_t initialize(void * self, wchar_t * ico_path, wchar_t * bmp_path, int32_t _show_icon) {
|
||||
manager_instance = self;
|
||||
show_icon = _show_icon;
|
||||
|
||||
// Load the images
|
||||
g_espanso_bmp = (HBITMAP)LoadImage(NULL, bmp_path, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
|
||||
|
@ -440,7 +444,9 @@ int32_t initialize(void * self, wchar_t * ico_path, wchar_t * bmp_path) {
|
|||
StringCchCopy(nid.szTip, ARRAYSIZE(nid.szTip), L"espanso");
|
||||
|
||||
// Show the notification.
|
||||
Shell_NotifyIcon(NIM_ADD, &nid);
|
||||
if (show_icon) {
|
||||
Shell_NotifyIcon(NIM_ADD, &nid);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// Something went wrong, error.
|
||||
|
|
|
@ -33,7 +33,7 @@ extern void * manager_instance;
|
|||
* Initialize the Windows parameters
|
||||
* return: 1 if OK, -1 otherwise.
|
||||
*/
|
||||
extern "C" int32_t initialize(void * self, wchar_t * ico_path, wchar_t * bmp_path);
|
||||
extern "C" int32_t initialize(void * self, wchar_t * ico_path, wchar_t * bmp_path, int32_t show_icon);
|
||||
|
||||
#define LEFT_VARIANT 1
|
||||
#define RIGHT_VARIANT 2
|
||||
|
|
|
@ -30,7 +30,7 @@ pub struct WindowsMenuItem {
|
|||
#[link(name="winbridge", kind="static")]
|
||||
extern {
|
||||
pub fn start_daemon_process() -> i32;
|
||||
pub fn initialize(s: *const c_void, ico_path: *const u16, bmp_path: *const u16) -> i32;
|
||||
pub fn initialize(s: *const c_void, ico_path: *const u16, bmp_path: *const u16, show_icon: i32) -> i32;
|
||||
|
||||
// SYSTEM
|
||||
pub fn get_active_window_name(buffer: *mut u16, size: i32) -> i32;
|
||||
|
|
|
@ -87,8 +87,14 @@ impl WindowsContext {
|
|||
let ico_file_c = U16CString::from_str(ico_icon).unwrap();
|
||||
let bmp_file_c = U16CString::from_str(bmp_icon).unwrap();
|
||||
|
||||
let show_icon = if config.show_icon {
|
||||
1
|
||||
}else{
|
||||
0
|
||||
};
|
||||
|
||||
// Initialize the windows
|
||||
let res = initialize(context_ptr, ico_file_c.as_ptr(), bmp_file_c.as_ptr());
|
||||
let res = initialize(context_ptr, ico_file_c.as_ptr(), bmp_file_c.as_ptr(), show_icon);
|
||||
if res != 1 {
|
||||
panic!("Can't initialize Windows context")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user