mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 19:38:14 +00:00
Fixed automation tests using the dummy video driver
This commit is contained in:
@@ -204,6 +204,14 @@ int SDL_InitMouse(void)
|
|||||||
|
|
||||||
mouse->cursor_shown = SDL_TRUE;
|
mouse->cursor_shown = SDL_TRUE;
|
||||||
|
|
||||||
|
if (!mouse->CreateCursor) {
|
||||||
|
SDL_Surface *surface = SDL_CreateSurface(1, 1, SDL_PIXELFORMAT_ARGB8888);
|
||||||
|
if (surface) {
|
||||||
|
SDL_memset(surface->pixels, 0, (size_t)surface->h * surface->pitch);
|
||||||
|
SDL_SetDefaultCursor(SDL_CreateColorCursor(surface, 0, 0));
|
||||||
|
SDL_DestroySurface(surface);
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -846,8 +854,12 @@ void SDL_QuitMouse(void)
|
|||||||
mouse->cursors = NULL;
|
mouse->cursors = NULL;
|
||||||
mouse->cur_cursor = NULL;
|
mouse->cur_cursor = NULL;
|
||||||
|
|
||||||
if (mouse->def_cursor && mouse->FreeCursor) {
|
if (mouse->def_cursor) {
|
||||||
mouse->FreeCursor(mouse->def_cursor);
|
if (mouse->FreeCursor) {
|
||||||
|
mouse->FreeCursor(mouse->def_cursor);
|
||||||
|
} else {
|
||||||
|
SDL_free(mouse->def_cursor);
|
||||||
|
}
|
||||||
mouse->def_cursor = NULL;
|
mouse->def_cursor = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1220,11 +1232,6 @@ SDL_Cursor *SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mouse->CreateCursor) {
|
|
||||||
SDL_SetError("Cursors are not currently supported");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sanity check the hot spot */
|
/* Sanity check the hot spot */
|
||||||
if ((hot_x < 0) || (hot_y < 0) ||
|
if ((hot_x < 0) || (hot_y < 0) ||
|
||||||
(hot_x >= surface->w) || (hot_y >= surface->h)) {
|
(hot_x >= surface->w) || (hot_y >= surface->h)) {
|
||||||
@@ -1240,7 +1247,14 @@ SDL_Cursor *SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
|
|||||||
surface = temp;
|
surface = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor = mouse->CreateCursor(surface, hot_x, hot_y);
|
if (mouse->CreateCursor) {
|
||||||
|
cursor = mouse->CreateCursor(surface, hot_x, hot_y);
|
||||||
|
} else {
|
||||||
|
cursor = SDL_calloc(1, sizeof(*cursor));
|
||||||
|
if (!cursor) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (cursor) {
|
if (cursor) {
|
||||||
cursor->next = mouse->cursors;
|
cursor->next = mouse->cursors;
|
||||||
mouse->cursors = cursor;
|
mouse->cursors = cursor;
|
||||||
@@ -1365,6 +1379,8 @@ void SDL_DestroyCursor(SDL_Cursor *cursor)
|
|||||||
|
|
||||||
if (mouse->FreeCursor) {
|
if (mouse->FreeCursor) {
|
||||||
mouse->FreeCursor(curr);
|
mouse->FreeCursor(curr);
|
||||||
|
} else {
|
||||||
|
SDL_free(curr);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -1607,9 +1607,18 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
|
|||||||
}
|
}
|
||||||
if (_this->SetWindowFullscreen) {
|
if (_this->SetWindowFullscreen) {
|
||||||
_this->SetWindowFullscreen(_this, window, display, SDL_TRUE);
|
_this->SetWindowFullscreen(_this, window, display, SDL_TRUE);
|
||||||
|
} else {
|
||||||
|
resized = SDL_TRUE;
|
||||||
}
|
}
|
||||||
display->fullscreen_window = window;
|
display->fullscreen_window = window;
|
||||||
|
|
||||||
|
if (mode) {
|
||||||
|
mode_w = mode->w;
|
||||||
|
mode_h = mode->h;
|
||||||
|
} else {
|
||||||
|
mode_w = display->desktop_mode.w;
|
||||||
|
mode_h = display->desktop_mode.h;
|
||||||
|
}
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
/* Android may not resize the window to exactly what our fullscreen mode is,
|
/* Android may not resize the window to exactly what our fullscreen mode is,
|
||||||
* especially on windowed Android environments like the Chromebook or Samsung DeX.
|
* especially on windowed Android environments like the Chromebook or Samsung DeX.
|
||||||
@@ -1621,13 +1630,6 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
|
|||||||
* WM_WINDOWPOSCHANGED will send SDL_EVENT_WINDOW_RESIZED).
|
* WM_WINDOWPOSCHANGED will send SDL_EVENT_WINDOW_RESIZED).
|
||||||
*/
|
*/
|
||||||
#else
|
#else
|
||||||
if (mode) {
|
|
||||||
mode_w = mode->w;
|
|
||||||
mode_h = mode->h;
|
|
||||||
} else {
|
|
||||||
mode_w = display->desktop_mode.w;
|
|
||||||
mode_h = display->desktop_mode.h;
|
|
||||||
}
|
|
||||||
if (window->w != mode_w || window->h != mode_h) {
|
if (window->w != mode_w || window->h != mode_h) {
|
||||||
resized = SDL_TRUE;
|
resized = SDL_TRUE;
|
||||||
}
|
}
|
||||||
@@ -1642,14 +1644,22 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
|
|||||||
SDL_RestoreMousePosition(window);
|
SDL_RestoreMousePosition(window);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
SDL_bool resized = SDL_FALSE;
|
||||||
|
|
||||||
/* Restore the desktop mode */
|
/* Restore the desktop mode */
|
||||||
SDL_SetDisplayModeForDisplay(display, NULL);
|
SDL_SetDisplayModeForDisplay(display, NULL);
|
||||||
if (_this->SetWindowFullscreen) {
|
if (_this->SetWindowFullscreen) {
|
||||||
_this->SetWindowFullscreen(_this, window, display, SDL_FALSE);
|
_this->SetWindowFullscreen(_this, window, display, SDL_FALSE);
|
||||||
|
} else {
|
||||||
|
resized = SDL_TRUE;
|
||||||
}
|
}
|
||||||
display->fullscreen_window = NULL;
|
display->fullscreen_window = NULL;
|
||||||
|
|
||||||
SDL_OnWindowResized(window);
|
if (resized) {
|
||||||
|
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, window->windowed.w, window->windowed.h);
|
||||||
|
} else {
|
||||||
|
SDL_OnWindowResized(window);
|
||||||
|
}
|
||||||
|
|
||||||
/* Restore the cursor position */
|
/* Restore the cursor position */
|
||||||
SDL_RestoreMousePosition(window);
|
SDL_RestoreMousePosition(window);
|
||||||
@@ -2804,6 +2814,9 @@ int SDL_ShowWindow(SDL_Window *window)
|
|||||||
|
|
||||||
if (_this->ShowWindow) {
|
if (_this->ShowWindow) {
|
||||||
_this->ShowWindow(_this, window);
|
_this->ShowWindow(_this, window);
|
||||||
|
} else {
|
||||||
|
SDL_SetMouseFocus(window);
|
||||||
|
SDL_SetKeyboardFocus(window);
|
||||||
}
|
}
|
||||||
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_SHOWN, 0, 0);
|
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_SHOWN, 0, 0);
|
||||||
|
|
||||||
@@ -2847,6 +2860,9 @@ int SDL_HideWindow(SDL_Window *window)
|
|||||||
window->is_hiding = SDL_TRUE;
|
window->is_hiding = SDL_TRUE;
|
||||||
if (_this->HideWindow) {
|
if (_this->HideWindow) {
|
||||||
_this->HideWindow(_this, window);
|
_this->HideWindow(_this, window);
|
||||||
|
} else {
|
||||||
|
SDL_SetMouseFocus(NULL);
|
||||||
|
SDL_SetKeyboardFocus(NULL);
|
||||||
}
|
}
|
||||||
window->is_hiding = SDL_FALSE;
|
window->is_hiding = SDL_FALSE;
|
||||||
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_HIDDEN, 0, 0);
|
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_HIDDEN, 0, 0);
|
||||||
|
@@ -53,7 +53,6 @@
|
|||||||
|
|
||||||
/* Initialization/Query functions */
|
/* Initialization/Query functions */
|
||||||
static int DUMMY_VideoInit(SDL_VideoDevice *_this);
|
static int DUMMY_VideoInit(SDL_VideoDevice *_this);
|
||||||
static int DUMMY_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode);
|
|
||||||
static void DUMMY_VideoQuit(SDL_VideoDevice *_this);
|
static void DUMMY_VideoQuit(SDL_VideoDevice *_this);
|
||||||
|
|
||||||
/* DUMMY driver bootstrap functions */
|
/* DUMMY driver bootstrap functions */
|
||||||
@@ -93,7 +92,6 @@ static SDL_VideoDevice *DUMMY_InternalCreateDevice(const char *enable_hint)
|
|||||||
/* Set the function pointers */
|
/* Set the function pointers */
|
||||||
device->VideoInit = DUMMY_VideoInit;
|
device->VideoInit = DUMMY_VideoInit;
|
||||||
device->VideoQuit = DUMMY_VideoQuit;
|
device->VideoQuit = DUMMY_VideoQuit;
|
||||||
device->SetDisplayMode = DUMMY_SetDisplayMode;
|
|
||||||
device->PumpEvents = DUMMY_PumpEvents;
|
device->PumpEvents = DUMMY_PumpEvents;
|
||||||
device->CreateWindowFramebuffer = SDL_DUMMY_CreateWindowFramebuffer;
|
device->CreateWindowFramebuffer = SDL_DUMMY_CreateWindowFramebuffer;
|
||||||
device->UpdateWindowFramebuffer = SDL_DUMMY_UpdateWindowFramebuffer;
|
device->UpdateWindowFramebuffer = SDL_DUMMY_UpdateWindowFramebuffer;
|
||||||
@@ -158,11 +156,6 @@ int DUMMY_VideoInit(SDL_VideoDevice *_this)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int DUMMY_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DUMMY_VideoQuit(SDL_VideoDevice *_this)
|
void DUMMY_VideoQuit(SDL_VideoDevice *_this)
|
||||||
{
|
{
|
||||||
#ifdef SDL_INPUT_LINUXEV
|
#ifdef SDL_INPUT_LINUXEV
|
||||||
|
@@ -172,6 +172,8 @@ static int video_createWindowVariousFlags(void *arg)
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
flags = SDL_WINDOW_OPENGL;
|
flags = SDL_WINDOW_OPENGL;
|
||||||
|
/* Skip - not every video driver supports OpenGL; comment out next line to run test */
|
||||||
|
continue;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
Reference in New Issue
Block a user