SDL2 MOUSEBUTTONDOWN & MOUSEMOTION Event Bug! |
Extra Notes |
Magnet
|
Some Extra Notes:
Even if you put some extra checking on SDL_WINDOWEVENT_FOCUS_GAINED or LOST. This only catches maybe 50% then without it. The issues are still there when clicking DESKTOP, Then Window Title, DESKTOP, then Window Title. Also what is odd, is when you click the window title and regain focus, it never gives the output in the debug window from the MOUSEBUTTONDOWN event ex..
I don't see the std::cout printed the the screen. So something is off I believe, and when I get more time i'll have to dig through the actual event code in SDL. |
|||||||||||||
|
Little more research |
Magnet
|
I added some more SDL Logging and found the following:
If you click on a canvas a several times, then click out of the window (desktop). Then click back on the Applications title bar you get all of the following events INFO: Window 1 gained keyboard focus INFO: Mouse entered window 1 Mouse pressed at: 490,0 INFO: SDL_MOUSEBUTTONDOWN 1 shown Mouse moved by: 3, -18 : 493,0 So you get a: 1. Gained Keyboard focus 2. Window entered, which should only happen after you move over the canvas. 3. Mouse Pressed showing 1 = LEFT BUTTON 4. Extra Mouse Movement This is from a single click and release on the Window Title with no movement over the canvas. Keep in mind there is still no MOUSEBUTTONUP for a release so this state stays in motion. Then if you click on the canvas, you do not get another MOUSEBUTTONDOWN, only a MOUSEBUTTONUP for a release. I hope someone else will give this a shot and confirm my finding sometime. I believe this will be an issue for anyone using the mouse and holding down the button and dragging for tasks, and if they leave the window and click back on the title bar which a lot of people do and their button and motions are still considered active it will cause issues. Thanks for your help. |
|||||||||||
|
Update |
Magnet
|
I've had another developer confirm the bug for me so I've created a bugzilla entry.
https://bugzilla.libsdl.org/show_bug.cgi?id=2842 There is also a main.cpp source file attached to the bug report giving proof of concept. Thanks/ |
|||||||||||
|
SDL2 MOUSEBUTTONDOWN & MOUSEMOTION Event Bug! |
Jonny D
|
Can you try using if(event.motion.state & SDL_BUTTON_LMASK ...) in the mouse motion event test? The way you are testing event.button.button will generate undefined behavior (due to union type).
Jonny D On Monday, January 12, 2015, Magnet wrote:
|
|||||||||||||
|
Re: SDL2 MOUSEBUTTONDOWN & MOUSEMOTION Event Bug! |
Naith
|
I am using the SDL_BUTTON mask (which the SDL_BUTTON_LMASK internally is using) whenever I check for a mouse events and I can confirm that the bug is occuring when it is used aswell. Bug occur in this way: I hold a mouse button, the mouse pointer leaves the window (still holding the button), click on another window so that the SDL window looses focus, I release the mouse button and returns to the SDL window by clicking on the SDL window top bar. When doing this, SDL thinks I'm still holding the mouse button and I have to click inside the window to "release the button". If I, when returning to the SDL window, clicks directly inside the window (i.e not clicking on the window top bar), SDL understands that I have released the button. |
|||||||||||||
|
SDL2 MOUSEBUTTONDOWN & MOUSEMOTION Event Bug! |
Jonny D
|
My comment is not specifically about the mask usage. It's about using event.motion.state versus using event.button.button in an SDL_MOUSEMOTIONEVENT.  event.button.button is invalid in that context, yet that is what the provided code uses.
Jonny D On Mon, Jan 12, 2015 at 10:37 AM, Naith wrote:
|
|||||||||||||
|
Re: SDL2 MOUSEBUTTONDOWN & MOUSEMOTION Event Bug! |
Magnet
|
HI Jonny,
Thanks for the time and response. As soon as I get home I'll be happy to test your suggestion. I still think there is a problem in general where a MouseButtonDown event is trigger with no release when clicking on the title bar. I'm still new working on my first SDL application so I appreciate the clarification. MIke
|
|||||||||||||||
|
Re: SDL2 MOUSEBUTTONDOWN & MOUSEMOTION Event Bug! |
Magnet
|
Hi Jonny, I just tried your suggestion and there is no change in behavior. The issue still persists with LEFT Mouse button still being active.
isMouseSelection is of course true because the click on the title bar registers the MOUSEBUTTONDOWN event. However, the SDL_BUTTON_LMASK is still showing as active leaving no change in the behavior. |
|||||||||||||||
|