Adopt windows-sys (#2057)
This commit is contained in:
parent
78e5a395da
commit
b222dde835
17 changed files with 1424 additions and 1239 deletions
|
|
@ -7,9 +7,9 @@ use std::{
|
|||
time::Instant,
|
||||
};
|
||||
|
||||
use winapi::{
|
||||
shared::{minwindef::DWORD, windef::HWND},
|
||||
um::winuser,
|
||||
use windows_sys::Win32::{
|
||||
Foundation::HWND,
|
||||
Graphics::Gdi::{RedrawWindow, RDW_INTERNALPAINT},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
|
|
@ -24,7 +24,7 @@ pub(crate) type EventLoopRunnerShared<T> = Rc<EventLoopRunner<T>>;
|
|||
pub(crate) struct EventLoopRunner<T: 'static> {
|
||||
// The event loop's win32 handles
|
||||
pub(super) thread_msg_target: HWND,
|
||||
wait_thread_id: DWORD,
|
||||
wait_thread_id: u32,
|
||||
|
||||
control_flow: Cell<ControlFlow>,
|
||||
runner_state: Cell<RunnerState>,
|
||||
|
|
@ -63,7 +63,7 @@ enum BufferedEvent<T: 'static> {
|
|||
}
|
||||
|
||||
impl<T> EventLoopRunner<T> {
|
||||
pub(crate) fn new(thread_msg_target: HWND, wait_thread_id: DWORD) -> EventLoopRunner<T> {
|
||||
pub(crate) fn new(thread_msg_target: HWND, wait_thread_id: u32) -> EventLoopRunner<T> {
|
||||
EventLoopRunner {
|
||||
thread_msg_target,
|
||||
wait_thread_id,
|
||||
|
|
@ -113,7 +113,7 @@ impl<T> EventLoopRunner<T> {
|
|||
self.thread_msg_target
|
||||
}
|
||||
|
||||
pub fn wait_thread_id(&self) -> DWORD {
|
||||
pub fn wait_thread_id(&self) -> u32 {
|
||||
self.wait_thread_id
|
||||
}
|
||||
|
||||
|
|
@ -208,18 +208,16 @@ impl<T> EventLoopRunner<T> {
|
|||
self.move_state_to(RunnerState::HandlingRedrawEvents);
|
||||
}
|
||||
self.call_event_handler(event);
|
||||
} else if self.should_buffer() {
|
||||
// If the runner is already borrowed, we're in the middle of an event loop invocation. Add
|
||||
// the event to a buffer to be processed later.
|
||||
self.event_buffer
|
||||
.borrow_mut()
|
||||
.push_back(BufferedEvent::from_event(event))
|
||||
} else {
|
||||
if self.should_buffer() {
|
||||
// If the runner is already borrowed, we're in the middle of an event loop invocation. Add
|
||||
// the event to a buffer to be processed later.
|
||||
self.event_buffer
|
||||
.borrow_mut()
|
||||
.push_back(BufferedEvent::from_event(event))
|
||||
} else {
|
||||
self.move_state_to(RunnerState::HandlingMainEvents);
|
||||
self.call_event_handler(event);
|
||||
self.dispatch_buffered_events();
|
||||
}
|
||||
self.move_state_to(RunnerState::HandlingMainEvents);
|
||||
self.call_event_handler(event);
|
||||
self.dispatch_buffered_events();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -394,12 +392,7 @@ impl<T> EventLoopRunner<T> {
|
|||
};
|
||||
self.call_event_handler(Event::NewEvents(start_cause));
|
||||
self.dispatch_buffered_events();
|
||||
winuser::RedrawWindow(
|
||||
self.thread_msg_target,
|
||||
ptr::null(),
|
||||
ptr::null_mut(),
|
||||
winuser::RDW_INTERNALPAINT,
|
||||
);
|
||||
RedrawWindow(self.thread_msg_target, ptr::null(), 0, RDW_INTERNALPAINT);
|
||||
}
|
||||
|
||||
unsafe fn call_redraw_events_cleared(&self) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue