{"record":{"id":"0752fd8171969f6a","repo":"linebender/druid","slug":"invalid-screen-num","errorCode":null,"errorMessage":"Invalid screen num: {}","messagePattern":"Invalid screen num: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"druid-shell/src/backend/x11/application.rs","lineNumber":301,"sourceCode":"            text: load_cursor(\"text\"),\n            pointer: load_cursor(\"pointer\"),\n            crosshair: load_cursor(\"crosshair\"),\n            not_allowed: load_cursor(\"not-allowed\"),\n            row_resize: load_cursor(\"row-resize\"),\n            col_resize: load_cursor(\"col-resize\"),\n        };\n\n        let atoms = Rc::new(\n            AppAtoms::new(&*connection)?\n                .reply()\n                .context(\"get X11 atoms\")?,\n        );\n\n        let screen = connection\n            .setup()\n            .roots\n            .get(screen_num)\n            .ok_or_else(|| anyhow!(\"Invalid screen num: {}\", screen_num))?;\n        let root_visual_type = util::get_visual_from_screen(screen)\n            .ok_or_else(|| anyhow!(\"Couldn't get visual from screen\"))?;\n        let argb_visual_type = util::get_argb_visual_type(&connection, screen)?;\n\n        let timestamp = Rc::new(Cell::new(x11rb::CURRENT_TIME));\n        let pending_events = Default::default();\n        let clipboard = Clipboard::new(\n            Rc::clone(&connection),\n            screen_num,\n            Rc::clone(&atoms),\n            atoms.CLIPBOARD,\n            Rc::clone(&pending_events),\n            Rc::clone(&timestamp),\n        );\n        let primary = Clipboard::new(\n            Rc::clone(&connection),\n            screen_num,\n            Rc::clone(&atoms),","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/linebender/druid/blob/0f8b1195e4e073f9597f2865299c3d18f8e4005f/druid-shell/src/backend/x11/application.rs#L283-L319","documentation":"Thrown by Application::new in the X11 backend when the supplied screen_num index does not exist in the X server's list of screens (connection.setup().roots). The X server exposes one root screen per configured monitor/seat, and this index must point at one of them. The library throws instead of silently defaulting to screen 0 because running on the wrong screen would create windows on the wrong root.","triggerScenarios":"Calling druid_shell::backend::x11::Application::new(None, screen_num) with a screen_num >= connection.setup().roots.len(), e.g. hardcoded 1 on a single-screen X server, or a value obtained from DISPLAY parsing when the X server was restarted with fewer screens.","commonSituations":"Hardcoded screen indices in CI containers or headless setups (Xvfb started without +extension or with only :0.0); DISPLAY strings like :0.1 that no longer match the server config after a display-manager restart; code copied from multi-monitor setups run on single-screen machines.","solutions":["Pass 0 (or None to use the default screen from DISPLAY) as screen_num unless you know the server has multiple screens.","Query the valid range first: connection.setup().roots.len() and clamp/validate the index before calling Application::new.","Check how Xvfb/Xorg was started; launch with the right number of screens (e.g. Xvfb :1 -screen 0 ...) or fix the DISPLAY environment variable."],"exampleFix":"// before\nlet app = Application::new(None, 1)?; // fails on single-screen servers\n// after\nlet app = Application::new(None, 0)?; // default screen from DISPLAY","handlingStrategy":"validation","validationCode":"// before Application::new\nlet conn = x11rb::connect(None).map(|(c, s)| (c, s))?.0;\nlet screen_count = conn.setup().roots.len();\nassert!(screen_num < screen_count, \"screen {} out of 0..{}\", screen_num, screen_count);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer passing None so the default screen from DISPLAY is used.","Never hardcode screen indices; derive them from the connection setup.","In CI, start Xvfb with an explicit, known screen configuration."],"tags":["x11","invalid-argument-value","display"],"backgroundTag":"invalid-argument-value","analyzedSha":"0f8b1195e4e073f9597f2865299c3d18f8e4005f","analyzedAt":"2026-09-10T14:27:34.582Z","contentChangedAt":"2026-09-10T14:27:34.582Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}