- Timestamp:
- Jun 9, 2009 12:40:36 PM (16 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxSDL
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.cpp
r19844 r20433 66 66 } 67 67 #endif /* VBOX_SECURELABEL */ 68 69 static SDL_Surface *gWMIcon; /**< the application icon */ 70 static RTNATIVETHREAD gSdlNativeThread; /**< the SDL thread */ 68 71 69 72 // … … 83 86 * @param iFixedHeight fixed SDL height (-1 means not set) 84 87 */ 85 VBoxSDLFB::VBoxSDLFB(bool fFullscreen, bool fResizable, bool fShowSDLConfig, 88 VBoxSDLFB::VBoxSDLFB(uint32_t uScreenId, 89 bool fFullscreen, bool fResizable, bool fShowSDLConfig, 86 90 bool fKeepHostRes, uint32_t u32FixedWidth, 87 91 uint32_t u32FixedHeight, uint32_t u32FixedBPP) … … 94 98 #endif 95 99 100 mScreenId = uScreenId; 96 101 mScreen = NULL; 102 #ifdef VBOX_WITH_SDL13 103 mWindow = 0; 104 mTexture = 0; 105 #endif 97 106 mSurfVRAM = NULL; 98 107 mfInitialized = false; … … 105 114 mFixedSDLHeight = u32FixedHeight; 106 115 mFixedSDLBPP = u32FixedBPP; 107 mDefaultSDLBPP = 32;108 116 mCenterXOffset = 0; 109 117 mCenterYOffset = 0; … … 122 130 mLabelOffs = 0; 123 131 #endif 124 mWMIcon = NULL;125 126 /* memorize the thread that inited us, that's the SDL thread */127 mSdlNativeThread = RTThreadNativeSelf();128 132 129 133 rc = RTCritSectInit(&mUpdateLock); 130 134 AssertMsg(rc == VINF_SUCCESS, ("Error from RTCritSectInit!\n")); 135 136 resizeGuest(); 137 Assert(mScreen); 138 mfInitialized = true; 139 } 140 141 VBoxSDLFB::~VBoxSDLFB() 142 { 143 LogFlow(("VBoxSDLFB::~VBoxSDLFB\n")); 144 if (mSurfVRAM) 145 { 146 SDL_FreeSurface(mSurfVRAM); 147 mSurfVRAM = NULL; 148 } 149 mScreen = NULL; 150 151 #ifdef VBOX_SECURELABEL 152 if (mLabelFont) 153 pTTF_CloseFont(mLabelFont); 154 if (pTTF_Quit) 155 pTTF_Quit(); 156 #endif 157 158 RTCritSectDelete(&mUpdateLock); 159 } 160 161 void VBoxSDLFB::init(bool fShowSDLConfig) 162 { 163 LogFlow(("VBoxSDLFB::init\n")); 164 165 /* memorize the thread that inited us, that's the SDL thread */ 166 gSdlNativeThread = RTThreadNativeSelf(); 131 167 132 168 #ifdef RT_OS_WINDOWS … … 143 179 RTEnvSet("SDL_VIDEO_X11_DGAMOUSE", "0"); 144 180 #endif 145 rc = SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE);181 int rc = SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE); 146 182 if (rc != 0) 147 183 { … … 154 190 if (videoInfo) 155 191 { 156 switch (videoInfo->vfmt->BitsPerPixel)157 {158 case 16: mDefaultSDLBPP = 16; break;159 case 24: mDefaultSDLBPP = 24; break;160 default:161 case 32: mDefaultSDLBPP = 32; break;162 }163 164 192 /* output what SDL is capable of */ 165 if ( mfShowSDLConfig)193 if (fShowSDLConfig) 166 194 RTPrintf("SDL capabilities:\n" 167 195 " Hardware surface support: %s\n" … … 193 221 if (12320 == g_cbIco64x01) 194 222 { 195 mWMIcon = SDL_AllocSurface(SDL_SWSURFACE, 64, 64, 24, 0xff, 0xff00, 0xff0000, 0);223 gWMIcon = SDL_AllocSurface(SDL_SWSURFACE, 64, 64, 24, 0xff, 0xff00, 0xff0000, 0); 196 224 /** @todo make it as simple as possible. No PNM interpreter here... */ 197 if ( mWMIcon)225 if (gWMIcon) 198 226 { 199 memcpy( mWMIcon->pixels, g_abIco64x01+32, g_cbIco64x01-32);200 SDL_WM_SetIcon( mWMIcon, NULL);227 memcpy(gWMIcon->pixels, g_abIco64x01+32, g_cbIco64x01-32); 228 SDL_WM_SetIcon(gWMIcon, NULL); 201 229 } 202 230 } 203 204 resizeGuest(); 205 Assert(mScreen); 206 mfInitialized = true; 207 } 208 209 VBoxSDLFB::~VBoxSDLFB() 210 { 211 LogFlow(("VBoxSDLFB::~VBoxSDLFB\n")); 212 RTCritSectDelete(&mUpdateLock); 213 } 214 231 } 232 233 /** 234 * Terminate SDL 235 * 236 * @remarks must be called from the SDL thread! 237 */ 238 void VBoxSDLFB::uninit() 239 { 240 AssertMsg(gSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n")); 241 SDL_QuitSubSystem(SDL_INIT_VIDEO); 242 if (gWMIcon) 243 { 244 SDL_FreeSurface(gWMIcon); 245 gWMIcon = NULL; 246 } 247 } 215 248 216 249 /** … … 280 313 return E_INVALIDARG; 281 314 282 if (mSurfVRAM) 283 { 284 *address = (BYTE *) mSurfVRAM->pixels; 285 } 286 else 315 if (!mSurfVRAM) 287 316 { 288 317 /* That's actually rather bad. */ … … 290 319 return E_FAIL; 291 320 } 321 322 *address = (BYTE *) mSurfVRAM->pixels; 292 323 LogFlow(("VBoxSDL::GetAddress returning %p\n", *address)); 293 324 return S_OK; … … 425 456 SDL_Event event; 426 457 event.type = SDL_USEREVENT; 458 event.user.code = mScreenId; 427 459 event.user.type = SDL_USER_EVENT_UPDATERECT; 428 460 // 16 bit is enough for coordinates … … 502 534 event.type = SDL_USEREVENT; 503 535 event.user.type = SDL_USER_EVENT_RESIZE; 536 event.user.code = mScreenId; 504 537 505 538 /* Try multiple times if necessary */ … … 593 626 { 594 627 LogFlowFunc (("mGuestXRes: %d, mGuestYRes: %d\n", mGuestXRes, mGuestYRes)); 595 AssertMsg( mSdlNativeThread == RTThreadNativeSelf(),628 AssertMsg(gSdlNativeThread == RTThreadNativeSelf(), 596 629 ("Wrong thread! SDL is not threadsafe!\n")); 597 630 … … 643 676 if (mUsesGuestVRAM) 644 677 { 645 646 678 /* Create a source surface from guest VRAM. */ 647 679 mSurfVRAM = SDL_CreateRGBSurfaceFrom(mPtrVRAM, mGuestXRes, mGuestYRes, mBitsPerPixel, 648 680 mBytesPerLine, Rmask, Gmask, Bmask, Amask); 681 LogRel(("mSurfVRAM from guest %d x %d\n", mGuestXRes, mGuestYRes)); 649 682 } 650 683 else … … 653 686 mSurfVRAM = SDL_CreateRGBSurface(SDL_SWSURFACE, mGuestXRes, mGuestYRes, mBitsPerPixel, 654 687 Rmask, Gmask, Bmask, Amask); 688 LogRel(("mSurfVRAM from SDL %d x %d\n", mGuestXRes, mGuestYRes)); 655 689 } 656 690 LogFlow(("VBoxSDL:: created VRAM surface %p\n", mSurfVRAM)); … … 751 785 mTopOffset = 0; 752 786 787 #if defined(VBOX_WITH_SDL13) 788 int sdlWindowFlags = SDL_WINDOW_SHOWN; 789 if (mfResizable) 790 sdlWindowFlags |= SDL_WINDOW_RESIZABLE; 791 if (!mWindow) 792 { 793 SDL_DisplayMode desktop_mode; 794 int x = 40 + mScreenId * 20; 795 int y = 40 + mScreenId * 15; 796 797 SDL_GetDesktopDisplayMode(&desktop_mode); 798 /* create new window */ 799 800 char szTitle[64]; 801 RTStrPrintf(szTitle, sizeof(szTitle), "SDL window %d", mScreenId); 802 mWindow = SDL_CreateWindow(szTitle, x, y, 803 newWidth, newHeight, sdlWindowFlags); 804 if (SDL_CreateRenderer(mWindow, -1, 805 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD) < 0) 806 AssertReleaseFailed(); 807 808 SDL_GetRendererInfo(&mRenderInfo); 809 810 mTexture = SDL_CreateTexture(desktop_mode.format, 811 SDL_TEXTUREACCESS_STREAMING, newWidth, newHeight); 812 if (!mTexture) 813 AssertReleaseFailed(); 814 } 815 else 816 { 817 int w, h; 818 uint32_t format; 819 int access; 820 821 /* resize current window */ 822 SDL_GetWindowSize(mWindow, &w, &h); 823 824 if (w != (int)newWidth || h != (int)newHeight) 825 SDL_SetWindowSize(mWindow, newWidth, newHeight); 826 827 SDL_QueryTexture(mTexture, &format, &access, &w, &h); 828 SDL_SelectRenderer(mWindow); 829 SDL_DestroyTexture(mTexture); 830 mTexture = SDL_CreateTexture(format, access, newWidth, newHeight); 831 if (!mTexture) 832 AssertReleaseFailed(); 833 } 834 835 void *pixels; 836 int pitch; 837 int w, h, bpp; 838 uint32_t Rmask, Gmask, Bmask, Amask; 839 uint32_t format; 840 841 if (SDL_QueryTexture(mTexture, &format, NULL, &w, &h) < 0) 842 AssertReleaseFailed(); 843 844 if (!SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) 845 AssertReleaseFailed(); 846 847 if (SDL_QueryTexturePixels(mTexture, &pixels, &pitch) == 0) 848 { 849 mScreen = SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, 850 Rmask, Gmask, Bmask, Amask); 851 } 852 else 853 { 854 mScreen = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask); 855 AssertReleaseFailed(); 856 } 857 858 SDL_SetClipRect(mScreen, NULL); 859 860 #else 753 861 /* 754 862 * Now set the screen resolution and get the surface pointer … … 756 864 */ 757 865 mScreen = SDL_SetVideoMode(newWidth, newHeight, 0, sdlFlags); 866 #endif 758 867 #ifdef VBOX_SECURELABEL 759 868 /* … … 816 925 { 817 926 #ifdef VBOXSDL_WITH_X11 818 AssertMsg( mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));927 AssertMsg(gSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n")); 819 928 #endif 820 929 Assert(mScreen); … … 822 931 if (!mScreen || !mSurfVRAM) 823 932 return; 824 933 825 934 /* the source and destination rectangles */ 826 935 SDL_Rect srcRect; … … 880 989 dstRect.h = RT_MAX(0, h - yCutoffGuest); 881 990 882 //RTPrintf("y = %d h = %d mapped to srcY %d srcH %d mapped to dstY = %d dstH %d (guestrel: %d, mLabelHeight: %d, mTopOffset: %d)\n",883 // y, h, srcRect.y, srcRect.h, dstRect.y, dstRect.h, fGuestRelative, mLabelHeight, mTopOffset);884 885 991 /* 886 992 * Now we just blit … … 888 994 SDL_BlitSurface(mSurfVRAM, &srcRect, mScreen, &dstRect); 889 995 /* hardware surfaces don't need update notifications */ 996 #if defined(VBOX_WITH_SDL13) 997 AssertRelease(mScreen->flags & SDL_PREALLOC); 998 SDL_SelectRenderer(mWindow); 999 SDL_DirtyTexture(mTexture, 1, &dstRect); 1000 AssertRelease(mRenderInfo.flags & SDL_RENDERER_PRESENTCOPY); 1001 SDL_RenderCopy(mTexture, &dstRect, &dstRect); 1002 SDL_RenderPresent(); 1003 #else 890 1004 if ((mScreen->flags & SDL_HWSURFACE) == 0) 891 1005 SDL_UpdateRect(mScreen, dstRect.x, dstRect.y, dstRect.w, dstRect.h); 1006 #endif 892 1007 893 1008 #ifdef VBOX_SECURELABEL … … 904 1019 void VBoxSDLFB::repaint() 905 1020 { 906 AssertMsg( mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));1021 AssertMsg(gSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n")); 907 1022 LogFlow(("VBoxSDLFB::repaint\n")); 908 1023 update(0, 0, mScreen->w, mScreen->h, false /* fGuestRelative */); 909 1024 } 910 1025 911 bool VBoxSDLFB::getFullscreen()912 {913 LogFlow(("VBoxSDLFB::getFullscreen\n"));914 return mfFullscreen;915 }916 917 1026 /** 918 1027 * Toggle fullscreen mode … … 922 1031 void VBoxSDLFB::setFullscreen(bool fFullscreen) 923 1032 { 924 AssertMsg( mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));1033 AssertMsg(gSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n")); 925 1034 LogFlow(("VBoxSDLFB::SetFullscreen: fullscreen: %d\n", fFullscreen)); 926 1035 mfFullscreen = fFullscreen; … … 965 1074 } 966 1075 967 /**968 * Returns the current x offset of the start of the guest screen969 *970 * @returns current x offset in pixels971 */972 int VBoxSDLFB::getXOffset()973 {974 /* there can only be an offset for centering */975 return mCenterXOffset;976 }977 978 /**979 * Returns the current y offset of the start of the guest screen980 *981 * @returns current y offset in pixels982 */983 int VBoxSDLFB::getYOffset()984 {985 /* we might have a top offset and a center offset */986 return mTopOffset + mCenterYOffset;987 }988 989 1076 #ifdef VBOX_SECURELABEL 990 1077 /** … … 1051 1138 { 1052 1139 #ifdef VBOXSDL_WITH_X11 1053 AssertMsg( mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));1140 AssertMsg(gSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n")); 1054 1141 #endif 1055 1142 /* only when the function is present */ … … 1086 1173 } 1087 1174 #endif /* VBOX_SECURELABEL */ 1088 1089 /**1090 * Terminate SDL1091 *1092 * @remarks must be called from the SDL thread!1093 */1094 void VBoxSDLFB::uninit()1095 {1096 AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));1097 if (mSurfVRAM)1098 {1099 SDL_FreeSurface(mSurfVRAM);1100 mSurfVRAM = NULL;1101 }1102 SDL_QuitSubSystem(SDL_INIT_VIDEO);1103 #ifdef VBOX_SECURELABEL1104 if (mLabelFont)1105 pTTF_CloseFont(mLabelFont);1106 if (pTTF_Quit)1107 pTTF_Quit();1108 #endif1109 mScreen = NULL;1110 if (mWMIcon)1111 {1112 SDL_FreeSurface(mWMIcon);1113 mWMIcon = NULL;1114 }1115 }1116 1175 1117 1176 // IFramebufferOverlay -
trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.h
r19844 r20433 42 42 extern DECLSPEC void (SDLCALL *pTTF_Quit)(void); 43 43 } 44 #endif /* VBOX_SECURELABEL */44 #endif /* VBOX_SECURELABEL && !VBOX_WITH_SDL13 */ 45 45 46 46 class VBoxSDLFBOverlay; … … 50 50 { 51 51 public: 52 VBoxSDLFB(bool fFullscreen = false, bool fResizable = true, bool fShowSDLConfig = false, 52 VBoxSDLFB(uint32_t uScreenId, 53 bool fFullscreen = false, bool fResizable = true, bool fShowSDLConfig = false, 53 54 bool fKeepHostRes = false, uint32_t u32FixedWidth = ~(uint32_t)0, 54 55 uint32_t u32FixedHeight = ~(uint32_t)0, uint32_t u32FixedBPP = ~(uint32_t)0); 55 56 virtual ~VBoxSDLFB(); 57 58 static void init(bool fShowSDLConfig); 59 static void uninit(); 56 60 57 61 #ifdef RT_OS_WINDOWS … … 118 122 void update(int x, int y, int w, int h, bool fGuestRelative); 119 123 void repaint(); 120 bool getFullscreen();121 124 void setFullscreen(bool fFullscreen); 122 int getXOffset();123 int getYOffset();124 125 void getFullscreenGeometry(uint32_t *width, uint32_t *height); 126 uint32_t getScreenId() { return mScreenId; } 125 127 uint32_t getGuestXRes() { return mGuestXRes; } 126 128 uint32_t getGuestYRes() { return mGuestYRes; } 129 int32_t getOriginX() { return mOriginX; } 130 int32_t getOriginY() { return mOriginY; } 131 int32_t getXOffset() { return mCenterXOffset; } 132 int32_t getYOffset() { return mCenterYOffset; } 133 #ifdef VBOX_WITH_SDL13 134 bool hasWindow(SDL_WindowID id) { return mScreen && mWindow == id; } 135 #endif 127 136 #ifdef VBOX_SECURELABEL 128 137 int initSecureLabel(uint32_t height, char *font, uint32_t pointsize, uint32_t labeloffs); … … 131 140 void paintSecureLabel(int x, int y, int w, int h, bool fForce); 132 141 #endif 133 void uninit();134 142 void setWinId(uint64_t winId) { mWinId = winId; } 143 void setOrigin(int32_t axOrigin, int32_t ayOrigin) { mOriginX = axOrigin; mOriginY = ayOrigin; } 144 bool getFullscreen() { return mfFullscreen; } 135 145 136 146 private: 137 /** the sdl thread */138 RTNATIVETHREAD mSdlNativeThread;139 147 /** current SDL framebuffer pointer (also includes screen width/height) */ 140 148 SDL_Surface *mScreen; 149 #ifdef VBOX_WITH_SDL13 150 /** the SDL window */ 151 SDL_WindowID mWindow; 152 /** the texture */ 153 SDL_TextureID mTexture; 154 /** render info */ 155 SDL_RendererInfo mRenderInfo; 156 #endif 141 157 /** false if constructor failed */ 142 158 bool mfInitialized; 159 /** the screen number of this framebuffer */ 160 uint32_t mScreenId; 143 161 /** maximum possible screen width in pixels (~0 = no restriction) */ 144 162 uint32_t mMaxScreenWidth; … … 149 167 /** current guest screen height in pixels */ 150 168 ULONG mGuestYRes; 169 int32_t mOriginX; 170 int32_t mOriginY; 151 171 /** fixed SDL screen width (~0 = not set) */ 152 172 uint32_t mFixedSDLWidth; … … 155 175 /** fixed SDL bits per pixel (~0 = not set) */ 156 176 uint32_t mFixedSDLBPP; 157 /** default BPP */158 uint32_t mDefaultSDLBPP;159 177 /** Y offset in pixels, i.e. guest-nondrawable area at the top */ 160 178 uint32_t mTopOffset; … … 189 207 /** secure label offset from the top of the secure label */ 190 208 uint32_t mLabelOffs; 209 191 210 #endif 192 211 #ifdef RT_OS_WINDOWS … … 201 220 BOOL mUsesGuestVRAM; 202 221 BOOL mfSameSizeRequested; 203 204 /** the application Icon */205 SDL_Surface *mWMIcon;206 222 }; 207 223 -
trunk/src/VBox/Frontends/VBoxSDL/Makefile.kmk
r18422 r20433 66 66 67 67 VBoxSDL_DEFS = 68 ifdef VBOX_WITH_SECURELABEL 69 VBoxSDL_DEFS += VBOX_SECURELABEL 68 ifdef VBOX_WITH_SDL13 69 VBoxSDL_DEFS += VBOX_WITH_SDL13 70 else 71 ifdef VBOX_WITH_SECURELABEL 72 VBoxSDL_DEFS += VBOX_SECURELABEL 73 endif 70 74 endif 71 75 ifdef VBOX_WITH_VRDP -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r20374 r20433 148 148 static void InputGrabStart(void); 149 149 static void InputGrabEnd(void); 150 static void SendMouseEvent( int dz, int button, int down);150 static void SendMouseEvent(VBoxSDLFB *fb, int dz, int button, int down); 151 151 static void UpdateTitlebar(TitlebarMode mode, uint32_t u32User = 0); 152 152 static void SetPointerShape(const PointerShapeChangeData *data); … … 158 158 static int WaitSDLEvent(SDL_Event *event); 159 159 static void SetFullscreen(bool enable); 160 #ifdef VBOX_WITH_SDL13 161 static VBoxSDLFB * getFbFromWinId(SDL_WindowID id); 162 #endif 160 163 161 164 … … 188 191 static BOOL gfGuestScrollLockPressed = FALSE; 189 192 static BOOL gfACPITerm = FALSE; 190 static BOOL gfXCursorEnabled = TRUE;193 static BOOL gfXCursorEnabled = FALSE; 191 194 static int gcGuestNumLockAdaptions = 2; 192 195 static int gcGuestCapsLockAdaptions = 2; … … 206 209 static ComPtr<IProgress> gProgress; 207 210 208 static VBoxSDLFB *gpFrameBuffer = NULL; 211 static unsigned gcMonitors = 1; 212 static VBoxSDLFB *gpFramebuffer[64]; 213 //static VBoxSDLFB *gpFramebufferCurrent = NULL; 209 214 static SDL_Cursor *gpDefaultCursor = NULL; 210 215 #ifdef VBOXSDL_WITH_X11 … … 215 220 #endif 216 221 static SDL_Cursor *gpCustomCursor = NULL; 222 #ifndef VBOX_WITH_SDL13 217 223 static WMcursor *gpCustomOrigWMcursor = NULL; 224 #endif 218 225 static SDL_Cursor *gpOffCursor = NULL; 219 226 static SDL_TimerID gSdlResizeTimer = NULL; 220 227 static SDL_TimerID gSdlQuitTimer = NULL; 221 228 222 #if def VBOXSDL_WITH_X11229 #if defined(VBOXSDL_WITH_X11) && !defined(VBOX_WITH_SDL13) 223 230 static SDL_SysWMinfo gSdlInfo; 224 231 #endif … … 1961 1968 #endif 1962 1969 1963 // create our SDL framebuffer instance 1964 gpFrameBuffer = new VBoxSDLFB(fFullscreen, fResizable, fShowSDLConfig, false, 1965 fixedWidth, fixedHeight, fixedBPP); 1966 1967 if (!gpFrameBuffer) 1968 { 1969 RTPrintf("Error: could not create framebuffer object!\n"); 1970 goto leave; 1970 /* static initialization of the SDL stuff */ 1971 VBoxSDLFB::init(fShowSDLConfig); 1972 1973 gMachine->COMGETTER(MonitorCount)(&gcMonitors); 1974 if (gcMonitors > 64) 1975 gcMonitors = 64; 1976 1977 for (unsigned i = 0; i < gcMonitors; i++) 1978 { 1979 // create our SDL framebuffer instance 1980 gpFramebuffer[i] = new VBoxSDLFB(i, fFullscreen, fResizable, fShowSDLConfig, false, 1981 fixedWidth, fixedHeight, fixedBPP); 1982 1983 if (!gpFramebuffer[i]) 1984 { 1985 RTPrintf("Error: could not create framebuffer object!\n"); 1986 goto leave; 1987 } 1971 1988 } 1972 1989 1973 1990 #ifdef VBOX_WIN32_UI 1974 gpFrameBuffer->setWinId(winId); 1975 #endif 1976 1977 if (!gpFrameBuffer->initialized()) 1978 goto leave; 1979 gpFrameBuffer->AddRef(); 1980 if (fFullscreen) 1981 SetFullscreen(true); 1991 gpFramebuffer[0]->setWinId(winId); 1992 #endif 1993 1994 for (unsigned i = 0; i < gcMonitors; i++) 1995 { 1996 if (!gpFramebuffer[i]->initialized()) 1997 goto leave; 1998 gpFramebuffer[i]->AddRef(); 1999 if (fFullscreen) 2000 SetFullscreen(true); 2001 } 1982 2002 1983 2003 #ifdef VBOX_SECURELABEL … … 2011 2031 rcVBox = RTLdrGetSymbol(gLibrarySDL_ttf, "TTF_Quit", (void**)&pTTF_Quit); 2012 2032 if (RT_SUCCESS(rcVBox)) 2013 rcVBox = gpFrame Buffer->initSecureLabel(SECURE_LABEL_HEIGHT, secureLabelFontFile, secureLabelPointSize, secureLabelFontOffs);2033 rcVBox = gpFramebuffer[0]->initSecureLabel(SECURE_LABEL_HEIGHT, secureLabelFontFile, secureLabelPointSize, secureLabelFontOffs); 2014 2034 if (RT_FAILURE(rcVBox)) 2015 2035 { … … 2024 2044 * Now update the label 2025 2045 */ 2026 gpFrame Buffer->setSecureLabelColor(secureLabelColorFG, secureLabelColorBG);2027 gpFrame Buffer->setSecureLabelText(labelUtf8.raw());2046 gpFramebuffer[0]->setSecureLabelColor(secureLabelColorFG, secureLabelColorBG); 2047 gpFramebuffer[0]->setSecureLabelText(labelUtf8.raw()); 2028 2048 } 2029 2049 #endif … … 2037 2057 #endif 2038 2058 2039 // register our framebuffer 2040 rc = gDisplay->SetFramebuffer(VBOX_VIDEO_PRIMARY_SCREEN, gpFrameBuffer); 2041 if (rc != S_OK) 2042 { 2043 RTPrintf("Error: could not register framebuffer object!\n"); 2044 goto leave; 2045 } 2059 for (unsigned i = 0; i < gcMonitors; i++) 2060 { 2061 // register our framebuffer 2062 rc = gDisplay->SetFramebuffer(i, gpFramebuffer[i]); 2063 if (rc != S_OK) 2064 { 2065 RTPrintf("Error: could not register framebuffer object!\n"); 2066 goto leave; 2067 } 2068 IFramebuffer *dummyFb; 2069 int xOrigin, yOrigin; 2070 rc = gDisplay->GetFramebuffer(i, &dummyFb, &xOrigin, &yOrigin); 2071 gpFramebuffer[i]->setOrigin(xOrigin, yOrigin); 2072 } 2073 // gpFramebufferCurrent = gpFramebuffer[0]; 2046 2074 2047 2075 // register a callback for global events … … 2144 2172 gpDefaultCursor = SDL_GetCursor(); 2145 2173 2146 #ifdef VBOXSDL_WITH_X11 2174 #if !defined(VBOX_WITH_SDL13) 2175 # if defined(VBOXSDL_WITH_X11) 2147 2176 /* Get Window Manager info. We only need the X11 display. */ 2148 2177 SDL_VERSION(&gSdlInfo.version); 2149 2178 if (!SDL_GetWMInfo(&gSdlInfo)) 2150 {2151 2179 RTPrintf("Error: could not get SDL Window Manager info -- no Xcursor support!\n"); 2152 gfXCursorEnabled = FALSE;2153 }2154 2155 # if !defined(VBOX_WITHOUT_XCURSOR)2180 else 2181 gfXCursorEnabled = TRUE; 2182 2183 # if !defined(VBOX_WITHOUT_XCURSOR) 2156 2184 /* SDL uses its own (plain) default cursor. Use the left arrow cursor instead which might look 2157 2185 * much better if a mouse cursor theme is installed. */ … … 2162 2190 SDL_SetCursor(gpDefaultCursor); 2163 2191 } 2164 # endif2165 # endif /* VBOXSDL_WITH_X11 */2192 # endif 2193 # endif /* VBOXSDL_WITH_X11 */ 2166 2194 2167 2195 /* create a fake empty cursor */ … … 2172 2200 gpCustomCursor->wm_cursor = NULL; 2173 2201 } 2202 #endif /* !VBOX_WITH_SDL13 */ 2174 2203 2175 2204 /* … … 2276 2305 { 2277 2306 LogFlow(("SDL_USER_EVENT_RESIZE\n")); 2278 gpFrameBuffer->resizeGuest(); 2307 IFramebuffer *dummyFb; 2308 int xOrigin, yOrigin; 2309 gpFramebuffer[event.user.code]->resizeGuest(); 2310 /* update xOrigin, yOrigin -> mouse */ 2311 rc = gDisplay->GetFramebuffer(event.user.code, &dummyFb, &xOrigin, &yOrigin); 2312 gpFramebuffer[event.user.code]->setOrigin(xOrigin, yOrigin); 2279 2313 /* notify the display that the resize has been completed */ 2280 gDisplay->ResizeCompleted( 0);2314 gDisplay->ResizeCompleted(event.user.code); 2281 2315 break; 2282 2316 } … … 2400 2434 * The screen needs to be repainted. 2401 2435 */ 2436 #ifdef VBOX_WITH_SDL13 2437 case SDL_WINDOWEVENT: 2438 { 2439 switch (event.window.event) 2440 { 2441 case SDL_WINDOWEVENT_EXPOSED: 2442 { 2443 VBoxSDLFB *fb = getFbFromWinId(event.window.windowID); 2444 if (fb) 2445 fb->repaint(); 2446 break; 2447 } 2448 case SDL_WINDOWEVENT_FOCUS_GAINED: 2449 { 2450 /* XXX hack */ 2451 // gpFramebufferCurrent = getFbFromWinId(event.window.windowID); 2452 break; 2453 } 2454 default: 2455 break; 2456 } 2457 } 2458 #else 2402 2459 case SDL_VIDEOEXPOSE: 2403 2460 { 2404 /// @todo that somehow doesn't seem to work! 2405 gpFrameBuffer->repaint(); 2461 gpFramebuffer[0]->repaint(); 2406 2462 break; 2407 2463 } 2464 #endif 2408 2465 2409 2466 /* … … 2543 2600 if (gfGrabbed || UseAbsoluteMouse()) 2544 2601 { 2545 SendMouseEvent(0, 0, 0); 2602 VBoxSDLFB *fb; 2603 #ifdef VBOX_WITH_SDL13 2604 fb = getFbFromWinId(event.motion.windowID); 2605 #else 2606 fb = NULL; 2607 #endif 2608 SendMouseEvent(fb, 0, 0, 0); 2546 2609 } 2547 2610 break; … … 2596 2659 } 2597 2660 2598 SendMouseEvent(dz, event.type == SDL_MOUSEBUTTONDOWN, bev->button); 2661 VBoxSDLFB *fb; 2662 #ifdef VBOX_WITH_SDL13 2663 fb = getFbFromWinId(event.button.windowID); 2664 #else 2665 fb = NULL; 2666 #endif 2667 SendMouseEvent(fb, dz, event.type == SDL_MOUSEBUTTONDOWN, bev->button); 2599 2668 } 2600 2669 break; … … 2671 2740 x, y, w, h)); 2672 2741 2673 Assert(gpFrame Buffer);2674 gpFrame Buffer->update(x, y, w, h, true /* fGuestRelative */);2742 Assert(gpFramebuffer[event.user.code]); 2743 gpFramebuffer[event.user.code]->update(x, y, w, h, true /* fGuestRelative */); 2675 2744 2676 2745 #undef DECODEX … … 2705 2774 { 2706 2775 LogFlow(("SDL_USER_EVENT_RESIZE\n")); 2707 gpFrameBuffer->resizeGuest(); 2776 IFramebuffer *dummyFb; 2777 int xOrigin, yOrigin; 2778 gpFramebuffer[event.user.code]->resizeGuest(); 2779 /* update xOrigin, yOrigin -> mouse */ 2780 rc = gDisplay->GetFramebuffer(event.user.code, &dummyFb, &xOrigin, &yOrigin); 2781 gpFramebuffer[event.user.code]->setOrigin(xOrigin, yOrigin); 2708 2782 /* notify the display that the resize has been completed */ 2709 gDisplay->ResizeCompleted( 0);2783 gDisplay->ResizeCompleted(event.user.code); 2710 2784 break; 2711 2785 } … … 2759 2833 * Now update the label 2760 2834 */ 2761 gpFrame Buffer->setSecureLabelText(labelUtf8.raw());2835 gpFramebuffer[0]->setSecureLabelText(labelUtf8.raw()); 2762 2836 break; 2763 2837 } … … 2853 2927 } 2854 2928 2929 #ifndef VBOX_WITH_SDL13 2855 2930 /* restore the default cursor and free the custom one if any */ 2856 2931 if (gpDefaultCursor) 2857 2932 { 2858 # ifdef VBOXSDL_WITH_X112933 # ifdef VBOXSDL_WITH_X11 2859 2934 Cursor pDefaultTempX11Cursor = *(Cursor*)gpDefaultCursor->wm_cursor; 2860 2935 *(Cursor*)gpDefaultCursor->wm_cursor = gpDefaultOrigX11Cursor; 2861 # endif /* VBOXSDL_WITH_X11 */2936 # endif /* VBOXSDL_WITH_X11 */ 2862 2937 SDL_SetCursor(gpDefaultCursor); 2863 # if defined(VBOXSDL_WITH_X11) && !defined(VBOX_WITHOUT_XCURSOR)2938 # if defined(VBOXSDL_WITH_X11) && !defined(VBOX_WITHOUT_XCURSOR) 2864 2939 if (gfXCursorEnabled) 2865 2940 XFreeCursor(gSdlInfo.info.x11.display, pDefaultTempX11Cursor); 2866 # endif /* VBOXSDL_WITH_X11 && !VBOX_WITHOUT_XCURSOR */2941 # endif /* VBOXSDL_WITH_X11 && !VBOX_WITHOUT_XCURSOR */ 2867 2942 } 2868 2943 … … 2874 2949 if (pCustomTempWMCursor) 2875 2950 { 2876 # if defined (RT_OS_WINDOWS)2951 # if defined (RT_OS_WINDOWS) 2877 2952 ::DestroyCursor(*(HCURSOR *) pCustomTempWMCursor); 2878 # elif defined (VBOXSDL_WITH_X11) && !defined (VBOX_WITHOUT_XCURSOR)2953 # elif defined (VBOXSDL_WITH_X11) && !defined (VBOX_WITHOUT_XCURSOR) 2879 2954 if (gfXCursorEnabled) 2880 2955 XFreeCursor(gSdlInfo.info.x11.display, *(Cursor *) pCustomTempWMCursor); 2881 # endif /* VBOXSDL_WITH_X11 && !VBOX_WITHOUT_XCURSOR */2956 # endif /* VBOXSDL_WITH_X11 && !VBOX_WITHOUT_XCURSOR */ 2882 2957 free(pCustomTempWMCursor); 2883 2958 } 2884 2959 } 2960 #endif 2885 2961 2886 2962 LogFlow(("Releasing mouse, keyboard, vrdpserver, display, console...\n")); 2887 2963 if (gDisplay) 2888 gDisplay->SetFramebuffer(VBOX_VIDEO_PRIMARY_SCREEN, NULL); 2964 { 2965 for (unsigned i = 0; i < gcMonitors; i++) 2966 gDisplay->SetFramebuffer(0, NULL); 2967 } 2889 2968 gMouse = NULL; 2890 2969 gKeyboard = NULL; … … 2895 2974 gProgress = NULL; 2896 2975 // we can only uninitialize SDL here because it is not threadsafe 2897 if (gpFrameBuffer) 2898 { 2899 LogFlow(("Releasing framebuffer...\n")); 2900 gpFrameBuffer->uninit(); 2901 gpFrameBuffer->Release(); 2902 } 2976 2977 for (unsigned i = 0; i < gcMonitors; i++) 2978 { 2979 if (gpFramebuffer[i]) 2980 { 2981 LogFlow(("Releasing framebuffer...\n")); 2982 gpFramebuffer[i]->Release(); 2983 gpFramebuffer[i] = NULL; 2984 } 2985 } 2986 2987 VBoxSDLFB::uninit(); 2988 2903 2989 #ifdef VBOX_SECURELABEL 2904 2990 /* must do this after destructing the framebuffer */ … … 3137 3223 3138 3224 #ifdef VBOXSDL_WITH_X11 3225 # ifdef VBOX_WITH_SDL13 3226 3227 switch (ev->keysym.sym) 3228 { 3229 case SDLK_ESCAPE: return 0x01; 3230 case SDLK_EXCLAIM: 3231 case SDLK_1: return 0x02; 3232 case SDLK_AT: 3233 case SDLK_2: return 0x03; 3234 case SDLK_HASH: 3235 case SDLK_3: return 0x04; 3236 case SDLK_DOLLAR: 3237 case SDLK_4: return 0x05; 3238 /* % */ 3239 case SDLK_5: return 0x06; 3240 case SDLK_CARET: 3241 case SDLK_6: return 0x07; 3242 case SDLK_AMPERSAND: 3243 case SDLK_7: return 0x08; 3244 case SDLK_ASTERISK: 3245 case SDLK_8: return 0x09; 3246 case SDLK_LEFTPAREN: 3247 case SDLK_9: return 0x0a; 3248 case SDLK_RIGHTPAREN: 3249 case SDLK_0: return 0x0b; 3250 case SDLK_UNDERSCORE: 3251 case SDLK_MINUS: return 0x0c; 3252 case SDLK_PLUS: return 0x0d; 3253 case SDLK_BACKSPACE: return 0x0e; 3254 case SDLK_TAB: return 0x0f; 3255 case SDLK_q: return 0x10; 3256 case SDLK_w: return 0x11; 3257 case SDLK_e: return 0x12; 3258 case SDLK_r: return 0x13; 3259 case SDLK_t: return 0x14; 3260 case SDLK_y: return 0x15; 3261 case SDLK_u: return 0x16; 3262 case SDLK_i: return 0x17; 3263 case SDLK_o: return 0x18; 3264 case SDLK_p: return 0x19; 3265 case SDLK_RETURN: return 0x1c; 3266 case SDLK_KP_ENTER: return 0x1c | 0x100; 3267 case SDLK_LCTRL: return 0x1d; 3268 case SDLK_RCTRL: return 0x1d | 0x100; 3269 case SDLK_a: return 0x1e; 3270 case SDLK_s: return 0x1f; 3271 case SDLK_d: return 0x20; 3272 case SDLK_f: return 0x21; 3273 case SDLK_g: return 0x22; 3274 case SDLK_h: return 0x23; 3275 case SDLK_j: return 0x24; 3276 case SDLK_k: return 0x25; 3277 case SDLK_l: return 0x26; 3278 case SDLK_COLON: return 0x27; 3279 case SDLK_QUOTEDBL: 3280 case SDLK_QUOTE: return 0x28; 3281 case SDLK_BACKQUOTE: return 0x29; 3282 case SDLK_LSHIFT: return 0x2a; 3283 case SDLK_z: return 0x2c; 3284 case SDLK_x: return 0x2d; 3285 case SDLK_c: return 0x2e; 3286 case SDLK_v: return 0x2f; 3287 case SDLK_b: return 0x30; 3288 case SDLK_n: return 0x31; 3289 case SDLK_m: return 0x32; 3290 case SDLK_LESS: return 0x33; 3291 case SDLK_GREATER: return 0x34; 3292 case SDLK_KP_DIVIDE: /*??*/ 3293 case SDLK_QUESTION: return 0x35; 3294 case SDLK_RSHIFT: return 0x36; 3295 case SDLK_KP_MULTIPLY: 3296 case SDLK_PRINT: return 0x37; /* fixme */ 3297 case SDLK_LALT: return 0x38; 3298 case SDLK_MODE: /* alt gr*/ 3299 case SDLK_RALT: return 0x38 | 0x100; 3300 case SDLK_SPACE: return 0x39; 3301 case SDLK_CAPSLOCK: return 0x3a; 3302 case SDLK_F1: return 0x3b; 3303 case SDLK_F2: return 0x3c; 3304 case SDLK_F3: return 0x3d; 3305 case SDLK_F4: return 0x3e; 3306 case SDLK_F5: return 0x3f; 3307 case SDLK_F6: return 0x40; 3308 case SDLK_F7: return 0x41; 3309 case SDLK_F8: return 0x42; 3310 case SDLK_F9: return 0x43; 3311 case SDLK_F10: return 0x44; 3312 case SDLK_PAUSE: return 0x45; /* not right */ 3313 case SDLK_NUMLOCK: return 0x45; 3314 case SDLK_SCROLLOCK: return 0x46; 3315 case SDLK_KP7: return 0x47; 3316 case SDLK_HOME: return 0x47 | 0x100; 3317 case SDLK_KP8: return 0x48; 3318 case SDLK_UP: return 0x48 | 0x100; 3319 case SDLK_KP9: return 0x49; 3320 case SDLK_PAGEUP: return 0x49 | 0x100; 3321 case SDLK_KP_MINUS: return 0x4a; 3322 case SDLK_KP4: return 0x4b; 3323 case SDLK_LEFT: return 0x4b | 0x100; 3324 case SDLK_KP5: return 0x4c; 3325 case SDLK_KP6: return 0x4d; 3326 case SDLK_RIGHT: return 0x4d | 0x100; 3327 case SDLK_KP_PLUS: return 0x4e; 3328 case SDLK_KP1: return 0x4f; 3329 case SDLK_END: return 0x4f | 0x100; 3330 case SDLK_KP2: return 0x50; 3331 case SDLK_DOWN: return 0x50 | 0x100; 3332 case SDLK_KP3: return 0x51; 3333 case SDLK_PAGEDOWN: return 0x51 | 0x100; 3334 case SDLK_KP0: return 0x52; 3335 case SDLK_INSERT: return 0x52 | 0x100; 3336 case SDLK_KP_PERIOD: return 0x53; 3337 case SDLK_DELETE: return 0x53 | 0x100; 3338 case SDLK_SYSREQ: return 0x54; 3339 case SDLK_F11: return 0x57; 3340 case SDLK_F12: return 0x58; 3341 case SDLK_F13: return 0x5b; 3342 case SDLK_F14: return 0x5c; 3343 case SDLK_F15: return 0x5d; 3344 case SDLK_MENU: return 0x5d | 0x100; 3345 default: 3346 return 0; 3347 } 3139 3348 // workaround for SDL keyboard translation issues on Linux 3140 3349 // keycodes > 0x100 are sent as 0xe0 keycode … … 3143 3352 // work on other hosts or on other servers on Linux hosts. 3144 3353 // For a more general approach, see the Wine code in the GUI. 3354 3355 # else 3145 3356 static const uint16_t x_keycode_to_pc_keycode[61] = 3146 3357 { … … 3290 3501 keycode -= 8; 3291 3502 } 3292 # ifdef RT_OS_LINUX3503 # ifdef RT_OS_LINUX 3293 3504 else if (keycode < 158 && guseEvdevKeymap) 3294 3505 { … … 3296 3507 keycode = evdev_keycode_to_pc_keycode[keycode - 97]; 3297 3508 } 3298 # endif3509 # endif 3299 3510 else if (keycode < 158) 3300 3511 { … … 3316 3527 keycode = 0; 3317 3528 } 3318 3529 # endif 3319 3530 #elif defined(RT_OS_DARWIN) 3320 3531 /* This is derived partially from SDL_QuartzKeys.h and partially from testing. */ … … 3491 3702 3492 3703 #elif RT_OS_OS2 3493 3704 keycode = Keyevent2KeycodeFallback(ev); 3494 3705 #endif /* RT_OS_DARWIN */ 3495 3706 return keycode; … … 3525 3736 static void ProcessKey(SDL_KeyboardEvent *ev) 3526 3737 { 3527 #if defined(DEBUG) || defined(VBOX_WITH_STATISTICS)3738 #if (defined(DEBUG) || defined(VBOX_WITH_STATISTICS)) && !defined(VBOX_WITH_SDL13) 3528 3739 if (gMachineDebugger && ev->type == SDL_KEYDOWN) 3529 3740 { … … 3791 4002 SDL_WM_GrabInput(SDL_GRAB_ON); 3792 4003 // dummy read to avoid moving the mouse 3793 SDL_GetRelativeMouseState(NULL, NULL); 4004 SDL_GetRelativeMouseState( 4005 #ifdef VBOX_WITH_SDL13 4006 0, 4007 #endif 4008 NULL, NULL); 3794 4009 gfGrabbed = TRUE; 3795 4010 UpdateTitlebar(TITLEBAR_NORMAL); … … 3816 4031 * @param dz Relative mouse wheel movement 3817 4032 */ 3818 static void SendMouseEvent( int dz, int down, int button)4033 static void SendMouseEvent(VBoxSDLFB *fb, int dz, int down, int button) 3819 4034 { 3820 4035 int x, y, state, buttons; 3821 4036 bool abs; 4037 4038 #ifdef VBOX_WITH_SDL13 4039 if (!fb) 4040 { 4041 SDL_GetMouseState(0, &x, &y); 4042 RTPrintf("MouseEvent: Cannot find fb mouse = %d,%d\n", x, y); 4043 return; 4044 } 4045 #endif 3822 4046 3823 4047 /* … … 3835 4059 3836 4060 /* only used if abs == TRUE */ 3837 int xMin = gpFrameBuffer->getXOffset(); 3838 int yMin = gpFrameBuffer->getYOffset(); 3839 int xMax = xMin + (int)gpFrameBuffer->getGuestXRes(); 3840 int yMax = yMin + (int)gpFrameBuffer->getGuestYRes(); 3841 3842 state = abs ? SDL_GetMouseState(&x, &y) : SDL_GetRelativeMouseState(&x, &y); 4061 int xOrigin = fb->getOriginX(); 4062 int yOrigin = fb->getOriginY(); 4063 int xMin = fb->getXOffset() + xOrigin; 4064 int yMin = fb->getYOffset() + yOrigin; 4065 int xMax = xMin + (int)fb->getGuestXRes(); 4066 int yMax = yMin + (int)fb->getGuestYRes(); 4067 4068 state = abs ? SDL_GetMouseState( 4069 #ifdef VBOX_WITH_SDL13 4070 0, 4071 #endif 4072 &x, &y) 4073 : SDL_GetRelativeMouseState( 4074 #ifdef VBOX_WITH_SDL13 4075 0, 4076 #endif 4077 &x, &y); 3843 4078 3844 4079 /* … … 3855 4090 if (abs) 3856 4091 { 4092 x += xOrigin; 4093 y += yOrigin; 4094 3857 4095 /* 3858 4096 * Check if the mouse event is inside the guest area. This solves the … … 3937 4175 * or state it in PutMouseEventAbsolute() docs? 3938 4176 */ 3939 gMouse->PutMouseEventAbsolute(x + 1 - xMin ,3940 y + 1 - yMin ,4177 gMouse->PutMouseEventAbsolute(x + 1 - xMin + xOrigin, 4178 y + 1 - yMin + yOrigin, 3941 4179 dz, buttons | tmp_button); 3942 4180 } … … 3956 4194 * or state it in PutMouseEventAbsolute() docs? 3957 4195 */ 3958 gMouse->PutMouseEventAbsolute(x + 1 - xMin ,3959 y + 1 - yMin ,4196 gMouse->PutMouseEventAbsolute(x + 1 - xMin + xOrigin, 4197 y + 1 - yMin + yOrigin, 3960 4198 dz, buttons); 3961 4199 } … … 4521 4759 } 4522 4760 4761 #ifndef VBOX_WITH_SDL13 4523 4762 Cursor cur = XcursorImageLoadCursor (gSdlInfo.info.x11.display, img); 4524 4763 Assert (cur); … … 4546 4785 ok = true; 4547 4786 } 4787 #endif 4548 4788 } 4549 4789 XcursorImageDestroy (img); … … 4630 4870 if (machineState == MachineState_Running) 4631 4871 gConsole->Pause(); 4632 SetFullscreen(!gpFrame Buffer->getFullscreen());4872 SetFullscreen(!gpFramebuffer[0]->getFullscreen()); 4633 4873 if (machineState == MachineState_Running) 4634 4874 gConsole->Resume(); … … 4882 5122 int rc = SDL_PushEvent(event); 4883 5123 RTSemEventSignal(g_EventSemSDLEvents); 5124 #ifdef VBOX_WITH_SDL13 5125 if (rc == 1) 5126 #else 4884 5127 if (rc == 0) 5128 #endif 4885 5129 return 0; 4886 Log(("PushSDLEventForSure: waiting for 2ms \n"));5130 Log(("PushSDLEventForSure: waiting for 2ms (rc = %d)\n", rc)); 4887 5131 RTThreadSleep(2); 4888 5132 } … … 4900 5144 { 4901 5145 int rc = SDL_PushEvent(event); 5146 #ifdef VBOX_WITH_SDL13 5147 bool fSuccess = (rc == 1); 5148 #else 5149 bool fSuccess = (rc == 0); 5150 #endif 5151 4902 5152 RTSemEventSignal(g_EventSemSDLEvents); 4903 AssertMsg( !rc, ("SDL_PushEvent returned SDL error\n"));5153 AssertMsg(fSuccess, ("SDL_PushEvent returned SDL error\n")); 4904 5154 /* A global counter is faster than SDL_PeepEvents() */ 4905 if ( !rc)5155 if (fSuccess) 4906 5156 ASMAtomicIncS32(&g_cNotifyUpdateEventsPending); 4907 5157 /* In order to not flood the SDL event queue, yield the CPU or (if there are already many … … 4924 5174 static void SetFullscreen(bool enable) 4925 5175 { 4926 if (enable == gpFrame Buffer->getFullscreen())5176 if (enable == gpFramebuffer[0]->getFullscreen()) 4927 5177 return; 4928 5178 … … 4932 5182 * The old/default way: SDL will resize the host to fit the guest screen resolution. 4933 5183 */ 4934 gpFrame Buffer->setFullscreen(enable);5184 gpFramebuffer[0]->setFullscreen(enable); 4935 5185 } 4936 5186 else … … 4944 5194 { 4945 5195 /* switch to fullscreen */ 4946 gmGuestNormalXRes = gpFrame Buffer->getGuestXRes();4947 gmGuestNormalYRes = gpFrame Buffer->getGuestYRes();4948 gpFrame Buffer->getFullscreenGeometry(&NewWidth, &NewHeight);5196 gmGuestNormalXRes = gpFramebuffer[0]->getGuestXRes(); 5197 gmGuestNormalYRes = gpFramebuffer[0]->getGuestYRes(); 5198 gpFramebuffer[0]->getFullscreenGeometry(&NewWidth, &NewHeight); 4949 5199 } 4950 5200 else … … 4956 5206 if (NewWidth != 0 && NewHeight != 0) 4957 5207 { 4958 gpFrame Buffer->setFullscreen(enable);5208 gpFramebuffer[0]->setFullscreen(enable); 4959 5209 gfIgnoreNextResize = TRUE; 4960 5210 gDisplay->SetVideoModeHint(NewWidth, NewHeight, 0, 0); … … 4962 5212 } 4963 5213 } 5214 5215 #ifdef VBOX_WITH_SDL13 5216 static VBoxSDLFB * getFbFromWinId(SDL_WindowID id) 5217 { 5218 for (unsigned i = 0; i < gcMonitors; i++) 5219 if (gpFramebuffer[i]->hasWindow(id)) 5220 return gpFramebuffer[i]; 5221 5222 return NULL; 5223 } 5224 #endif
Note:
See TracChangeset
for help on using the changeset viewer.