Changeset 71655 in vbox
- Timestamp:
- Apr 4, 2018 1:27:43 PM (7 years ago)
- 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 1 1 /* $Id$ */ 2 2 /** @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. 5 4 */ 6 5 7 6 /* 8 * Copyright (C) 2010-201 7Oracle Corporation7 * Copyright (C) 2010-2018 Oracle Corporation 9 8 * 10 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 19 #define ___CocoaEventHelper_h 21 20 21 /* Other VBox includes: */ 22 #include <iprt/cdefs.h> 22 23 #include <VBox/VBoxCocoa.h> 23 #include <iprt/cdefs.h> /* for RT_C_DECLS_BEGIN/RT_C_DECLS_END & stuff */24 24 25 /* Cocoa declarations: */ 25 26 ADD_COCOA_NATIVE_REF(NSEvent); 27 26 28 27 29 RT_C_DECLS_BEGIN 28 30 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. */ 35 32 uint32_t darwinEventModifierFlagsXlated(ConstNativeNSEventRef pEvent); 36 const char *darwinEventTypeName(unsigned long eEvtType); 33 34 /** Get the name for a Cocoa @a enmEventType. */ 35 const 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. */ 37 40 void darwinPrintEvent(const char *pszPrefix, ConstNativeNSEventRef pEvent); 41 42 /** Posts stripped mouse event based on passed @a pEvent. */ 38 43 void darwinPostStrippedMouseEvent(ConstNativeNSEventRef pEvent); 39 44 40 45 RT_C_DECLS_END 41 46 47 42 48 #endif /* !___CocoaEventHelper_h */ 43 49 -
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/CocoaEventHelper.mm
r69500 r71655 5 5 6 6 /* 7 * Copyright (C) 2009-201 7Oracle Corporation7 * Copyright (C) 2009-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 /* Local includes*/18 /* GUI includes: */ 19 19 #include "CocoaEventHelper.h" 20 20 #include "DarwinKeyboard.h" 21 21 22 /* Global includes*/22 /* External includes: */ 23 23 #import <Cocoa/Cocoa.h> 24 24 #import <AppKit/NSEvent.h> 25 25 #include <Carbon/Carbon.h> 26 26 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 45 28 uint32_t darwinEventModifierFlagsXlated(ConstNativeNSEventRef pEvent) 46 29 { 47 NSUInteger fCocoa= [pEvent modifierFlags];48 uint32_t 30 NSUInteger fCocoa = [pEvent modifierFlags]; 31 uint32_t fCarbon = 0; 49 32 if (fCocoa) 50 33 { … … 118 101 } 119 102 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) 103 const char *darwinEventTypeName(unsigned long enmEventType) 104 { 105 switch (enmEventType) 129 106 { 130 107 #define EVT_CASE(nm) case nm: return #nm … … 166 143 } 167 144 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 */174 145 void darwinPrintEvent(const char *pszPrefix, ConstNativeNSEventRef pEvent) 175 146 { 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]; 181 152 182 153 printf("%s%p: Type=%lu Modifiers=%08lx pWindow=%p #Wnd=%ld pGraphCtx=%p %s\n", 183 pszPrefix, (void*)pEvent, (unsigned long)e EvtType, (unsigned long)fEvtMask, (void*)pEvtWindow,184 (long)iEv tWindow, (void*)pEvtGraphCtx, darwinEventTypeName(eEvtType));185 186 /* dump type specific into.*/187 switch (e EvtType)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) 188 159 { 189 160 case NSLeftMouseDown: … … 240 211 241 212 printf(" KeyCode=%04x", (int)[pEvent keyCode]); 242 #define PRINT_MOD(cnst, nm) do { if (fEv tMask & (cnst)) printf(" %s", #nm); } while (0)213 #define PRINT_MOD(cnst, nm) do { if (fEventMask & (cnst)) printf(" %s", #nm); } while (0) 243 214 /* device-independent: */ 244 215 PRINT_MOD(NSAlphaShiftKeyMask, "AlphaShift"); … … 261 232 #undef PRINT_MOD 262 233 263 fOddBits = fEv tMask & ~fOddBits;234 fOddBits = fEventMask & ~fOddBits; 264 235 if (fOddBits) 265 236 printf(" fOddBits=%#08lx", (unsigned long)fOddBits);
Note:
See TracChangeset
for help on using the changeset viewer.