VirtualBox

Changeset 25211 in vbox


Ignore:
Timestamp:
Dec 7, 2009 2:47:25 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt4-OSX: Reenable CMD+Key combinations, even if the Host-Key isn't CMD (public #5684).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r25135 r25211  
    138138        ::VBoxCocoaApplication_printEvent ("view: ", pvCocoaEvent);
    139139#endif
    140 
    141     /*
    142      * Not sure but this seems an triggered event if the spotlight searchbar is
    143      * displayed. So flag that the host key isn't pressed alone.
    144      */
    145     if (   eventClass == 'cgs '
    146         && view->mIsHostkeyPressed
    147         && ::GetEventKind (inEvent) == 0x15)
    148         view->mIsHostkeyAlone = false;
     140    /* Check if this is an application key combo. In that case we will not pass
     141       the event to the guest, but let the host process it. */
     142    if (VBoxCocoaApplication_isApplicationCommand(pvCocoaEvent))
     143        return false;
    149144
    150145    /*
     
    154149    {
    155150        if (view->darwinKeyboardEvent (pvCocoaEvent, inEvent))
    156             return true;
    157     }
    158     /*
    159      * Command-H and Command-Q aren't properly disabled yet, and it's still
    160      * possible to use the left command key to invoke them when the keyboard
    161      * is captured. We discard the events these if the keyboard is captured
    162      * as a half measure to prevent unexpected behaviour. However, we don't
    163      * get any key down/up events, so these combinations are dead to the guest...
    164      */
    165     else if (eventClass == kEventClassCommand)
    166     {
    167         if (view->mKbdCaptured)
    168151            return true;
    169152    }
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxCocoaApplication.h

    r20374 r25211  
    9191void VBoxCocoaApplication_setMouseCoalescingEnabled(bool fEnabled);
    9292const char *VBoxCocoaApplication_eventTypeName(unsigned long eEvtType);
     93bool VBoxCocoaApplication_isApplicationCommand(const void *pvEvent);
    9394void VBoxCocoaApplication_printEvent(const char *pszPrefix, const void *pvEvent);
    9495/** @} */
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxCocoaApplication.m

    r23463 r25211  
    340340}
    341341
     342/**
     343 * Check for some default application key combinations a Mac user expect, like
     344 * CMD+Q or CMD+H.
     345 *
     346 * @returns true if such a key combo was hit, false otherwise.
     347 * @param   eEvtType        The Cocoa event type.
     348 */
     349bool VBoxCocoaApplication_isApplicationCommand(const void *pvEvent)
     350{
     351    NSEvent     *pEvent = (NSEvent *)pvEvent;
     352    NSEventType  eEvtType = [pEvent type];
     353    bool         fGlobalHotkey = false;
     354
     355    switch (eEvtType)
     356    {
     357        case NSKeyDown:
     358        case NSKeyUp:
     359        {
     360            NSUInteger fEvtMask = [pEvent modifierFlags];
     361            unsigned short KeyCode = [pEvent keyCode];
     362            if (   fEvtMask & (NX_NONCOALSESCEDMASK | NX_COMMANDMASK | NX_DEVICELCMDKEYMASK)  // L+CMD
     363                || fEvtMask & (NX_NONCOALSESCEDMASK | NX_COMMANDMASK | NX_DEVICERCMDKEYMASK)) // R+CMD
     364            {
     365                if (   KeyCode == 0x0c  // CMD+Q (Quit)
     366                    || KeyCode == 0x04) // CMD+H (Hide)
     367                    fGlobalHotkey = true;
     368            }
     369            else if (   fEvtMask & (NX_NONCOALSESCEDMASK | NX_ALTERNATEMASK | NX_DEVICELALTKEYMASK | NX_COMMANDMASK | NX_DEVICELCMDKEYMASK)  // L+ALT+CMD
     370                     || fEvtMask & (NX_NONCOALSESCEDMASK | NX_ALTERNATEMASK | NX_DEVICERCMDKEYMASK | NX_COMMANDMASK | NX_DEVICERCMDKEYMASK)) // R+ALT+CMD
     371            {
     372                if (KeyCode == 0x04)    // ALT+CMD+H (Hide-Others)
     373                    fGlobalHotkey = true;
     374            }
     375            break;
     376        }
     377        default: break;
     378    }
     379    return fGlobalHotkey;
     380}
    342381
    343382/**
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