Skip to content

Commit 2253565

Browse files
aloucksOsspial
authored andcommitted
Prevent the event loop from pausing when entering modal loop (eventloop-2.0) (#839)
* Prevent the event loop from pausing after entering modal loop After clicking the window title bar or border (for a drag or resize), the event loop pauses until the mouse is moved. This change relays the WM_NCLBUTTONDOWN message to the dummy window where it queues a redraw and consumes the message. This effectively jumpstarts the modal loop and it continues to fire draw requests. * Handle WM_NCLBUTTONDOWN in public_window_callback instead of relaying. Relaying the WM_NCLBUTTONDOWN message to the modal window turned out to be unnecessary.
1 parent 2ead1c1 commit 2253565

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/platform_impl/windows/event_loop.rs

+14
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,20 @@ unsafe extern "system" fn public_window_callback<T>(
799799
commctrl::DefSubclassProc(window, msg, wparam, lparam)
800800
},
801801

802+
winuser::WM_NCLBUTTONDOWN => {
803+
// jumpstart the modal loop
804+
winuser::RedrawWindow(
805+
window,
806+
ptr::null(),
807+
ptr::null_mut(),
808+
winuser::RDW_INTERNALPAINT
809+
);
810+
if wparam == winuser::HTCAPTION as _ {
811+
winuser::PostMessageW(window, winuser::WM_MOUSEMOVE, 0, 0);
812+
}
813+
commctrl::DefSubclassProc(window, msg, wparam, lparam)
814+
},
815+
802816
winuser::WM_CLOSE => {
803817
use event::WindowEvent::CloseRequested;
804818
subclass_input.send_event(Event::WindowEvent {

0 commit comments

Comments
 (0)