Add Window::title getter on Windows and macOS
This commit is contained in:
parent
a7a7cc64cd
commit
08f9e374e0
11 changed files with 64 additions and 7 deletions
|
|
@ -40,13 +40,13 @@ use windows_sys::Win32::{
|
|||
},
|
||||
WindowsAndMessaging::{
|
||||
CreateWindowExW, FlashWindowEx, GetClientRect, GetCursorPos, GetForegroundWindow,
|
||||
GetSystemMetrics, GetWindowPlacement, IsWindowVisible, LoadCursorW, PeekMessageW,
|
||||
PostMessageW, RegisterClassExW, SetCursor, SetCursorPos, SetForegroundWindow,
|
||||
SetWindowPlacement, SetWindowPos, SetWindowTextW, CS_HREDRAW, CS_VREDRAW,
|
||||
CW_USEDEFAULT, FLASHWINFO, FLASHW_ALL, FLASHW_STOP, FLASHW_TIMERNOFG, FLASHW_TRAY,
|
||||
GWLP_HINSTANCE, HTCAPTION, MAPVK_VK_TO_VSC, NID_READY, PM_NOREMOVE, SM_DIGITIZER,
|
||||
SWP_ASYNCWINDOWPOS, SWP_NOACTIVATE, SWP_NOSIZE, SWP_NOZORDER, WM_NCLBUTTONDOWN,
|
||||
WNDCLASSEXW,
|
||||
GetSystemMetrics, GetWindowPlacement, GetWindowTextLengthW, GetWindowTextW,
|
||||
IsWindowVisible, LoadCursorW, PeekMessageW, PostMessageW, RegisterClassExW, SetCursor,
|
||||
SetCursorPos, SetForegroundWindow, SetWindowPlacement, SetWindowPos, SetWindowTextW,
|
||||
CS_HREDRAW, CS_VREDRAW, CW_USEDEFAULT, FLASHWINFO, FLASHW_ALL, FLASHW_STOP,
|
||||
FLASHW_TIMERNOFG, FLASHW_TRAY, GWLP_HINSTANCE, HTCAPTION, MAPVK_VK_TO_VSC, NID_READY,
|
||||
PM_NOREMOVE, SM_DIGITIZER, SWP_ASYNCWINDOWPOS, SWP_NOACTIVATE, SWP_NOSIZE,
|
||||
SWP_NOZORDER, WM_NCLBUTTONDOWN, WNDCLASSEXW,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
@ -698,6 +698,14 @@ impl Window {
|
|||
Some(self.window_state_lock().current_theme)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn title(&self) -> String {
|
||||
let len = unsafe { GetWindowTextLengthW(self.window.0) } + 1;
|
||||
let mut buf = vec![0; len as usize];
|
||||
unsafe { GetWindowTextW(self.window.0, buf.as_mut_ptr(), len) };
|
||||
util::decode_wide(&buf).to_string_lossy().to_string()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_skip_taskbar(&self, skip: bool) {
|
||||
self.window_state_lock().skip_taskbar = skip;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue