VirtualBox

Changeset 965 in vbox


Ignore:
Timestamp:
Feb 18, 2007 12:49:09 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
18735
Message:

Disable global hotkeys when grabbing the keyboard.

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

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/VBox/Frontends/VBoxBFE/SDLConsole.cpp

    r963 r965  
    2525*******************************************************************************/
    2626#define LOG_GROUP LOG_GROUP_GUI
     27#ifdef __DARWIN__
     28# include <Carbon/Carbon.h>
     29# define OSType VBoxOSType
     30# undef PAGE_SIZE
     31# undef PAGE_SHIFT
     32#endif
    2733
    2834#ifdef VBOXBFE_WITHOUT_COM
     
    10271033}
    10281034
     1035#ifdef __DARWIN__
     1036
     1037__BEGIN_DECLS
     1038/* Private interface in 10.3 and later. */
     1039typedef int CGSConnection;
     1040typedef enum
     1041{
     1042    kCGSGlobalHotKeyEnable = 0,
     1043    kCGSGlobalHotKeyDisable,
     1044    kCGSGlobalHotKeyInvalid = -1 /* bird */
     1045} CGSGlobalHotKeyOperatingMode;
     1046extern CGSConnection _CGSDefaultConnection(void);
     1047extern CGError CGSGetGlobalHotKeyOperatingMode(CGSConnection Connection, CGSGlobalHotKeyOperatingMode *enmMode);
     1048extern CGError CGSSetGlobalHotKeyOperatingMode(CGSConnection Connection, CGSGlobalHotKeyOperatingMode enmMode);
     1049__END_DECLS
     1050
     1051/** Keeping track of whether we disabled the hotkeys or not. */
     1052static bool g_fHotKeysDisabled = false;
     1053/** Whether we've connected or not. */
     1054static bool g_fConnectedToCGS = false;
     1055/** Cached connection. */
     1056static CGSConnection g_CGSConnection;
     1057
     1058/**
     1059 * Disables or enabled global hot keys.
     1060 */
     1061static void DisableGlobalHotKeys(bool fDisable)
     1062{
     1063    if (!g_fConnectedToCGS)
     1064    {
     1065        g_CGSConnection = _CGSDefaultConnection();
     1066        g_fConnectedToCGS = true;
     1067    }
     1068
     1069    /* get current mode. */
     1070    CGSGlobalHotKeyOperatingMode enmMode = kCGSGlobalHotKeyInvalid;
     1071    CGSGetGlobalHotKeyOperatingMode(g_CGSConnection, &enmMode);
     1072
     1073    /* calc new mode. */
     1074    if (fDisable)
     1075    {
     1076        if (enmMode != kCGSGlobalHotKeyEnable)
     1077            return;
     1078        enmMode = kCGSGlobalHotKeyDisable;
     1079    }
     1080    else
     1081    {
     1082        if (    enmMode != kCGSGlobalHotKeyDisable
     1083            /*||  !g_fHotKeysDisabled*/)
     1084            return;
     1085        enmMode = kCGSGlobalHotKeyEnable;
     1086    }
     1087
     1088    /* try set it and check the actual result. */
     1089    CGSSetGlobalHotKeyOperatingMode(g_CGSConnection, enmMode);
     1090    CGSGlobalHotKeyOperatingMode enmNewMode = kCGSGlobalHotKeyInvalid;
     1091    CGSGetGlobalHotKeyOperatingMode(g_CGSConnection, &enmNewMode);
     1092    if (enmNewMode == enmMode)
     1093        g_fHotKeysDisabled = enmMode == kCGSGlobalHotKeyDisable;
     1094}
     1095#endif /* __DARWIN__ */
     1096
    10291097/**
    10301098 * Start grabbing the mouse.
     
    10321100void SDLConsole::inputGrabStart()
    10331101{
     1102#ifdef __DARWIN__
     1103    DisableGlobalHotKeys(true);
     1104#endif
    10341105    if (!gMouse->getNeedsHostCursor())
    10351106        SDL_ShowCursor(SDL_DISABLE);
     
    10491120    if (!gMouse->getNeedsHostCursor())
    10501121        SDL_ShowCursor(SDL_ENABLE);
     1122#ifdef __DARWIN__
     1123    DisableGlobalHotKeys(false);
     1124#endif
    10511125    fInputGrab = 0;
    10521126    updateTitlebar();
  • TabularUnified trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r964 r965  
    32363236}
    32373237
     3238#ifdef __DARWIN__
     3239#include <Carbon/Carbon.h>
     3240__BEGIN_DECLS
     3241/* Private interface in 10.3 and later. */
     3242typedef int CGSConnection;
     3243typedef enum
     3244{
     3245    kCGSGlobalHotKeyEnable = 0,
     3246    kCGSGlobalHotKeyDisable,
     3247    kCGSGlobalHotKeyInvalid = -1 /* bird */
     3248} CGSGlobalHotKeyOperatingMode;
     3249extern CGSConnection _CGSDefaultConnection(void);
     3250extern CGError CGSGetGlobalHotKeyOperatingMode(CGSConnection Connection, CGSGlobalHotKeyOperatingMode *enmMode);
     3251extern CGError CGSSetGlobalHotKeyOperatingMode(CGSConnection Connection, CGSGlobalHotKeyOperatingMode enmMode);
     3252__END_DECLS
     3253
     3254/** Keeping track of whether we disabled the hotkeys or not. */
     3255static bool g_fHotKeysDisabled = false;
     3256/** Whether we've connected or not. */
     3257static bool g_fConnectedToCGS = false;
     3258/** Cached connection. */
     3259static CGSConnection g_CGSConnection;
     3260
     3261/**
     3262 * Disables or enabled global hot keys.
     3263 */
     3264static void DisableGlobalHotKeys(bool fDisable)
     3265{
     3266    if (!g_fConnectedToCGS)
     3267    {
     3268        g_CGSConnection = _CGSDefaultConnection();
     3269        g_fConnectedToCGS = true;
     3270    }
     3271
     3272    /* get current mode. */
     3273    CGSGlobalHotKeyOperatingMode enmMode = kCGSGlobalHotKeyInvalid;
     3274    CGSGetGlobalHotKeyOperatingMode(g_CGSConnection, &enmMode);
     3275
     3276    /* calc new mode. */
     3277    if (fDisable)
     3278    {
     3279        if (enmMode != kCGSGlobalHotKeyEnable)
     3280            return;
     3281        enmMode = kCGSGlobalHotKeyDisable;
     3282    }
     3283    else
     3284    {
     3285        if (    enmMode != kCGSGlobalHotKeyDisable
     3286            /*||  !g_fHotKeysDisabled*/)
     3287            return;
     3288        enmMode = kCGSGlobalHotKeyEnable;
     3289    }
     3290
     3291    /* try set it and check the actual result. */
     3292    CGSSetGlobalHotKeyOperatingMode(g_CGSConnection, enmMode);
     3293    CGSGlobalHotKeyOperatingMode enmNewMode = kCGSGlobalHotKeyInvalid;
     3294    CGSGetGlobalHotKeyOperatingMode(g_CGSConnection, &enmNewMode);
     3295    if (enmNewMode == enmMode)
     3296        g_fHotKeysDisabled = enmMode == kCGSGlobalHotKeyDisable;
     3297}
     3298#endif /* __DARWIN__ */
     3299
    32383300/**
    32393301 * Start grabbing the mouse.
     
    32413303static void InputGrabStart(void)
    32423304{
     3305#ifdef __DARWIN__
     3306    DisableGlobalHotKeys(true);
     3307#endif
    32433308    if (!gfGuestNeedsHostCursor)
    32443309        SDL_ShowCursor(SDL_DISABLE);
     
    32583323    if (!gfGuestNeedsHostCursor)
    32593324        SDL_ShowCursor(SDL_ENABLE);
     3325#ifdef __DARWIN__
     3326    DisableGlobalHotKeys(false);
     3327#endif
    32603328    gfGrabbed = FALSE;
    32613329    UpdateTitlebar(TITLEBAR_NORMAL);
Note: See TracChangeset for help on using the changeset viewer.

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