VirtualBox

Changeset 16610 in vbox for trunk/src


Ignore:
Timestamp:
Feb 10, 2009 12:32:12 AM (16 years ago)
Author:
vboxsync
Message:

Qt/Cocoa: Subclass NSApplication to catch keyboard events passing thru -[NSApplication sendEvent:(NSEvent *)theEvent]. Adopted QIHotKeyEdit to make use of this.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r16469 r16610  
    206206# r=bird: what is -lz doing here? it belongs in LIBS.
    207207VirtualBox_LDFLAGS.darwin = -lz \
    208         -framework IOKit -framework AppKit -framework ApplicationServices -framework Foundation -framework Carbon -framework QuickTime \
     208        -framework IOKit -framework AppKit -framework ApplicationServices -framework Foundation -framework Carbon \
    209209        $(if $(VBOX_WITH_HARDENING),-install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VirtualBox.dylib)
     210VirtualBox_LDFLAGS.darwin.x86 = -framework QuickTime
    210211ifdef VBOX_WITH_ICHAT_THEATER
    211212 VirtualBox_LDFLAGS.darwin += -framework InstantMessage -framework QuartzCore
     
    391392ifdef VBOX_WITH_ICHAT_THEATER
    392393 VirtualBox_SOURCES.darwin += \
    393          src/darwin/VBoxIChatTheaterWrapper.m
    394 endif
     394        src/darwin/VBoxIChatTheaterWrapper.m
     395endif
     396
     397VirtualBox_SOURCES.darwin.amd64 += \
     398        src/darwin/VBoxCocoaApplication.m
    395399
    396400# The Qt modules we're using.
  • trunk/src/VBox/Frontends/VirtualBox/include/QIHotKeyEdit.h

    r16469 r16610  
    2828#include <QMap>
    2929#endif
    30 #if defined (Q_WS_MAC) && !defined (QT_MAC_USE_COCOA)
     30#if defined (Q_WS_MAC)
    3131# include <Carbon/Carbon.h>
    3232#endif
     
    8282#elif defined (Q_WS_X11)
    8383    bool x11Event (XEvent *event);
    84 #elif defined (Q_WS_MAC) && !defined (QT_MAC_USE_COCOA)
    85     static pascal OSStatus darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef,
    86                                                    EventRef inEvent, void *inUserData);
     84#elif defined (Q_WS_MAC)
     85# ifdef QT_MAC_USE_COCOA
     86    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
    8790    bool darwinKeyboardEvent (EventRef inEvent);
    8891#endif
     
    106109#endif
    107110
    108 #if defined (Q_WS_MAC) && !defined (QT_MAC_USE_COCOA)
     111#if defined (Q_WS_MAC)
     112# ifndef QT_MAC_USE_COCOA
    109113    /** Event handler reference. NULL if the handler isn't installed. */
    110114    EventHandlerRef mDarwinEventHandlerRef;
     115# endif
    111116    /** The current modifier key mask. Used to figure out which modifier
    112117     *  key was pressed when we get a kEventRawKeyModifiersChanged event. */
  • trunk/src/VBox/Frontends/VirtualBox/src/QIHotKeyEdit.cpp

    r16471 r16610  
    7171# include "DarwinKeyboard.h"
    7272# include <Carbon/Carbon.h>
     73# ifdef QT_MAC_USE_COCOA
     74#  include "darwin/VBoxCocoaApplication.h"
     75# endif
    7376#endif
    7477
     
    133136
    134137#ifdef Q_WS_MAC
     138    mDarwinKeyModifiers = GetCurrentEventKeyModifiers();
    135139# ifdef QT_MAC_USE_COCOA
    136 /** @todo Carbon -> Cocoa */
     140    ::VBoxCocoaApplication_setCallback(UINT32_MAX, QIHotKeyEdit::darwinEventHandlerProc, this);
    137141# else  /* !QT_MAC_USE_COCOA */
    138     mDarwinKeyModifiers = GetCurrentEventKeyModifiers();
    139 
    140142    EventTypeSpec eventTypes [4];
    141143    eventTypes [0].eventClass = kEventClassKeyboard;
     
    164166    ::DarwinReleaseKeyboard();
    165167# ifdef QT_MAC_USE_COCOA
    166     /** @todo Carbon -> Cocoa */
     168    ::VBoxCocoaApplication_unsetCallback(UINT32_MAX, QIHotKeyEdit::darwinEventHandlerProc, this);
    167169# else
    168170    ::RemoveEventHandler (mDarwinEventHandlerRef);
     
    667669#elif defined (Q_WS_MAC)
    668670# ifdef QT_MAC_USE_COCOA
    669 /** @todo Carbon -> Cocoa */
    670 # else /* !QT_MAC_USE_COCOA */
    671 
     671/* static */
     672bool QIHotKeyEdit::darwinEventHandlerProc (const void *pvCocoaEvent, const void *pvCarbonEvent, void *pvUser)
     673{
     674    QIHotKeyEdit *edit = (QIHotKeyEdit *) pvUser;
     675    EventRef inEvent = (EventRef)pvCarbonEvent;
     676    UInt32 EventClass = ::GetEventClass (inEvent);
     677    if (EventClass == kEventClassKeyboard)
     678        return edit->darwinKeyboardEvent (inEvent);
     679    return false;
     680}
     681
     682# else  /* !QT_MAC_USE_COCOA */
    672683/* static */
    673684pascal OSStatus QIHotKeyEdit::darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef,
     
    683694    return CallNextEventHandler (inHandlerCallRef, inEvent);
    684695}
     696# endif /* !QT_MAC_USE_COCOA */
    685697
    686698bool QIHotKeyEdit::darwinKeyboardEvent (EventRef inEvent)
     
    725737    return false;
    726738}
    727 # endif /* !QT_MAC_USE_COCOA */
    728739
    729740#else
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r15906 r16610  
    2525#include "VBoxSelectorWnd.h"
    2626#include "VBoxConsoleWnd.h"
    27 #ifdef Q_WS_MAC
     27#include "VBoxUtils.h"
     28#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
    2829# include "QIApplication.h"
    29 # include "VBoxUtils.h"
    3030#else
    3131# define QIApplication QApplication
     32#endif
     33#ifdef QT_MAC_USE_COCOA
     34# include "darwin/VBoxCocoaApplication.h"
    3235#endif
    3336
     
    234237    sigaction (SIGBUS, &sa, NULL);
    235238    sigaction (SIGUSR1, &sa, NULL);
     239#endif
     240
     241#ifdef QT_MAC_USE_COCOA
     242    /* Instantiate our NSApplication derivative before QApplication
     243     * forces NSApplication to be instantiated. */
     244    VBoxCocoaApplication_sharedApplication();
    236245#endif
    237246
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