VirtualBox

Changeset 2968 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jun 1, 2007 1:00:44 AM (18 years ago)
Author:
vboxsync
Message:

Implemented the VM selector 'Show' feature on darwin, including the restoring the console if it was minimized.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h

    r2736 r2968  
    140140#endif
    141141        ActivateMenuEventType,
     142#if defined (Q_WS_MAC)
     143        ShowWindowEventType,
     144#endif
    142145    };
    143146};
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r2835 r2968  
    411411            return E_POINTER;
    412412
     413#if defined (Q_WS_MAC)
     414        /*
     415         * Let's try the simple approach first - grab the focus.
     416         * Getting a window out of the dock (minimized or whatever it's called)
     417         * needs to be done on the GUI thread, so post it a note.
     418         */
     419        *winId = 0;
     420        if (!mView)
     421            return S_OK;
     422
     423        ProcessSerialNumber psn = { 0, kCurrentProcess };
     424        OSErr rc = ::SetFrontProcess (&psn);
     425        if (!rc)
     426            QApplication::postEvent (mView, new QEvent ((QEvent::Type)VBoxDefs::ShowWindowEventType));
     427        else
     428        {
     429            /*
     430             * It failed for some reason, send the other process our PSN so it can try.
     431             * (This is just a precaution should Mac OS X start imposing the same sensible
     432             * focus stealing restrictions that other window managers implement.)
     433             */
     434            AssertMsgFailed(("SetFrontProcess -> %#x\n", rc));
     435            if (::GetCurrentProcess (&psn))
     436                *winId = RT_MAKE_U64 (psn.lowLongOfPSN, psn.highLongOfPSN);
     437        }
     438
     439#else
    413440        /* Return the ID of the top-level console window. */
    414441        *winId = (ULONG64) mView->topLevelWidget()->winId();
     442#endif
    415443
    416444        return S_OK;
     
    10251053            }
    10261054
     1055#ifdef Q_WS_MAC
     1056            /* posted OnShowWindow */
     1057            case VBoxDefs::ShowWindowEventType:
     1058            {
     1059                /*
     1060                 *  Dunno what Qt3 thinks a window that has minimized to the dock
     1061                 *  should be - it is not hidden, neither is it minimized. OTOH it is
     1062                 *  marked shown and visible, but not activated. This latter isn't of
     1063                 *  much help though, since at this point nothing is marked activated.
     1064                 *  I might have overlooked something, but I'm buggered what if I know
     1065                 *  what. So, I'll just always show & activate the stupid window to
     1066                 *  make it get out of the dock when the user wishes to show a VM.
     1067                 */
     1068                topLevelWidget()->show();
     1069                topLevelWidget()->setActiveWindow();
     1070                return true;
     1071            }
     1072#endif
    10271073            default:
    10281074                break;
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxVMListBox.cpp

    r2708 r2968  
    3434#include <qfileinfo.h>
    3535
    36 /// @todo Remove? See @c todo in #switchTo() below.
    3736#if defined (Q_WS_MAC)
    3837# include <Carbon/Carbon.h>
     
    541540bool VBoxVMListBoxItem::switchTo()
    542541{
     542#ifdef Q_WS_MAC
     543    ULONG64 id = mMachine.ShowConsoleWindow();
     544#else
    543545    WId id = (WId) mMachine.ShowConsoleWindow();
     546#endif
    544547    AssertWrapperOk (mMachine);
    545548    if (!mMachine.isOk())
     
    556559
    557560#elif defined (Q_WS_MAC)
    558 
    559     /// @todo (r=dmik) Knut, everything you have to do here is to raise the
    560     /// given window over all other top-level windows and give it focus. Ah,
    561     /// and deiconify/show it first if it is minimized/hidden. I really hope
    562     /// it's better on Mac than on X11. If not, feel free to revert to the
    563     /// previous pid-based behavior.
    564 
    565     return false;
     561    /*
     562     * This is just for the case were the other process cannot steal
     563     * the focus from us. It will send us a PSN so we can try.
     564     */
     565    ProcessSerialNumber psn;
     566    psn.highLongOfPSN = id >> 32;
     567    psn.lowLongOfPSN = (UInt32)id;
     568    OSErr rc = ::SetFrontProcess (&psn);
     569    if (!rc)
     570        Log (("GUI: %#RX64 couldn't do SetFrontProcess on itself, the selector (we) had to do it...\n", id));
     571    else
     572        Log (("GUI: Failed to bring %#RX64 to front. rc=%#x\n", id, rc));
     573    return !rc;
    566574
    567575#endif
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