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 306 - Fullscreen with mouse pointer suppressed reports wrong click coords
Summary: Fullscreen with mouse pointer suppressed reports wrong click coords
Status: RESOLVED WORKSFORME
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 1.2.11
Hardware: x86 Windows (XP)
: P2 major
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-23 20:40 UTC by Damian Sobieralski
Modified: 2007-02-16 05:27 UTC (History)
0 users

See Also:


Attachments
test app that works (2.50 KB, text/plain)
2007-02-16 05:25 UTC, Ryan C. Gordon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Damian Sobieralski 2006-08-23 20:40:20 UTC
When disabling the mouse cursor and left clicking on an exclusive full screen SDL app, mouse click coordinates don't register correctly.  If I enable the mouse pointer and left click, things report fine.  If I disable the mouse pointer but change to windowed mode - all works fine.  But if I disable the mouse pointer AND go to fullscreen mode a wierd thing happens.  The origin of the coordinate system (normally 0,0 is at the upper left most corner of the screen) seems to get shifted to the center of the screen. So any click in the upper left of the screen all report as 0,0.  At the bottom of this bug report description is a toy but functional C++ code that demonstrate th eproblem. It saves moue click coordinates to stdout.txt.  I cycle between enabling and disabling the mouse pointer in the code so that one can see where the pointer is being clicked at (the mouse pointer flashes). The same problem occurs when one does this as well as just disabling it all together. Lower case 'q' ends the program.

 This code originally was for a touchscreen (hence the mouse pointer disabled). I tried it both on the touchscreen machine AND another machine that has never been hooked up to a touchscreen (to eliminate the chance to the touchscreen driver causing the problem. This second box never has had the driver installed on it).

 This is compiled via MinGW 5.0.3
---------------------
#include <iostream.h>
#include <stdio.h>
#include <SDL.h>

char* renderText(int, int, SDL_Surface*, char*);

int main(int argc, char *argv[])
{
	SDL_Surface *screen = NULL;
	SDL_Event event;
	int quit = 0;
	char buffer[100];

    cout << "Initializing SDL.\n";

    
    /* Initialize defaults */
    if((SDL_Init(SDL_INIT_VIDEO) < 0)) 
    { 
        cout << "Could not initialize SDL:" << SDL_GetError();
        return 1;
    }

    cout << "SDL initialized.\n";

    /* Clean up on exit */
    atexit(SDL_Quit);

    /*
     * Initialize the display to the desktop resolution (0,0 for
     * first two parms to SDL_SetVideoMode), requesting a software surface
     */
    screen = SDL_SetVideoMode(0, 0, 0, SDL_SWSURFACE|SDL_ANYFORMAT|SDL_FULLSCREEN);
   
    if (screen == NULL) 
    {
      cout << "Couldn't set video mode: " << SDL_GetError();
      return 1;
    }

    
    sprintf(buffer, "Screen set to resolution %d, %d\n", screen->w, screen->h);
    cout << buffer;
    
        while (quit == 0)
        {
    SDL_ShowCursor(SDL_ENABLE);

// hide the mouse pointer
    SDL_ShowCursor(SDL_DISABLE);

//Event Processing
    	  while( SDL_PollEvent(&event))
    	  {        
             	  switch(event.type)
    		      {
    		      case SDL_KEYDOWN:
    			    cout << SDL_GetKeyName(event.key.keysym.sym) << " key down is pressed\n";
    			    break;
    		      case SDL_KEYUP:
    			    cout << SDL_GetKeyName(event.key.keysym.sym) << " key up is pressed\n";
                    if (strcmp(SDL_GetKeyName(event.key.keysym.sym), "q") == 0)
                      quit = 1;
    			    break;
    			  case SDL_QUIT:
    			    quit = 1;
    			    break;
    			  case SDL_MOUSEBUTTONDOWN:
    			    if( event.button.button == SDL_BUTTON_LEFT)
    			    {
    			      cout << "mouse click at " << event.button.x << ", " << event.button.y << "\n";
    			    }
    	          
       			    break;
    		       } // switch 
        } // while EVENT Processing loop
      } // while quit = 0
        
    return 0;		
}
Comment 1 rasz 2006-10-23 04:49:37 UTC
dupe of 299?
Comment 2 rasz 2006-10-23 04:51:28 UTC
(In reply to comment #1)
> dupe of 299?
> 

i mean http://bugzilla.libsdl.org/show_bug.cgi?id=299 of course
Comment 3 Ryan C. Gordon 2007-02-16 05:25:30 UTC
Created attachment 190 [details]
test app that works


Just tried this on Windows XP with the Platform SDK compiler, and it works, with a caveat.

First, enabling/disabling the cursor every frame confuses the windib driver. Don't do that...it gives me bad mouse motion behaviour until I disable it.

Besides patching up the code for Visual Studio to like it, I replaced the flickering cursor with a little red square. This moves around the screen correctly, windib or directx driver.

Either we fixed this or the touchscreen driver was causing problems, would be my guess.

Attaching my modified test program.

--ryan.
Comment 4 Ryan C. Gordon 2007-02-16 05:27:01 UTC
Closing bug as WORKSFORME, but if your problem still persists and can be tracked down to an SDL bug, please feel free to reopen it.

--ryan.