VirtualBox

Ignore:
Timestamp:
Mar 8, 2007 5:13:23 PM (18 years ago)
Author:
vboxsync
Message:

darwin: intercept the events before HI gets them. a bit of a hack because of Qt but otherwise it's the right thing to do.

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

Legend:

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

    r1317 r1339  
    135135VirtualBox_DEFS.debug     = VBOX_GUI_DEBUG VBOX_CHECK_STATE # QT_FATAL_ASSERT
    136136VirtualBox_DEFS.win       = UNICODE QT_DLL
     137VirtualBox_DEFS.darwin    = VBOX_WITH_HACKED_QT
    137138ifeq ($(BUILD_TYPE),release)
    138139 VirtualBox_DEFS.win     += VBOX_GUI_USE_QIMAGE
    139140 VirtualBox_DEFS.linux   += VBOX_GUI_USE_SDL
    140  VirtualBox_DEFS.darwin  += VBOX_GUI_USE_SDL
     141 VirtualBox_DEFS.darwin  += VBOX_GUI_USE_QIMAGE
    141142else
    142143 VirtualBox_DEFS         += VBOX_WITH_DEBUGGER_GUI_MENU
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h

    r1285 r1339  
    239239                                                  WPARAM wParam, LPARAM lParam);
    240240#elif defined (Q_WS_MAC)
     241# ifndef VBOX_WITH_HACKED_QT
    241242    static pascal OSStatus darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef,
    242243                                                   EventRef inEvent, void *inUserData);
     244# else  /* VBOX_WITH_HACKED_QT */
     245    static bool macEventFilter (EventRef inEvent, void *inUserData);
     246# endif /* VBOX_WITH_HACKED_QT */
    243247#endif
    244248
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r1320 r1339  
    8080#if defined (Q_WS_MAC)
    8181# include "DarwinKeyboard.h"
     82# ifdef VBOX_WITH_HACKED_QT
     83#  include "QIApplication.h"
     84# endif
    8285#endif /* defined (Q_WS_MAC) */
    8386
     
    106109#if defined (Q_WS_MAC)
    107110
     111# ifndef VBOX_WITH_HACKED_QT
    108112/**
    109113 *  Event handler callback for Mac OS X.
    110114 */
    111115/* static */
    112 pascal OSStatus VBoxConsoleView::darwinEventHandlerProc(EventHandlerCallRef inHandlerCallRef,
    113                                                         EventRef inEvent, void *inUserData)
     116pascal OSStatus VBoxConsoleView::darwinEventHandlerProc (EventHandlerCallRef inHandlerCallRef,
     117                                                         EventRef inEvent, void *inUserData)
    114118{
    115119    VBoxConsoleView *view = (VBoxConsoleView *)inUserData;
     
    134138    return ::CallNextEventHandler (inHandlerCallRef, inEvent);
    135139}
     140
     141# else /* VBOX_WITH_HACKED_QT */
     142
     143/**
     144 *  Event handler callback for Mac OS X.
     145 */
     146/* static */
     147bool VBoxConsoleView::macEventFilter (EventRef inEvent, void *inUserData)
     148{
     149    VBoxConsoleView *view = (VBoxConsoleView *)inUserData;
     150    UInt32 EventClass = ::GetEventClass (inEvent);
     151    if (EventClass == kEventClassKeyboard)
     152    {
     153        if (view->darwinKeyboardEvent (inEvent))
     154            return true;
     155    }
     156    return false;
     157}
     158# endif /* VBOX_WITH_HACKED_QT */
    136159
    137160#endif /* Q_WS_MAC */
     
    13441367
    13451368/**
    1346  *  Invoked by VBoxConsoleView::darwinEventHandlerProc when it gets a raw keyboard event.
     1369 *  Invoked by VBoxConsoleView::darwinEventHandlerProc / VBoxConsoleView::macEventFilter when
     1370 *  it receives a raw keyboard event.
    13471371 *
    13481372 *  @param inEvent      The keyboard event.
     
    14011425        newMask = ::DarwinAdjustModifierMask (newMask);
    14021426        UInt32 changed = newMask ^ m_darwinKeyModifiers;
     1427        ret = kbd_captured;
    14031428        if (changed)
    14041429        {
     
    14191444                    scanCode &= ~0x80;
    14201445                }
    1421                 keyEvent (keyCode, scanCode, flags);
     1446                ret |= keyEvent (keyCode, scanCode, flags);
    14221447            }
    14231448        }
    14241449
    14251450        m_darwinKeyModifiers = newMask;
    1426 
    1427         ret = kbd_captured; //??
    14281451    }
    14291452
     
    14431466        ::SetMouseCoalescingEnabled (false, NULL);      //??
    14441467        ::CGSetLocalEventsSuppressionInterval (0.0);    //??
     1468
     1469#ifndef VBOX_WITH_HACKED_QT
    14451470
    14461471        EventTypeSpec eventTypes[6];
     
    14541479        eventTypes[3].eventKind  = kEventRawKeyModifiersChanged;
    14551480        /* For ignorning Command-H and Command-Q which aren't affected by the
    1456          * global hotkey stuff: */
     1481         * global hotkey stuff (doesn't work well): */
    14571482        eventTypes[4].eventClass = kEventClassCommand;
    14581483        eventTypes[4].eventKind  = kEventCommandProcess;
     
    14671492        ::DisposeEventHandlerUPP (eventHandler);
    14681493
     1494#else /* VBOX_WITH_HACKED_QT */
     1495        ((QIApplication *)qApp)->setEventFilter (VBoxConsoleView::macEventFilter, this);
     1496#endif /* VBOX_WITH_HACKED_QT */
     1497
    14691498        ::DarwinGrabKeyboard (false);
    14701499    }
     
    14771506            m_darwinEventHandlerRef = NULL;
    14781507        }
     1508#ifdef VBOX_WITH_HACKED_QT
     1509        ((QIApplication *)qApp)->setEventFilter (NULL, NULL);
     1510#endif
    14791511    }
    14801512}
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r967 r1339  
    2424#include "VBoxSelectorWnd.h"
    2525#include "VBoxConsoleWnd.h"
     26#ifdef Q_WS_MAC
     27# include "QIApplication.h"
     28#else
     29# define QIApplication
     30#endif
    2631
    2732#include <qmessagebox.h>
     
    136141    /** @todo automatically start VBoxSVC. */
    137142}
    138 #endif
     143
     144#endif
     145
    139146
    140147int main( int argc, char ** argv )
     
    162169    qInstallMsgHandler (QtMessageOutput);
    163170
    164     QApplication a (argc, argv);
     171    QIApplication a (argc, argv);
    165172
    166173#ifdef Q_WS_X11
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