Changeset 81537 in vbox for trunk/src/VBox/Frontends/VBoxSDL
- Timestamp:
- Oct 25, 2019 11:46:30 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 134270
- Location:
- trunk/src/VBox/Frontends/VBoxSDL
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.cpp
r77370 r81537 113 113 bool fUpdateImage) 114 114 { 115 int rc;116 115 LogFlow(("VBoxSDLFB::VBoxSDLFB\n")); 117 116 … … 119 118 mfUpdateImage = fUpdateImage; 120 119 mScreen = NULL; 121 #ifdef VBOX_WITH_SDL13 122 mWindow = 0; 123 mTexture = 0; 120 #ifdef VBOX_WITH_SDL2 121 mpWindow = NULL; 122 mpTexture = NULL; 123 mpRenderer = NULL; 124 124 #endif 125 125 mSurfVRAM = NULL; … … 150 150 mfUpdates = false; 151 151 152 rc = RTCritSectInit(&mUpdateLock);152 int rc = RTCritSectInit(&mUpdateLock); 153 153 AssertMsg(rc == VINF_SUCCESS, ("Error from RTCritSectInit!\n")); 154 154 … … 161 161 #endif 162 162 163 return 0; 163 #ifdef VBOX_WITH_SDL2 164 rc = SDL_GetRendererInfo(mpRenderer, &mRenderInfo); 165 if (RT_SUCCESS(rc)) 166 { 167 if (fShowSDLConfig) 168 RTPrintf("Render info:\n" 169 " Name: %s\n" 170 " Render flags: 0x%x\n" 171 " SDL video driver: %s\n", 172 mRenderInfo.name, 173 mRenderInfo.flags, 174 RTEnvGet("SDL_VIDEODRIVER")); 175 } 176 #endif 177 178 return rc; 164 179 } 165 180 … … 184 199 } 185 200 201 /* static */ 186 202 bool VBoxSDLFB::init(bool fShowSDLConfig) 187 203 { … … 195 211 if (!RTEnvExist("SDL_VIDEODRIVER")) 196 212 { 197 _putenv("SDL_VIDEODRIVER=directx"); 198 // _putenv("SDL_VIDEODRIVER=windib"); 213 # ifndef VBOX_WITH_SDL2 214 /* Always select the windib driver by default, as the directx one is known to be broken on newer Windows OSes. */ 215 RTEnvSet("SDL_VIDEODRIVER", "windib"); 216 # else 217 RTEnvSet("SDL_VIDEODRIVER", "directx"); 218 # endif 199 219 } 200 220 #endif … … 204 224 RTEnvSet("SDL_VIDEO_X11_DGAMOUSE", "0"); 205 225 #endif 226 206 227 int rc = SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE); 207 228 if (rc != 0) … … 212 233 gfSdlInitialized = true; 213 234 235 #ifdef VBOX_WITH_SDL2 236 RT_NOREF(fShowSDLConfig); 237 #else 214 238 const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo(); 215 Assert (videoInfo);239 AssertPtr(videoInfo); 216 240 if (videoInfo) 217 241 { … … 244 268 RTEnvGet("SDL_VIDEODRIVER")); 245 269 } 246 247 if (12320 == g_cbIco64x01) 248 { 249 250 251 252 253 254 255 256 } 270 #endif /* !VBOX_WITH_SDL2 */ 271 272 #ifndef VBOX_WITH_SDL2 273 gWMIcon = SDL_AllocSurface(SDL_SWSURFACE, 64, 64, 24, 0xff, 0xff00, 0xff0000, 0); 274 /** @todo make it as simple as possible. No PNM interpreter here... */ 275 if (gWMIcon) 276 { 277 memcpy(gWMIcon->pixels, g_abIco64x01+32, g_cbIco64x01-32); 278 SDL_WM_SetIcon(gWMIcon, NULL); 279 } 280 #endif 257 281 258 282 return true; … … 270 294 AssertMsg(gSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n")); 271 295 SDL_QuitSubSystem(SDL_INIT_VIDEO); 296 297 #ifndef VBOX_WITH_SDL2 272 298 if (gWMIcon) 273 299 { … … 275 301 gWMIcon = NULL; 276 302 } 303 #endif 277 304 } 278 305 } … … 581 608 /* nope, we don't want that (but still don't freak out if it is set) */ 582 609 #ifdef DEBUG 583 printf("VBoxSDL::VideoModeSupported: we refused mode %dx%dx%d\n", width, height, bpp);610 RTPrintf("VBoxSDL::VideoModeSupported: we refused mode %dx%dx%d\n", width, height, bpp); 584 611 #endif 585 612 *supported = false; … … 770 797 { 771 798 LogFlow(("VBoxSDL:resizeSDL\n")); 799 800 #ifdef VBOX_WITH_SDL2 801 const int cDisplays = SDL_GetNumVideoDisplays(); 802 if (cDisplays > 0) 803 { 804 for (int d = 0; d < cDisplays; d++) 805 { 806 const int cDisplayModes = SDL_GetNumDisplayModes(d); 807 for (int m = 0; m < cDisplayModes; m++) 808 { 809 SDL_DisplayMode mode = { SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0 }; 810 if (SDL_GetDisplayMode(d, m, &mode) != 0) 811 { 812 RTPrintf("Display #%d, mode %d:\t\t%i bpp\t%i x %i", 813 SDL_BITSPERPIXEL(mode.format), mode.w, mode.h); 814 } 815 816 if (m == 0) 817 { 818 /* 819 * according to the SDL documentation, the API guarantees that 820 * the modes are sorted from larger to smaller, so we just 821 * take the first entry as the maximum. 822 */ 823 mMaxScreenWidth = mode.w; 824 mMaxScreenHeight = mode.h; 825 } 826 827 /* Keep going. */ 828 } 829 } 830 } 831 else 832 AssertFailed(); /** @todo */ 833 #else 772 834 773 835 /* … … 814 876 mMaxScreenHeight = ~(uint32_t)0; 815 877 } 878 #endif /* VBOX_WITH_SDL2 */ 816 879 817 880 uint32_t newWidth; … … 841 904 mTopOffset = 0; 842 905 843 #if defined(VBOX_WITH_SDL13)906 #ifdef VBOX_WITH_SDL2 844 907 int sdlWindowFlags = SDL_WINDOW_SHOWN; 845 908 if (mfResizable) 846 909 sdlWindowFlags |= SDL_WINDOW_RESIZABLE; 847 if (!m Window)910 if (!mpWindow) 848 911 { 849 912 SDL_DisplayMode desktop_mode; … … 851 914 int y = 40 + mScreenId * 15; 852 915 853 SDL_GetDesktopDisplayMode( &desktop_mode);916 SDL_GetDesktopDisplayMode(mScreenId, &desktop_mode); 854 917 /* create new window */ 855 918 856 919 char szTitle[64]; 857 920 RTStrPrintf(szTitle, sizeof(szTitle), "SDL window %d", mScreenId); 858 m Window = SDL_CreateWindow(szTitle, x, y,921 mpWindow = SDL_CreateWindow(szTitle, x, y, 859 922 newWidth, newHeight, sdlWindowFlags); 860 if (SDL_CreateRenderer(mWindow, -1, 861 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD) < 0) 923 mpRenderer = SDL_CreateRenderer(mpWindow, -1, 0 /* SDL_RendererFlags */); 924 if (mpRenderer) 925 { 926 SDL_GetRendererInfo(mpRenderer, &mRenderInfo); 927 928 mpTexture = SDL_CreateTexture(mpRenderer, desktop_mode.format, 929 SDL_TEXTUREACCESS_STREAMING, newWidth, newHeight); 930 if (!mpTexture) 931 AssertReleaseFailed(); 932 } 933 else 862 934 AssertReleaseFailed(); 863 935 864 SDL_GetRendererInfo(&mRenderInfo); 865 866 mTexture = SDL_CreateTexture(desktop_mode.format, 867 SDL_TEXTUREACCESS_STREAMING, newWidth, newHeight); 868 if (!mTexture) 869 AssertReleaseFailed(); 936 if (12320 == g_cbIco64x01) 937 { 938 gWMIcon = SDL_CreateRGBSurface(0 /* Flags, must be 0 */, 64, 64, 24, 0xff, 0xff00, 0xff0000, 0); 939 /** @todo make it as simple as possible. No PNM interpreter here... */ 940 if (gWMIcon) 941 { 942 memcpy(gWMIcon->pixels, g_abIco64x01+32, g_cbIco64x01-32); 943 SDL_SetWindowIcon(mpWindow, gWMIcon); 944 } 945 } 870 946 } 871 947 else … … 876 952 877 953 /* resize current window */ 878 SDL_GetWindowSize(m Window, &w, &h);954 SDL_GetWindowSize(mpWindow, &w, &h); 879 955 880 956 if (w != (int)newWidth || h != (int)newHeight) 881 SDL_SetWindowSize(mWindow, newWidth, newHeight); 882 883 SDL_QueryTexture(mTexture, &format, &access, &w, &h); 884 SDL_SelectRenderer(mWindow); 885 SDL_DestroyTexture(mTexture); 886 mTexture = SDL_CreateTexture(format, access, newWidth, newHeight); 887 if (!mTexture) 957 SDL_SetWindowSize(mpWindow, newWidth, newHeight); 958 959 SDL_QueryTexture(mpTexture, &format, &access, &w, &h); 960 SDL_DestroyTexture(mpTexture); 961 mpTexture = SDL_CreateTexture(mpRenderer, format, access, newWidth, newHeight); 962 if (!mpTexture) 888 963 AssertReleaseFailed(); 889 964 } … … 895 970 uint32_t format; 896 971 897 if (SDL_QueryTexture(m Texture, &format, NULL, &w, &h) < 0)972 if (SDL_QueryTexture(mpTexture, &format, NULL, &w, &h) < 0) 898 973 AssertReleaseFailed(); 899 974 … … 901 976 AssertReleaseFailed(); 902 977 903 if (SDL_ QueryTexturePixels(mTexture, &pixels, &pitch) == 0)978 if (SDL_LockTexture(mpTexture, NULL /* SDL_Rect */, &pixels, &pitch) == 0) 904 979 { 905 980 mScreen = SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, 906 981 Rmask, Gmask, Bmask, Amask); 982 SDL_UnlockTexture(mpTexture); /** @BUGBUG See: https://bugzilla.libsdl.org/show_bug.cgi?id=1586 */ 907 983 } 908 984 else … … 933 1009 SDL_VERSION(&info.version); 934 1010 if (SDL_GetWMInfo(&info)) 935 mWinId = (LONG64) info.info.x11.wm window;1011 mWinId = (LONG64) info.info.x11.wmpWindow; 936 1012 # elif defined(RT_OS_DARWIN) 937 1013 mWinId = (intptr_t)VBoxSDLGetDarwinWindowId(); … … 939 1015 /* XXX ignore this for other architectures */ 940 1016 # endif 941 #endif 1017 #endif /* VBOX_WITH_SDL2 */ 942 1018 #ifdef VBOX_SECURELABEL 943 1019 /* … … 971 1047 mCenterYOffset = (mFixedSDLHeight - (mGuestYRes + mLabelHeight)) / 2; 972 1048 } 973 #endif 1049 #endif /* VBOX_SECURELABEL */ 1050 974 1051 AssertMsg(mScreen, ("Error: SDL_SetVideoMode failed!\n")); 975 1052 if (mScreen) … … 980 1057 #endif 981 1058 if (mfShowSDLConfig) 982 RTPrintf("Resized to %dx%d, screen surface type: %s\n", mScreen->w, mScreen->h, 983 ((mScreen->flags & SDL_HWSURFACE) == 0) ? "software" : "hardware"); 1059 RTPrintf("Resized to %dx%d\n", mScreen->w, mScreen->h); 984 1060 } 985 1061 } … … 1079 1155 SDL_BlitSurface(mSurfVRAM, &srcRect, mScreen, &dstRect); 1080 1156 /* hardware surfaces don't need update notifications */ 1081 #if defined(VBOX_WITH_SDL 13)1157 #if defined(VBOX_WITH_SDL2) 1082 1158 AssertRelease(mScreen->flags & SDL_PREALLOC); 1083 SDL_SelectRenderer(mWindow); 1084 SDL_DirtyTexture(mTexture, 1, &dstRect); 1085 AssertRelease(mRenderInfo.flags & SDL_RENDERER_PRESENTCOPY); 1086 SDL_RenderCopy(mTexture, &dstRect, &dstRect); 1087 SDL_RenderPresent(); 1159 /** @todo Do we need to update the dirty rect for the texture for SDL2 here as well? */ 1160 SDL_RenderClear(mpRenderer); 1161 SDL_RenderCopy(mpRenderer, mpTexture, &dstRect, &dstRect); 1162 SDL_RenderPresent(mpRenderer); 1088 1163 #else 1089 1164 if ((mScreen->flags & SDL_HWSURFACE) == 0) … … 1131 1206 void VBoxSDLFB::getFullscreenGeometry(uint32_t *width, uint32_t *height) 1132 1207 { 1208 #ifndef VBOX_WITH_SDL2 1133 1209 SDL_Rect **modes; 1134 1210 … … 1159 1235 } 1160 1236 } 1161 } 1237 #else 1238 SDL_DisplayMode dm; 1239 int rc = SDL_GetDesktopDisplayMode(0, &dm); /** @BUGBUG Handle multi monitor setups! */ 1240 if (rc == 0) 1241 { 1242 *width = dm.w; 1243 *height = dm.w; 1244 } 1245 #endif 1246 } 1247 1248 #ifdef VBOX_WITH_SDL2 1249 int VBoxSDLFB::setWindowTitle(const char *pcszTitle) 1250 { 1251 SDL_SetWindowTitle(mpWindow, pcszTitle); 1252 1253 return VINF_SUCCESS; 1254 } 1255 #endif 1162 1256 1163 1257 #ifdef VBOX_SECURELABEL … … 1302 1396 HRESULT VBoxSDLFBOverlay::init() 1303 1397 { 1304 mBlendedBits = SDL_CreateRGBSurface(SDL_ANYFORMAT, mOverlayWidth, mOverlayHeight, 32, 1398 #ifndef VBOX_WITH_SDL2 1399 Uint32 fFlags = SDL_ANYFORMAT; 1400 #else 1401 Uint32 fFlags = 0; 1402 #endif 1403 1404 mBlendedBits = SDL_CreateRGBSurface(fFlags, mOverlayWidth, mOverlayHeight, 32, 1305 1405 0x00ff0000, 0x0000ff00, 0x000000ff, 0); 1306 1406 AssertMsgReturn(mBlendedBits != NULL, ("Failed to create an SDL surface\n"), 1307 1407 E_OUTOFMEMORY); 1308 mOverlayBits = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, mOverlayWidth, 1408 1409 #ifndef VBOX_WITH_SDL2 1410 fFlags = SDL_SWSURFACE | SDL_SRCALPHA, mOverlayWidth; 1411 #else 1412 fFlags = 0; 1413 #endif 1414 1415 mOverlayBits = SDL_CreateRGBSurface(fFlags, 1309 1416 mOverlayHeight, 32, 0x00ff0000, 0x0000ff00, 1310 0x000000ff, 0xff000000 );1417 0x000000ff, 0xff000000, 0); 1311 1418 AssertMsgReturn(mOverlayBits != NULL, ("Failed to create an SDL surface\n"), 1312 1419 E_OUTOFMEMORY); … … 1617 1724 mOverlayHeight = h; 1618 1725 SDL_FreeSurface(mOverlayBits); 1619 mBlendedBits = SDL_CreateRGBSurface(SDL_ANYFORMAT, mOverlayWidth, mOverlayHeight, 32, 1726 1727 #ifndef VBOX_WITH_SDL2 1728 Uint32 fFlags = SDL_ANYFORMAT; 1729 #else 1730 Uint32 fFlags = 0; 1731 #endif 1732 1733 mBlendedBits = SDL_CreateRGBSurface(fFlags, mOverlayWidth, mOverlayHeight, 32, 1620 1734 0x00ff0000, 0x0000ff00, 0x000000ff, 0); 1621 1735 AssertMsgReturn(mBlendedBits != NULL, ("Failed to create an SDL surface\n"), 1622 1736 E_OUTOFMEMORY); 1623 mOverlayBits = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, mOverlayWidth, 1737 1738 #ifndef VBOX_WITH_SDL2 1739 fFlags = SDL_SWSURFACE | SDL_SRCALPHA; 1740 #else 1741 fFlags = 0; 1742 #endif 1743 1744 mOverlayBits = SDL_CreateRGBSurface(fFlags, mOverlayWidth, 1624 1745 mOverlayHeight, 32, 0x00ff0000, 0x0000ff00, 1625 1746 0x000000ff, 0xff000000); -
trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.h
r76582 r81537 42 42 extern DECLSPEC void (SDLCALL *pTTF_Quit)(void); 43 43 } 44 #endif /* VBOX_SECURELABEL && !VBOX_WITH_SDL 13*/44 #endif /* VBOX_SECURELABEL && !VBOX_WITH_SDL2 */ 45 45 46 46 class VBoxSDLFBOverlay; … … 118 118 int32_t getXOffset() { return mCenterXOffset; } 119 119 int32_t getYOffset() { return mCenterYOffset; } 120 #ifdef VBOX_WITH_SDL13 121 bool hasWindow(SDL_WindowID id) { return mScreen && mWindow == id; } 120 #ifdef VBOX_WITH_SDL2 121 SDL_Window *getWindow() { return mpWindow; } 122 bool hasWindow(uint32_t id) { return mScreen && SDL_GetWindowID(mpWindow) == id; } 123 int setWindowTitle(const char *pcszTitle); 122 124 #endif 123 125 #ifdef VBOX_SECURELABEL … … 134 136 /** current SDL framebuffer pointer (also includes screen width/height) */ 135 137 SDL_Surface *mScreen; 136 #ifdef VBOX_WITH_SDL 13138 #ifdef VBOX_WITH_SDL2 137 139 /** the SDL window */ 138 SDL_Window ID mWindow;140 SDL_Window *mpWindow; 139 141 /** the texture */ 140 SDL_TextureID mTexture; 142 SDL_Texture *mpTexture; 143 /** renderer */ 144 SDL_Renderer *mpRenderer; 141 145 /** render info */ 142 146 SDL_RendererInfo mRenderInfo; -
trunk/src/VBox/Frontends/VBoxSDL/Makefile.kmk
r80569 r81537 50 50 VBoxSDL_SOURCES.darwin = \ 51 51 VBoxSDLMain-darwin.m \ 52 52 Framebuffer-darwin.m 53 53 54 54 VBoxSDL_DEFS = 55 ifdef VBOX_WITH_SDL13 56 VBoxSDL_DEFS += VBOX_WITH_SDL13 57 else 55 ifdef VBOX_WITH_SDL2 56 VBoxSDL_DEFS += VBOX_WITH_SDL2 57 endif 58 if !defined(VBOX_WITH_SDL2) 58 59 ifdef VBOX_WITH_SECURELABEL 59 60 VBoxSDL_DEFS += VBOX_SECURELABEL … … 161 162 endif # !VBOX_WITH_HARDENING || "$(KBUILD_TARGET)" != "darwin" 162 163 include $(FILE_KBUILD_SUB_FOOTER) 163 -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r80824 r81537 46 46 #endif 47 47 48 #include "VBoxSDL.h" 49 48 50 #ifdef _MSC_VER 49 51 # pragma warning(push) … … 57 59 #endif 58 60 59 #include "VBoxSDL.h"60 61 #include "Framebuffer.h" 61 62 #include "Helper.h" … … 173 174 static void SetFullscreen(bool enable); 174 175 175 #ifdef VBOX_WITH_SDL 13176 static VBoxSDLFB * getFbFromWinId(SDL_WindowIDid);176 #ifdef VBOX_WITH_SDL2 177 static VBoxSDLFB *getFbFromWinId(Uint32 id); 177 178 #endif 178 179 … … 226 227 #endif 227 228 static SDL_Cursor *gpCustomCursor = NULL; 228 #ifndef VBOX_WITH_SDL 13229 #ifndef VBOX_WITH_SDL2 229 230 static WMcursor *gpCustomOrigWMcursor = NULL; 230 231 #endif … … 233 234 static SDL_TimerID gSdlQuitTimer = NULL; 234 235 235 #if defined(VBOXSDL_WITH_X11) && !defined(VBOX_WITH_SDL 13)236 #if defined(VBOXSDL_WITH_X11) && !defined(VBOX_WITH_SDL2) 236 237 static SDL_SysWMinfo gSdlInfo; 237 238 #endif … … 537 538 /* SDL feature not available on Quartz */ 538 539 #else 540 bool fCanShow = false; 541 542 # ifdef VBOX_WITH_SDL2 543 Uint32 winId = 0; 544 545 VBoxSDLFB *fb = getFbFromWinId(winId); 546 547 SDL_SysWMinfo info; 548 SDL_VERSION(&info.version); 549 if (SDL_GetWindowWMInfo(fb->getWindow(), &info)) 550 fCanShow = true; 551 # else 539 552 SDL_SysWMinfo info; 540 553 SDL_VERSION(&info.version); 541 554 if (!SDL_GetWMInfo(&info)) 555 fCanShow = false; 556 else 557 fCanShow = true; 558 # endif /* VBOX_WITH_SDL2 */ 559 560 if (fCanShow) 561 pCSWEv->AddApproval(NULL); 562 else 542 563 pCSWEv->AddVeto(NULL); 543 else544 pCSWEv->AddApproval(NULL);545 564 #endif 546 565 break; … … 558 577 SDL_SysWMinfo info; 559 578 SDL_VERSION(&info.version); 579 # ifdef VBOX_WITH_SDL2 580 VBoxSDLFB *fb = getFbFromWinId(winId); 581 if (SDL_GetWindowWMInfo(fb->getWindow(), &info)) 582 # else 560 583 if (SDL_GetWMInfo(&info)) 584 # endif /* VBOX_WITH_SDL2 */ 561 585 { 562 586 # if defined(VBOXSDL_WITH_X11) 563 587 pSWEv->COMSETTER(WinId)((LONG64)info.info.x11.wmwindow); 564 588 # elif defined(RT_OS_WINDOWS) 589 # ifdef VBOX_WITH_SDL2 590 pSWEv->COMSETTER(WinId)((intptr_t)info.info.win.window); 591 # else 565 592 pSWEv->COMSETTER(WinId)((intptr_t)info.window); 566 # else 593 # endif /* VBOX_WITH_SDL2 */ 594 # else /* !RT_OS_WINDOWS */ 567 595 AssertFailed(); 568 596 # endif … … 793 821 || !strcmp(argv[1], "--detecthostkey"))) 794 822 { 795 int rc = SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE); 823 Uint32 fInitSubSystem = SDL_INIT_VIDEO | SDL_INIT_TIMER; 824 #ifndef VBOX_WITH_SDL2 825 fInitSubSystem |= SDL_INIT_NOPARACHUTE; 826 #endif 827 int rc = SDL_InitSubSystem(fInitSubSystem); 796 828 if (rc != 0) 797 829 { … … 800 832 } 801 833 /* we need a video window for the keyboard stuff to work */ 834 #ifndef VBOX_WITH_SDL2 /** @todo Is this correct? */ 802 835 if (!SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE)) 803 836 { … … 805 838 return 1; 806 839 } 807 840 #endif 808 841 RTPrintf("Please hit one or two function key(s) to get the --hostkey value...\n"); 809 842 … … 2174 2207 gpDefaultCursor = SDL_GetCursor(); 2175 2208 2176 #if !defined(VBOX_WITH_SDL 13)2209 #if !defined(VBOX_WITH_SDL2) 2177 2210 # if defined(VBOXSDL_WITH_X11) 2178 2211 /* Get Window Manager info. We only need the X11 display. */ … … 2204 2237 gpCustomCursor->wm_cursor = NULL; 2205 2238 } 2206 #endif /* !VBOX_WITH_SDL 13*/2239 #endif /* !VBOX_WITH_SDL2 */ 2207 2240 2208 2241 /* … … 2446 2479 UpdateTitlebar(TITLEBAR_NORMAL); 2447 2480 2481 #ifdef VBOX_WITH_SDL2 2482 /* Key repeats are enabled by default on SDL2. */ 2483 #else 2448 2484 /* 2449 2485 * Enable keyboard repeats 2450 2486 */ 2451 2487 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 2488 #endif 2452 2489 2453 2490 /* … … 2483 2520 * The screen needs to be repainted. 2484 2521 */ 2485 #ifdef VBOX_WITH_SDL 132522 #ifdef VBOX_WITH_SDL2 2486 2523 case SDL_WINDOWEVENT: 2487 2524 { … … 2499 2536 break; 2500 2537 } 2538 case SDL_WINDOWEVENT_FOCUS_LOST: 2539 { 2540 break; 2541 } 2542 case SDL_WINDOWEVENT_RESIZED: 2543 { 2544 if (gpDisplay) 2545 { 2546 if (gfIgnoreNextResize) 2547 { 2548 gfIgnoreNextResize = FALSE; 2549 break; 2550 } 2551 uResizeWidth = event.window.data1; 2552 #ifdef VBOX_SECURELABEL 2553 if (fSecureLabel) 2554 uResizeHeight = RT_MAX(0, event.window.data2 - SECURE_LABEL_HEIGHT); 2555 else 2556 #endif 2557 uResizeHeight = event.window.data2; 2558 if (gSdlResizeTimer) 2559 SDL_RemoveTimer(gSdlResizeTimer); 2560 gSdlResizeTimer = SDL_AddTimer(300, ResizeTimer, NULL); 2561 } 2562 break; 2563 } 2501 2564 default: 2502 2565 break; … … 2517 2580 case SDL_KEYUP: 2518 2581 { 2582 #ifdef VBOX_WITH_SDL2 2583 SDL_Keycode ksym = event.key.keysym.sym; 2584 #else 2519 2585 SDLKey ksym = event.key.keysym.sym; 2520 2586 #endif 2521 2587 switch (enmHKeyState) 2522 2588 { … … 2660 2726 { 2661 2727 VBoxSDLFB *fb; 2662 #ifdef VBOX_WITH_SDL 132728 #ifdef VBOX_WITH_SDL2 2663 2729 fb = getFbFromWinId(event.motion.windowID); 2664 2730 #else 2665 2731 fb = gpFramebuffer[0]; 2666 2732 #endif 2733 AssertPtrBreak(fb); 2667 2734 SendMouseEvent(fb, 0, 0, 0); 2668 2735 } … … 2688 2755 else if (gfGrabbed || UseAbsoluteMouse()) 2689 2756 { 2757 #ifdef VBOX_WITH_SDL2 2758 int dz = 0; /** @todo Implement mouse wheel support with SDL2 (event SDL_MOUSEWHEEL). */ 2759 #else 2690 2760 int dz = bev->button == SDL_BUTTON_WHEELUP 2691 2761 ? -1 … … 2693 2763 ? +1 2694 2764 : 0; 2695 2765 #endif 2696 2766 /* end host key combination (CTRL+MouseButton) */ 2697 2767 switch (enmHKeyState) … … 2719 2789 2720 2790 VBoxSDLFB *fb; 2721 #ifdef VBOX_WITH_SDL 132791 #ifdef VBOX_WITH_SDL2 2722 2792 fb = getFbFromWinId(event.button.windowID); 2723 2793 #else 2724 2794 fb = gpFramebuffer[0]; 2725 2795 #endif 2796 AssertPtrBreak(fb); 2726 2797 SendMouseEvent(fb, dz, event.type == SDL_MOUSEBUTTONDOWN, bev->button); 2727 2798 } … … 2729 2800 } 2730 2801 2802 #ifndef VBOX_WITH_SDL2 2731 2803 /* 2732 2804 * The window has gained or lost focus. 2733 2805 */ 2734 case SDL_ACTIVEEVENT: 2806 case SDL_ACTIVEEVENT: /** @todo Needs to be also fixed with SDL2? Check! */ 2735 2807 { 2736 2808 /* … … 2751 2823 2752 2824 /* 2753 * The SDL window was resized 2825 * The SDL window was resized. 2826 * For SDL2 this is done in SDL_WINDOWEVENT. 2754 2827 */ 2755 2828 case SDL_VIDEORESIZE: … … 2775 2848 break; 2776 2849 } 2850 #endif 2777 2851 2778 2852 /* … … 3010 3084 } 3011 3085 3012 #ifndef VBOX_WITH_SDL 133086 #ifndef VBOX_WITH_SDL2 3013 3087 /* restore the default cursor and free the custom one if any */ 3014 3088 if (gpDefaultCursor) … … 3328 3402 3329 3403 #ifdef VBOXSDL_WITH_X11 3330 # ifdef VBOX_WITH_SDL 133404 # ifdef VBOX_WITH_SDL2 3331 3405 3332 3406 switch (ev->keysym.sym) … … 3662 3736 static void ProcessKey(SDL_KeyboardEvent *ev) 3663 3737 { 3664 #if (defined(DEBUG) || defined(VBOX_WITH_STATISTICS)) && !defined(VBOX_WITH_SDL 13)3738 #if (defined(DEBUG) || defined(VBOX_WITH_STATISTICS)) && !defined(VBOX_WITH_SDL2) 3665 3739 if (gpMachineDebugger && ev->type == SDL_KEYDOWN) 3666 3740 { … … 3926 4000 if (!gfGuestNeedsHostCursor && gfRelativeMouseGuest) 3927 4001 SDL_ShowCursor(SDL_DISABLE); 4002 #ifdef VBOX_WITH_SDL2 4003 SDL_SetRelativeMouseMode(SDL_TRUE); 4004 #else 3928 4005 SDL_WM_GrabInput(SDL_GRAB_ON); 3929 4006 // dummy read to avoid moving the mouse 3930 SDL_GetRelativeMouseState( 3931 #ifdef VBOX_WITH_SDL13 3932 0, 3933 #endif 3934 NULL, NULL); 4007 SDL_GetRelativeMouseState(NULL, NULL); 4008 #endif 3935 4009 gfGrabbed = TRUE; 3936 4010 UpdateTitlebar(TITLEBAR_NORMAL); … … 3942 4016 static void InputGrabEnd(void) 3943 4017 { 4018 #ifdef VBOX_WITH_SDL2 4019 SDL_SetRelativeMouseMode(SDL_FALSE); 4020 #else 3944 4021 SDL_WM_GrabInput(SDL_GRAB_OFF); 4022 #endif 3945 4023 if (!gfGuestNeedsHostCursor && gfRelativeMouseGuest) 3946 4024 SDL_ShowCursor(SDL_ENABLE); … … 3962 4040 bool abs; 3963 4041 3964 #ifdef VBOX_WITH_SDL 134042 #ifdef VBOX_WITH_SDL2 3965 4043 if (!fb) 3966 4044 { 3967 SDL_GetMouseState( 0,&x, &y);4045 SDL_GetMouseState(&x, &y); 3968 4046 RTPrintf("MouseEvent: Cannot find fb mouse = %d,%d\n", x, y); 3969 4047 return; … … 3997 4075 int yMax = yMin + (int)fb->getGuestYRes(); 3998 4076 3999 state = abs ? SDL_GetMouseState( 4000 #ifdef VBOX_WITH_SDL13 4001 0, 4002 #endif 4003 &x, &y) 4004 : SDL_GetRelativeMouseState( 4005 #ifdef VBOX_WITH_SDL13 4006 0, 4007 #endif 4008 &x, &y); 4077 state = abs ? SDL_GetMouseState(&x, &y) 4078 : SDL_GetRelativeMouseState(&x, &y); 4009 4079 4010 4080 /* … … 4420 4490 setUITitle(szTitle); 4421 4491 #else 4492 # ifdef VBOX_WITH_SDL2 4493 for (unsigned i = 0; i < gcMonitors; i++) 4494 gpFramebuffer[i]->setWindowTitle(szTitle); 4495 # else 4422 4496 SDL_WM_SetCaption(szTitle, VBOX_PRODUCT); 4497 # endif 4423 4498 #endif 4424 4499 } … … 4509 4584 HBITMAP hBitmap; 4510 4585 void *lpBits; 4511 HCURSOR hAlphaCursor = NULL;4512 4586 4513 4587 ::ZeroMemory(&bi, sizeof(BITMAPV5HEADER)); … … 4609 4683 } 4610 4684 4685 #ifndef VBOX_WITH_SDL2 /** @BUGBUG Implement alpha cursor support handling. */ 4611 4686 ICONINFO ii; 4612 4687 ii.fIcon = FALSE; … … 4616 4691 ii.hbmColor = hBitmap; 4617 4692 4618 hAlphaCursor = ::CreateIconIndirect(&ii);4693 HCURSOR hAlphaCursor = ::CreateIconIndirect(&ii); 4619 4694 Assert(hAlphaCursor); 4620 4695 if (hAlphaCursor) … … 4624 4699 4625 4700 WMcursor *pCustomTempWMCursor = gpCustomCursor->wm_cursor; 4626 4627 4701 // see SDL12/src/video/wincommon/SDL_sysmouse.c 4628 4702 void *wm_cursor = malloc(sizeof(HCURSOR) + sizeof(uint8_t *) * 2); … … 4641 4715 ok = true; 4642 4716 } 4717 #endif 4643 4718 } 4644 4719 … … 4696 4771 } 4697 4772 4698 #ifndef VBOX_WITH_SDL 134773 #ifndef VBOX_WITH_SDL2 4699 4774 Cursor cur = XcursorImageLoadCursor(gSdlInfo.info.x11.display, img); 4700 4775 Assert(cur); … … 5074 5149 int rc = SDL_PushEvent(event); 5075 5150 RTSemEventSignal(g_EventSemSDLEvents); 5076 #ifdef VBOX_WITH_SDL 135151 #ifdef VBOX_WITH_SDL2 5077 5152 if (rc == 1) 5078 5153 #else … … 5096 5171 { 5097 5172 int rc = SDL_PushEvent(event); 5098 #ifdef VBOX_WITH_SDL 135173 #ifdef VBOX_WITH_SDL2 5099 5174 bool fSuccess = (rc == 1); 5100 5175 #else … … 5167 5242 } 5168 5243 5169 #ifdef VBOX_WITH_SDL 135170 static VBoxSDLFB * getFbFromWinId(SDL_WindowIDid)5244 #ifdef VBOX_WITH_SDL2 5245 static VBoxSDLFB *getFbFromWinId(Uint32 id) 5171 5246 { 5172 5247 for (unsigned i = 0; i < gcMonitors; i++) -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.h
r76582 r81537 34 34 # pragma warning(push) 35 35 # pragma warning(disable: 4121) /* warning C4121: 'SDL_SysWMmsg' : alignment of a member was sensitive to packing*/ 36 # pragma warning(disable: 4668) /* warning C4668: '__GNUC__' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' */ 36 37 #endif 37 38 #include <SDL.h>
Note:
See TracChangeset
for help on using the changeset viewer.