fix(title_bar): clear CSD drag flag via paint-phase window-level mous…#2465
Open
gaoyia wants to merge 1 commit into
Open
fix(title_bar): clear CSD drag flag via paint-phase window-level mous…#2465gaoyia wants to merge 1 commit into
gaoyia wants to merge 1 commit into
Conversation
…e_up listener On Linux client-side decorations, when the pointer leaves the title-bar element mid-drag, the element-level `on_mouse_up` never fires. As a result `should_move` stays `true` and the next mouse move re-triggers `start_window_move`, causing the window to keep moving unexpectedly. Register a window-level `mouse_up` listener that resets `should_move`. Because `window.on_mouse_event` may only be called during the paint phase (calling it from `RenderOnce::render` panics with "this method can only be called during paint"), the listener is wrapped in a zero-size `Element` (`TitleBarWindowMouseUpListener`) that is only attached on Linux when the window is client-decorated. The existing drag and double-click logic is left unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Linux client-side decorations, when the pointer leaves the title-bar element mid-drag, the element-level
on_mouse_upnever fires. As a resultshould_movestaystrue, and the next mouse move re-triggersstart_window_move, causing the window to keep moving unexpectedly.This PR registers a window-level
mouse_uplistener that resetsshould_move. Becausewindow.on_mouse_eventmay only be called during the paint phase (calling it fromRenderOnce::renderpanics with "this method can only be called during paint"), the listener is wrapped in a zero-sizeElement(TitleBarWindowMouseUpListener) that is only attached on Linux when the window is client-decorated.The existing drag and double-click logic is left unchanged.
Description
On Linux with client-side decorations (CSD), the title bar tracks a
should_moveflag: mouse-down sets it, the next mouse-move callsstart_window_move, and mouse-up clears it. The problem is that once the compositor begins moving the window, the pointer can leave the title-bar element, so its element-levelon_mouse_upnever fires. The flag staystrue, and a later mouse-move re-triggersstart_window_move, making the window "stick" to the cursor.This PR adds a window-level
mouse_uplistener that clearsshould_moveregardless of where the pointer is released. Sincewindow.on_mouse_eventmay only be called during the paint phase — calling it fromRenderOnce::renderpanics with "this method can only be called during paint" — the listener is implemented as a zero-sizeElement(TitleBarWindowMouseUpListener,display: none) that registers the listener in itspaint. The listener only reacts to left-button release during the bubble phase. It is attached only whenis_linux && is_client_decorated, so other platforms and server-side decorations are unaffected. The existing drag and double-click (maximize) behavior is unchanged.Break Changes
None.
How to Test
On Linux with client-side decorations:
Also verify normal behavior is intact:
On macOS/Windows, confirm no behavioral change (the listener is not attached).
Checklist
cargo runfor story tests related to the changes.