VirtualBox

Changeset 14397 in vbox


Ignore:
Timestamp:
Nov 20, 2008 11:01:52 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
39625
Message:

FE/Qt4-OSX: added helper functions for the external window handling

Location:
trunk/src/VBox/Frontends/VirtualBox4
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxConsoleView.h

    r13580 r14397  
    302302                                                  WPARAM wParam, LPARAM lParam);
    303303#elif defined (Q_WS_MAC)
     304    EventHandlerRef mDarwinWindowOverlayHandlerRef;
    304305# ifndef VBOX_WITH_HACKED_QT
    305306    static pascal OSStatus darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef,
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxUtils.h

    r13631 r14397  
    220220OSStatus darwinRegionHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
    221221
     222/* Handler for the OpenGL overlay window stuff & the possible messages. */
     223enum
     224{
     225    /* Event classes */
     226    kEventClassVBox        = 'vbox',
     227    /* Event kinds */
     228    kEventVBoxShowWindow   = 'swin',
     229    kEventVBoxMoveWindow   = 'mwin',
     230    kEventVBoxResizeWindow = 'rwin',
     231};
     232OSStatus darwinOverlayWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
     233
    222234# ifdef DEBUG
    223235void darwinDebugPrintEvent (const char *aPrefix, EventRef aEvent);
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxConsoleView.cpp

    r14295 r14397  
    680680    /* Overlay logo for the dock icon */
    681681    mVirtualBoxLogo = ::darwinToCGImageRef ("VirtualBox_cube_42px.png");
     682
     683    /* Install the event handler which will proceed external window handling */
     684    EventHandlerUPP eventHandler = ::NewEventHandlerUPP (::darwinOverlayWindowHandler);
     685    EventTypeSpec eventTypes[] =
     686    {
     687        { kEventClassVBox, kEventVBoxShowWindow },
     688        { kEventClassVBox, kEventVBoxMoveWindow },
     689        { kEventClassVBox, kEventVBoxResizeWindow }
     690    };
     691
     692    mDarwinWindowOverlayHandlerRef = NULL;
     693    ::InstallApplicationEventHandler (eventHandler, RT_ELEMENTS (eventTypes), &eventTypes[0],
     694                                      this, &mDarwinWindowOverlayHandlerRef);
     695    ::DisposeEventHandlerUPP (eventHandler);
    682696#endif
    683697
     
    855869
    856870#ifdef Q_WS_MAC
     871    if (mDarwinWindowOverlayHandlerRef)
     872    {
     873        ::RemoveEventHandler (mDarwinWindowOverlayHandlerRef);
     874        mDarwinWindowOverlayHandlerRef = NULL;
     875    }
    857876    CGImageRelease (mVirtualBoxLogo);
    858877#endif
  • trunk/src/VBox/Frontends/VirtualBox4/src/darwin/VBoxUtils-darwin.cpp

    r12857 r14397  
    373373    return status;
    374374}
     375
     376OSStatus darwinOverlayWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData)
     377{
     378    if (aInUserData)
     379        return ::CallNextEventHandler (aInHandlerCallRef, aInEvent);
     380
     381    UInt32 eventClass = ::GetEventClass (aInEvent);
     382    UInt32 eventKind = ::GetEventKind (aInEvent);
     383    /* For debugging events */
     384    /*
     385    if (!(eventClass == 'cute'))
     386        ::darwinDebugPrintEvent ("view: ", aInEvent);
     387    */
     388    QWidget *view = static_cast<QWidget *> (aInUserData);
     389
     390    if (eventClass == kEventClassVBox)
     391    {
     392        if (eventKind == kEventVBoxShowWindow)
     393        {
     394//            printf ("ShowWindow requested\n");
     395            WindowRef w;
     396            if (GetEventParameter (aInEvent, kEventParamWindowRef, typeWindowRef, NULL, sizeof (w), NULL, &w) != noErr)
     397                return noErr;
     398            ShowWindow (w);
     399            SelectWindow (w);
     400            return noErr;
     401        }
     402        if (eventKind == kEventVBoxMoveWindow)
     403        {
     404//            printf ("MoveWindow requested\n");
     405            WindowPtr w;
     406            if (GetEventParameter (aInEvent, kEventParamWindowRef, typeWindowRef, NULL, sizeof (w), NULL, &w) != noErr)
     407                return noErr;
     408            HIPoint p;
     409            if (GetEventParameter (aInEvent, kEventParamOrigin, typeHIPoint, NULL, sizeof (p), NULL, &p) != noErr)
     410                return noErr;
     411            ChangeWindowGroupAttributes (GetWindowGroup (w), 0, kWindowGroupAttrMoveTogether);
     412            QPoint p1 = view->mapToGlobal (QPoint (p.x, p.y));
     413            MoveWindow (w, p1.x(), p1.y(), true);
     414            ChangeWindowGroupAttributes (GetWindowGroup (w), kWindowGroupAttrMoveTogether, 0);
     415            return noErr;
     416        }
     417        if (eventKind == kEventVBoxResizeWindow)
     418        {
     419//            printf ("ResizeWindow requested\n");
     420            WindowPtr w;
     421            if (GetEventParameter (aInEvent, kEventParamWindowRef, typeWindowRef, NULL, sizeof (w), NULL, &w) != noErr)
     422                return noErr;
     423            HISize s;
     424            if (GetEventParameter (aInEvent, kEventParamDimensions, typeHISize, NULL, sizeof (s), NULL, &s) != noErr)
     425                return noErr;
     426            SizeWindow (w, s.width, s.height, true);
     427            return noErr;
     428        }
     429    }
     430
     431    return ::CallNextEventHandler (aInHandlerCallRef, aInEvent);
     432}
     433
     434
    375435
    376436/* Event debugging stuff. Borrowed from the Knuts Qt patch. */
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