VirtualBox

Changeset 29816 in vbox for trunk/src


Ignore:
Timestamp:
May 26, 2010 1:52:52 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
62027
Message:

FE/Qt4-OSX: more Carbon cleanup

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxCocoaApplication.h

    r28800 r29816  
    2323# import <AppKit/NSApplication.h>
    2424#endif
    25 #include <Carbon/Carbon.h>
    2625
    2726RT_C_DECLS_BEGIN
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxCocoaApplication.m

    r28800 r29816  
    2424#import <AppKit/NSWindow.h>
    2525#import <AppKit/NSEvent.h>
     26
     27#include <Carbon/Carbon.h>
    2628
    2729#include <stdio.h>
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIHotKeyEdit.cpp

    r28800 r29816  
    143143#ifdef Q_WS_MAC
    144144    mDarwinKeyModifiers = GetCurrentEventKeyModifiers();
    145 # ifdef QT_MAC_USE_COCOA
    146145    ::VBoxCocoaApplication_setCallback (UINT32_MAX, QIHotKeyEdit::darwinEventHandlerProc, this);
    147 # else  /* !QT_MAC_USE_COCOA */
    148     EventTypeSpec eventTypes [4];
    149     eventTypes [0].eventClass = kEventClassKeyboard;
    150     eventTypes [0].eventKind  = kEventRawKeyDown;
    151     eventTypes [1].eventClass = kEventClassKeyboard;
    152     eventTypes [1].eventKind  = kEventRawKeyUp;
    153     eventTypes [2].eventClass = kEventClassKeyboard;
    154     eventTypes [2].eventKind  = kEventRawKeyRepeat;
    155     eventTypes [3].eventClass = kEventClassKeyboard;
    156     eventTypes [3].eventKind  = kEventRawKeyModifiersChanged;
    157 
    158     EventHandlerUPP eventHandler = ::NewEventHandlerUPP (QIHotKeyEdit::darwinEventHandlerProc);
    159 
    160     mDarwinEventHandlerRef = NULL;
    161     ::InstallApplicationEventHandler (eventHandler, RT_ELEMENTS (eventTypes), &eventTypes [0],
    162                                       this, &mDarwinEventHandlerRef);
    163     ::DisposeEventHandlerUPP (eventHandler);
    164 # endif /* !QT_MAC_USE_COCOA */
    165146    ::DarwinGrabKeyboard (false /* just modifiers */);
    166147#endif
     
    171152#ifdef Q_WS_MAC
    172153    ::DarwinReleaseKeyboard();
    173 # ifdef QT_MAC_USE_COCOA
    174154    ::VBoxCocoaApplication_unsetCallback (UINT32_MAX, QIHotKeyEdit::darwinEventHandlerProc, this);
    175 # else
    176     ::RemoveEventHandler (mDarwinEventHandlerRef);
    177     mDarwinEventHandlerRef = NULL;
    178 # endif
    179155#endif
    180156}
  • trunk/src/VBox/Frontends/VirtualBox/src/extensions/QIHotKeyEdit.h

    r28800 r29816  
    2121
    2222#include <QLabel>
    23 #if defined (Q_WS_X11)
    24 #include <QMap>
    25 #endif
    26 #if defined (Q_WS_MAC)
    27 # include <Carbon/Carbon.h>
    28 /* Carbon.h includes AssertMacros.h which defines the macro "check". In
    29  * QItemDelegate a class method is called check also. As we not used the macro
    30  * undefine it here. */
    31 # undef check
     23
     24#ifdef Q_WS_X11
     25# include <QMap>
    3226#endif
    3327
    34 #if defined (Q_WS_PM)
     28#ifdef Q_WS_PM
    3529/* Extra virtual keys returned by QIHotKeyEdit::virtualKey() */
    36 #define VK_LSHIFT   VK_USERFIRST + 0
    37 #define VK_LCTRL    VK_USERFIRST + 1
    38 #define VK_LWIN     VK_USERFIRST + 2
    39 #define VK_RWIN     VK_USERFIRST + 3
    40 #define VK_WINMENU  VK_USERFIRST + 4
    41 #define VK_FORWARD  VK_USERFIRST + 5
    42 #define VK_BACKWARD VK_USERFIRST + 6
     30# define VK_LSHIFT   VK_USERFIRST + 0
     31# define VK_LCTRL    VK_USERFIRST + 1
     32# define VK_LWIN     VK_USERFIRST + 2
     33# define VK_RWIN     VK_USERFIRST + 3
     34# define VK_WINMENU  VK_USERFIRST + 4
     35# define VK_FORWARD  VK_USERFIRST + 5
     36# define VK_BACKWARD VK_USERFIRST + 6
    4337#endif
    4438
     
    6054    QSize minimumSizeHint() const;
    6155
    62 #if defined (Q_WS_PM)
     56#ifdef Q_WS_PM
    6357    static int virtualKey (QMSG *aMsg);
    6458#endif
     
    8377    bool x11Event (XEvent *event);
    8478#elif defined (Q_WS_MAC)
    85 # ifdef QT_MAC_USE_COCOA
    8679    static bool darwinEventHandlerProc (const void *pvCocoaEvent, const void *pvCarbonEvent, void *pvUser);
    87 # else
    88     static pascal OSStatus darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData);
    89 # endif
    9080    bool darwinKeyboardEvent (const void *pvCocoaEvent, EventRef inEvent);
    9181#endif
     
    10999#endif
    110100
    111 #if defined (Q_WS_MAC)
    112 # ifndef QT_MAC_USE_COCOA
    113     /** Event handler reference. NULL if the handler isn't installed. */
    114     EventHandlerRef mDarwinEventHandlerRef;
    115 # endif
     101#ifdef Q_WS_MAC
    116102    /** The current modifier key mask. Used to figure out which modifier
    117103     *  key was pressed when we get a kEventRawKeyModifiersChanged event. */
    118     UInt32 mDarwinKeyModifiers;
     104    uint32_t mDarwinKeyModifiers;
    119105#endif
    120106
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQuartz2D.h

    r28800 r29816  
    2626#include "UIFrameBuffer.h"
    2727
    28 #include <Carbon/Carbon.h>
     28#include <ApplicationServices/ApplicationServices.h>
    2929
    3030/* Local forward declarations */
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachine.cpp

    r29700 r29816  
    3030
    3131#ifdef Q_WS_MAC
    32 # include <Carbon/Carbon.h>
     32# include <ApplicationServices/ApplicationServices.h>
    3333#endif /* Q_WS_MAC */
    3434
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.cpp

    r29773 r29816  
    8282# include "DockIconPreview.h"
    8383# include "DarwinKeyboard.h"
    84 # include "darwin/VBoxCocoaApplication.h"
     84# include "VBoxCocoaApplication.h"
    8585# include <VBox/err.h>
     86# include <Carbon/Carbon.h>
    8687#endif /* Q_WS_MAC */
    8788
     
    11021103                if (mouseEvent(pWheelEvent->type(), pWheelEvent->pos(), pWheelEvent->globalPos(),
    11031104#ifdef QT_MAC_USE_COCOA
    1104                                 /* Qt Cocoa is buggy. It always reports a left button pressed when the
    1105                                  * mouse wheel event occurs. A workaround is to ask the application which
    1106                                  * buttons are pressed currently: */
    1107                                 QApplication::mouseButtons(),
     1105                               /* Qt Cocoa is buggy. It always reports a left button pressed when the
     1106                                * mouse wheel event occurs. A workaround is to ask the application which
     1107                                * buttons are pressed currently: */
     1108                               QApplication::mouseButtons(),
    11081109#else /* QT_MAC_USE_COCOA */
    1109                                 pWheelEvent->buttons(),
    1110 #endif /* QT_MAC_USE_COCOA */
    1111                                 pWheelEvent->modifiers(),
    1112                                 iDelta, pWheelEvent->orientation()))
     1110                               pWheelEvent->buttons(),
     1111#endif /* !QT_MAC_USE_COCOA */
     1112                               pWheelEvent->modifiers(),
     1113                               iDelta, pWheelEvent->orientation()))
    11131114                    return true;
    11141115                break;
     
    23262327
    23272328        /* Register the event callback/hook and grab the keyboard. */
    2328 # ifdef QT_MAC_USE_COCOA
    23292329        ::VBoxCocoaApplication_setCallback (UINT32_MAX, /** @todo fix mask */
    23302330                                            UIMachineView::darwinEventHandlerProc, this);
    23312331
    2332 # else /* QT_MAC_USE_COCOA */
    2333         EventTypeSpec eventTypes[6];
    2334         eventTypes[0].eventClass = kEventClassKeyboard;
    2335         eventTypes[0].eventKind  = kEventRawKeyDown;
    2336         eventTypes[1].eventClass = kEventClassKeyboard;
    2337         eventTypes[1].eventKind  = kEventRawKeyUp;
    2338         eventTypes[2].eventClass = kEventClassKeyboard;
    2339         eventTypes[2].eventKind  = kEventRawKeyRepeat;
    2340         eventTypes[3].eventClass = kEventClassKeyboard;
    2341         eventTypes[3].eventKind  = kEventRawKeyModifiersChanged;
    2342         /* For ignorning Command-H and Command-Q which aren't affected by the
    2343          * global hotkey stuff (doesn't work well): */
    2344         eventTypes[4].eventClass = kEventClassCommand;
    2345         eventTypes[4].eventKind  = kEventCommandProcess;
    2346         eventTypes[5].eventClass = kEventClassCommand;
    2347         eventTypes[5].eventKind  = kEventCommandUpdateStatus;
    2348 
    2349         EventHandlerUPP eventHandler = ::NewEventHandlerUPP(UIMachineView::darwinEventHandlerProc);
    2350 
    2351         m_darwinEventHandlerRef = NULL;
    2352         ::InstallApplicationEventHandler(eventHandler, RT_ELEMENTS (eventTypes), &eventTypes[0],
    2353                                          this, &m_darwinEventHandlerRef);
    2354         ::DisposeEventHandlerUPP(eventHandler);
    2355 # endif /* !QT_MAC_USE_COCOA */
    2356 
    23572332        ::DarwinGrabKeyboard (false);
    23582333    }
     
    23602335    {
    23612336        ::DarwinReleaseKeyboard();
    2362 # ifdef QT_MAC_USE_COCOA
    23632337        ::VBoxCocoaApplication_unsetCallback(UINT32_MAX, /** @todo fix mask */
    23642338                                             UIMachineView::darwinEventHandlerProc, this);
    2365 # else /* QT_MAC_USE_COCOA */
    2366         if (m_darwinEventHandlerRef)
    2367         {
    2368             ::RemoveEventHandler(m_darwinEventHandlerRef);
    2369             m_darwinEventHandlerRef = NULL;
    2370         }
    2371 # endif /* !QT_MAC_USE_COCOA */
    2372     }
    2373 }
    2374 
    2375 # ifdef QT_MAC_USE_COCOA
     2339    }
     2340}
     2341
    23762342bool UIMachineView::darwinEventHandlerProc(const void *pvCocoaEvent, const void *pvCarbonEvent, void *pvUser)
    23772343{
     
    23942360    return false;
    23952361}
    2396 # else /* QT_MAC_USE_COCOA */
    2397 
    2398 pascal OSStatus UIMachineView::darwinEventHandlerProc(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData)
    2399 {
    2400     UIMachineView *view = static_cast<UIMachineView *> (inUserData);
    2401     UInt32 eventClass = ::GetEventClass (inEvent);
    2402 
    2403     /* Not sure but this seems an triggered event if the spotlight searchbar is
    2404      * displayed. So flag that the host key isn't pressed alone. */
    2405     if (eventClass == 'cgs ' && view->m_bIsHostkeyPressed && ::GetEventKind (inEvent) == 0x15)
    2406         view->m_bIsHostkeyAlone = false;
    2407 
    2408     if (eventClass == kEventClassKeyboard)
    2409     {
    2410         if (view->darwinKeyboardEvent (NULL, inEvent))
    2411             return 0;
    2412     }
    2413 
    2414     /*
    2415      * Command-H and Command-Q aren't properly disabled yet, and it's still
    2416      * possible to use the left command key to invoke them when the keyboard
    2417      * is captured. We discard the events these if the keyboard is captured
    2418      * as a half measure to prevent unexpected behaviour. However, we don't
    2419      * get any key down/up events, so these combinations are dead to the guest...
    2420      */
    2421     else if (eventClass == kEventClassCommand)
    2422     {
    2423         if (view->m_bIsKeyboardCaptured)
    2424             return 0;
    2425     }
    2426     return ::CallNextEventHandler(inHandlerCallRef, inEvent);
    2427 }
    2428 # endif /* !QT_MAC_USE_COCOA */
    24292362
    24302363#endif
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineView.h

    r29410 r29816  
    195195    bool darwinKeyboardEvent(const void *pvCocoaEvent, EventRef inEvent);
    196196    void darwinGrabKeyboardEvents(bool fGrab);
    197 # ifdef QT_MAC_USE_COCOA
    198197    static bool darwinEventHandlerProc(const void *pvCocoaEvent, const void *pvCarbonEvent, void *pvUser);
    199 # else /* QT_MAC_USE_COCOA */
    200     static pascal OSStatus darwinEventHandlerProc(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData);
    201 # endif /* !QT_MAC_USE_COCOA */
    202198#endif
    203199
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsHD.h

    r29010 r29816  
    2121
    2222/* Global includes */
     23#include <qglobal.h> /* for Q_WS_MAC */
     24#ifdef Q_WS_MAC
     25/* Somewhere Carbon.h includes AssertMacros.h which defines the macro "check".
     26 * In QItemDelegate a class method is called "check" also. As we not used the
     27 * macro undefine it here. */
     28# undef check
     29#endif /* Q_WS_MAC */
    2330#include <QItemDelegate>
    2431#include <QPointer>
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