We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3300

Summary: Window Focus Mouse-Down Event Discrepancy across platforms (win32/linux/osx)
Product: SDL Reporter: bazz <mbazzinotti>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: amaranth72
Version: 2.0.4   
Hardware: Other   
OS: Other   
URL: https://www.youtube.com/watch?v=MN9c-Pyctvg&feature=youtu.be

Description bazz 2016-03-30 03:22:00 UTC
This is likely a Video OR Events bug. I've done a bug search, I don't think this is a reproduced bug file. This is also my first bug submission (on this website) - please be kind to me. Thanks

Background information
----------------------
SDL 2.0.4 release version on all 3 platforms:
OSX Yosemite 10.10.4 (64-bit)
Gentoo Linux 3.18.11 (64-bit)
Win32 (tested on WINE - version not offhand)

I have a nice video demonstrating the core of my issue: https://www.youtube.com/watch?v=MN9c-Pyctvg&feature=youtu.be

Further Explanation
-------------------
I use SDL_CreateWindowAndRenderer() to create several hidden windows at app-startup..
I then call SDL_ShowWindow() / SDL_HideWindow() at certain times.

If I have 2 windows open - and switch context from one to the other (no calling of SDL window functions is necessary or done for the context switch):
Linux/Windows - MousedownEvent is processed at the newly focused window where I clicked (if clicked in content area)
OSX - The mousedown event is not sent.

This difference in functionality is not desired, and I consider it a bug in OSX implementation of event handling.

I could code in some kind of app-level platform-specific patch, but I figure you all would want uniform behavior on these platforms anyways! Thus, filed the bug!

Note: I also tried the SDL mercurial "tip" archive tonight with no change in behavior.
Comment 1 bazz 2016-03-30 15:32:47 UTC
Here's a demonstration you can try that shows a native OSX app doing what I expect the OSX SDL app to do: 

You can try this with a native OSX App called "Calculator" in /Applications/Calculator -- simply unfocus the calculator by having another app window focused .. Then focus the calculator by clicking over one of its number buttons -- you will see the number actually entered as a valid input to the calculator upon it being focused. <-- This is what I desire in my OSX SDL app! -- which is how my Linux/Windows SDL apps behave!
Comment 2 Alex Szpakowski 2016-04-02 14:54:42 UTC
I've added a SDL hint to control the behaviour in OS X: https://hg.libsdl.org/SDL/rev/6dd5f49e4a77
Comment 3 Sam Lantinga 2016-09-30 18:35:38 UTC
FYI, the behavior in 2.0.5 will be consistent across platforms, where the first click on the window will bring it to the foreground and not be delivered to the application.

You can set the hint SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH to "1" to have the click delivered to the application, on all platforms.