VirtualBox

Changeset 71655 in vbox


Ignore:
Timestamp:
Apr 4, 2018 1:27:43 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9049: Large cleanup for CocoaEventHelper stuff.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin
Files:
2 edited

Legend:

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

    r69500 r71655  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - Declarations of utility functions for handling Darwin Cocoa
    4  * specific event handling tasks.
     3 * VBox Qt GUI - Declarations of utility functions for handling Darwin Cocoa specific event-handling tasks.
    54 */
    65
    76/*
    8  * Copyright (C) 2010-2017 Oracle Corporation
     7 * Copyright (C) 2010-2018 Oracle Corporation
    98 *
    109 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2019#define ___CocoaEventHelper_h
    2120
     21/* Other VBox includes: */
     22#include <iprt/cdefs.h>
    2223#include <VBox/VBoxCocoa.h>
    23 #include <iprt/cdefs.h> /* for RT_C_DECLS_BEGIN/RT_C_DECLS_END & stuff */
    2424
     25/* Cocoa declarations: */
    2526ADD_COCOA_NATIVE_REF(NSEvent);
     27
    2628
    2729RT_C_DECLS_BEGIN
    2830
    29 /********************************************************************************
    30  *
    31  * Event/Keyboard helpers (OS System native)
    32  *
    33  ********************************************************************************/
    34 unsigned long darwinEventModifierFlags(ConstNativeNSEventRef pEvent);
     31/** Calls the -(NSUInteger)modifierFlags method on @a pEvent object and converts the flags to carbon style. */
    3532uint32_t darwinEventModifierFlagsXlated(ConstNativeNSEventRef pEvent);
    36 const char *darwinEventTypeName(unsigned long eEvtType);
     33
     34/** Get the name for a Cocoa @a enmEventType. */
     35const char *darwinEventTypeName(unsigned long enmEventType);
     36
     37/** Debug helper function for dumping a Cocoa event to stdout.
     38  * @param   pszPrefix  Brings the message prefix.
     39  * @param   pEvent     Brings the Cocoa event. */
    3740void darwinPrintEvent(const char *pszPrefix, ConstNativeNSEventRef pEvent);
     41
     42/** Posts stripped mouse event based on passed @a pEvent. */
    3843void darwinPostStrippedMouseEvent(ConstNativeNSEventRef pEvent);
    3944
    4045RT_C_DECLS_END
    4146
     47
    4248#endif /* !___CocoaEventHelper_h */
    4349
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/CocoaEventHelper.mm

    r69500 r71655  
    55
    66/*
    7  * Copyright (C) 2009-2017 Oracle Corporation
     7 * Copyright (C) 2009-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 /* Local includes */
     18/* GUI includes: */
    1919#include "CocoaEventHelper.h"
    2020#include "DarwinKeyboard.h"
    2121
    22 /* Global includes */
     22/* External includes: */
    2323#import <Cocoa/Cocoa.h>
    2424#import <AppKit/NSEvent.h>
    2525#include <Carbon/Carbon.h>
    2626
    27 /**
    28  * Calls the -(NSUInteger)modifierFlags method on a NSEvent object.
    29  *
    30  * @return  The Cocoa event modifier mask.
    31  * @param   pEvent          The Cocoa event.
    32  */
    33 unsigned long darwinEventModifierFlags(ConstNativeNSEventRef pEvent)
    34 {
    35     return [pEvent modifierFlags];
    36 }
    37 
    38 /**
    39  * Calls the -(NSUInteger)modifierFlags method on a NSEvent object and
    40  * converts the flags to carbon style.
    41  *
    42  * @return  The Carbon modifier mask.
    43  * @param   pEvent          The Cocoa event.
    44  */
     27
    4528uint32_t darwinEventModifierFlagsXlated(ConstNativeNSEventRef pEvent)
    4629{
    47     NSUInteger  fCocoa = [pEvent modifierFlags];
    48     uint32_t    fCarbon = 0;
     30    NSUInteger fCocoa = [pEvent modifierFlags];
     31    uint32_t fCarbon = 0;
    4932    if (fCocoa)
    5033    {
     
    118101}
    119102
    120 /**
    121  * Get the name for a Cocoa event type.
    122  *
    123  * @returns Read-only name string.
    124  * @param   eEvtType        The Cocoa event type.
    125  */
    126 const char *darwinEventTypeName(unsigned long eEvtType)
    127 {
    128     switch (eEvtType)
     103const char *darwinEventTypeName(unsigned long enmEventType)
     104{
     105    switch (enmEventType)
    129106    {
    130107#define EVT_CASE(nm) case nm: return #nm
     
    166143}
    167144
    168 /**
    169  * Debug helper function for dumping a Cocoa event to stdout.
    170  *
    171  * @param   pszPrefix       Message prefix.
    172  * @param   pEvent          The Cocoa event.
    173  */
    174145void darwinPrintEvent(const char *pszPrefix, ConstNativeNSEventRef pEvent)
    175146{
    176     NSEventType         eEvtType = [pEvent type];
    177     NSUInteger          fEvtMask = [pEvent modifierFlags];
    178     NSWindow           *pEvtWindow = [pEvent window];
    179     NSInteger           iEvtWindow = [pEvent windowNumber];
    180     NSGraphicsContext  *pEvtGraphCtx = [pEvent context];
     147    NSEventType enmEventType = [pEvent type];
     148    NSUInteger fEventMask = [pEvent modifierFlags];
     149    NSWindow *pEventWindow = [pEvent window];
     150    NSInteger iEventWindow = [pEvent windowNumber];
     151    NSGraphicsContext *pEventGraphicsContext = [pEvent context];
    181152
    182153    printf("%s%p: Type=%lu Modifiers=%08lx pWindow=%p #Wnd=%ld pGraphCtx=%p %s\n",
    183            pszPrefix, (void*)pEvent, (unsigned long)eEvtType, (unsigned long)fEvtMask, (void*)pEvtWindow,
    184            (long)iEvtWindow, (void*)pEvtGraphCtx, darwinEventTypeName(eEvtType));
    185 
    186     /* dump type specific into. */
    187     switch (eEvtType)
     154           pszPrefix, (void*)pEvent, (unsigned long)enmEventType, (unsigned long)fEventMask, (void*)pEventWindow,
     155           (long)iEventWindow, (void*)pEventGraphicsContext, darwinEventTypeName(enmEventType));
     156
     157    /* Dump type specific info: */
     158    switch (enmEventType)
    188159    {
    189160        case NSLeftMouseDown:
     
    240211
    241212            printf("    KeyCode=%04x", (int)[pEvent keyCode]);
    242 #define PRINT_MOD(cnst, nm) do { if (fEvtMask & (cnst)) printf(" %s", #nm); } while (0)
     213#define PRINT_MOD(cnst, nm) do { if (fEventMask & (cnst)) printf(" %s", #nm); } while (0)
    243214            /* device-independent: */
    244215            PRINT_MOD(NSAlphaShiftKeyMask, "AlphaShift");
     
    261232#undef  PRINT_MOD
    262233
    263             fOddBits = fEvtMask & ~fOddBits;
     234            fOddBits = fEventMask & ~fOddBits;
    264235            if (fOddBits)
    265236                printf(" fOddBits=%#08lx", (unsigned long)fOddBits);
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