linebender/druid · warning

No window with id

Error message

No window with id {}

What it means

Thrown by Application::window when a window id received from the X event stream is not present in the application's windows HashMap. The X server can deliver events for windows the backend does not track (foreign windows, windows already destroyed), and the backend surfaces that as this error to handle_event, which typically logs and drops the event.

Solutions

  1. Generally benign: the backend drops the event — upgrade druid/druid-shell if it is noisy (recent versions tolerate it).
  2. Ensure windows are not destroyed while their event loop callbacks still reference them; close windows through the official close API.
  3. If reproducible, log the offending id and check for code that manipulates window ids it doesn't own (e.g. from XQueryPointer or grabs).

Example fix

// before: treating every window lookup failure as fatal
let win = app.window(id).expect("window must exist");
// after: tolerate events for untracked windows
if let Ok(win) = app.window(id) { win.handle_event(ev); }
Defensive patterns

Strategy: fallback

Validate before calling

// caller-side check before acting on a window
if app.window(id).is_err() { return; } // window already gone

Try / catch

match app.window(id) {
    Ok(win) => win.handle_event(ev),
    Err(_) => { /* window closed or foreign; drop stale event */ }
}

Prevention

When it happens

Trigger: handle_event receives an XKB/XCB event (keypress, motion, etc.) whose window id is not owned by this Application — e.g. events for a window that was just closed but whose queued events are still draining, or synthetic/grab events targeting other clients' windows.

Common situations: Rapidly closing windows while events are in flight; running under window managers that send synthetic events; embedded/multi-window apps interacting with foreign windows via global grabs (screen lockers, screenshot tools).

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of linebender/druid@0f8b1195e4 (2026-09-10). Data as JSON: /api/errors/e0112c7dc7b2791b. Report an issue: GitHub.

Appendix: source

Thrown at druid-shell/src/backend/x11/application.rs:456

    pub(crate) fn add_window(&self, id: u32, window: Rc<Window>) -> Result<(), Error> {
        borrow_mut!(self.state)?.windows.insert(id, window);
        Ok(())
    }

    /// Remove the specified window from the `Application` and return the number of windows left.
    fn remove_window(&self, id: u32) -> Result<usize, Error> {
        let mut state = borrow_mut!(self.state)?;
        state.windows.remove(&id);
        Ok(state.windows.len())
    }

    fn window(&self, id: u32) -> Result<Rc<Window>, Error> {
        borrow!(self.state)?
            .windows
            .get(&id)
            .cloned()
            .ok_or_else(|| anyhow!("No window with id {}", id))
    }

    #[inline]
    pub(crate) fn connection(&self) -> &Rc<XCBConnection> {
        &self.connection
    }

    #[inline]
    pub(crate) fn screen_num(&self) -> usize {
        self.screen_num
    }

    #[inline]
    pub(crate) fn argb_visual_type(&self) -> Option<Visualtype> {
        // Check if a composite manager is running
        let atom_name = format!("_NET_WM_CM_S{}", self.screen_num);
        let owner = self
            .connection

View on GitHub (pinned to 0f8b1195e4)