mirror of
https://github.com/tauri-apps/tao.git
synced 2026-01-31 00:35:16 +01:00
chore(deps): update windows crate to 0.58 (#963)
* chore(deps): update windows crate to 0.58 * cocoa as well * core-* crates
This commit is contained in:
10
Cargo.toml
10
Cargo.toml
@@ -58,10 +58,10 @@ softbuffer = "0.4"
|
||||
parking_lot = "0.12"
|
||||
unicode-segmentation = "1.11"
|
||||
windows-version = "0.1"
|
||||
windows-core = "0.57"
|
||||
windows-core = "0.58"
|
||||
|
||||
[target."cfg(target_os = \"windows\")".dependencies.windows]
|
||||
version = "0.57"
|
||||
version = "0.58"
|
||||
features = [
|
||||
"implement",
|
||||
"Win32_Devices_HumanInterfaceDevice",
|
||||
@@ -106,9 +106,9 @@ tao-macros = { version = "0.1.0", path = "./tao-macros" }
|
||||
objc = "0.2"
|
||||
|
||||
[target."cfg(target_os = \"macos\")".dependencies]
|
||||
cocoa = "0.25"
|
||||
core-foundation = "0.9"
|
||||
core-graphics = "0.23"
|
||||
cocoa = "0.26"
|
||||
core-foundation = "0.10"
|
||||
core-graphics = "0.24"
|
||||
dispatch = "0.2"
|
||||
scopeguard = "1.2"
|
||||
|
||||
|
||||
@@ -188,12 +188,12 @@ pub trait WindowExtWindows {
|
||||
impl WindowExtWindows for Window {
|
||||
#[inline]
|
||||
fn hinstance(&self) -> isize {
|
||||
self.window.hinstance().0
|
||||
self.window.hinstance().0 as _
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn hwnd(&self) -> isize {
|
||||
self.window.hwnd().0
|
||||
self.window.hwnd().0 as _
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -380,7 +380,7 @@ impl MonitorHandleExtWindows for MonitorHandle {
|
||||
|
||||
#[inline]
|
||||
fn hmonitor(&self) -> isize {
|
||||
self.inner.hmonitor().0
|
||||
self.inner.hmonitor().0 as _
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ use std::ffi::c_void;
|
||||
|
||||
use crate::window::Theme;
|
||||
|
||||
static HUXTHEME: Lazy<HMODULE> =
|
||||
Lazy::new(|| unsafe { LoadLibraryA(s!("uxtheme.dll")).unwrap_or_default() });
|
||||
static HUXTHEME: Lazy<isize> =
|
||||
Lazy::new(|| unsafe { LoadLibraryA(s!("uxtheme.dll")).unwrap_or_default().0 as _ });
|
||||
|
||||
static WIN10_BUILD_VERSION: Lazy<Option<u32>> = Lazy::new(|| {
|
||||
let version = windows_version::OsVersion::current();
|
||||
@@ -44,12 +44,12 @@ pub fn allow_dark_mode_for_app(is_dark_mode: bool) {
|
||||
const UXTHEME_ALLOWDARKMODEFORAPP_ORDINAL: u16 = 135;
|
||||
type AllowDarkModeForApp = unsafe extern "system" fn(bool) -> bool;
|
||||
static ALLOW_DARK_MODE_FOR_APP: Lazy<Option<AllowDarkModeForApp>> = Lazy::new(|| unsafe {
|
||||
if HUXTHEME.is_invalid() {
|
||||
if HMODULE(*HUXTHEME as _).is_invalid() {
|
||||
return None;
|
||||
}
|
||||
|
||||
GetProcAddress(
|
||||
*HUXTHEME,
|
||||
HMODULE(*HUXTHEME as _),
|
||||
PCSTR::from_raw(UXTHEME_ALLOWDARKMODEFORAPP_ORDINAL as usize as *mut _),
|
||||
)
|
||||
.map(|handle| std::mem::transmute(handle))
|
||||
@@ -66,12 +66,12 @@ pub fn allow_dark_mode_for_app(is_dark_mode: bool) {
|
||||
const UXTHEME_SETPREFERREDAPPMODE_ORDINAL: u16 = 135;
|
||||
type SetPreferredAppMode = unsafe extern "system" fn(PreferredAppMode) -> PreferredAppMode;
|
||||
static SET_PREFERRED_APP_MODE: Lazy<Option<SetPreferredAppMode>> = Lazy::new(|| unsafe {
|
||||
if HUXTHEME.is_invalid() {
|
||||
if HMODULE(*HUXTHEME as _).is_invalid() {
|
||||
return None;
|
||||
}
|
||||
|
||||
GetProcAddress(
|
||||
*HUXTHEME,
|
||||
HMODULE(*HUXTHEME as _),
|
||||
PCSTR::from_raw(UXTHEME_SETPREFERREDAPPMODE_ORDINAL as usize as *mut _),
|
||||
)
|
||||
.map(|handle| std::mem::transmute(handle))
|
||||
@@ -100,12 +100,12 @@ fn refresh_immersive_color_policy_state() {
|
||||
type RefreshImmersiveColorPolicyState = unsafe extern "system" fn();
|
||||
static REFRESH_IMMERSIVE_COLOR_POLICY_STATE: Lazy<Option<RefreshImmersiveColorPolicyState>> =
|
||||
Lazy::new(|| unsafe {
|
||||
if HUXTHEME.is_invalid() {
|
||||
if HMODULE(*HUXTHEME as _).is_invalid() {
|
||||
return None;
|
||||
}
|
||||
|
||||
GetProcAddress(
|
||||
*HUXTHEME,
|
||||
HMODULE(*HUXTHEME as _),
|
||||
PCSTR::from_raw(UXTHEME_REFRESHIMMERSIVECOLORPOLICYSTATE_ORDINAL as usize as *mut _),
|
||||
)
|
||||
.map(|handle| std::mem::transmute(handle))
|
||||
@@ -142,12 +142,12 @@ pub fn allow_dark_mode_for_window(hwnd: HWND, is_dark_mode: bool) {
|
||||
const UXTHEME_ALLOWDARKMODEFORWINDOW_ORDINAL: u16 = 133;
|
||||
type AllowDarkModeForWindow = unsafe extern "system" fn(HWND, bool) -> bool;
|
||||
static ALLOW_DARK_MODE_FOR_WINDOW: Lazy<Option<AllowDarkModeForWindow>> = Lazy::new(|| unsafe {
|
||||
if HUXTHEME.is_invalid() {
|
||||
if HMODULE(*HUXTHEME as _).is_invalid() {
|
||||
return None;
|
||||
}
|
||||
|
||||
GetProcAddress(
|
||||
*HUXTHEME,
|
||||
HMODULE(*HUXTHEME as _),
|
||||
PCSTR::from_raw(UXTHEME_ALLOWDARKMODEFORWINDOW_ORDINAL as usize as *mut _),
|
||||
)
|
||||
.map(|handle| std::mem::transmute(handle))
|
||||
@@ -206,12 +206,12 @@ fn should_apps_use_dark_mode() -> bool {
|
||||
const UXTHEME_SHOULDAPPSUSEDARKMODE_ORDINAL: u16 = 132;
|
||||
type ShouldAppsUseDarkMode = unsafe extern "system" fn() -> bool;
|
||||
static SHOULD_APPS_USE_DARK_MODE: Lazy<Option<ShouldAppsUseDarkMode>> = Lazy::new(|| unsafe {
|
||||
if HUXTHEME.is_invalid() {
|
||||
if HMODULE(*HUXTHEME as _).is_invalid() {
|
||||
return None;
|
||||
}
|
||||
|
||||
GetProcAddress(
|
||||
*HUXTHEME,
|
||||
HMODULE(*HUXTHEME as _),
|
||||
PCSTR::from_raw(UXTHEME_SHOULDAPPSUSEDARKMODE_ORDINAL as usize as *mut _),
|
||||
)
|
||||
.map(|handle| std::mem::transmute(handle))
|
||||
|
||||
@@ -102,7 +102,7 @@ impl FileDropHandler {
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
impl IDropTarget_Impl for FileDropHandler {
|
||||
impl IDropTarget_Impl for FileDropHandler_Impl {
|
||||
fn DragEnter(
|
||||
&self,
|
||||
pDataObj: Option<&IDataObject>,
|
||||
@@ -112,9 +112,9 @@ impl IDropTarget_Impl for FileDropHandler {
|
||||
) -> windows::core::Result<()> {
|
||||
use crate::event::WindowEvent::HoveredFile;
|
||||
unsafe {
|
||||
let hdrop = Self::iterate_filenames(pDataObj, |filename| {
|
||||
let hdrop = FileDropHandler::iterate_filenames(pDataObj, |filename| {
|
||||
(self.send_event)(Event::WindowEvent {
|
||||
window_id: SuperWindowId(WindowId(self.window.0)),
|
||||
window_id: SuperWindowId(WindowId(self.window.0 as _)),
|
||||
event: HoveredFile(filename),
|
||||
});
|
||||
});
|
||||
@@ -147,7 +147,7 @@ impl IDropTarget_Impl for FileDropHandler {
|
||||
use crate::event::WindowEvent::HoveredFileCancelled;
|
||||
if unsafe { *self.hovered_is_valid.get() } {
|
||||
(self.send_event)(Event::WindowEvent {
|
||||
window_id: SuperWindowId(WindowId(self.window.0)),
|
||||
window_id: SuperWindowId(WindowId(self.window.0 as _)),
|
||||
event: HoveredFileCancelled,
|
||||
});
|
||||
}
|
||||
@@ -163,9 +163,9 @@ impl IDropTarget_Impl for FileDropHandler {
|
||||
) -> windows::core::Result<()> {
|
||||
use crate::event::WindowEvent::DroppedFile;
|
||||
unsafe {
|
||||
let hdrop = Self::iterate_filenames(pDataObj, |filename| {
|
||||
let hdrop = FileDropHandler::iterate_filenames(pDataObj, |filename| {
|
||||
(self.send_event)(Event::WindowEvent {
|
||||
window_id: SuperWindowId(WindowId(self.window.0)),
|
||||
window_id: SuperWindowId(WindowId(self.window.0 as _)),
|
||||
event: DroppedFile(filename),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -186,8 +186,8 @@ impl<T: 'static> EventLoop<T> {
|
||||
|
||||
super::dark_mode::allow_dark_mode_for_app(true);
|
||||
|
||||
let send_thread_msg_target = thread_msg_target;
|
||||
thread::spawn(move || wait_thread(thread_id, send_thread_msg_target));
|
||||
let send_thread_msg_target = thread_msg_target.0 as isize;
|
||||
thread::spawn(move || wait_thread(thread_id, HWND(send_thread_msg_target as _)));
|
||||
let wait_thread_id = get_wait_thread_id();
|
||||
|
||||
let runner_shared = Rc::new(EventLoopRunner::new(thread_msg_target, wait_thread_id));
|
||||
@@ -670,6 +670,12 @@ fn create_event_target_window() -> HWND {
|
||||
None,
|
||||
)
|
||||
};
|
||||
|
||||
let window = match window {
|
||||
Ok(w) => w,
|
||||
Err(_) => return HWND::default(),
|
||||
};
|
||||
|
||||
util::SetWindowLongPtrW(
|
||||
window,
|
||||
GWL_STYLE,
|
||||
@@ -852,7 +858,7 @@ fn update_modifiers<T>(window: HWND, subclass_input: &SubclassInput<T>) -> Modif
|
||||
|
||||
unsafe {
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: ModifiersChanged(modifiers),
|
||||
});
|
||||
}
|
||||
@@ -865,7 +871,7 @@ unsafe fn gain_active_focus<T>(window: HWND, subclass_input: &SubclassInput<T>)
|
||||
update_modifiers(window, subclass_input);
|
||||
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: Focused(true),
|
||||
});
|
||||
}
|
||||
@@ -875,12 +881,12 @@ unsafe fn lose_active_focus<T>(window: HWND, subclass_input: &SubclassInput<T>)
|
||||
|
||||
subclass_input.window_state.lock().modifiers_state = ModifiersState::empty();
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: ModifiersChanged(ModifiersState::empty()),
|
||||
});
|
||||
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: Focused(false),
|
||||
});
|
||||
}
|
||||
@@ -968,7 +974,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
let events = {
|
||||
let mut key_event_builders =
|
||||
crate::platform_impl::platform::keyboard::KEY_EVENT_BUILDERS.lock();
|
||||
if let Some(key_event_builder) = key_event_builders.get_mut(&WindowId(window.0)) {
|
||||
if let Some(key_event_builder) = key_event_builders.get_mut(&WindowId(window.0 as _)) {
|
||||
key_event_builder.process_message(window, msg, wparam, lparam, &mut result)
|
||||
} else {
|
||||
Vec::new()
|
||||
@@ -976,7 +982,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
};
|
||||
for event in events {
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: KeyboardInput {
|
||||
device_id: DEVICE_ID,
|
||||
event: event.event,
|
||||
@@ -1004,7 +1010,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
};
|
||||
if let Some(str) = text {
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: ReceivedImeText(str),
|
||||
});
|
||||
}
|
||||
@@ -1046,7 +1052,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
|
||||
use crate::event::WindowEvent::DecorationsClick;
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: DecorationsClick,
|
||||
});
|
||||
}
|
||||
@@ -1054,7 +1060,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
win32wm::WM_CLOSE => {
|
||||
use crate::event::WindowEvent::CloseRequested;
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: CloseRequested,
|
||||
});
|
||||
result = ProcResult::Value(LRESULT(0));
|
||||
@@ -1064,7 +1070,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
use crate::event::WindowEvent::Destroyed;
|
||||
let _ = RevokeDragDrop(window);
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: Destroyed,
|
||||
});
|
||||
subclass_input.event_loop_runner.remove_window(window);
|
||||
@@ -1084,7 +1090,9 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
let _ = RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT);
|
||||
} else {
|
||||
let managing_redraw = flush_paint_messages(Some(window), &subclass_input.event_loop_runner);
|
||||
subclass_input.send_event(Event::RedrawRequested(RootWindowId(WindowId(window.0))));
|
||||
subclass_input.send_event(Event::RedrawRequested(RootWindowId(WindowId(
|
||||
window.0 as _,
|
||||
))));
|
||||
if managing_redraw {
|
||||
subclass_input.event_loop_runner.redraw_events_cleared();
|
||||
process_control_flow(&subclass_input.event_loop_runner);
|
||||
@@ -1187,7 +1195,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
if (*windowpos).flags & SWP_NOMOVE != SWP_NOMOVE {
|
||||
let physical_position = PhysicalPosition::new((*windowpos).x as i32, (*windowpos).y as i32);
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: Moved(physical_position),
|
||||
});
|
||||
}
|
||||
@@ -1203,7 +1211,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
|
||||
let physical_size = PhysicalSize::new(w, h);
|
||||
let event = Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: Resized(physical_size),
|
||||
};
|
||||
|
||||
@@ -1260,7 +1268,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
|
||||
if mouse_was_outside_window {
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: CursorEntered {
|
||||
device_id: DEVICE_ID,
|
||||
},
|
||||
@@ -1290,7 +1298,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
if cursor_moved {
|
||||
let modifiers = update_modifiers(window, subclass_input);
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: CursorMoved {
|
||||
device_id: DEVICE_ID,
|
||||
position,
|
||||
@@ -1312,7 +1320,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
}
|
||||
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: CursorLeft {
|
||||
device_id: DEVICE_ID,
|
||||
},
|
||||
@@ -1330,7 +1338,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
let modifiers = update_modifiers(window, subclass_input);
|
||||
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: WindowEvent::MouseWheel {
|
||||
device_id: DEVICE_ID,
|
||||
delta: LineDelta(0.0, value),
|
||||
@@ -1351,7 +1359,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
let modifiers = update_modifiers(window, subclass_input);
|
||||
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: WindowEvent::MouseWheel {
|
||||
device_id: DEVICE_ID,
|
||||
delta: LineDelta(value, 0.0),
|
||||
@@ -1377,7 +1385,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
let modifiers = update_modifiers(window, subclass_input);
|
||||
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: MouseInput {
|
||||
device_id: DEVICE_ID,
|
||||
state: Pressed,
|
||||
@@ -1396,7 +1404,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
let modifiers = update_modifiers(window, subclass_input);
|
||||
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: MouseInput {
|
||||
device_id: DEVICE_ID,
|
||||
state: Released,
|
||||
@@ -1415,7 +1423,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
let modifiers = update_modifiers(window, subclass_input);
|
||||
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: MouseInput {
|
||||
device_id: DEVICE_ID,
|
||||
state: Pressed,
|
||||
@@ -1434,7 +1442,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
let modifiers = update_modifiers(window, subclass_input);
|
||||
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: MouseInput {
|
||||
device_id: DEVICE_ID,
|
||||
state: Released,
|
||||
@@ -1453,7 +1461,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
let modifiers = update_modifiers(window, subclass_input);
|
||||
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: MouseInput {
|
||||
device_id: DEVICE_ID,
|
||||
state: Pressed,
|
||||
@@ -1472,7 +1480,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
let modifiers = update_modifiers(window, subclass_input);
|
||||
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: MouseInput {
|
||||
device_id: DEVICE_ID,
|
||||
state: Released,
|
||||
@@ -1492,7 +1500,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
let modifiers = update_modifiers(window, subclass_input);
|
||||
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: MouseInput {
|
||||
device_id: DEVICE_ID,
|
||||
state: Pressed,
|
||||
@@ -1512,7 +1520,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
let modifiers = update_modifiers(window, subclass_input);
|
||||
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: MouseInput {
|
||||
device_id: DEVICE_ID,
|
||||
state: Released,
|
||||
@@ -1528,7 +1536,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
// If it is the same as our window, then we're essentially retaining the capture. This
|
||||
// can happen if `SetCapture` is called on our window when it already has the mouse
|
||||
// capture.
|
||||
if lparam.0 != window.0 {
|
||||
if lparam.0 != window.0 as _ {
|
||||
subclass_input.window_state.lock().mouse.capture_count = 0;
|
||||
}
|
||||
result = ProcResult::Value(LRESULT(0));
|
||||
@@ -1538,7 +1546,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
let pcount = usize::from(util::LOWORD(wparam.0 as u32));
|
||||
let mut inputs: Vec<TOUCHINPUT> = Vec::with_capacity(pcount);
|
||||
let uninit_inputs = inputs.spare_capacity_mut();
|
||||
let htouch = HTOUCHINPUT(lparam.0);
|
||||
let htouch = HTOUCHINPUT(lparam.0 as _);
|
||||
if GetTouchInputInfo(
|
||||
htouch,
|
||||
mem::transmute(uninit_inputs),
|
||||
@@ -1561,7 +1569,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
let y = location.y as f64 + (input.y % 100) as f64 / 100f64;
|
||||
let location = PhysicalPosition::new(x, y);
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: WindowEvent::Touch(Touch {
|
||||
phase: if (input.dwFlags & TOUCHEVENTF_DOWN) != Default::default() {
|
||||
TouchPhase::Started
|
||||
@@ -1697,7 +1705,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
let y = location.y as f64 + y.fract();
|
||||
let location = PhysicalPosition::new(x, y);
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: WindowEvent::Touch(Touch {
|
||||
phase: if (pointer_info.pointerFlags & POINTER_FLAG_DOWN) != Default::default() {
|
||||
TouchPhase::Started
|
||||
@@ -1924,7 +1932,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
}
|
||||
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: ScaleFactorChanged {
|
||||
scale_factor: new_scale_factor,
|
||||
new_inner_size: &mut new_physical_inner_size,
|
||||
@@ -2071,7 +2079,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||
window_state.current_theme = new_theme;
|
||||
mem::drop(window_state);
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window.0)),
|
||||
window_id: RootWindowId(WindowId(window.0 as _)),
|
||||
event: ThemeChanged(new_theme),
|
||||
});
|
||||
}
|
||||
@@ -2283,7 +2291,7 @@ unsafe extern "system" fn thread_event_target_callback<T: 'static>(
|
||||
}
|
||||
|
||||
win32wm::WM_INPUT => {
|
||||
if let Some(data) = raw_input::get_raw_input_data(HRAWINPUT(lparam.0)) {
|
||||
if let Some(data) = raw_input::get_raw_input_data(HRAWINPUT(lparam.0 as _)) {
|
||||
handle_raw_input(&subclass_input, data);
|
||||
let _ = RedrawWindow(window, None, HRGN::default(), RDW_INTERNALPAINT);
|
||||
}
|
||||
|
||||
@@ -178,20 +178,20 @@ impl<T> EventLoopRunner<T> {
|
||||
}
|
||||
pub fn register_window(&self, window: HWND) {
|
||||
let mut owned_windows = self.owned_windows.take();
|
||||
owned_windows.insert(window.0);
|
||||
owned_windows.insert(window.0 as _);
|
||||
self.owned_windows.set(owned_windows);
|
||||
}
|
||||
|
||||
pub fn remove_window(&self, window: HWND) {
|
||||
let mut owned_windows = self.owned_windows.take();
|
||||
owned_windows.remove(&window.0);
|
||||
owned_windows.remove(&(window.0 as _));
|
||||
self.owned_windows.set(owned_windows);
|
||||
}
|
||||
|
||||
pub fn owned_windows(&self, mut f: impl FnMut(HWND)) {
|
||||
let mut owned_windows = self.owned_windows.take();
|
||||
for hwnd in &owned_windows {
|
||||
f(HWND(*hwnd));
|
||||
f(HWND(*hwnd as _));
|
||||
}
|
||||
let new_owned_windows = self.owned_windows.take();
|
||||
owned_windows.extend(&new_owned_windows);
|
||||
@@ -440,7 +440,7 @@ impl<T> BufferedEvent<T> {
|
||||
|
||||
if new_inner_size != os_inner_size {
|
||||
util::set_inner_size_physical(
|
||||
HWND(window_id.0 .0),
|
||||
HWND(window_id.0 .0 as _),
|
||||
new_inner_size.width as _,
|
||||
new_inner_size.height as _,
|
||||
true,
|
||||
|
||||
@@ -134,7 +134,7 @@ impl WinIcon {
|
||||
hwnd,
|
||||
WM_SETICON,
|
||||
WPARAM(icon_type as _),
|
||||
LPARAM(self.as_raw_handle().0),
|
||||
LPARAM(self.as_raw_handle().0 as _),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ use windows::Win32::{
|
||||
Foundation::{HWND, LPARAM, LRESULT, WPARAM},
|
||||
UI::{
|
||||
Input::KeyboardAndMouse::{self as win32km, *},
|
||||
TextServices::HKL,
|
||||
WindowsAndMessaging::{self as win32wm, *},
|
||||
},
|
||||
};
|
||||
@@ -451,7 +450,7 @@ impl KeyEventBuilder {
|
||||
} else {
|
||||
WindowsModifiers::empty()
|
||||
};
|
||||
let layout = layouts.layouts.get(&locale_id.0).unwrap();
|
||||
let layout = layouts.layouts.get(&(locale_id.0 as _)).unwrap();
|
||||
let logical_key = layout.get_key(mods, num_lock_on, vk, scancode, code);
|
||||
let key_without_modifiers =
|
||||
layout.get_key(WindowsModifiers::empty(), false, vk, scancode, code);
|
||||
@@ -533,12 +532,14 @@ impl PartialKeyEventInfo {
|
||||
let scancode = if lparam_struct.scancode == 0 {
|
||||
// In some cases (often with media keys) the device reports a scancode of 0 but a
|
||||
// valid virtual key. In these cases we obtain the scancode from the virtual key.
|
||||
unsafe { MapVirtualKeyExW(u32::from(vkey.0), MAPVK_VK_TO_VSC_EX, layout.hkl) as u16 }
|
||||
unsafe {
|
||||
MapVirtualKeyExW(u32::from(vkey.0), MAPVK_VK_TO_VSC_EX, HKL(layout.hkl as _)) as u16
|
||||
}
|
||||
} else {
|
||||
new_ex_scancode(lparam_struct.scancode, lparam_struct.extended)
|
||||
};
|
||||
let code = KeyCode::from_scancode(scancode as u32);
|
||||
let location = get_location(scancode, layout.hkl);
|
||||
let location = get_location(scancode, HKL(layout.hkl as _));
|
||||
|
||||
let kbd_state = get_kbd_state();
|
||||
let mods = WindowsModifiers::active_modifiers(&kbd_state);
|
||||
|
||||
@@ -9,10 +9,7 @@ use lazy_static::lazy_static;
|
||||
|
||||
use windows::Win32::{
|
||||
System::SystemServices::{LANG_JAPANESE, LANG_KOREAN},
|
||||
UI::{
|
||||
Input::KeyboardAndMouse::{self as win32km, *},
|
||||
TextServices::HKL,
|
||||
},
|
||||
UI::Input::KeyboardAndMouse::{self as win32km, *},
|
||||
};
|
||||
|
||||
use super::keyboard::ExScancode;
|
||||
@@ -156,7 +153,7 @@ impl WindowsModifiers {
|
||||
}
|
||||
|
||||
pub(crate) struct Layout {
|
||||
pub hkl: HKL,
|
||||
pub hkl: isize,
|
||||
|
||||
/// Maps numpad keys from Windows virtual key to a `Key`.
|
||||
///
|
||||
@@ -206,7 +203,8 @@ impl Layout {
|
||||
// building the keys map) sometimes maps virtual keys to odd scancodes that don't match
|
||||
// the scancode coming from the KEYDOWN message for the same key. For example: `VK_LEFT`
|
||||
// is mapped to `0x004B`, but the scancode for the left arrow is `0xE04B`.
|
||||
let key_from_vkey = vkey_to_non_char_key(vkey, native_code, self.hkl, self.has_alt_graph);
|
||||
let key_from_vkey =
|
||||
vkey_to_non_char_key(vkey, native_code, HKL(self.hkl as _), self.has_alt_graph);
|
||||
|
||||
if !matches!(key_from_vkey, Key::Unidentified(_)) {
|
||||
return key_from_vkey;
|
||||
@@ -242,7 +240,7 @@ impl LayoutCache {
|
||||
/// The current layout is then returned.
|
||||
pub fn get_current_layout<'a>(&'a mut self) -> (HKL, &'a Layout) {
|
||||
let locale_id = unsafe { GetKeyboardLayout(0) };
|
||||
match self.layouts.entry(locale_id.0) {
|
||||
match self.layouts.entry(locale_id.0 as _) {
|
||||
Entry::Occupied(entry) => (locale_id, entry.into_mut()),
|
||||
Entry::Vacant(entry) => {
|
||||
let layout = Self::prepare_layout(&mut self.strings, locale_id);
|
||||
@@ -273,7 +271,7 @@ impl LayoutCache {
|
||||
|
||||
fn prepare_layout(strings: &mut HashSet<&'static str>, locale_id: HKL) -> Layout {
|
||||
let mut layout = Layout {
|
||||
hkl: locale_id,
|
||||
hkl: locale_id.0 as _,
|
||||
numlock_on_keys: Default::default(),
|
||||
numlock_off_keys: Default::default(),
|
||||
keys: Default::default(),
|
||||
|
||||
@@ -64,12 +64,6 @@ impl Default for PlatformSpecificWindowBuilderAttributes {
|
||||
unsafe impl Send for PlatformSpecificWindowBuilderAttributes {}
|
||||
unsafe impl Sync for PlatformSpecificWindowBuilderAttributes {}
|
||||
|
||||
// Cursor name in UTF-16. Used to set cursor in `WM_SETCURSOR`.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Cursor(pub *const u16);
|
||||
unsafe impl Send for Cursor {}
|
||||
unsafe impl Sync for Cursor {}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct DeviceId(isize);
|
||||
|
||||
@@ -82,7 +76,7 @@ impl DeviceId {
|
||||
impl DeviceId {
|
||||
pub fn persistent_identifier(&self) -> Option<String> {
|
||||
if self.0 != 0 {
|
||||
raw_input::get_raw_input_device_name(HANDLE(self.0))
|
||||
raw_input::get_raw_input_device_name(HANDLE(self.0 as _))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ pub(crate) fn get_monitor_info(hmonitor: HMONITOR) -> Result<MONITORINFOEXW, io:
|
||||
|
||||
impl MonitorHandle {
|
||||
pub(crate) fn new(hmonitor: HMONITOR) -> Self {
|
||||
MonitorHandle(hmonitor.0)
|
||||
MonitorHandle(hmonitor.0 as _)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -191,7 +191,7 @@ impl MonitorHandle {
|
||||
|
||||
#[inline]
|
||||
pub fn hmonitor(&self) -> HMONITOR {
|
||||
HMONITOR(self.0)
|
||||
HMONITOR(self.0 as _)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
@@ -133,7 +133,7 @@ pub fn register_all_mice_and_keyboards_for_raw_input(
|
||||
// RIDEV_REMOVE: don't receive device events (requires NULL hwndTarget)
|
||||
let flags = match filter {
|
||||
DeviceEventFilter::Always => {
|
||||
window_handle = HWND(0);
|
||||
window_handle = HWND(std::ptr::null_mut());
|
||||
RIDEV_REMOVE
|
||||
}
|
||||
DeviceEventFilter::Unfocused => RIDEV_DEVNOTIFY,
|
||||
|
||||
@@ -27,7 +27,6 @@ use windows::{
|
||||
UI::{
|
||||
HiDpi::*,
|
||||
Input::KeyboardAndMouse::*,
|
||||
TextServices::HKL,
|
||||
WindowsAndMessaging::{self as win32wm, *},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -57,6 +57,17 @@ use crate::{
|
||||
|
||||
use super::keyboard::{KeyEventBuilder, KEY_EVENT_BUILDERS};
|
||||
|
||||
/// A simple non-owning wrapper around a window.
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct WindowWrapper(pub HWND);
|
||||
|
||||
// Send and Sync are not implemented for HWND and HDC, we have to wrap it and implement them manually.
|
||||
// For more info see:
|
||||
// https://github.com/retep998/winapi-rs/issues/360
|
||||
// https://github.com/retep998/winapi-rs/issues/396
|
||||
unsafe impl Sync for WindowWrapper {}
|
||||
unsafe impl Send for WindowWrapper {}
|
||||
|
||||
/// The Win32 implementation of the main `Window` object.
|
||||
pub struct Window {
|
||||
/// Main handle for the window.
|
||||
@@ -146,10 +157,10 @@ impl Window {
|
||||
}
|
||||
#[inline]
|
||||
pub fn set_visible(&self, visible: bool) {
|
||||
let window = self.window.clone();
|
||||
let window = self.window.0 .0 as isize;
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
self.thread_executor.execute_in_thread(move || {
|
||||
WindowState::set_window_flags(window_state.lock(), window.0, |f| {
|
||||
WindowState::set_window_flags(window_state.lock(), HWND(window as _), |f| {
|
||||
f.set(WindowFlags::VISIBLE, visible)
|
||||
});
|
||||
});
|
||||
@@ -203,9 +214,9 @@ impl Window {
|
||||
let (x, y): (i32, i32) = position.to_physical::<i32>(self.scale_factor()).into();
|
||||
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
let window = self.window.clone();
|
||||
let window = self.window.0 .0 as isize;
|
||||
self.thread_executor.execute_in_thread(move || {
|
||||
WindowState::set_window_flags(window_state.lock(), window.0, |f| {
|
||||
WindowState::set_window_flags(window_state.lock(), HWND(window as _), |f| {
|
||||
f.set(WindowFlags::MAXIMIZED, false)
|
||||
});
|
||||
});
|
||||
@@ -260,9 +271,9 @@ impl Window {
|
||||
.window_flags
|
||||
.contains(WindowFlags::MARKER_DECORATIONS);
|
||||
|
||||
let window = self.window.clone();
|
||||
let window = self.window.0 .0 as isize;
|
||||
self.thread_executor.execute_in_thread(move || {
|
||||
WindowState::set_window_flags(window_state.lock(), window.0, |f| {
|
||||
WindowState::set_window_flags(window_state.lock(), HWND(window as _), |f| {
|
||||
f.set(WindowFlags::MAXIMIZED, false)
|
||||
});
|
||||
});
|
||||
@@ -310,11 +321,11 @@ impl Window {
|
||||
|
||||
#[inline]
|
||||
pub fn set_resizable(&self, resizable: bool) {
|
||||
let window = self.window.clone();
|
||||
let window = self.window.0 .0 as isize;
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
|
||||
self.thread_executor.execute_in_thread(move || {
|
||||
WindowState::set_window_flags(window_state.lock(), window.0, |f| {
|
||||
WindowState::set_window_flags(window_state.lock(), HWND(window as _), |f| {
|
||||
f.set(WindowFlags::RESIZABLE, resizable)
|
||||
});
|
||||
});
|
||||
@@ -322,11 +333,11 @@ impl Window {
|
||||
|
||||
#[inline]
|
||||
pub fn set_minimizable(&self, minimizable: bool) {
|
||||
let window = self.window.clone();
|
||||
let window = self.window.0 .0 as isize;
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
|
||||
self.thread_executor.execute_in_thread(move || {
|
||||
WindowState::set_window_flags(window_state.lock(), window.0, |f| {
|
||||
WindowState::set_window_flags(window_state.lock(), HWND(window as _), |f| {
|
||||
f.set(WindowFlags::MINIMIZABLE, minimizable)
|
||||
});
|
||||
});
|
||||
@@ -334,11 +345,11 @@ impl Window {
|
||||
|
||||
#[inline]
|
||||
pub fn set_maximizable(&self, maximizable: bool) {
|
||||
let window = self.window.clone();
|
||||
let window = self.window.0 .0 as isize;
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
|
||||
self.thread_executor.execute_in_thread(move || {
|
||||
WindowState::set_window_flags(window_state.lock(), window.0, |f| {
|
||||
WindowState::set_window_flags(window_state.lock(), HWND(window as _), |f| {
|
||||
f.set(WindowFlags::MAXIMIZABLE, maximizable)
|
||||
});
|
||||
});
|
||||
@@ -346,10 +357,10 @@ impl Window {
|
||||
|
||||
#[inline]
|
||||
pub fn set_closable(&self, closable: bool) {
|
||||
let window = self.window.clone();
|
||||
let window = self.window.0 .0 as isize;
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
self.thread_executor.execute_in_thread(move || {
|
||||
WindowState::set_window_flags(window_state.lock(), window.0, |f| {
|
||||
WindowState::set_window_flags(window_state.lock(), HWND(window as _), |f| {
|
||||
f.set(WindowFlags::CLOSABLE, closable)
|
||||
});
|
||||
});
|
||||
@@ -398,7 +409,7 @@ impl Window {
|
||||
let mut window_handle = rwh_06::Win32WindowHandle::new(unsafe {
|
||||
// SAFETY: Handle will never be zero.
|
||||
let window = self.window.0 .0;
|
||||
std::num::NonZeroIsize::new_unchecked(window)
|
||||
std::num::NonZeroIsize::new_unchecked(window as _)
|
||||
});
|
||||
let hinstance = util::GetWindowLongPtrW(self.hwnd(), GWLP_HINSTANCE);
|
||||
window_handle.hinstance = std::num::NonZeroIsize::new(hinstance);
|
||||
@@ -424,7 +435,7 @@ impl Window {
|
||||
|
||||
#[inline]
|
||||
pub fn set_cursor_grab(&self, grab: bool) -> Result<(), ExternalError> {
|
||||
let window = self.window.clone();
|
||||
let window = self.window.0 .0 as isize;
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
let (tx, rx) = channel::unbounded();
|
||||
|
||||
@@ -432,7 +443,7 @@ impl Window {
|
||||
let result = window_state
|
||||
.lock()
|
||||
.mouse
|
||||
.set_cursor_flags(window.0, |f| f.set(CursorFlags::GRABBED, grab))
|
||||
.set_cursor_flags(HWND(window as _), |f| f.set(CursorFlags::GRABBED, grab))
|
||||
.map_err(|e| ExternalError::Os(os_error!(OsError::IoError(e))));
|
||||
let _ = tx.send(result);
|
||||
});
|
||||
@@ -441,7 +452,7 @@ impl Window {
|
||||
|
||||
#[inline]
|
||||
pub fn set_cursor_visible(&self, visible: bool) {
|
||||
let window = self.window.clone();
|
||||
let window = self.window.0 .0 as isize;
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
let (tx, rx) = channel::unbounded();
|
||||
|
||||
@@ -449,7 +460,7 @@ impl Window {
|
||||
let result = window_state
|
||||
.lock()
|
||||
.mouse
|
||||
.set_cursor_flags(window.0, |f| f.set(CursorFlags::HIDDEN, !visible))
|
||||
.set_cursor_flags(HWND(window as _), |f| f.set(CursorFlags::HIDDEN, !visible))
|
||||
.map_err(|e| e.to_string());
|
||||
let _ = tx.send(result);
|
||||
});
|
||||
@@ -521,10 +532,10 @@ impl Window {
|
||||
|
||||
#[inline]
|
||||
pub fn set_ignore_cursor_events(&self, ignore: bool) -> Result<(), ExternalError> {
|
||||
let window = self.window.clone();
|
||||
let window = self.window.0 .0 as isize;
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
self.thread_executor.execute_in_thread(move || {
|
||||
WindowState::set_window_flags(window_state.lock(), window.0, |f| {
|
||||
WindowState::set_window_flags(window_state.lock(), HWND(window as _), |f| {
|
||||
f.set(WindowFlags::IGNORE_CURSOR_EVENT, ignore)
|
||||
});
|
||||
});
|
||||
@@ -534,12 +545,12 @@ impl Window {
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> WindowId {
|
||||
WindowId(self.window.0 .0)
|
||||
WindowId(self.window.0 .0 as _)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_minimized(&self, minimized: bool) {
|
||||
let window = self.window.clone();
|
||||
let window = self.window.0 .0 as isize;
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
|
||||
let is_minimized = self.is_minimized();
|
||||
@@ -548,7 +559,7 @@ impl Window {
|
||||
WindowState::set_window_flags_in_place(&mut window_state.lock(), |f| {
|
||||
f.set(WindowFlags::MINIMIZED, is_minimized)
|
||||
});
|
||||
WindowState::set_window_flags(window_state.lock(), window.0, |f| {
|
||||
WindowState::set_window_flags(window_state.lock(), HWND(window as _), |f| {
|
||||
f.set(WindowFlags::MINIMIZED, minimized)
|
||||
});
|
||||
});
|
||||
@@ -556,11 +567,11 @@ impl Window {
|
||||
|
||||
#[inline]
|
||||
pub fn set_maximized(&self, maximized: bool) {
|
||||
let window = self.window.clone();
|
||||
let window = self.window.0 .0 as isize;
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
|
||||
self.thread_executor.execute_in_thread(move || {
|
||||
WindowState::set_window_flags(window_state.lock(), window.0, |f| {
|
||||
WindowState::set_window_flags(window_state.lock(), HWND(window as _), |f| {
|
||||
f.set(WindowFlags::MAXIMIZED, maximized)
|
||||
});
|
||||
});
|
||||
@@ -643,7 +654,9 @@ impl Window {
|
||||
window_state_lock.fullscreen = fullscreen.clone();
|
||||
drop(window_state_lock);
|
||||
|
||||
let window_isize = window.0 .0 as isize;
|
||||
self.thread_executor.execute_in_thread(move || {
|
||||
let hwnd = HWND(window_isize as _);
|
||||
// Change video mode if we're transitioning to or from exclusive
|
||||
// fullscreen
|
||||
match (&old_fullscreen, &fullscreen) {
|
||||
@@ -707,7 +720,7 @@ impl Window {
|
||||
}
|
||||
|
||||
// Update window style
|
||||
WindowState::set_window_flags(window_state.lock(), window.0, |f| {
|
||||
WindowState::set_window_flags(window_state.lock(), HWND(window_isize as _), |f| {
|
||||
f.set(
|
||||
WindowFlags::MARKER_EXCLUSIVE_FULLSCREEN,
|
||||
matches!(fullscreen, Some(Fullscreen::Exclusive(_))),
|
||||
@@ -724,7 +737,7 @@ impl Window {
|
||||
// Save window bounds before entering fullscreen
|
||||
let placement = unsafe {
|
||||
let mut placement = WINDOWPLACEMENT::default();
|
||||
let _ = GetWindowPlacement(window.0, &mut placement);
|
||||
let _ = GetWindowPlacement(hwnd, &mut placement);
|
||||
placement
|
||||
};
|
||||
|
||||
@@ -734,7 +747,7 @@ impl Window {
|
||||
Fullscreen::Exclusive(video_mode) => video_mode.monitor(),
|
||||
Fullscreen::Borderless(Some(monitor)) => monitor.clone(),
|
||||
Fullscreen::Borderless(None) => RootMonitorHandle {
|
||||
inner: monitor::current_monitor(window.0),
|
||||
inner: monitor::current_monitor(hwnd),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -743,7 +756,7 @@ impl Window {
|
||||
|
||||
unsafe {
|
||||
let _ = SetWindowPos(
|
||||
window.0,
|
||||
hwnd,
|
||||
HWND::default(),
|
||||
position.0,
|
||||
position.1,
|
||||
@@ -751,7 +764,7 @@ impl Window {
|
||||
size.1 as i32,
|
||||
SWP_ASYNCWINDOWPOS | SWP_NOZORDER,
|
||||
);
|
||||
let _ = InvalidateRgn(window.0, HRGN::default(), false);
|
||||
let _ = InvalidateRgn(hwnd, HRGN::default(), false);
|
||||
}
|
||||
}
|
||||
None => {
|
||||
@@ -759,26 +772,26 @@ impl Window {
|
||||
if let Some(SavedWindow { placement }) = window_state_lock.saved_window.take() {
|
||||
drop(window_state_lock);
|
||||
unsafe {
|
||||
let _ = SetWindowPlacement(window.0, &placement);
|
||||
let _ = InvalidateRgn(window.0, HRGN::default(), false);
|
||||
let _ = SetWindowPlacement(hwnd, &placement);
|
||||
let _ = InvalidateRgn(hwnd, HRGN::default(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe {
|
||||
taskbar_mark_fullscreen(window.0, fullscreen.is_some());
|
||||
taskbar_mark_fullscreen(hwnd, fullscreen.is_some());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_decorations(&self, decorations: bool) {
|
||||
let window = self.window.clone();
|
||||
let window = self.window.0 .0 as isize;
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
|
||||
self.thread_executor.execute_in_thread(move || {
|
||||
WindowState::set_window_flags(window_state.lock(), window.0, |f| {
|
||||
WindowState::set_window_flags(window_state.lock(), HWND(window as _), |f| {
|
||||
f.set(WindowFlags::MARKER_DECORATIONS, decorations)
|
||||
});
|
||||
});
|
||||
@@ -786,11 +799,11 @@ impl Window {
|
||||
|
||||
#[inline]
|
||||
pub fn set_always_on_bottom(&self, always_on_bottom: bool) {
|
||||
let window = self.window.clone();
|
||||
let window = self.window.0 .0 as isize;
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
|
||||
self.thread_executor.execute_in_thread(move || {
|
||||
WindowState::set_window_flags(window_state.lock(), window.0, |f| {
|
||||
WindowState::set_window_flags(window_state.lock(), HWND(window as _), |f| {
|
||||
f.set(WindowFlags::ALWAYS_ON_BOTTOM, always_on_bottom)
|
||||
});
|
||||
});
|
||||
@@ -798,22 +811,22 @@ impl Window {
|
||||
|
||||
#[inline]
|
||||
pub fn set_always_on_top(&self, always_on_top: bool) {
|
||||
let window = self.window.clone();
|
||||
let window = self.window.0 .0 as isize;
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
|
||||
self.thread_executor.execute_in_thread(move || {
|
||||
WindowState::set_window_flags(window_state.lock(), window.0, |f| {
|
||||
WindowState::set_window_flags(window_state.lock(), HWND(window as _), |f| {
|
||||
f.set(WindowFlags::ALWAYS_ON_TOP, always_on_top)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
pub fn set_rtl(&self, rtl: bool) {
|
||||
let window = self.window.clone();
|
||||
let window = self.window.0 .0 as isize;
|
||||
let window_state = Arc::clone(&self.window_state);
|
||||
|
||||
self.thread_executor.execute_in_thread(move || {
|
||||
WindowState::set_window_flags(window_state.lock(), window.0, |f| {
|
||||
WindowState::set_window_flags(window_state.lock(), HWND(window as _), |f| {
|
||||
f.set(WindowFlags::RIGHT_TO_LEFT_LAYOUT, rtl)
|
||||
});
|
||||
});
|
||||
@@ -885,6 +898,8 @@ impl Window {
|
||||
}
|
||||
}
|
||||
|
||||
let window_isize = window.0 .0 as isize;
|
||||
|
||||
self.thread_executor.execute_in_thread(move || unsafe {
|
||||
let (flags, count) = request_type
|
||||
.map(|ty| match ty {
|
||||
@@ -895,7 +910,7 @@ impl Window {
|
||||
|
||||
let flash_info = FLASHWINFO {
|
||||
cbSize: mem::size_of::<FLASHWINFO>() as u32,
|
||||
hwnd: window.0,
|
||||
hwnd: HWND(window_isize as _),
|
||||
dwFlags: flags,
|
||||
uCount: count,
|
||||
dwTimeout: 0,
|
||||
@@ -1015,17 +1030,6 @@ impl Drop for Window {
|
||||
}
|
||||
}
|
||||
|
||||
/// A simple non-owning wrapper around a window.
|
||||
#[derive(Clone)]
|
||||
pub struct WindowWrapper(HWND);
|
||||
|
||||
// Send and Sync are not implemented for HWND and HDC, we have to wrap it and implement them manually.
|
||||
// For more info see:
|
||||
// https://github.com/retep998/winapi-rs/issues/360
|
||||
// https://github.com/retep998/winapi-rs/issues/396
|
||||
unsafe impl Sync for WindowWrapper {}
|
||||
unsafe impl Send for WindowWrapper {}
|
||||
|
||||
unsafe fn init<T: 'static>(
|
||||
attributes: WindowAttributes,
|
||||
pl_attribs: PlatformSpecificWindowBuilderAttributes,
|
||||
@@ -1094,7 +1098,7 @@ unsafe fn init<T: 'static>(
|
||||
pl_attribs.menu.unwrap_or_default(),
|
||||
GetModuleHandleW(PCWSTR::null()).unwrap_or_default(),
|
||||
Some(Box::into_raw(Box::new(window_flags)) as _),
|
||||
);
|
||||
)?;
|
||||
|
||||
if !IsWindow(handle).as_bool() {
|
||||
return Err(os_error!(OsError::IoError(io::Error::last_os_error())));
|
||||
|
||||
@@ -38,7 +38,6 @@ pub struct WindowState {
|
||||
pub fullscreen: Option<Fullscreen>,
|
||||
pub current_theme: Theme,
|
||||
pub preferred_theme: Option<Theme>,
|
||||
pub high_surrogate: Option<u16>,
|
||||
|
||||
pub ime_handler: MinimalIme,
|
||||
|
||||
@@ -49,6 +48,9 @@ pub struct WindowState {
|
||||
pub is_focused: bool,
|
||||
}
|
||||
|
||||
unsafe impl Send for WindowState {}
|
||||
unsafe impl Sync for WindowState {}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SavedWindow {
|
||||
pub placement: WINDOWPLACEMENT,
|
||||
@@ -149,7 +151,6 @@ impl WindowState {
|
||||
fullscreen: None,
|
||||
current_theme,
|
||||
preferred_theme,
|
||||
high_surrogate: None,
|
||||
ime_handler: MinimalIme::default(),
|
||||
window_flags: WindowFlags::empty(),
|
||||
is_active: false,
|
||||
|
||||
Reference in New Issue
Block a user