{"record":{"id":"dbc4df23bcdbe779","repo":"LGUG2Z/komorebi","slug":"window-handles-for-move-operation-don-t-match","errorCode":null,"errorMessage":"window handles for move operation don't match: {} != {}","messagePattern":"window handles for move operation don't match: (.+?) != (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"komorebi/src/process_event.rs","lineNumber":672,"sourceCode":"                WindowsApi::bring_window_to_top(window.hwnd)?;\n\n                let pending_move_op = Arc::make_mut(&mut self.pending_move_op);\n                *pending_move_op = Option::from((monitor_idx, workspace_idx, window.hwnd));\n            }\n            WindowManagerEvent::MoveResizeEnd(_, window) => {\n                // We need this because if the event ends on a different monitor,\n                // that monitor will already have been focused and updated in the state\n                let pending = *self.pending_move_op;\n                // Always consume the pending move op whenever this event is handled\n                let pending_move_op = Arc::make_mut(&mut self.pending_move_op);\n                *pending_move_op = None;\n\n                // If the window handles don't match then something went wrong and the pending move\n                // is not related to this current move, if so abort this operation.\n                if let Some((_, _, w_hwnd)) = pending\n                    && w_hwnd != window.hwnd\n                {\n                    color_eyre::eyre::bail!(\n                        \"window handles for move operation don't match: {} != {}\",\n                        w_hwnd,\n                        window.hwnd\n                    );\n                }\n\n                let target_monitor_idx = self\n                    .monitor_idx_from_current_pos()\n                    .ok_or_eyre(\"cannot get monitor idx from current position\")?;\n\n                let focused_monitor_idx = self.focused_monitor_idx();\n                let focused_workspace_idx = self.focused_workspace_idx().unwrap_or_default();\n                let window_management_behaviour =\n                    self.window_management_behaviour(focused_monitor_idx, focused_workspace_idx);\n\n                let workspace = self.focused_workspace_mut()?;\n                let focused_container_idx = workspace.focused_container_idx();\n                let new_position = WindowsApi::window_rect(window.hwnd)?;","sourceCodeStart":654,"sourceCodeEnd":690,"githubUrl":"https://github.com/LGUG2Z/komorebi/blob/e0709f02bfae4e503bf4640f58ee75ecbbfdbb97/komorebi/src/process_event.rs#L654-L690","documentation":"In process_event, when handling a pending EVENT_SYSTEM_MOVESIZE END, komorebi compares the stored pending move's window handle with the hwnd of the window in the current move event. If they differ, the pending move is stale or belongs to another window, so it aborts with this error naming both handles.","triggerScenarios":"A WinEvent hook move/resize end event arrives whose hwnd does not match the recorded pending move hwnd — e.g. rapid drag of another window before the previous pending move was cleared, out-of-order events, or a destroyed-and-recreated window reusing state.","commonSituations":"Dragging windows very quickly, minimizing/closing a window mid-drag, race with floating window management, multi-monitor drags generating interleaved events.","solutions":["Update komorebi; this is an internal invariant check and recent versions may reconcile stale pending moves instead of failing.","Reproduce slowly / disable conflicting drag utilities (PowerToys FancyZones, DisplayFusion) that inject move events.","If persistent, report with the two hwnd values from the message and steps to reproduce."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Caller-side guard: ensure the event's hwnd still matches the pending move before replaying\nif pending.hwnd != event.hwnd { return Ok(()); /* drop stale event instead of failing */ }","typeGuard":null,"tryCatchPattern":"if let Err(e) = process_event(&event) {\n    if e.to_string().contains(\"window handles for move operation don't match\") {\n        tracing::debug!(\"stale pending move ignored: {e}\");\n    }\n}","preventionTips":["Avoid dragging windows extremely rapidly","Disable third-party window managers/overlays that inject move events (FancyZones, DisplayFusion)","Update komorebi — stale pending-move handling improves across versions"],"tags":["win32","event-hook","race-condition"],"backgroundTag":"internal-invariant-violation","analyzedSha":"e0709f02bfae4e503bf4640f58ee75ecbbfdbb97","analyzedAt":"2026-09-06T07:08:05.107Z","contentChangedAt":"2026-09-06T07:08:05.107Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}