| | |
| | | /* |
| | | Simple DirectMedia Layer |
| | | Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> |
| | | Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org> |
| | | |
| | | This software is provided 'as-is', without any express or implied |
| | | warranty. In no event will the authors be held liable for any damages |
| | |
| | | #include "SDL_opengl.h" |
| | | #endif /* SDL_VIDEO_OPENGL */ |
| | | |
| | | #if SDL_VIDEO_OPENGL_ES |
| | | #if SDL_VIDEO_OPENGL_ES && !SDL_VIDEO_OPENGL |
| | | #include "SDL_opengles.h" |
| | | #endif /* SDL_VIDEO_OPENGL_ES */ |
| | | #endif /* SDL_VIDEO_OPENGL_ES && !SDL_VIDEO_OPENGL */ |
| | | |
| | | /* GL and GLES2 headers conflict on Linux 32 bits */ |
| | | #if SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL |
| | |
| | | #endif |
| | | #if SDL_VIDEO_DRIVER_X11 |
| | | &X11_bootstrap, |
| | | #endif |
| | | #if SDL_VIDEO_DRIVER_MIR |
| | | &MIR_bootstrap, |
| | | #endif |
| | | #if SDL_VIDEO_DRIVER_WAYLAND |
| | | &Wayland_bootstrap, |
| | |
| | | #endif |
| | | #if SDL_VIDEO_DRIVER_QNX |
| | | &QNX_bootstrap, |
| | | #endif |
| | | #if SDL_VIDEO_DRIVER_OFFSCREEN |
| | | &OFFSCREEN_bootstrap, |
| | | #endif |
| | | #if SDL_VIDEO_DRIVER_DUMMY |
| | | &DUMMY_bootstrap, |
| | |
| | | return _this->displays[displayIndex].driverdata; |
| | | } |
| | | |
| | | SDL_bool |
| | | SDL_IsVideoContextExternal(void) |
| | | { |
| | | return SDL_GetHintBoolean(SDL_HINT_VIDEO_EXTERNAL_CONTEXT, SDL_FALSE); |
| | | } |
| | | |
| | | const char * |
| | | SDL_GetDisplayName(int displayIndex) |
| | | { |
| | |
| | | return 0; /* !!! FIXME: should this be an error if (rect==NULL) ? */ |
| | | } |
| | | |
| | | int SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect * rect) |
| | | static int |
| | | ParseDisplayUsableBoundsHint(SDL_Rect *rect) |
| | | { |
| | | const char *hint = SDL_GetHint(SDL_HINT_DISPLAY_USABLE_BOUNDS); |
| | | return hint && (SDL_sscanf(hint, "%d,%d,%d,%d", &rect->x, &rect->y, &rect->w, &rect->h) == 4); |
| | | } |
| | | |
| | | int |
| | | SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect * rect) |
| | | { |
| | | CHECK_DISPLAY_INDEX(displayIndex, -1); |
| | | |
| | | if (rect) { |
| | | SDL_VideoDisplay *display = &_this->displays[displayIndex]; |
| | | |
| | | if ((displayIndex == 0) && ParseDisplayUsableBoundsHint(rect)) { |
| | | return 0; |
| | | } |
| | | |
| | | if (_this->GetDisplayUsableBounds) { |
| | | if (_this->GetDisplayUsableBounds(_this, display, rect) == 0) { |
| | |
| | | |
| | | /* Some platforms have OpenGL enabled by default */ |
| | | #if (SDL_VIDEO_OPENGL && __MACOSX__) || __IPHONEOS__ || __ANDROID__ || __NACL__ |
| | | if (!_this->is_dummy && !(flags & SDL_WINDOW_VULKAN)) { |
| | | if (!_this->is_dummy && !(flags & SDL_WINDOW_VULKAN) && !SDL_IsVideoContextExternal()) { |
| | | flags |= SDL_WINDOW_OPENGL; |
| | | } |
| | | #endif |
| | |
| | | window->surface->flags &= ~SDL_DONTFREE; |
| | | SDL_FreeSurface(window->surface); |
| | | window->surface = NULL; |
| | | window->surface_valid = SDL_FALSE; |
| | | } |
| | | if (_this->DestroyWindowFramebuffer) { |
| | | _this->DestroyWindowFramebuffer(_this, window); |
| | |
| | | } else { |
| | | SDL_GL_UnloadLibrary(); |
| | | } |
| | | } else if (window->flags & SDL_WINDOW_OPENGL) { |
| | | SDL_GL_UnloadLibrary(); |
| | | if (SDL_GL_LoadLibrary(NULL) < 0) { |
| | | return -1; |
| | | } |
| | | loaded_opengl = SDL_TRUE; |
| | | } |
| | | |
| | | if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) { |
| | |
| | | if (_this->SetWindowPosition) { |
| | | _this->SetWindowPosition(_this, window); |
| | | } |
| | | SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | static SDL_bool |
| | | CanMinimizeWindow(SDL_Window * window) |
| | | { |
| | | if (!_this->MinimizeWindow) { |
| | | return SDL_FALSE; |
| | | } |
| | | return SDL_TRUE; |
| | | } |
| | | |
| | | void |
| | | SDL_MinimizeWindow(SDL_Window * window) |
| | | { |
| | | CHECK_WINDOW_MAGIC(window,); |
| | | |
| | | if (window->flags & SDL_WINDOW_MINIMIZED) { |
| | | return; |
| | | } |
| | | |
| | | if (!CanMinimizeWindow(window)) { |
| | | return; |
| | | } |
| | | |
| | |
| | | #ifdef __MACOSX__ |
| | | if (SDL_strcmp(_this->name, "cocoa") == 0) { /* don't do this for X11, etc */ |
| | | if (Cocoa_IsWindowInFullscreenSpace(window)) { |
| | | return SDL_FALSE; |
| | | } |
| | | } |
| | | #endif |
| | | |
| | | #ifdef __ANDROID__ |
| | | { |
| | | extern SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss(void); |
| | | if (! Android_JNI_ShouldMinimizeOnFocusLoss()) { |
| | | return SDL_FALSE; |
| | | } |
| | | } |
| | |
| | | #if SDL_VIDEO_DRIVER_X11 |
| | | #include "x11/SDL_x11messagebox.h" |
| | | #endif |
| | | #if SDL_VIDEO_DRIVER_HAIKU |
| | | #include "haiku/SDL_bmessagebox.h" |
| | | #endif |
| | | |
| | | |
| | | #if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT || SDL_VIDEO_DRIVER_COCOA || SDL_VIDEO_DRIVER_UIKIT || SDL_VIDEO_DRIVER_X11 |
| | | #if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT || SDL_VIDEO_DRIVER_COCOA || SDL_VIDEO_DRIVER_UIKIT || SDL_VIDEO_DRIVER_X11 || SDL_VIDEO_DRIVER_HAIKU |
| | | static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype) |
| | | { |
| | | SDL_SysWMinfo info; |
| | |
| | | if (retval == -1 && |
| | | SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_X11) && |
| | | X11_ShowMessageBox(messageboxdata, buttonid) == 0) { |
| | | retval = 0; |
| | | } |
| | | #endif |
| | | #if SDL_VIDEO_DRIVER_HAIKU |
| | | if (retval == -1 && |
| | | SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_HAIKU) && |
| | | HAIKU_ShowMessageBox(messageboxdata, buttonid) == 0) { |
| | | retval = 0; |
| | | } |
| | | #endif |
| | |
| | | } |
| | | } |
| | | |
| | | SDL_MetalView |
| | | SDL_Metal_CreateView(SDL_Window * window) |
| | | { |
| | | CHECK_WINDOW_MAGIC(window, NULL); |
| | | |
| | | if (_this->Metal_CreateView) { |
| | | return _this->Metal_CreateView(_this, window); |
| | | } else { |
| | | SDL_SetError("Metal is not supported."); |
| | | return NULL; |
| | | } |
| | | } |
| | | |
| | | void |
| | | SDL_Metal_DestroyView(SDL_MetalView view) |
| | | { |
| | | if (_this && view && _this->Metal_DestroyView) { |
| | | _this->Metal_DestroyView(_this, view); |
| | | } |
| | | } |
| | | |
| | | /* vi: set ts=4 sw=4 expandtab: */ |