MacOS X, multiple SDL_SetVideoMode, and mouse grab

There seems to be some issues on MacOS X involving multiple SetVideoMode
calls and the mouse’s state. If you create a window, and then try to
recreate a new one, the cursor’s grab state and/or visibility seems to get
munged up.

Minimal test case: comment the SDL_PumpEvents() call to make this “work”.
If the PumpEvents is there, the mouse gets hosed. I specified SDL_NOFRAME
and SDL_OPENGL (since this is what the ut2003 splash screen/main window
use), but I think that it’s just a matter of forcing SDL to destroy one
window and create another by changing a significant property such as
whether it has a title bar or not, etc.

Any insight?

Thanks,
–ryan.

// build with "gcc -o test test.c sdl-config --cflags sdl-config --libs

#include “SDL.h”

int main(int argc, char **argv)
{
SDL_Init(SDL_INIT_VIDEO);
SDL_SetVideoMode(640, 480, 0, SDL_NOFRAME);
SDL_Delay(2000);

SDL_PumpEvents();  // broken if event loop is pumped here.

SDL_ShowCursor(0);
SDL_WM_GrabInput(SDL_GRAB_ON);
SDL_SetVideoMode(800, 600, 0, SDL_OPENGL);

while (1)
{
    SDL_Event event;
    if (!SDL_PollEvent(&event))
        SDL_Delay(10);
    else if ((event.type == SDL_KEYDOWN) &&
             (event.key.keysym.sym == SDLK_ESCAPE))
    {
        break;
    }
}

SDL_Quit();
return(0);

}

There seems to be some issues on MacOS X involving multiple
SetVideoMode
calls and the mouse’s state. If you create a window, and then try to
recreate a new one, the cursor’s grab state and/or visibility seems to
get
munged up.

Minimal test case: comment the SDL_PumpEvents() call to make this
"work".
If the PumpEvents is there, the mouse gets hosed. I specified
SDL_NOFRAME
and SDL_OPENGL (since this is what the ut2003 splash screen/main window
use), but I think that it’s just a matter of forcing SDL to destroy one
window and create another by changing a significant property such as
whether it has a title bar or not, etc.

Any insight?

The cursor is always shown when unsetting the video mode. I put this in
there so apps can’t quit and leave the cursor hidden (which would be
really annoying to users).

I really put this in the wrong place, in QZ_UnsetVideoMode(). I’m
moving it to QZ_VideoQuit(). This fixes the problem.

Note: This patch also comments out a line I thought might be the
problem (before I really found the problem). This line should be
commented out (or removed) because it fixes an error in the release of
the window that can cause a double release and will cause a crash.

-------------- next part --------------
A non-text attachment was scrubbed…
Name: src-video-quartz-grabhide.diff
Type: application/octet-stream
Size: 1655 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20021213/0b57b8b0/attachment.objOn Thursday, December 12, 2002, at 03:01 PM, sdl-request at libsdl.org wrote:

Subject: [SDL] MacOS X, multiple SDL_SetVideoMode, and mouse grab.
Reply-To: sdl at libsdl.org

I really put this in the wrong place, in QZ_UnsetVideoMode(). I’m
moving it to QZ_VideoQuit(). This fixes the problem.

Indeed it does.

As always, much thanks, Darrell.

–ryan.

I really put this in the wrong place, in QZ_UnsetVideoMode(). I’m
moving it to QZ_VideoQuit(). This fixes the problem.

Indeed it does.

(Oh, and this is in CVS now, btw).

–ryan.

I really put this in the wrong place, in QZ_UnsetVideoMode(). I’m
moving it to QZ_VideoQuit(). This fixes the problem.

Indeed it does.

(Oh, and this is in CVS now, btw).

Thanks guys! :slight_smile:

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment