mirror of https://github.com/encounter/SDL.git
Fixed a message box getting the mouse capture state out of sync
This commit is contained in:
parent
622311c016
commit
e19a9a7931
|
@ -1019,7 +1019,8 @@ SDL_UpdateMouseCapture(SDL_bool force_release)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!force_release) {
|
if (!force_release) {
|
||||||
if (mouse->capture_desired || (mouse->auto_capture && SDL_GetMouseState(NULL, NULL) != 0)) {
|
if (SDL_GetMessageBoxCount() == 0 &&
|
||||||
|
(mouse->capture_desired || (mouse->auto_capture && SDL_GetMouseState(NULL, NULL) != 0))) {
|
||||||
if (!mouse->relative_mode) {
|
if (!mouse->relative_mode) {
|
||||||
capture_window = SDL_GetKeyboardFocus();
|
capture_window = SDL_GetKeyboardFocus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -474,6 +474,7 @@ extern SDL_VideoDisplay *SDL_GetDisplay(int displayIndex);
|
||||||
extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window);
|
extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window);
|
||||||
extern void *SDL_GetDisplayDriverData( int displayIndex );
|
extern void *SDL_GetDisplayDriverData( int displayIndex );
|
||||||
extern SDL_bool SDL_IsVideoContextExternal(void);
|
extern SDL_bool SDL_IsVideoContextExternal(void);
|
||||||
|
extern int SDL_GetMessageBoxCount(void);
|
||||||
|
|
||||||
extern void SDL_GL_DeduceMaxSupportedESProfile(int* major, int* minor);
|
extern void SDL_GL_DeduceMaxSupportedESProfile(int* major, int* minor);
|
||||||
|
|
||||||
|
|
|
@ -291,6 +291,7 @@ SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window * window, Uint32 * fo
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_VideoDevice *_this = NULL;
|
static SDL_VideoDevice *_this = NULL;
|
||||||
|
static SDL_atomic_t SDL_messagebox_count;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, const SDL_Rect * rects, int numrects)
|
SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window * window, const SDL_Rect * rects, int numrects)
|
||||||
|
@ -4271,6 +4272,12 @@ SDL_IsScreenKeyboardShown(SDL_Window *window)
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
SDL_GetMessageBoxCount(void)
|
||||||
|
{
|
||||||
|
return SDL_AtomicGet(&SDL_messagebox_count);
|
||||||
|
}
|
||||||
|
|
||||||
#if SDL_VIDEO_DRIVER_ANDROID
|
#if SDL_VIDEO_DRIVER_ANDROID
|
||||||
#include "android/SDL_androidmessagebox.h"
|
#include "android/SDL_androidmessagebox.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -4331,7 +4338,6 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
SDL_bool relative_mode;
|
SDL_bool relative_mode;
|
||||||
int show_cursor_prev;
|
int show_cursor_prev;
|
||||||
SDL_bool mouse_captured;
|
|
||||||
SDL_Window *current_window;
|
SDL_Window *current_window;
|
||||||
SDL_MessageBoxData mbdata;
|
SDL_MessageBoxData mbdata;
|
||||||
|
|
||||||
|
@ -4341,10 +4347,11 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||||
return SDL_SetError("Invalid number of buttons");
|
return SDL_SetError("Invalid number of buttons");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_AtomicIncRef(&SDL_messagebox_count);
|
||||||
|
|
||||||
current_window = SDL_GetKeyboardFocus();
|
current_window = SDL_GetKeyboardFocus();
|
||||||
mouse_captured = current_window && ((SDL_GetWindowFlags(current_window) & SDL_WINDOW_MOUSE_CAPTURE) != 0);
|
|
||||||
relative_mode = SDL_GetRelativeMouseMode();
|
relative_mode = SDL_GetRelativeMouseMode();
|
||||||
SDL_CaptureMouse(SDL_FALSE);
|
SDL_UpdateMouseCapture(SDL_FALSE);
|
||||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||||
show_cursor_prev = SDL_ShowCursor(1);
|
show_cursor_prev = SDL_ShowCursor(1);
|
||||||
SDL_ResetKeyboard();
|
SDL_ResetKeyboard();
|
||||||
|
@ -4448,15 +4455,15 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_AtomicDecRef(&SDL_messagebox_count);
|
||||||
|
|
||||||
if (current_window) {
|
if (current_window) {
|
||||||
SDL_RaiseWindow(current_window);
|
SDL_RaiseWindow(current_window);
|
||||||
if (mouse_captured) {
|
|
||||||
SDL_CaptureMouse(SDL_TRUE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_ShowCursor(show_cursor_prev);
|
SDL_ShowCursor(show_cursor_prev);
|
||||||
SDL_SetRelativeMouseMode(relative_mode);
|
SDL_SetRelativeMouseMode(relative_mode);
|
||||||
|
SDL_UpdateMouseCapture(SDL_FALSE);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue