Skip to content

win32: events stop processing when menubar is active #310

Description

@tronical

When a menu from the menubar is visible/open on Windows, the main event loops stops processing. To reproduce, apply the following patch to the winit.rs example:

diff --git a/examples/winit.rs b/examples/winit.rs
index 1911bae..9fba310 100644
--- a/examples/winit.rs
+++ b/examples/winit.rs
@@ -141,6 +141,10 @@ impl ApplicationHandler<AppEvent> for App {
                 self.use_window_pos = !self.use_window_pos;
             }

+            WindowEvent::RedrawRequested => {
+                eprintln!("redraw {:#?}", std::time::Instant::now());
+            }
+
             _ => {}
         }
     }
@@ -157,6 +161,15 @@ impl ApplicationHandler<AppEvent> for App {
             }
         }
     }
+
+    fn about_to_wait(&mut self, event_loop: &ActiveEventLoop) {
+        for (_, window) in &self.windows {
+            window.request_redraw();
+        }
+        event_loop.set_control_flow(winit::event_loop::ControlFlow::WaitUntil(
+            std::time::Instant::now() + std::time::Duration::from_millis(16),
+        ));
+    }
 }

 struct AppMenu {

Observe how every 16 ms the redraw message is printed, but that stops when a menu from the menubar is opened.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions