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

Mouse release event ignored if released too quickly #91

Closed
aswerw opened this issue Jan 20, 2024 · 11 comments
Closed

Mouse release event ignored if released too quickly #91

aswerw opened this issue Jan 20, 2024 · 11 comments
Labels
Bug A report of unintended or broken behavior.

Comments

@aswerw
Copy link

aswerw commented Jan 20, 2024

If you depress the left mouse button, and release it too quickly, the release event seems to be ignored.

For example, if you do it over a line in the text view widget it'll be stuck selecting text afterwards, but it also happens with other widgets (menu items and tabs).

Here is a recording of it happening, by sending automated down and up events without any delay to reproduce it consistently:

click.mp4
@ryanfleury ryanfleury added the Bug A report of unintended or broken behavior. label Jan 21, 2024
@ryanfleury
Copy link
Collaborator

Fixed in fd0feef.

@aswerw
Copy link
Author

aswerw commented Jan 29, 2024

This was initially fixed for me, but I think it broke again in 0d1ccd7.

I think the issue is with this if statement:

// src\raddbg\raddbg.c
for(OS_Event *ev = leftover_events.first, *next = 0; ev != 0; ev = next)
{
  next = ev->next;
  if(ev->timestamp_us+1000000 < os_now_microseconds() ||
     ev->kind == OS_EventKind_Text ||
      (ev->kind == OS_EventKind_Press && ev->key != OS_Key_LeftMouseButton) ||
      (ev->kind == OS_EventKind_Press && ev->key != OS_Key_RightMouseButton) ||
      (ev->kind == OS_EventKind_Press && ev->key != OS_Key_MiddleMouseButton) ||
      (ev->kind == OS_EventKind_Release && ev->key != OS_Key_LeftMouseButton) ||
      (ev->kind == OS_EventKind_Release && ev->key != OS_Key_RightMouseButton) ||
       (ev->kind == OS_EventKind_Release && ev->key != OS_Key_MiddleMouseButton) ||
       (ev->kind == OS_EventKind_Scroll))
  {
    os_eat_event(&leftover_events, ev);
  }
}

All press and release events will be eaten regardless of ev->key.

@ryanfleury
Copy link
Collaborator

Oops... must've been on autopilot there. Fixed again in baca24c.

@ryanfleury
Copy link
Collaborator

I'm experiencing issues on my end with unconsumed events sticking around, so I am going to disable this behavior & reopen this issue until this is fully fixed.

@ryanfleury ryanfleury reopened this Jan 29, 2024
@ryanfleury
Copy link
Collaborator

I've just completed a more proper solution of this in c637ad6. This issue should be resolved; just let me know if you see any other manifestations of the same thing.

@aswerw
Copy link
Author

aswerw commented Feb 8, 2024

It seems fixed for the menu items and tabs, but the text view widget seems to ignore the down event now as well (text cursor doesn't update).

@ryanfleury
Copy link
Collaborator

Can you show a video of what you're seeing? I am not seeing that on my end.

@ryanfleury
Copy link
Collaborator

I think I see one potential issue - you might be expecting whatever mouse positions are attached to the mouse press/release events (presumably auto-generated) to show up in the selection itself, without forcibly changing what the mouse position is?

If that's the case, can you expand on the intended use case you have in mind for that?

@aswerw
Copy link
Author

aswerw commented Feb 8, 2024

click2.mp4

Yeah, the fast click events are auto-generated to reproduce it consistently for video.

#pragma comment(lib, "user32.lib")

#include <Windows.h>

int main()
{
    if(RegisterHotKey(0, 1, MOD_NOREPEAT, 'A'))
    {
        MSG Msg = {0};
        while(GetMessage(&Msg, 0, 0, 0) != 0)
        {
            if(Msg.message == WM_HOTKEY)
            {
                int const Count = 2;
                INPUT Inputs[Count] = {};

                Inputs[0].type = INPUT_MOUSE;
                Inputs[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;

                Inputs[1].type = INPUT_MOUSE;
                Inputs[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;

                if(SendInput(Count, Inputs, sizeof(INPUT)) != Count)
                {
                    break;
                }
            }
        } 
    }

    return 0;
}

(Also tested with a Logitech mouse macro, and my actual use case, remote desktop.)

@ryanfleury
Copy link
Collaborator

ryanfleury commented Feb 8, 2024

Ahhhhh okay makes perfect sense, thanks. Looks like I've fixed this on my end in 11dd5fd. Can you give that a try?

@aswerw
Copy link
Author

aswerw commented Feb 8, 2024

Seems to be working! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A report of unintended or broken behavior.
Projects
None yet
Development

No branches or pull requests

2 participants