fix: Clear mouse area drag_initiated state on dbl click #201
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.
Change
This PR changes the mouse_area event handling code to clear the
drag_initiated
flag in the widget state on a double-click.Reason
After some investigation into issue #536 for libcosmic, I think I've pinned this down as the cause. As far as I can tell, when you double-click on the header bar to maximize, a drag message is emitted after. Something about this drag event is not handled properly in the winit windows platform code. Specifically the issue is here:
When a drag is initiated, a flag is set in the window_state to mark that the window is being dragged. As far as I can tell, this is supposed to be cleaned up here but for some reason the odd drag request being emitted after a double-click maximize doesn't get handled properly and that dragging flag in the window state is never cleared, so any future drag requests just get ignored since the "handle_os_dragging" function exits early if that flag is set.
The cause of the odd drag request appears to be the way mouse_area handles checking for potential drag events. On a double-click, the first click will set the
drag_initiated
flag, then the double_press event is triggered. But thedrag_initiated
flag is still set, so, after a maximize, the mouse position changes relative to the window, triggering the drag event. At least, as far as I can tell.