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 12 - Bogus coords in mousedown on Mac OS X
Summary: Bogus coords in mousedown on Mac OS X
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 1.2.9
Hardware: PowerPC Mac OS X (All)
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on: 720
Blocks:
  Show dependency treegraph
 
Reported: 2006-01-03 11:55 UTC by Ryan C. Gordon
Modified: 2009-03-26 00:04 UTC (History)
1 user (show)

See Also:


Attachments
Patch to fix the problem. (753 bytes, patch)
2006-01-19 10:21 UTC, Christian Walther
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan C. Gordon 2006-01-03 11:55:07 UTC
To: "A list for developers using the SDL library. \(includes    SDL-announce\)"
<sdl@libsdl.org>
From: Michael Benfield <leftfist@mac.com>
Date: Sun, 4 Sep 2005 17:41:53 -0400
Subject: [SDL] SDL gives incorrect mouse coordinates under Mac OS X

Under Mac OS 10.3 with a recent SDL, I get incorrect mouse coordinates
for button down events in a specific circumstance. If I pass another
window over the SDL window, and then draw back that window, and then
click in the middle of the SDL window, every subsequent click in the
SDL window until I move the mouse will generate a mouse button down
event with a Y coordinate of 0 regardless of where the click actually
is. This doesn't happen under x86 Linux.

I'm including at the end of this email a tiny program that makes it
easy to reproduce and see the issue.

Thanks,
Mike Benfield


#include<SDL.h>

int main(int argc, char** argv)
{
   SDL_Init(SDL_INIT_VIDEO);
   SDL_SetVideoMode(400, 400, 32, 0);

   SDL_Event e;
   for(;;) {
     if(SDL_PollEvent(&e))
       switch(e.type) {
       case SDL_MOUSEBUTTONDOWN:
         printf("click x: %d, y: %d\n", e.button.x, e.button.y);
         break;
       case SDL_QUIT:
         return 0;
       }
   }
}
Comment 1 Ryan C. Gordon 2006-01-03 11:55:27 UTC
(This may be fixed in the latest CVS...pleases test!)

--ryan.

Comment 2 Christian Walther 2006-01-04 10:41:36 UTC
I can reproduce what's probably this problem here with both SDL 1.2.8 from Fink and my recent (but not completely up-to-date) CVS version. The issue seems to be that SDL's internal mouse location is not updated when the SDL window is brought to the front by clicking into it, it's still what it was when the application was switched away from (until the first mouse motion event comes in). If you switched away from the application by clicking into some other window, that's somewhere at the edge of the SDL window, e.g. with a y coordinate of 0. If you switch away using cmd-tab, it can be in the middle of the window.

Solutions could be updating the internal mouse location when the application becomes active, or doing it on mousedown events.
Comment 3 Christian Walther 2006-01-19 10:21:47 UTC
Created attachment 25 [details]
Patch to fix the problem.

Here's a simple patch that fixes the problem (at least the one I described, which I hope is the one the original poster meant) by updating SDL's mouse location when the application is activated.

(I'll post a separate patch shortly that contains a lot more changes to SDL's activation/deactivation handling.)
Comment 4 Ryan C. Gordon 2006-01-27 11:23:02 UTC
Setting Sam as "QA Contact" on all bugs (even resolved ones) so he'll definitely be in the loop to any further discussion here about SDL.

--ryan.

Comment 5 Ryan C. Gordon 2006-03-20 19:35:35 UTC
This patch is in CVS now.

--ryan.