Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Clear mouse area drag_initiated state on dbl click #201

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

netraptor
Copy link

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:

 unsafe fn handle_os_dragging(&self, wparam: WPARAM) {
        let window = self.window;
        let window_state = self.window_state.clone();

        self.thread_executor.execute_in_thread(move || {
            {
                let mut guard = window_state.lock().unwrap();
                if !guard.dragging {
                    guard.dragging = true;
                } else {
                    return;
                }
            }
// ...continues on to trigger dragging...

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 the drag_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.

@netraptor netraptor changed the title Clear mouse area drag_initiated state on dbl click fix: Clear mouse area drag_initiated state on dbl click Dec 2, 2024
@wash2 wash2 merged commit 07c720f into pop-os:master Dec 2, 2024
2 of 16 checks passed
@netraptor netraptor deleted the windows-broken-drag-fix branch December 4, 2024 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants