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

Docking sometimes failed when dropped on drop indicators #306

Closed
liszto opened this issue Aug 10, 2022 · 2 comments
Closed

Docking sometimes failed when dropped on drop indicators #306

liszto opened this issue Aug 10, 2022 · 2 comments

Comments

@liszto
Copy link

liszto commented Aug 10, 2022

Hello !
I'm using Qt 5.14 + Windows 10 + KDDockWidget 1.5
When I release my mouse above the drop indicator, sometimes it matches with the lambda check (every 100ms) and I supposed the mouse left button state between Qt & Window is not the same just at this particular moment and it fails to dock whereas the click release is on an indicator.
If I click and release without moving at the same place it will dock.

I try to comment the code used for the this bugfix (166) and the issue seems gone (I say seems because it's not 100% reproduced) and without the code I can't reproduced the bug mentioned above.

I though maybe it could be better to check if at this particular moment we are in the same "state" than handleMouseButtonRelease in order to call dropped() or draggedCanceled() depending on the situation ? 🤔

Edit:

I made this and it works fine (maybe not the best solution but at least it will cover your initial case and the one we are facing).
Here a part of your initial StateDragging constructor

        const bool mouseButtonIsReallyDown = (GetKeyState(VK_LBUTTON) & 0x8000);
        if (!mouseButtonIsReallyDown && isLeftButtonPressed()) {
            qCDebug(state) << "Canceling drag, Qt thinks mouse button is pressed"
                << "but Windows knows it's not";
           Q_EMIT q->dragCanceled();
        }

and here what we changed

        const bool mouseButtonIsReallyDown = (GetKeyState(VK_LBUTTON) & 0x8000);
        if (!mouseButtonIsReallyDown && isLeftButtonPressed()) {
            qCDebug(state) << "Dropping or Canceling drag, Qt thinks mouse button is pressed"
                << "but Windows knows it's not";
		QPoint globalCursorPos = QCursor::pos();
		handleMouseButtonRelease( globalCursorPos );
        }
@liszto liszto changed the title Docking failed when dropped on drop indicators Docking sometimes failed when dropped on drop indicators Aug 10, 2022
iamsergio added a commit that referenced this issue Aug 16, 2022
As explained in commit message for #166, there's a case where Qt
doesn't receive the mouse release from Windows. If that happens
then allow to drop if we're over a drop indicator.

Fixes issue #306
@iamsergio
Copy link
Contributor

yeah that's fine, there's not much else we can do here

@liszto
Copy link
Author

liszto commented Aug 18, 2022

Thanks for the fix integration in your codebase @iamsergio

You don't need to keep the Q_EMIT q->dragCanceled();
because it's already managed by the handleMouseButtonRelease( globalCursorPos ); for all its states

iamsergio added a commit that referenced this issue Sep 7, 2022
As explained in commit message for #166, there's a case where Qt
doesn't receive the mouse release from Windows. If that happens
then allow to drop if we're over a drop indicator.

Fixes issue #306

(cherry-picked from commit bde5be9)
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

No branches or pull requests

2 participants