VirtualBox

Changeset 30122 in vbox


Ignore:
Timestamp:
Jun 9, 2010 1:50:26 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
62517
Message:

FE/Qt4-OSX/Global: Split the event handling methods and the Qt methods for usage without Qt.

Location:
trunk
Files:
4 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxCocoa.h

    r30114 r30122  
    11/** @file
    22 *
    3  * VBox frontends: Qt GUI ("VirtualBox"):
    43 * VBoxCocoa Helper
    54 */
    65
    76/*
    8  * Copyright (C) 2009 Oracle Corporation
     7 * Copyright (C) 2009-2010 Oracle Corporation
    98 *
    109 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1716 */
    1817
    19 #ifndef ___darwin_VBoxCocoaHelper_h
    20 #define ___darwin_VBoxCocoaHelper_h
     18#ifndef __VBoxCocoa_h__
     19#define __VBoxCocoa_h__
    2120
    2221/* Macro which add a typedef of the given Cocoa class in an appropriate form
     
    3938#ifdef __OBJC__
    4039
    41 /* System includes */
    42 #import <AppKit/NSImage.h>
     40/* Global includes */
    4341#import <Foundation/NSAutoreleasePool.h>
    44 #import <CoreFoundation/CFString.h>
    45 
    46 /* Qt includes */
    47 #include <QString>
    48 #include <QVarLengthArray>
    49 
    50 inline NSString *darwinQStringToNSString (const QString &aString)
    51 {
    52     return [reinterpret_cast<const NSString *>(CFStringCreateWithCharacters (0, reinterpret_cast<const UniChar *> (aString.unicode()),
    53                                                                              aString.length())) autorelease];
    54 }
    55 
    56 inline QString darwinNSStringToQString (const NSString *aString)
    57 {
    58     CFStringRef str = reinterpret_cast<const CFStringRef> (aString);
    59     if(!str)
    60         return QString();
    61     CFIndex length = CFStringGetLength (str);
    62     const UniChar *chars = CFStringGetCharactersPtr (str);
    63     if (chars)
    64         return QString (reinterpret_cast<const QChar *> (chars), length);
    65 
    66     QVarLengthArray<UniChar> buffer (length);
    67     CFStringGetCharacters (str, CFRangeMake (0, length), buffer.data());
    68     return QString (reinterpret_cast<const QChar *> (buffer.constData()), length);
    69 }
    70 
    71 inline NSImage *darwinCGImageToNSImage (const CGImageRef aImage)
    72 {
    73     /* Create a bitmap rep from the image. */
    74     NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage:aImage];
    75     /* Create an NSImage and add the bitmap rep to it */
    76     NSImage *image = [[NSImage alloc] init];
    77     [image addRepresentation:bitmapRep];
    78     [bitmapRep release];
    79     return image;
    80 }
    8142
    8243/* Helper class for automatic creation & destroying of a cocoa auto release
     
    10061#endif /* __OBJC__ */
    10162
    102 #endif /* ___darwin_VBoxCocoaHelper_h */
     63#endif /* __VBoxCocoa_h__ */
    10364
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r30118 r30122  
    523523 VirtualBox_DEFS += VBOX_DARWIN_USE_NATIVE_CONTROLS
    524524 VirtualBox_SOURCES.darwin += \
     525        src/darwin/CocoaEventHelper.mm \
    525526        src/darwin/UICocoaApplication.mm \
    526527        src/darwin/VBoxUtils-darwin-cocoa.mm \
     
    841842#
    842843ifdef VBOX_WITH_TESTCASES
    843 #PROGRAMS.darwin += tstDarwinKeyboard
     844PROGRAMS.darwin += tstDarwinKeyboard
    844845tstDarwinKeyboard_NAME = tstDarwinKeyboard
    845846tstDarwinKeyboard_TEMPLATE = VBOXR3TSTEXE
     
    850851        src/darwin/DarwinKeyboard.cpp
    851852tstDarwinKeyboard_SOURCES.amd64 = \
    852         src/darwin/UICocoaApplication.mm
     853        src/darwin/CocoaEventHelper.mm
    853854tstDarwinKeyboard_LDFLAGS = -framework IOKit -framework Carbon -framework AppKit
    854855tstDarwinKeyboard_LIBS = \
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/CocoaEventHelper.h

    r30114 r30122  
    22 *
    33 * VBox frontends: Qt GUI ("VirtualBox"):
    4  * Declarations of utility classes and functions for handling Darwin specific
    5  * tasks
     4 * Declarations of utility functions for handling Darwin Cocoa specific event
     5 * handling tasks
    66 */
    77
     
    1818 */
    1919
    20 #ifndef ___VBoxUtils_darwin_h
    21 #define ___VBoxUtils_darwin_h
     20#ifndef ___CocoaEventHelper_h
     21#define ___CocoaEventHelper_h
    2222
    23 /*
    24  * Here is some really magic in. The "OS System native" methods are implemented
    25  * in the current OS specific way. This means either Carbon
    26  * (VBoxUtils-darwin-carbon.cpp) or Cocoa (VBoxUtils-darwin-cocoa.m). The Qt
    27  * wrapper methods handle the conversion from Q* data types to the native one
    28  * (VBoxUtils-darwin.cpp).
    29  */
    30 
    31 #ifdef __OBJC__
    32 #import <AppKit/NSWindow.h>
    33 
    34 typedef NSWindow *NativeWindowRef;
    35 typedef NSView *NativeViewRef;
    36 #else
    37 
    38 # include <qglobal.h> /* for QT_MAC_USE_COCOA */
    39 # include <ApplicationServices/ApplicationServices.h>
    40 
    41 class QMainWindow;
    42 class QToolBar;
    43 class QPixmap;
    44 class QImage;
    45 class QMenu;
    46 
    47 # ifdef QT_MAC_USE_COCOA
    48 /* Cast this to void, cause Cocoa classes aren't usable in the C++ context. */
    49 typedef void *NativeWindowRef;
    50 typedef void *NativeViewRef;
    51 # endif /* QT_MAC_USE_COCOA */
    52 #endif /* __OBJC__ */
    53 
    54 #include "VBoxCocoaHelper.h"
     23#include <VBox/VBoxCocoa.h>
    5524#include <iprt/cdefs.h> /* for RT_C_DECLS_BEGIN/RT_C_DECLS_END & stuff */
    56 #include <QRect>
    57 
    58 class QWidget;
    5925
    6026ADD_COCOA_NATIVE_REF(NSEvent);
    6127
    6228RT_C_DECLS_BEGIN
    63 
    64 /********************************************************************************
    65  *
    66  * Window/View management (OS System native)
    67  *
    68  ********************************************************************************/
    69 NativeWindowRef darwinToNativeWindowImpl(NativeViewRef aView);
    70 NativeViewRef darwinToNativeViewImpl(NativeWindowRef aWindow);
    71 
    72 /********************************************************************************
    73  *
    74  * Simple setter methods (OS System native)
    75  *
    76  ********************************************************************************/
    77 void darwinSetShowsToolbarButtonImpl(NativeWindowRef aWindow, bool aEnabled);
    78 void darwinSetShowsResizeIndicatorImpl(NativeWindowRef aWindow, bool aEnabled);
    79 void darwinSetHidesAllTitleButtonsImpl(NativeWindowRef aWindow);
    80 void darwinSetShowsWindowTransparentImpl(NativeWindowRef aWindow, bool aEnabled);
    81 void darwinSetMouseCoalescingEnabled(bool aEnabled);
    82 
    83 /********************************************************************************
    84  *
    85  * Simple helper methods (OS System native)
    86  *
    87  ********************************************************************************/
    88 void darwinWindowAnimateResizeImpl(NativeWindowRef aWindow, int x, int y, int width, int height);
    89 void darwinWindowInvalidateShapeImpl(NativeWindowRef aWindow);
    90 void darwinWindowInvalidateShadowImpl(NativeWindowRef aWindow);
    91 int  darwinWindowToolBarHeight(NativeWindowRef aWindow);
    92 bool darwinIsToolbarVisible(NativeWindowRef pWindow);
    93 bool darwinIsWindowMaximized(NativeWindowRef aWindow);
    94 
    95 float darwinSmallFontSize();
    96 bool darwinSetFrontMostProcess();
    97 uint64_t darwinGetCurrentProcessId();
    98 
    99 bool darwinUnifiedToolbarEvents(const void *pvCocoaEvent, const void *pvCarbonEvent, void *pvUser);
    100 void darwinCreateContextMenuEvent(void *pvWin, int x, int y);
    10129
    10230/********************************************************************************
     
    10735unsigned long darwinEventModifierFlags(ConstNativeNSEventRef pEvent);
    10836uint32_t darwinEventModifierFlagsXlated(ConstNativeNSEventRef pEvent);
    109 bool darwinIsApplicationCommand(ConstNativeNSEventRef pEvent);
    11037const char *darwinEventTypeName(unsigned long eEvtType);
    11138void darwinPrintEvent(const char *pszPrefix, ConstNativeNSEventRef pEvent);
     
    11340RT_C_DECLS_END
    11441
    115 DECLINLINE(CGRect) darwinToCGRect(const QRect& aRect) { return CGRectMake(aRect.x(), aRect.y(), aRect.width(), aRect.height()); }
    116 DECLINLINE(CGRect) darwinFlipCGRect(CGRect aRect, int aTargetHeight) { aRect.origin.y = aTargetHeight - aRect.origin.y - aRect.size.height; return aRect; }
    117 DECLINLINE(CGRect) darwinFlipCGRect(CGRect aRect, const CGRect &aTarget) { return darwinFlipCGRect(aRect, aTarget.size.height); }
    118 DECLINLINE(CGRect) darwinCenterRectTo(CGRect aRect, const CGRect& aToRect)
    119 {
    120     aRect.origin.x = aToRect.origin.x + (aToRect.size.width  - aRect.size.width)  / 2.0;
    121     aRect.origin.y = aToRect.origin.y + (aToRect.size.height - aRect.size.height) / 2.0;
    122     return aRect;
    123 }
     42#endif /* !___CocoaEventHelper_h */
    12443
    125 
    126 /********************************************************************************
    127  *
    128  * Window/View management (Qt Wrapper)
    129  *
    130  ********************************************************************************/
    131 
    132 /**
    133  * Returns a reference to the native View of the QWidget.
    134  *
    135  * @returns either HIViewRef or NSView* of the QWidget.
    136  * @param   aWidget   Pointer to the QWidget
    137  */
    138 NativeViewRef darwinToNativeView(QWidget *aWidget);
    139 
    140 /**
    141  * Returns a reference to the native Window of the QWidget.
    142  *
    143  * @returns either WindowRef or NSWindow* of the QWidget.
    144  * @param   aWidget   Pointer to the QWidget
    145  */
    146 NativeWindowRef darwinToNativeWindow(QWidget *aWidget);
    147 
    148 /* This is necessary because of the C calling convention. Its a simple wrapper
    149    for darwinToNativeWindowImpl to allow operator overloading which isn't
    150    allowed in C. */
    151 /**
    152  * Returns a reference to the native Window of the View..
    153  *
    154  * @returns either WindowRef or NSWindow* of the View.
    155  * @param   aWidget   Pointer to the native View
    156  */
    157 NativeWindowRef darwinToNativeWindow(NativeViewRef aView);
    158 
    159 /**
    160  * Returns a reference to the native View of the Window.
    161  *
    162  * @returns either HIViewRef or NSView* of the Window.
    163  * @param   aWidget   Pointer to the native Window
    164  */
    165 NativeViewRef darwinToNativeView(NativeWindowRef aWindow);
    166 
    167 #ifndef __OBJC__
    168 /********************************************************************************
    169  *
    170  * Simple setter methods (Qt Wrapper)
    171  *
    172  ********************************************************************************/
    173 void darwinSetShowsToolbarButton(QToolBar *aToolBar, bool aEnabled);
    174 void darwinSetShowsResizeIndicator(QWidget *aWidget, bool aEnabled);
    175 void darwinSetHidesAllTitleButtons(QWidget *aWidget);
    176 void darwinSetShowsWindowTransparent(QWidget *aWidget, bool aEnabled);
    177 void darwinSetDockIconMenu(QMenu *pMenu);
    178 void darwinDisableIconsInMenus(void);
    179 
    180 /********************************************************************************
    181  *
    182  * Simple helper methods (Qt Wrapper)
    183  *
    184  ********************************************************************************/
    185 void darwinWindowAnimateResize(QWidget *aWidget, const QRect &aTarget);
    186 void darwinWindowInvalidateShape(QWidget *aWidget);
    187 void darwinWindowInvalidateShadow(QWidget *aWidget);
    188 int  darwinWindowToolBarHeight(QWidget *aWidget);
    189 bool darwinIsToolbarVisible(QToolBar *pToolBar);
    190 bool darwinIsWindowMaximized(QWidget *aWidget);
    191 QString darwinSystemLanguage(void);
    192 QPixmap darwinCreateDragPixmap(const QPixmap& aPixmap, const QString &aText);
    193 
    194 void darwinRegisterForUnifiedToolbarContextMenuEvents(QMainWindow *pWindow);
    195 void darwinUnregisterForUnifiedToolbarContextMenuEvents(QMainWindow *pWindow);
    196 
    197 /********************************************************************************
    198  *
    199  * Graphics stuff (Qt Wrapper)
    200  *
    201  ********************************************************************************/
    202 /**
    203  * Returns a reference to the CGContext of the QWidget.
    204  *
    205  * @returns CGContextRef of the QWidget.
    206  * @param   aWidget      Pointer to the QWidget
    207  */
    208 CGContextRef darwinToCGContextRef(QWidget *aWidget);
    209 
    210 CGImageRef darwinToCGImageRef(const QImage *aImage);
    211 CGImageRef darwinToCGImageRef(const QPixmap *aPixmap);
    212 CGImageRef darwinToCGImageRef(const char *aSource);
    213 
    214 #endif /* !__OBJC__ */
    215 
    216 #endif /* !___VBoxUtils_darwin_h */
    217 
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/CocoaEventHelper.mm

    r30114 r30122  
    33 *
    44 * VBox frontends: Qt GUI ("VirtualBox"):
    5  * Declarations of utility classes and functions for handling Darwin Cocoa
    6  * specific tasks
     5 * Declarations of utility functions for handling Darwin Cocoa specific event
     6 * handling tasks
    77 */
    88
     
    1919 */
    2020
    21 #include "VBoxUtils-darwin.h"
    22 #include "VBoxCocoaHelper.h"
    23 
    24 #include <QMenu>
    25 
    26 #include <iprt/assert.h>
    27 
     21/* Local includes */
     22#include "CocoaEventHelper.h"
     23#include "DarwinKeyboard.h"
     24
     25/* Global includes */
    2826#import <AppKit/NSEvent.h>
    29 #import <AppKit/NSColor.h>
    30 #import <AppKit/NSFont.h>
    31 
    32 /* For the keyboard stuff */
    3327#include <Carbon/Carbon.h>
    34 #include "DarwinKeyboard.h"
    35 
    36 NativeWindowRef darwinToNativeWindowImpl(NativeViewRef aView)
    37 {
    38     NativeWindowRef window = NULL;
    39     if (aView)
    40         window = [aView window];
    41 
    42     return window;
    43 }
    44 
    45 NativeViewRef darwinToNativeViewImpl(NativeWindowRef aWindow)
    46 {
    47     NativeViewRef view = NULL;
    48     if (aWindow)
    49         view = [aWindow contentView];
    50 
    51     return view;
    52 }
    53 
    54 void darwinSetShowsToolbarButtonImpl(NativeWindowRef aWindow, bool aEnabled)
    55 {
    56     [aWindow setShowsToolbarButton:aEnabled];
    57 }
    58 
    59 void darwinSetShowsResizeIndicatorImpl(NativeWindowRef aWindow, bool aEnabled)
    60 {
    61     [aWindow setShowsResizeIndicator:aEnabled];
    62 }
    63 
    64 void darwinSetHidesAllTitleButtonsImpl(NativeWindowRef aWindow)
    65 {
    66     /* Remove all title buttons by changing the style mask. This method is
    67        available from 10.6 on only. */
    68     if ([aWindow respondsToSelector: @selector(setStyleMask:)])
    69         [aWindow performSelector: @selector(setStyleMask:) withObject: (id)NSTitledWindowMask];
    70     else
    71     {
    72         /* On pre 10.6 disable all the buttons currently displayed. Don't use
    73            setHidden cause this remove the buttons, but didn't release the
    74            place used for the buttons. */
    75         NSButton *pButton = [aWindow standardWindowButton:NSWindowCloseButton];
    76         if (pButton != Nil)
    77             [pButton setEnabled: NO];
    78         pButton = [aWindow standardWindowButton:NSWindowMiniaturizeButton];
    79         if (pButton != Nil)
    80             [pButton setEnabled: NO];
    81         pButton = [aWindow standardWindowButton:NSWindowZoomButton];
    82         if (pButton != Nil)
    83             [pButton setEnabled: NO];
    84         pButton = [aWindow standardWindowButton:NSWindowDocumentIconButton];
    85         if (pButton != Nil)
    86             [pButton setEnabled: NO];
    87     }
    88 }
    89 
    90 void darwinSetShowsWindowTransparentImpl(NativeWindowRef aWindow, bool aEnabled)
    91 {
    92     if (aEnabled)
    93     {
    94         [aWindow setOpaque:NO];
    95         [aWindow setBackgroundColor:[NSColor clearColor]];
    96         [aWindow setHasShadow:NO];
    97     }
    98     else
    99     {
    100         [aWindow setOpaque:YES];
    101         [aWindow setBackgroundColor:[NSColor windowBackgroundColor]];
    102         [aWindow setHasShadow:YES];
    103     }
    104 }
    105 
    106 void darwinSetDockIconMenu(QMenu* pMenu)
    107 {
    108     extern void qt_mac_set_dock_menu(QMenu *);
    109     qt_mac_set_dock_menu(pMenu);
    110 }
    111 
    112 /**
    113  * Calls the + (void)setMouseCoalescingEnabled:(BOOL)flag class method.
    114  *
    115  * @param   fEnabled    Whether to enable or disable coalescing.
    116  */
    117 void darwinSetMouseCoalescingEnabled(bool aEnabled)
    118 {
    119     [NSEvent setMouseCoalescingEnabled:aEnabled];
    120 }
    121 
    122 void darwinWindowAnimateResizeImpl(NativeWindowRef aWindow, int x, int y, int width, int height)
    123 {
    124     /* It seems that Qt doesn't return the height of the window with the
    125      * toolbar height included. So add this size manually. Could easily be that
    126      * the Trolls fix this in the final release. */
    127     NSToolbar *toolbar = [aWindow toolbar];
    128     NSRect windowFrame = [aWindow frame];
    129     int toolbarHeight = 0;
    130     if(toolbar && [toolbar isVisible])
    131         toolbarHeight = NSHeight(windowFrame) - NSHeight([[aWindow contentView] frame]);
    132     int h = height + toolbarHeight;
    133     int h1 = h - NSHeight(windowFrame);
    134     windowFrame.size.height = h;
    135     windowFrame.origin.y -= h1;
    136 
    137     [aWindow setFrame:windowFrame display:YES animate:YES];
    138 }
    139 
    140 void darwinWindowInvalidateShadowImpl(NativeWindowRef aWindow)
    141 {
    142     [aWindow invalidateShadow];
    143 }
    144 
    145 int darwinWindowToolBarHeight(NativeWindowRef aWindow)
    146 {
    147     NSToolbar *toolbar = [aWindow toolbar];
    148     NSRect windowFrame = [aWindow frame];
    149     int toolbarHeight = 0;
    150     int theight = (NSHeight([NSWindow contentRectForFrameRect:[aWindow frame] styleMask:[aWindow styleMask]]) - NSHeight([[aWindow contentView] frame]));
    151     /* toolbar height: */
    152     if(toolbar && [toolbar isVisible])
    153         /* title bar height: */
    154         toolbarHeight = NSHeight(windowFrame) - NSHeight([[aWindow contentView] frame]) - theight;
    155 
    156     return toolbarHeight;
    157 }
    158 
    159 bool darwinIsToolbarVisible(NativeWindowRef pWindow)
    160 {
    161     NSToolbar *pToolbar = [pWindow toolbar];
    162 
    163     return [pToolbar isVisible] == YES;
    164 }
    165 
    166 bool darwinIsWindowMaximized(NativeWindowRef aWindow)
    167 {
    168     bool fResult = [aWindow isZoomed];
    169 
    170     return fResult;
    171 }
    172 
    173 float darwinSmallFontSize()
    174 {
    175     float size = [NSFont systemFontSizeForControlSize: NSSmallControlSize];
    176 
    177     return size;
    178 }
    179 
    180 /* Cocoa event handler which checks if the user right clicked at the unified
    181    toolbar or the title area. */
    182 bool darwinUnifiedToolbarEvents(const void *pvCocoaEvent, const void *pvCarbonEvent, void *pvUser)
    183 {
    184     NSEvent *pEvent = (NSEvent*)pvCocoaEvent;
    185     NSEventType EvtType = [pEvent type];
    186     NSWindow *pWin = ::darwinToNativeWindow((QWidget*)pvUser);
    187     /* First check for the right event type and that we are processing events
    188        from the window which was registered by the user. */
    189     if (   EvtType == NSRightMouseDown
    190         && pWin == [pEvent window])
    191     {
    192         /* Get the mouse position of the event (screen coordinates) */
    193         NSPoint point = [NSEvent mouseLocation];
    194         /* Get the frame rectangle of the window (screen coordinates) */
    195         NSRect winFrame = [pWin frame];
    196         /* Calculate the height of the title and the toolbar */
    197         int i = NSHeight(winFrame) - NSHeight([[pWin contentView] frame]);
    198         /* Based on that height create a rectangle of the unified toolbar + title */
    199         winFrame.origin.y += winFrame.size.height - i;
    200         winFrame.size.height = i;
    201         /* Check if the mouse press event was on the unified toolbar or title */
    202         if (NSMouseInRect(point, winFrame, NO))
    203             /* Create a Qt context menu event, with flipped screen coordinates */
    204             ::darwinCreateContextMenuEvent(pvUser, point.x, NSHeight([[pWin screen] frame]) - point.y);
    205     }
    206     return false;
    207 }
    20828
    20929/**
     
    298118
    299119    return fCarbon;
    300 }
    301 
    302 /**
    303  * Check for some default application key combinations a Mac user expect, like
    304  * CMD+Q or CMD+H.
    305  *
    306  * @returns true if such a key combo was hit, false otherwise.
    307  * @param   pEvent          The Cocoa event.
    308  */
    309 bool darwinIsApplicationCommand(ConstNativeNSEventRef pEvent)
    310 {
    311     NSEventType  eEvtType = [pEvent type];
    312     bool         fGlobalHotkey = false;
    313 
    314     switch (eEvtType)
    315     {
    316         case NSKeyDown:
    317         case NSKeyUp:
    318         {
    319             NSUInteger fEvtMask = [pEvent modifierFlags];
    320             unsigned short KeyCode = [pEvent keyCode];
    321             if (   ((fEvtMask & (NX_NONCOALSESCEDMASK | NX_COMMANDMASK | NX_DEVICELCMDKEYMASK)) == (NX_NONCOALSESCEDMASK | NX_COMMANDMASK | NX_DEVICELCMDKEYMASK))  /* L+CMD */
    322                 || ((fEvtMask & (NX_NONCOALSESCEDMASK | NX_COMMANDMASK | NX_DEVICERCMDKEYMASK)) == (NX_NONCOALSESCEDMASK | NX_COMMANDMASK | NX_DEVICERCMDKEYMASK))) /* R+CMD */
    323             {
    324                 if (   KeyCode == 0x0c  /* CMD+Q (Quit) */
    325                     || KeyCode == 0x04) /* CMD+H (Hide) */
    326                     fGlobalHotkey = true;
    327             }
    328             else if (   ((fEvtMask & (NX_NONCOALSESCEDMASK | NX_ALTERNATEMASK | NX_DEVICELALTKEYMASK | NX_COMMANDMASK | NX_DEVICELCMDKEYMASK)) == (NX_NONCOALSESCEDMASK | NX_ALTERNATEMASK | NX_DEVICELALTKEYMASK | NX_COMMANDMASK | NX_DEVICELCMDKEYMASK)) /* L+ALT+CMD */
    329                      || ((fEvtMask & (NX_NONCOALSESCEDMASK | NX_ALTERNATEMASK | NX_DEVICERCMDKEYMASK | NX_COMMANDMASK | NX_DEVICERCMDKEYMASK)) == (NX_NONCOALSESCEDMASK | NX_ALTERNATEMASK | NX_DEVICERCMDKEYMASK | NX_COMMANDMASK | NX_DEVICERCMDKEYMASK))) /* R+ALT+CMD */
    330             {
    331                 if (KeyCode == 0x04)    /* ALT+CMD+H (Hide-Others) */
    332                     fGlobalHotkey = true;
    333             }
    334             break;
    335         }
    336         default: break;
    337     }
    338     return fGlobalHotkey;
    339120}
    340121
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/DarwinKeyboard.cpp

    r30114 r30122  
    4545
    4646#ifndef USE_HID_FOR_MODIFIERS
    47 # include "VBoxUtils-darwin.h"
     47# include "CocoaEventHelper.h"
    4848#endif
    4949
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxCocoaHelper.h

    r30114 r30122  
    2020#define ___darwin_VBoxCocoaHelper_h
    2121
    22 /* Macro which add a typedef of the given Cocoa class in an appropriate form
    23  * for the current context. This means void* in the C/CPP context and
    24  * NSWhatever* in the ObjC/ObjCPP context. Use
    25  * NativeNSWhateverRef/ConstNativeNSWhateverRef when you reference the Cocoa
    26  * type somewhere. The use of this prevents extensive casting of void* to the
    27  * right type in the Cocoa context. */
    28 #ifdef __OBJC__
    29 #define ADD_COCOA_NATIVE_REF(CocoaClass) \
    30 @class CocoaClass; \
    31 typedef CocoaClass *Native##CocoaClass##Ref; \
    32 typedef const CocoaClass *ConstNative##CocoaClass##Ref
    33 #else /* __OBJC__ */
    34 #define ADD_COCOA_NATIVE_REF(CocoaClass) \
    35 typedef void *Native##CocoaClass##Ref; \
    36 typedef const void *ConstNative##CocoaClass##Ref
    37 #endif /* __OBJC__ */
     22/* Global includes */
     23#include <VBox/VBoxCocoa.h>
    3824
    3925#ifdef __OBJC__
     
    8066}
    8167
    82 /* Helper class for automatic creation & destroying of a cocoa auto release
    83    pool. */
    84 class CocoaAutoreleasePool
    85 {
    86 public:
    87     inline CocoaAutoreleasePool()
    88     {
    89          mPool = [[NSAutoreleasePool alloc] init];
    90     }
    91     inline ~CocoaAutoreleasePool()
    92     {
    93         [mPool release];
    94     }
    95 
    96 private:
    97     NSAutoreleasePool *mPool;
    98 };
    99 
    10068#endif /* __OBJC__ */
    10169
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin.h

    r30114 r30122  
    5252#endif /* __OBJC__ */
    5353
    54 #include "VBoxCocoaHelper.h"
     54#include <VBox/VBoxCocoa.h>
    5555#include <iprt/cdefs.h> /* for RT_C_DECLS_BEGIN/RT_C_DECLS_END & stuff */
    5656#include <QRect>
     
    100100void darwinCreateContextMenuEvent(void *pvWin, int x, int y);
    101101
    102 /********************************************************************************
    103  *
    104  * Event/Keyboard helpers (OS System native)
    105  *
    106  ********************************************************************************/
    107 unsigned long darwinEventModifierFlags(ConstNativeNSEventRef pEvent);
    108 uint32_t darwinEventModifierFlagsXlated(ConstNativeNSEventRef pEvent);
    109102bool darwinIsApplicationCommand(ConstNativeNSEventRef pEvent);
    110 const char *darwinEventTypeName(unsigned long eEvtType);
    111 void darwinPrintEvent(const char *pszPrefix, ConstNativeNSEventRef pEvent);
    112103
    113104RT_C_DECLS_END
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