rust-windowing / rust-windowing/winit

Windows: Only one window will be redraw in a multiple window app

Open
#4,460 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

B - bug DS - win32
Dominant language
Rust
Stars
6.2k
Forks
1.3k
Avg merge
2d 19h
Merged PRs (30d)
9

Description

Description
use std::collections::HashMap;
use winit::{
    application::ApplicationHandler,
    dpi::LogicalSize,
    event::WindowEvent,
    event_loop::{ActiveEventLoop, ControlFlow, EventLoop},
    window::{Window, WindowAttributes, WindowId},
};

#[derive(Default)]
struct App {
    windows: HashMap<WindowId, Window>,
}

impl ApplicationHandler for App {
    fn resumed(&mut self, event_loop: &ActiveEventLoop) {
        let attrs1 = WindowAttributes::default()
            .with_title("1")
            .with_inner_size(LogicalSize::new(400.0, 300.0));
        let window1 = event_loop.create_window(attrs1).unwrap();

        let attrs2 = WindowAttributes::default()
            .with_title("2")
            .with_inner_size(LogicalSize::new(400.0, 300.0));
        let window2 = event_loop.create_window(attrs2).unwrap();

        self.windows.insert(window1.id(), window1);
        self.windows.insert(window2.id(), window2);

        for window in self.windows.values() {
            window.request_redraw();
        }
    }

    fn window_event(
        &mut self,
        event_loop: &ActiveEventLoop,
        window_id: WindowId,
        event: WindowEvent,
    ) {
        match event {
            WindowEvent::CloseRequested => {
                self.windows.remove(&window_id);
                if self.windows.is_empty() {
                    event_loop.exit();
                }
            }
            WindowEvent::RedrawRequested => {
                println!("RedrawRequested for window {:?}", window_id);

                for window in self.windows.values() {
                    window.request_redraw();
                }
            }

            _ => {}
        }
    }
}

fn main() {
    let event_loop = EventLoop::new().unwrap();

    event_loop.set_control_flow(ControlFlow::Wait);

    let mut app = App::default();
    event_loop.run_app(&mut app).unwrap();
}

When this app is running, I expect the two windows be redraw at the same time, but only one window gets the RedrawRequested event

Image

Windows version
Edition	Windows 11 Pro
Version	24H2
Installed on	‎5/‎15/‎2025
OS build	26100.7462
Experience	Windows Feature Experience Pack 1000.26100.275.0
Winit version

0.30.12

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided minimal Rust example on Windows with winit 0.30.12 and observe which windows emit RedrawRequested. Trace the Windows event-loop redraw path; done means both created windows receive RedrawRequested after each window requests a redraw. The issue names no repository file or test to begin with.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.