mirror of
https://github.com/yawut/SDL.git
synced 2026-10-02 05:06:46 -05:00
Fixed bug 875 - Title bar unresponsive after video mode change
Gabriel Gambetta 2009-11-04 04:51:46 PST If you change the video mode while holding the mouse button down, and then click on the window, you can't move the mouse pointer over the title bar or the close window button. It turns out WinMessage in SDL_Sysevents.c is using a static int mouse_pressed to keep track of whether it should call SetCapture() and ReleaseCapture(). Since it's static and initialized only once, it isn't cleared when the video mode changed, so there's a kind of one-off error and SetCapture() and ReleaseCapture() aren'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. --HG-- branch : SDL-1.2
This commit is contained in:
@@ -573,6 +573,10 @@ static void SDL_CreateShadowSurface(int depth)
|
||||
#include <sys/neutrino.h>
|
||||
#endif /* __QNXNTO__ */
|
||||
|
||||
#ifdef WIN32
|
||||
extern int sysevents_mouse_pressed;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set the requested video mode, allocating a shadow buffer if necessary.
|
||||
*/
|
||||
@@ -586,6 +590,10 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
|
||||
int is_opengl;
|
||||
SDL_GrabMode saved_grab;
|
||||
|
||||
#ifdef WIN32
|
||||
sysevents_mouse_pressed = 0;
|
||||
#endif
|
||||
|
||||
/* Start up the video driver, if necessary..
|
||||
WARNING: This is the only function protected this way!
|
||||
*/
|
||||
|
||||
@@ -243,13 +243,14 @@ static BOOL WINAPI WIN_TrackMouseEvent(TRACKMOUSEEVENT *ptme)
|
||||
}
|
||||
#endif /* WM_MOUSELEAVE */
|
||||
|
||||
int sysevents_mouse_pressed = 0;
|
||||
|
||||
/* The main Win32 event handler
|
||||
DJM: This is no longer static as (DX5/DIB)_CreateWindow needs it
|
||||
*/
|
||||
LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
SDL_VideoDevice *this = current_video;
|
||||
static int mouse_pressed = 0;
|
||||
SDL_VideoDevice *this = current_video;
|
||||
#ifdef WMMSG_DEBUG
|
||||
fprintf(stderr, "Received windows message: ");
|
||||
if ( msg > MAX_WMMSG ) {
|
||||
@@ -426,14 +427,14 @@ LRESULT CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
if ( state == SDL_PRESSED ) {
|
||||
/* Grab mouse so we get up events */
|
||||
if ( ++mouse_pressed > 0 ) {
|
||||
if ( ++sysevents_mouse_pressed > 0 ) {
|
||||
SetCapture(hwnd);
|
||||
}
|
||||
} else {
|
||||
/* Release mouse after all up events */
|
||||
if ( --mouse_pressed <= 0 ) {
|
||||
if ( --sysevents_mouse_pressed <= 0 ) {
|
||||
ReleaseCapture();
|
||||
mouse_pressed = 0;
|
||||
sysevents_mouse_pressed = 0;
|
||||
}
|
||||
}
|
||||
if ( mouse_relative ) {
|
||||
|
||||
Reference in New Issue
Block a user