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 3190

Summary: Mouse down events with cursor at top point of window are missed
Product: SDL Reporter: Joshua Bodine <josh>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: icculus
Version: HG 2.0   
Hardware: x86   
OS: Mac OS X (All)   
Attachments: Patch which corrects issue

Description Joshua Bodine 2015-11-28 19:40:59 UTC
Created attachment 2315 [details]
Patch which corrects issue

This is related to bug 2842, which was resolved by discarding button events which are not within the window content frame. With the current mercurial 2.0 code, on all versions of Mac OS X 10.7 through 10.11, when your cursor is at the very top of the window (easy to do in fullscreen mode), mouse button down events are not registered.

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/#//apple_ref/c/func/NSPointInRect states "Point-in-rectangle functions generally assume that the 'upper' and 'left' edges of a rectangle are inside the rectangle boundaries, while the 'lower' and 'right' edges are outside the boundaries." Since the origin is at the bottom left, this may explain why the NSPointInRect test is failing when the cursor is at the top edge of the screen (I'm not sure why the same issue is not seen on the right edge of the screen, however).

Adding one to the width and height of the rectangle seems to correct the issue, and allows clicks at the top edge of the window to be detected. See attached patch.
Comment 1 Ryan C. Gordon 2015-12-29 06:11:05 UTC
I added a comment to your patch to explain why we were incrementing the rectangle size, and pushed it as https://hg.libsdl.org/SDL/rev/bbe9ef8c2ecb ...thanks!

--ryan.