- Timestamp:
- Jan 25, 2023 4:48:39 PM (2 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxSDL
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.cpp
r98304 r98305 114 114 mScreenId = uScreenId; 115 115 mfUpdateImage = fUpdateImage; 116 #ifdef VBOX_WITH_SDL2117 116 mpWindow = NULL; 118 117 mpTexture = NULL; 119 118 mpRenderer = NULL; 120 #endif121 119 mSurfVRAM = NULL; 122 120 mfInitialized = false; … … 150 148 #endif 151 149 152 #ifdef VBOX_WITH_SDL2153 150 rc = SDL_GetRendererInfo(mpRenderer, &mRenderInfo); 154 151 if (RT_SUCCESS(rc)) … … 163 160 RTEnvGet("SDL_VIDEODRIVER")); 164 161 } 165 #endif166 162 167 163 return rc; … … 208 204 gfSdlInitialized = true; 209 205 210 #ifdef VBOX_WITH_SDL2211 206 RT_NOREF(fShowSDLConfig); 212 #endif /* !VBOX_WITH_SDL2 */213 214 207 return true; 215 208 } … … 718 711 LogFlow(("VBoxSDL:resizeSDL\n")); 719 712 720 #ifdef VBOX_WITH_SDL2721 713 const int cDisplays = SDL_GetNumVideoDisplays(); 722 714 if (cDisplays > 0) … … 751 743 else 752 744 AssertFailed(); /** @todo */ 753 #endif /* VBOX_WITH_SDL2 */754 745 755 746 uint32_t newWidth; … … 775 766 mTopOffset = 0; 776 767 777 #ifdef VBOX_WITH_SDL2778 768 int sdlWindowFlags = SDL_WINDOW_SHOWN; 779 769 if (mfResizable) … … 834 824 AssertReleaseFailed(); 835 825 } 836 #endif /* VBOX_WITH_SDL2 */837 826 } 838 827 … … 906 895 dstRect.h = RT_MAX(0, h - yCutoffGuest); 907 896 908 909 /* hardware surfaces don't need update notifications */910 #if defined(VBOX_WITH_SDL2)911 897 SDL_Texture *pNewTexture = SDL_CreateTextureFromSurface(mpRenderer, mSurfVRAM); 912 898 /** @todo Do we need to update the dirty rect for the texture for SDL2 here as well? */ … … 917 903 SDL_RenderPresent(mpRenderer); 918 904 SDL_DestroyTexture(pNewTexture); 919 #endif920 905 RTCritSectLeave(&mUpdateLock); 921 906 } … … 958 943 void VBoxSDLFB::getFullscreenGeometry(uint32_t *width, uint32_t *height) 959 944 { 960 #ifdef VBOX_WITH_SDL2961 945 SDL_DisplayMode dm; 962 946 int rc = SDL_GetDesktopDisplayMode(0, &dm); /** @BUGBUG Handle multi monitor setups! */ … … 966 950 *height = dm.w; 967 951 } 968 #endif 969 } 970 971 #ifdef VBOX_WITH_SDL2 952 } 953 972 954 int VBoxSDLFB::setWindowTitle(const char *pcszTitle) 973 955 { … … 976 958 return VINF_SUCCESS; 977 959 } 978 #endif -
trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.h
r98302 r98305 113 113 int32_t getXOffset() { return mCenterXOffset; } 114 114 int32_t getYOffset() { return mCenterYOffset; } 115 #ifdef VBOX_WITH_SDL2116 115 SDL_Window *getWindow() { return mpWindow; } 117 116 bool hasWindow(uint32_t id) { return SDL_GetWindowID(mpWindow) == id; } 118 117 int setWindowTitle(const char *pcszTitle); 119 #endif120 118 void setWinId(int64_t winId) { mWinId = winId; } 121 119 void setOrigin(int32_t axOrigin, int32_t ayOrigin) { mOriginX = axOrigin; mOriginY = ayOrigin; } … … 124 122 private: 125 123 126 #ifdef VBOX_WITH_SDL2127 124 /** the SDL window */ 128 125 SDL_Window *mpWindow; … … 133 130 /** render info */ 134 131 SDL_RendererInfo mRenderInfo; 135 #endif136 132 /** false if constructor failed */ 137 133 bool mfInitialized; -
trunk/src/VBox/Frontends/VBoxSDL/Makefile.kmk
r98302 r98305 63 63 64 64 VBoxSDL_DEFS = 65 ifdef VBOX_WITH_SDL266 VBoxSDL_DEFS += VBOX_WITH_SDL267 endif68 65 VBoxSDL_DEFS.freebsd = VBOXSDL_WITH_X11 69 66 VBoxSDL_DEFS.linux = _GNU_SOURCE VBOXSDL_WITH_X11 … … 122 119 # tstSDL 123 120 # 124 if ndef VBOX_WITH_SDL2121 if 0 125 122 PROGRAMS += tstSDL 126 123 tstSDL_TEMPLATE = VBoxR3TstExe -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r98304 r98305 176 176 static int WaitSDLEvent(SDL_Event *event); 177 177 static void SetFullscreen(bool enable); 178 179 #ifdef VBOX_WITH_SDL2180 178 static VBoxSDLFB *getFbFromWinId(Uint32 id); 181 #endif182 183 179 184 180 /********************************************************************************************************************************* … … 226 222 static Bstr gaFramebufferId[64]; 227 223 static SDL_Cursor *gpDefaultCursor = NULL; 228 #ifdef VBOXSDL_WITH_X11229 static Cursor gpDefaultOrigX11Cursor;230 #endif231 static SDL_Cursor *gpCustomCursor = 0;232 224 static SDL_Cursor *gpOffCursor = NULL; 233 225 static SDL_TimerID gSdlResizeTimer = 0; 234 226 static SDL_TimerID gSdlQuitTimer = 0; 235 236 #if defined(VBOXSDL_WITH_X11) && !defined(VBOX_WITH_SDL2)237 static SDL_SysWMinfo gSdlInfo;238 #endif239 227 240 228 static RTSEMEVENT g_EventSemSDLEvents; … … 499 487 #else 500 488 bool fCanShow = false; 501 502 # ifdef VBOX_WITH_SDL2503 489 Uint32 winId = 0; 504 505 490 VBoxSDLFB *fb = getFbFromWinId(winId); 506 507 491 SDL_SysWMinfo info; 508 492 SDL_VERSION(&info.version); 509 493 if (SDL_GetWindowWMInfo(fb->getWindow(), &info)) 510 494 fCanShow = true; 511 # else512 SDL_SysWMinfo info;513 SDL_VERSION(&info.version);514 if (!SDL_GetWMInfo(&info))515 fCanShow = false;516 else517 fCanShow = true;518 # endif /* VBOX_WITH_SDL2 */519 520 495 if (fCanShow) 521 496 pCSWEv->AddApproval(NULL); … … 537 512 SDL_SysWMinfo info; 538 513 SDL_VERSION(&info.version); 539 # ifdef VBOX_WITH_SDL2540 514 VBoxSDLFB *fb = getFbFromWinId(winId); 541 515 if (SDL_GetWindowWMInfo(fb->getWindow(), &info)) 542 # else543 if (SDL_GetWMInfo(&info))544 # endif /* VBOX_WITH_SDL2 */545 516 { 546 517 # if defined(VBOXSDL_WITH_X11) 547 # ifdef VBOX_WITH_SDL2548 518 pSWEv->COMSETTER(WinId)((LONG64)info.info.x11.window); 549 # else550 pSWEv->COMSETTER(WinId)((LONG64)info.info.x11.wmwindow);551 # endif552 519 # elif defined(RT_OS_WINDOWS) 553 # ifdef VBOX_WITH_SDL2554 520 pSWEv->COMSETTER(WinId)((intptr_t)info.info.win.window); 555 # else556 pSWEv->COMSETTER(WinId)((intptr_t)info.window);557 # endif /* VBOX_WITH_SDL2 */558 521 # else /* !RT_OS_WINDOWS */ 559 522 AssertFailed(); … … 1965 1928 /* memorize the default cursor */ 1966 1929 gpDefaultCursor = SDL_GetCursor(); 1967 1968 #if !defined(VBOX_WITH_SDL2)1969 # if defined(VBOXSDL_WITH_X11)1970 /* Get Window Manager info. We only need the X11 display. */1971 SDL_VERSION(&gSdlInfo.version);1972 if (!SDL_GetWMInfo(&gSdlInfo))1973 RTPrintf("Error: could not get SDL Window Manager info -- no Xcursor support!\n");1974 else1975 gfXCursorEnabled = TRUE;1976 1977 # if !defined(VBOX_WITHOUT_XCURSOR)1978 /* SDL uses its own (plain) default cursor. Use the left arrow cursor instead which might look1979 * much better if a mouse cursor theme is installed. */1980 if (gfXCursorEnabled)1981 {1982 gpDefaultOrigX11Cursor = *(Cursor*)gpDefaultCursor->wm_cursor;1983 *(Cursor*)gpDefaultCursor->wm_cursor = XCreateFontCursor(gSdlInfo.info.x11.display, XC_left_ptr);1984 SDL_SetCursor(gpDefaultCursor);1985 }1986 # endif1987 /* Initialise the keyboard */1988 X11DRV_InitKeyboard(gSdlInfo.info.x11.display, NULL, NULL, NULL, NULL);1989 # endif /* VBOXSDL_WITH_X11 */1990 1991 /* create a fake empty cursor */1992 {1993 uint8_t cursorData[1] = {0};1994 gpCustomCursor = SDL_CreateCursor(cursorData, cursorData, 8, 1, 0, 0);1995 gpCustomOrigWMcursor = gpCustomCursor->wm_cursor;1996 gpCustomCursor->wm_cursor = NULL;1997 }1998 #endif /* !VBOX_WITH_SDL2 */1999 2000 1930 /* 2001 1931 * Register our user signal handler. … … 2238 2168 UpdateTitlebar(TITLEBAR_NORMAL); 2239 2169 2240 #ifdef VBOX_WITH_SDL22241 /* Key repeats are enabled by default on SDL2. */2242 #else2243 /*2244 * Enable keyboard repeats2245 */2246 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);2247 #endif2248 2249 2170 /* 2250 2171 * Create PID file. … … 2279 2200 * The screen needs to be repainted. 2280 2201 */ 2281 #ifdef VBOX_WITH_SDL22282 2202 case SDL_WINDOWEVENT: 2283 2203 { … … 2319 2239 break; 2320 2240 } 2321 }2322 #else2323 case SDL_VIDEOEXPOSE:2324 {2325 gpFramebuffer[0]->repaint();2326 2241 break; 2327 2242 } 2328 #endif2329 2243 2330 2244 /* … … 2334 2248 case SDL_KEYUP: 2335 2249 { 2336 #ifdef VBOX_WITH_SDL22337 2250 SDL_Keycode ksym = event.key.keysym.sym; 2338 #else2339 SDLKey ksym = event.key.keysym.sym;2340 #endif2341 2251 switch (enmHKeyState) 2342 2252 { … … 2480 2390 { 2481 2391 VBoxSDLFB *fb; 2482 #ifdef VBOX_WITH_SDL22483 2392 fb = getFbFromWinId(event.motion.windowID); 2484 #else2485 fb = gpFramebuffer[0];2486 #endif2487 2393 AssertPtrBreak(fb); 2488 2394 SendMouseEvent(fb, 0, 0, 0); … … 2509 2415 else if (gfGrabbed || UseAbsoluteMouse()) 2510 2416 { 2511 #ifdef VBOX_WITH_SDL22512 2417 int dz = 0; /** @todo Implement mouse wheel support with SDL2 (event SDL_MOUSEWHEEL). */ 2513 #else2514 int dz = bev->button == SDL_BUTTON_WHEELUP2515 ? -12516 : bev->button == SDL_BUTTON_WHEELDOWN2517 ? +12518 : 0;2519 #endif2520 2418 /* end host key combination (CTRL+MouseButton) */ 2521 2419 switch (enmHKeyState) … … 2543 2441 2544 2442 VBoxSDLFB *fb; 2545 #ifdef VBOX_WITH_SDL22546 2443 fb = getFbFromWinId(event.button.windowID); 2547 #else2548 fb = gpFramebuffer[0];2549 #endif2550 2444 AssertPtrBreak(fb); 2551 2445 SendMouseEvent(fb, dz, event.type == SDL_MOUSEBUTTONDOWN, bev->button); … … 2554 2448 } 2555 2449 2556 #if ndef02450 #if 0 2557 2451 /* 2558 2452 * The window has gained or lost focus. … … 3087 2981 3088 2982 #ifdef VBOXSDL_WITH_X11 3089 # ifdef VBOX_WITH_SDL23090 3091 2983 switch (ev->keysym.sym) 3092 2984 { … … 3210 3102 return 0; 3211 3103 } 3212 # else3213 keycode = X11DRV_KeyEvent(gSdlInfo.info.x11.display, keycode);3214 # endif3215 3104 #elif defined(RT_OS_DARWIN) 3216 3105 /* This is derived partially from SDL_QuartzKeys.h and partially from testing. */ … … 3421 3310 static void ProcessKey(SDL_KeyboardEvent *ev) 3422 3311 { 3423 #if (defined(DEBUG) || defined(VBOX_WITH_STATISTICS)) && !defined(VBOX_WITH_SDL2)3312 #if 0 //(defined(DEBUG) || defined(VBOX_WITH_STATISTICS)) && !defined(VBOX_WITH_SDL2) 3424 3313 if (gpMachineDebugger && ev->type == SDL_KEYDOWN) 3425 3314 { … … 3653 3542 if (!gfGuestNeedsHostCursor && gfRelativeMouseGuest) 3654 3543 SDL_ShowCursor(SDL_DISABLE); 3655 #ifdef VBOX_WITH_SDL23656 3544 SDL_SetRelativeMouseMode(SDL_TRUE); 3657 #else3658 SDL_WM_GrabInput(SDL_GRAB_ON);3659 // dummy read to avoid moving the mouse3660 SDL_GetRelativeMouseState(NULL, NULL);3661 #endif3662 3545 gfGrabbed = TRUE; 3663 3546 UpdateTitlebar(TITLEBAR_NORMAL); … … 3669 3552 static void InputGrabEnd(void) 3670 3553 { 3671 #ifdef VBOX_WITH_SDL23672 3554 SDL_SetRelativeMouseMode(SDL_FALSE); 3673 #else3674 SDL_WM_GrabInput(SDL_GRAB_OFF);3675 #endif3676 3555 if (!gfGuestNeedsHostCursor && gfRelativeMouseGuest) 3677 3556 SDL_ShowCursor(SDL_ENABLE); … … 3693 3572 bool abs; 3694 3573 3695 #ifdef VBOX_WITH_SDL23696 3574 if (!fb) 3697 3575 { … … 3700 3578 return; 3701 3579 } 3702 #else3703 AssertRelease(fb != NULL);3704 #endif3705 3580 3706 3581 /* … … 4137 4012 setUITitle(szTitle); 4138 4013 #else 4139 # ifdef VBOX_WITH_SDL24140 4014 for (unsigned i = 0; i < gcMonitors; i++) 4141 4015 gpFramebuffer[i]->setWindowTitle(szTitle); 4142 # else4143 SDL_WM_SetCaption(szTitle, VBOX_PRODUCT);4144 # endif4145 4016 #endif 4146 4017 } … … 4734 4605 int rc = SDL_PushEvent(event); 4735 4606 RTSemEventSignal(g_EventSemSDLEvents); 4736 #ifdef VBOX_WITH_SDL24737 4607 if (rc == 1) 4738 #else4739 if (rc == 0)4740 #endif4741 4608 return 0; 4742 4609 Log(("PushSDLEventForSure: waiting for 2ms (rc = %d)\n", rc)); … … 4756 4623 { 4757 4624 int rc = SDL_PushEvent(event); 4758 #ifdef VBOX_WITH_SDL24759 4625 bool fSuccess = (rc == 1); 4760 #else4761 bool fSuccess = (rc == 0);4762 #endif4763 4626 4764 4627 RTSemEventSignal(g_EventSemSDLEvents); … … 4827 4690 } 4828 4691 4829 #ifdef VBOX_WITH_SDL24830 4692 static VBoxSDLFB *getFbFromWinId(Uint32 id) 4831 4693 { … … 4836 4698 return NULL; 4837 4699 } 4838 #endif
Note:
See TracChangeset
for help on using the changeset viewer.