[PATCH] Broken behavior in window bar

I found and fixed an obscure and hard to trigger bug in SDL 1.2.14 in
Windows.

If you changed the video mode while holding the mouse button down, and then
clicked on the window, you couldn’t move the mouse pointer over the title
bar or the close window button.

It turns out WinMessage in SDL_Sysevents.c was using a static int
mouse_pressed to keep track of whether it should call SetCapture() and
ReleaseCapture(). Since it was static and initialized only once, it wasn’t
cleared when the video mode changed, so there was a kind of one-off error
and SetCapture() and ReleaseCapture() weren’t being called when they should.

Here’s a patch - I just made that int accessible from the outside and reset
it to 0 in SDL_SetVideoMode, wrapped in #ifdef WIN32. Suggestions on how to
make this more elegant are welcome.

BTW, what’s the policy with new patches? Are they commited to SVN but there
are no new SDL 1.2 releases?

–Gabriel
-------------- next part --------------
A non-text attachment was scrubbed…
Name: mouse_pressed_patch.diff
Type: application/octet-stream
Size: 1838 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20091103/a10085c4/attachment.obj

Yep, although it’s better if bugs are reported in bugzilla so they
don’t get missed on the mailing list.
http://bugzilla.libsdl.org/On Tue, Nov 3, 2009 at 12:39 PM, Gabriel Gambetta wrote:

I found and fixed an obscure and hard to trigger bug in SDL 1.2.14 in
Windows.

If you changed the video mode while holding the mouse button down, and then
clicked on the window, you couldn’t move the mouse pointer over the title
bar or the close window button.

It turns out WinMessage in SDL_Sysevents.c was using a static int
mouse_pressed to keep track of whether it should call SetCapture() and
ReleaseCapture(). Since it was static and initialized only once, it wasn’t
cleared when the video mode changed, so there was a kind of one-off error
and SetCapture() and ReleaseCapture() weren’t being called when they should.

Here’s a patch - I just made that int accessible from the outside and reset
it to 0 in SDL_SetVideoMode, wrapped in #ifdef WIN32. Suggestions on how to
make this more elegant are welcome.

BTW, what’s the policy with new patches? Are they commited to SVN but there
are no new SDL 1.2 releases?

–Gabriel


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC