VirtualBox

Changeset 522 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 1, 2007 9:30:27 PM (18 years ago)
Author:
vboxsync
Message:

timer-based SDL window resize like FE/Qt (more reliable, also works when window is maximized)

Location:
trunk/src/VBox/Frontends/VBoxSDL
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r516 r522  
    140140static int     HandleHostKey(const SDL_KeyboardEvent *pEv);
    141141static Uint32  StartupTimer(Uint32 interval, void *param);
     142static Uint32  ResizeTimer(Uint32 interval, void *param);
    142143
    143144
     
    188189static WMcursor   *gpCustomOrigWMcursor = NULL;
    189190static SDL_Cursor *gpOffCursor = NULL;
     191static SDL_TimerID gSdlResizeTimer = NULL;
    190192
    191193#ifdef __LINUX__
     
    22442246            case SDL_ACTIVEEVENT:
    22452247            {
    2246                 /**
    2247                  * @todo This is a workaround for synchronization problems between EMT and the
    2248                  *       SDL main thread. It can happen that the SDL thread already starts a
    2249                  *       new resize operation while the EMT is still busy with the old one
    2250                  *       leading to a deadlock. Therefore we call SetVideoModeHint only once
    2251                  *       when the mouse button was released.
    2252                  */
    2253                 if (uResizeWidth != ~(uint32_t)0)
    2254                 {
    2255                     /* communicate the resize event to the guest */
    2256                     gDisplay->SetVideoModeHint(uResizeWidth, uResizeHeight, 0);
    2257                     uResizeWidth = ~(uint32_t)0;
    2258                 }
    2259 
    22602248                /*
    22612249                 * There is a strange behaviour in SDL when running without a window
     
    22872275                    uResizeHeight = event.resize.h;
    22882276#endif
     2277                    if (gSdlResizeTimer)
     2278                        SDL_RemoveTimer(gSdlResizeTimer);
     2279                    gSdlResizeTimer = SDL_AddTimer(300, ResizeTimer, NULL);
    22892280                }
    22902281                break;
     
    23212312                #undef DECODEH
    23222313                break;
     2314            }
     2315
     2316            /*
     2317             * User event: Window resize done
     2318             */
     2319            case SDL_USER_EVENT_WINDOW_RESIZE_DONE:
     2320            {
     2321                /**
     2322                 * @todo This is a workaround for synchronization problems between EMT and the
     2323                 *       SDL main thread. It can happen that the SDL thread already starts a
     2324                 *       new resize operation while the EMT is still busy with the old one
     2325                 *       leading to a deadlock. Therefore we call SetVideoModeHint only once
     2326                 *       when the mouse button was released.
     2327                 */
     2328                /* communicate the resize event to the guest */
     2329                gDisplay->SetVideoModeHint(uResizeWidth, uResizeHeight, 0);
     2330                break;
     2331
    23232332            }
    23242333
     
    38173826    return interval;
    38183827}
     3828
     3829/**
     3830 * Timer callback function to check if resizing is finished
     3831 */
     3832static Uint32 ResizeTimer(Uint32 interval, void *param)
     3833{
     3834    /* post message so the window is actually resized */
     3835    SDL_Event event = {0};
     3836    event.type      = SDL_USEREVENT;
     3837    event.user.type = SDL_USER_EVENT_WINDOW_RESIZE_DONE;
     3838    SDL_PushEvent(&event);
     3839    /* one-shot */
     3840    return 0;
     3841}
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.h

    r1 r522  
    4747/** custom SDL user event for resetting mouse cursor */
    4848#define SDL_USER_EVENT_GUEST_CAP_CHANGED  (SDL_USEREVENT + 12)
     49/** custom SDL user event for window resize down */
     50#define SDL_USER_EVENT_WINDOW_RESIZE_DONE (SDL_USEREVENT + 13)
    4951
    5052
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette