[SDL] bug in sdl
John Popplewell
john at johnnypops.demon.co.uk
Sun Jun 30 19:34:00 PDT 2002
Hi,
yep, I can reproduce the problem on Win98SE. It only seems to
happen using 'directx'.
I think most people go for the 'fix' you are using of quitting
the video subsystem and then re-initialising it.
However, I had a look at the SDL code that does a grab and found this
in 'wincommon/SDL_syswm.c':
SDL_GrabMode WIN_GrabInput(_THIS, SDL_GrabMode mode)
{
if ( mode == SDL_GRAB_OFF ) {
ClipCursor(NULL);
...
} else {
ClipCursor(&SDL_bounds);
...
}
}
In your test program, when ClipCursor() is executed, SDL_bounds
is invalid (something like [3,22,3,22]) which has zero width and height.
SDL_bounds is (only) set by the WM_MOVE message in
'wincommon/SDL_sysevents.c':
case WM_MOVE: {
SDL_VideoDevice *this = current_video;
GetClientRect(SDL_Window, &SDL_bounds);
ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds);
ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds+1);
if ( this->input_grab != SDL_GRAB_OFF ) {
ClipCursor(&SDL_bounds);
}
}
break;
and yes, this is producing the invalid rectangle.
Changing WM_MOVE: into WM_WINDOWPOSCHANGED: fixes the problem by
calculating SDL_bounds and executing ClipCursor() when the window
position OR size is changed (and a few other things, but that probably
doesn't matter),
cheers,
John.
----- Original Message -----
From: "Anders A" <cartwright at linux.nu>
To: <sdl at libsdl.org>
Sent: Sunday, June 30, 2002 9:49 AM
Subject: [SDL] bug in sdl
> I think I'e found a bug in SDL.
> If i switch from fullscreen to windowed mode and runs
> SDL_WM_GrabInput(SDL_GRAB_ON) the mouse pointer get stuck in the upper
left
> corner of the screen. The bug doesn't appear if I've never set fullscreen
> before windowed or if I run
> SDL_QuitSubSystem(SDL_INIT_VIDEO); SDL_InitSubSystem(SDL_INIT_VIDEO);
before
> setting the windowed screenmode.
> I should probably say that i've only tested this under Win98 and WinXP,
both
> with directx.
> Below are some sources to demonstrate the problem.
>
>
> #include <SDL.h>
>
> int main(int argc, char **argv) {
> SDL_Event event;
>
> SDL_Init(SDL_INIT_VIDEO);
> SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE | SDL_FULLSCREEN);
>
> while(1) {
> SDL_WaitEvent(&event);
> if (event.type == SDL_KEYDOWN)
> break;
> }
>
> //SDL_QuitSubSystem(SDL_INIT_VIDEO);
> //SDL_InitSubSystem(SDL_INIT_VIDEO);
> SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
> SDL_WM_GrabInput(SDL_GRAB_ON);
>
> while(1) {
> SDL_WaitEvent(&event);
> if (event.type == SDL_KEYDOWN)
> break;
> }
>
> SDL_Quit();
> return 0;
> }
>
>
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
More information about the SDL
mailing list