17 #include <Cocoa/Cocoa.h>
28 @interface FakeCrossingEvent : NSEvent {
29 NSWindow *fQuartzWindow;
30 NSPoint fLocationInWindow;
35 @implementation FakeCrossingEvent
38 - (
id) initWithWindow : (NSWindow *) window location : (NSPoint) location
41 assert(window &&
"initWithWindow:location:, parameter 'window' is nil");
43 if (
self = [super
init]) {
45 fLocationInWindow = location;
54 assert(fQuartzWindow &&
"window, fQuartzWindow is nil");
59 - (NSPoint) locationInWindow
61 assert(fQuartzWindow != nil &&
"locationInWindow, fQuartzWindow is nil");
62 return fLocationInWindow;
66 - (NSTimeInterval) timestamp
83 template<
typename T1,
typename T2>
90 return fFirst < rhs.fFirst;
99 assert(buf != 0 &&
"MapUnicharToKeySym, parameter 'buf' is null");
104 static const KeySymPair<unichar, EKeySym> keyMap[] = {
112 {NSUpArrowFunctionKey,
kKey_Up},
162 const unsigned nEntries =
sizeof keyMap /
sizeof keyMap[0];
166 KeySymPair<unichar, EKeySym> valueToFind = {};
167 valueToFind.fFirst = key;
168 const KeySymPair<unichar, EKeySym> *
iter = std::lower_bound(keyMap, keyMap + nEntries, valueToFind);
170 if (iter != keyMap + nEntries && iter->fFirst == key) {
171 buf[0] = key <= 0x7e ? key : 0;
172 rootKeySym = iter->fSecond;
183 if (keySym >= 0x20 && keySym <= 0x7e)
186 static const KeySymPair<EKeySym, unichar> keyMap[] = {
201 {
kKey_Up, NSUpArrowFunctionKey},
251 const unsigned nEntries =
sizeof keyMap /
sizeof keyMap[0];
253 KeySymPair<EKeySym, unichar> valueToFind = {};
254 valueToFind.fFirst =
static_cast<EKeySym>(keySym);
255 const KeySymPair<EKeySym, unichar> *
iter = std::lower_bound(keyMap, keyMap + nEntries, valueToFind);
256 if (iter != keyMap + nEntries && iter->fFirst == keySym)
257 return iter->fSecond;
265 NSUInteger cocoaModifiers = 0;
268 cocoaModifiers |= NSAlphaShiftKeyMask;
270 cocoaModifiers |= NSShiftKeyMask;
272 cocoaModifiers |= NSControlKeyMask;
274 cocoaModifiers |= NSAlternateKeyMask;
276 cocoaModifiers |= NSCommandKeyMask;
278 return cocoaModifiers;
284 const NSUInteger modifiers = [NSEvent modifierFlags];
287 if (modifiers & NSAlphaShiftKeyMask)
289 if (modifiers & NSShiftKeyMask)
291 if (modifiers & NSControlKeyMask)
293 if (modifiers & NSAlternateKeyMask)
295 if (modifiers & NSCommandKeyMask)
298 return rootModifiers;
305 const NSUInteger buttons = [NSEvent pressedMouseButtons];
310 if (buttons & (1 << 2))
313 return rootModifiers;
318 #pragma mark - Several aux. functions to extract parameters from Cocoa events.
324 assert(theEvent != nil &&
"TimeForCocoaEvent, parameter 'theEvent' is nil");
326 return [theEvent timestamp] * 1000;
334 assert(theEvent != nil &&
"NewX11EventFromCocoaEvent, parameter 'theEvent' is nil");
348 assert(cocoaEvent != nil &&
"ConvertEventLocationToROOTXY, parameter 'cocoaEvent' is nil");
349 assert(eventView != nil &&
"ConvertEventLocationToROOTXY, parameter 'eventView' is nil");
350 assert(rootEvent != 0 &&
"ConvertEventLocationToROOTXY, parameter 'rootEvent' is null");
354 NSLog(
@"Error in ConvertEventLocationToROOTXY, window property"
355 " of event is nil, can not convert coordinates correctly");
362 const NSPoint viewPoint = [eventView convertPoint : winPoint fromView : nil];
364 rootEvent->
fX = viewPoint.x;
365 rootEvent->
fY = viewPoint.y;
374 assert(theEvent != nil &&
"GetKeyboardModifiersFromCocoaEvent, parameter 'event' is nil");
376 const NSUInteger modifiers = [theEvent modifierFlags];
377 unsigned rootModifiers = 0;
378 if (modifiers & NSAlphaShiftKeyMask)
380 if (modifiers & NSShiftKeyMask)
382 if (modifiers & NSControlKeyMask)
384 if (modifiers & NSAlternateKeyMask)
386 if (modifiers & NSCommandKeyMask)
389 return rootModifiers;
395 assert(theEvent != nil &&
"GetModifiersFromCocoaEvent, parameter 'event' is nil");
398 const NSUInteger buttons = [NSEvent pressedMouseButtons];
403 if (buttons & (1 << 2))
406 return rootModifiers;
409 #pragma mark - Misc. aux. functions.
412 bool IsParent(NSView<X11Window> *testParent, NSView<X11Window> *testChild)
414 assert(testParent != nil &&
"IsParent, parameter 'testParent' is nil");
415 assert(testChild != nil &&
"IsParent, parameter 'testChild' is nil");
417 if (testChild.fParentView) {
418 NSView<X11Window> *parent = testChild.fParentView;
420 if(parent == testParent)
422 parent = parent.fParentView;
430 bool IsInBranch(NSView<X11Window> *parent, NSView<X11Window> *child, NSView<X11Window> *testView)
432 assert(child != nil &&
"IsInBranch, parameter 'child' is nil");
433 assert(testView != nil &&
"IsInBranch, parameter 'testView' is nil");
435 if (testView == child || testView == parent)
456 NSView<X11Window> **lca)
462 assert(view1 != nil &&
"FindLowestCommonAncestor, parameter 'view1' is nil");
463 assert(view2 != nil &&
"findLowestCommonAncestor, parameter 'view2' is nil");
464 assert(lca != 0 &&
"FindLowestCommonAncestor, parameter 'lca' is null");
466 if (!view1.fParentView)
469 if (!view2.fParentView)
472 NSView<X11Window> *
const ancestor = (NSView<X11Window> *)[view1 ancestorSharedWithView : view2];
485 assert(view1 != nil &&
"FindRelation, view1 parameter is nil");
486 assert(view2 != nil &&
"FindRelation, view2 parameter is nil");
487 assert(lca != 0 &&
"FindRelation, lca parameter is nil");
502 assert(viewFrom != nil &&
"FindViewToPropagateEvent, parameter 'view' is nil");
504 if (viewFrom.fEventMask & checkMask)
507 for (viewFrom = viewFrom.fParentView; viewFrom; viewFrom = viewFrom.fParentView) {
508 if (viewFrom.fEventMask & checkMask)
517 NSView<X11Window> *grabView,
Mask_t grabMask)
524 assert(viewFrom != nil &&
"FindViewToPropagateEvent, parameter 'view' is nil");
526 if (viewFrom.fEventMask & checkMask)
529 for (viewFrom = viewFrom.fParentView; viewFrom; viewFrom = viewFrom.fParentView) {
530 if (viewFrom.fEventMask & checkMask)
534 if (grabView && (grabMask & checkMask))
540 #pragma mark - Aux. 'low-level' functions to generate events and call HandleEvent for a root window.
551 assert(view != nil &&
"SendEnterEvent, parameter 'view' is nil");
552 assert(theEvent != nil &&
"SendEnterEvent, parameter 'event' is nil");
553 assert(view.fID != 0 &&
"SendEnterEvent, view.fID is 0");
557 #ifdef DEBUG_ROOT_COCOA
558 NSLog(
@"SendEnterEvent, ROOT's widget %u was not found", view.fID);
565 enterEvent.
fCode = detail;
574 queue.push_back(enterEvent);
586 assert(view != nil &&
"SendLeaveEvent, parameter 'view' is nil");
587 assert(theEvent != nil &&
"SendLeaveEvent, parameter 'event' is nil");
588 assert(view.fID != 0 &&
"SendLeaveEvent, view.fID is 0");
592 #ifdef DEBUG_ROOT_COCOA
593 NSLog(
@"SendLeaveEvent, ROOT's widget %u was not found", view.fID);
600 leaveEvent.
fCode = detail;
606 queue.push_back(leaveEvent);
617 assert(view != nil &&
"SendPointerMotionEvent, parameter 'view' is nil");
618 assert(theEvent != nil &&
"SendPointerMotionEvent, parameter 'event' is nil");
619 assert(view.fID != 0 &&
"SendPointerMotionEvent, view.fID is 0");
623 #ifdef DEBUG_ROOT_COCOA
624 NSLog(
@"SendPointerMotionEvent, ROOT's widget %u was not found", view.fID);
635 queue.push_back(motionEvent);
648 assert(view != nil &&
"SendButtonPressEvent, parameter 'view' is nil");
649 assert(theEvent != nil &&
"SendButtonPressEvent, parameter 'event' is nil");
650 assert(view.fID != 0 &&
"SendButtonPressEvent, view.fID is 0");
654 #ifdef DEBUG_ROOT_COCOA
655 NSLog(
@"SendButtonpressEvent, ROOT's widget %u was not found", view.fID);
662 pressEvent.
fCode = btn;
674 NSPoint viewPoint = {};
675 viewPoint.x = pressEvent.
fX;
676 viewPoint.y = pressEvent.
fY;
677 for (NSView<X11Window> *child in [view subviews]) {
678 if (!child.fIsOverlapped && [child hitTest : viewPoint]) {
679 pressEvent.
fUser[0] = child.fID;
685 queue.push_back(pressEvent);
697 assert(view != nil &&
"SendButtonReleaseEvent, parameter 'view' is nil");
698 assert(theEvent != nil &&
"SendButtonReleaseEvent, parameter 'event' is nil");
699 assert(view.fID != 0 &&
"SendButtonReleaseEvent, view.fID is 0");
703 #ifdef DEBUG_ROOT_COCOA
704 NSLog(
@"SendButtonReleaseEvent, ROOT's widget %u was not found", view.fID);
711 releaseEvent.
fCode = btn;
716 queue.push_back(releaseEvent);
721 NSEvent *theEvent, NSPoint windowPoint)
723 assert(view != nil &&
"SendKeyPressEvent, parameter 'view' is nil");
724 assert(theEvent != nil &&
"SendKeyPressEvent, parameter 'event' is nil");
725 assert(view.fID != 0 &&
"SendKeyPressEvent, view.fID is 0");
729 #ifdef DEBUG_ROOT_COCOA
730 NSLog(
@"SendKeyPressEvent, ROOT's widget %u was not found", view.fID);
739 NSString *
const characters = [theEvent charactersIgnoringModifiers];
740 assert(characters != nil &&
"SendKeyPressEvent, [theEvent characters] returned nil");
741 assert([characters
length] > 0 &&
"SendKeyPressEvent, characters is an empty string");
743 keyPressEvent.
fCode = [characters characterAtIndex : 0];
747 const NSPoint viewPoint = [view convertPoint : windowPoint fromView : nil];
750 keyPressEvent.
fX = viewPoint.x;
751 keyPressEvent.
fY = viewPoint.y;
753 keyPressEvent.
fXRoot = screenPoint.x;
754 keyPressEvent.
fYRoot = screenPoint.y;
757 keyPressEvent.
fUser[0] = childView.fID;
760 queue.push_back(keyPressEvent);
765 NSEvent *theEvent, NSPoint windowPoint)
767 assert(view != nil &&
"SendKeyReleaseEvent, parameter 'view' is nil");
768 assert(theEvent != nil &&
"SendKeyReleaseEvent, parameter 'event' is nil");
769 assert(view.fID != 0 &&
"SendKeyReleaseEvent, view.fID is 0");
773 #ifdef DEBUG_ROOT_COCOA
774 NSLog(
@"SendKeyPressEvent, ROOT's widget %u was not found", view.fID);
784 NSString *
const characters = [theEvent charactersIgnoringModifiers];
785 assert(characters != nil &&
"SendKeyReleaseEvent, [theEvent characters] returned nil");
786 assert([characters
length] > 0 &&
"SendKeyReleaseEvent, characters is an empty string");
787 keyReleaseEvent.
fCode = [characters characterAtIndex : 0];
790 const NSPoint viewPoint = [view convertPoint : windowPoint fromView : nil];
791 keyReleaseEvent.
fX = viewPoint.x;
792 keyReleaseEvent.
fY = viewPoint.y;
795 keyReleaseEvent.
fXRoot = screenPoint.x;
796 keyReleaseEvent.
fYRoot = screenPoint.y;
800 keyReleaseEvent.
fUser[0] = childView.fID;
803 queue.push_back(keyReleaseEvent);
810 assert(view != nil &&
"SendFocusInEvent, parameter 'view' is nil");
814 #ifdef DEBUG_ROOT_COCOA
815 NSLog(
@"SendFocusInEvent, ROOT's widget %u was not found", view.fID);
821 focusInEvent.
fWindow = view.fID;
823 focusInEvent.
fCode = mode;
825 queue.push_back(focusInEvent);
831 assert(view != nil &&
"SendFocusOutEvent, parameter 'view' is nil");
835 #ifdef DEBUG_ROOT_COCOA
836 NSLog(
@"SendFocusOutEvent, ROOT's widget %u was not found", view.fID);
842 focusOutEvent.
fWindow = view.fID;
844 focusOutEvent.
fCode = mode;
846 queue.push_back(focusOutEvent);
849 #pragma mark - Aux. functions to send events to view's branch.
853 NSEvent *theEvent,
EXMagic mode)
856 assert(from != nil &&
"SendEnterEventRange, 'from' parameter is nil");
857 assert(to != nil &&
"SendEnterEventRange, 'to' parameter is nil");
858 assert(theEvent != nil &&
"SendEnterEventRange, event parameter is nil");
863 from = from.fParentView;
869 NSEvent *theEvent,
EXMagic mode)
872 assert(from != nil &&
"SendEnterEventClosedRange, 'from' parameter is nil");
873 assert(to != nil &&
"SendEnterEventClosedRange, 'to' parameter is nil");
874 assert(theEvent != nil &&
"SendEnterEventClosedRange, event parameter is nil");
883 NSEvent *theEvent,
EXMagic mode)
886 assert(from != nil &&
"SendLeaveEventRange, 'from' parameter is nil");
887 assert(to != nil &&
"SendLeaveEventRange, 'to' parameter is nil");
888 assert(theEvent != nil &&
"SendLeaveEventRange, event parameter is nil");
893 from = from.fParentView;
899 NSEvent *theEvent,
EXMagic mode)
902 assert(from != nil &&
"SendLeaveEventClosedRange, 'from' parameter is nil");
903 assert(to != nil &&
"SendLeaveEventClosedRange, 'to' parameter is nil");
904 assert(theEvent != nil &&
"SendLeaveEventClosedRange, event parameter is nil");
911 #pragma mark - Top-level crossing event generators.
918 NSEvent *theEvent,
EXMagic detail)
927 assert(parent != nil &&
"GenerateCrossingEventChildToParent, parameter 'parent' is nil");
928 assert(child != nil &&
"GenerateCrossingEventChildToParent, parameter 'child' is nil");
929 assert(theEvent != nil &&
"GenerateCrossingEventChildToParent, parameter 'event' is nil");
930 assert(child.fParentView != nil &&
931 "GenerateCrossingEventChildToParent, parameter 'child' must have QuartzView* parent");
948 NSEvent *theEvent,
EXMagic detail)
958 assert(parent != nil &&
"GenerateCrossingEventParentToChild, parameter 'parent' is nil");
959 assert(child != nil &&
"GenerateCrossingEventParentToChild, parameter 'child' is nil");
960 assert(theEvent != nil &&
"GenerateCrossingEventParentToChild, parameter 'event' is nil");
961 assert(child.fParentView != nil &&
962 "GenerateCrossingEventParentToChild, parameter 'child' must have QuartzView* parent");
979 NSView<X11Window> *ancestor, NSEvent *theEvent,
EXMagic detail)
987 assert(child1 != nil &&
"GenerateCrossingEventFromChild1ToChild2, parameter 'child1' is nil");
988 assert(child2 != nil &&
"GenerateCrossingEventFromChild1ToChild2, child2 parameter is nil");
989 assert(theEvent != nil &&
"GenerateCrossingEventFromChild1ToChild2, theEvent parameter is nil");
999 if (child1.fParentView)
1001 (NSView<X11Window> *)[[child1
window] contentView], theEvent, detail);
1002 if (child2.fParentView)
1004 (NSView<X11Window> *)[[child2
window] contentView], theEvent, detail);
1006 if (child1.fParentView)
1008 if (child2.fParentView)
1019 NSEvent *theEvent,
EXMagic detail)
1024 assert(theEvent != nil &&
"GenerateCrossingEvent, event parameter is nil");
1026 if (fromView == toView) {
1043 }
else if (!toView) {
1048 NSView<X11Window> *ancestor = 0;
1090 NSView<X11Window> *grabView,
Mask_t grabEventMask, NSEvent *theEvent)
1095 assert(theEvent != nil &&
"GenerateCrossingEventForGrabView, parameter 'event' is nil");
1096 assert(grabView != nil &&
"GenerateCrossingEventForGrabView, parameter 'grabView' is nil");
1097 assert((fromView != nil || toView != nil) &&
1098 "GenerateCrossingEventForGrabView, both 'toView' and 'fromView' parameters are nil");
1100 if (fromView == toView)
1106 if (fromView == grabView && wantsLeave)
1109 if (toView == grabView && wantsEnter)
1115 if (wantsEnter &&
IsParent(grabView, toView))
1117 }
else if (!toView) {
1119 if (wantsLeave &&
IsParent(grabView, fromView))
1122 NSView<X11Window> *ancestor = 0;
1128 }
else if (
IsInBranch(nil, toView, grabView)) {
1139 : fViewUnderPointer(nil),
1143 fButtonGrabView(nil),
1154 assert(view != nil &&
"GenerateConfigureNotifyEvent, parameter 'view' is nil");
1160 newEvent.
fX = newFrame.origin.x;
1161 newEvent.
fY = newFrame.origin.y;
1164 newEvent.
fWidth = newFrame.size.width;
1165 newEvent.
fHeight = newFrame.size.height;
1168 assert(window != 0 &&
"GenerateConfigureNotifyEvent, window was not found");
1181 assert(view != nil &&
"GenerateExposeEvent, parameter 'view' is nil");
1184 exposeEvent.
fWindow = view.fID;
1186 exposeEvent.
fX = exposedRect.origin.x;
1187 exposeEvent.
fY = exposedRect.origin.y;
1188 exposeEvent.
fWidth = exposedRect.size.width;
1189 exposeEvent.
fHeight = exposedRect.size.height;
1192 assert(window != 0 &&
"GenerateExposeEvent, window was not found");
1201 assert(theEvent != nil &&
"GenerateCrossingEvent, parameter 'event' is nil");
1210 assert(theEvent &&
"GenerateCrossingEventNoGrab, parameter 'theEvent' is nil");
1221 assert(theEvent != nil &&
"GenerateCrossingEventActiveGrab, parameter 'theEvent' is nil");
1252 assert(theEvent != nil &&
"GeneratePointerMotionEvent, parameter 'theEvent' is nil");
1266 assert(eventView != nil &&
"GenerateButtonPressEvent, parameter 'eventView' is nil");
1267 assert(theEvent != nil &&
"GenerateButtonpressEvent, parameter 'theEvent' is nil");
1279 assert(eventView != nil &&
"GenerateButtonReleaseEvent, parameter 'eventView' is nil");
1280 assert(theEvent != nil &&
"GenerateButtonReleaseEvent, parameter 'theEvent' is nil");
1293 assert(eventView != nil &&
"GenerateKeyPressEvent, parameter 'eventView' is nil");
1294 assert(theEvent != nil &&
"GenerateKeyPressEvent, parameter 'theEvent' is nil");
1296 if (![[theEvent charactersIgnoringModifiers]
length])
1309 assert(eventView != nil &&
"GenerateKeyReleaseEvent, parameter 'eventView' is nil");
1310 assert(theEvent != nil &&
"GenerateKeyReleaseEvent, parameter 'theEvent' is nil");
1312 if (![[theEvent charactersIgnoringModifiers]
length])
1347 assert(grabView != nil &&
"SetPointerGrab, parameter 'grabView' is nil");
1370 const NSPoint location = [[grabView window] mouseLocationOutsideOfEventStream];
1372 location : location]);
1375 NSLog(
@"EventTranslator::SetPointerGrab, crossing event initialization failed");
1383 [
fButtonGrabView activateGrab : eventMask ownerEvents : fOwnerEvents];
1396 const NSPoint location = [[candidateView window] mouseLocationOutsideOfEventStream];
1398 location : location ]);
1402 NSLog(
@"EventTranslator::CancelPointerGrab, crossing event initialization failed");
1415 location : location ]);
1419 NSLog(
@"EventTranslator::CancelPointerGrab, crossing event initialization failed");
1465 void ClearPointerIfViewIsRelated(NSView<X11Window> *&
view,
Window_t winID)
1467 NSView<X11Window> *
v =
view;
1469 for (;
v; v = v.fParentView) {
1470 if (v.fID == winID) {
1491 if (view.fID == winID) {
1500 if (view.fID == winID) {
1501 NSPoint location = {};
1508 location : location]);
1511 NSLog(
@"EventTranslator::CheckUnmappedView, crossing event initialization failed");
1523 ClearPointerIfViewIsRelated(
fFocusView, winID);
1531 assert(theEvent != nil &&
"GeneratePointerMotionEventNoGrab, parameter 'theEvent' is nil");
1533 const Mask_t maskToTest = [NSEvent pressedMouseButtons] ?
1560 assert(theEvent != nil &&
"GeneratePointerMotionEventActiveGrab, parameter 'theEvent' is nil");
1562 const Mask_t maskToTest = [NSEvent pressedMouseButtons] ?
1594 assert(view != nil &&
"GenerateButtonPressEventNoGrab, parameter 'view' is nil");
1595 assert(theEvent != nil &&
"GenerateButtonPressEventNoGrab, parameter 'theEvent' is nil");
1629 assert(theEvent != nil &&
"GenerateButtonPressEventActiveGrab, parameter 'theEvent' is nil");
1661 assert(eventView != nil &&
"GenerateButtonReleaseEventNoGrab, parameter 'eventView' is nil");
1662 assert(theEvent != nil &&
"GenerateButtonReleaseEventNoGrabm parameter 'theEvent' is nil");
1674 assert(eventView != nil &&
"GenerateButtonReleaseEventActiveGrab, parameter 'eventView' is nil");
1675 assert(theEvent != nil &&
"GenerateButtonReleaseEventActiveGrab, parameter 'theEvent' is nil");
1715 assert(eventView != nil &&
"GenerateKeyPressEventNoGrab, parameter 'eventView' is nil");
1716 assert(theEvent != nil &&
"GenerateKeyPressEventNoGrab, parameter 'theEvent' is nil");
1717 assert(
fFocusView != nil &&
"GenerateKeyPressEventNoGrab, fFocusView is nil");
1722 NSView<X11Window> *candidateView =
fFocusView;
1728 candidateView = testView;
1740 assert(eventView != nil &&
"GenerateKeyEventActiveGrab, parameter 'eventView' is nil");
1741 assert(theEvent != nil &&
"GenerateKeyEventActiveGrab, parameter 'theEvent' is nil");
1742 assert(
fFocusView != nil &&
"GenerateKeyEventActiveGrab, fFocusView is nil");
1774 assert(eventView != nil &&
"GenerateKeyReleaseEventNoGrab, parameter 'eventView' is nil");
1775 assert(theEvent != nil &&
"GenerateKeyReleaseEventNoGrab, parameter 'theEvent' is nil");
1777 NSView<X11Window> *candidateView =
fFocusView;
1782 candidateView = testView;
1793 assert(view != nil &&
"GenerateKeyEventForView, parameter 'view' is nil");
1794 assert(theEvent != nil &&
"GenerateKeyEventForView, parameter 'theEvent' is nil");
1795 assert(theEvent.type == NSKeyDown || theEvent.type == NSKeyUp &&
1796 "GenerateKeyEvenForView, event's type must be keydown or keyup");
1801 NSView<X11Window> *childView = nil;
1803 NSPoint mousePosition = {};
1805 mousePosition = [topLevel mouseLocationOutsideOfEventStream];
1818 assert(fromView != nil &&
"FindButtonGrabView, parameter 'fromView' is nil");
1819 assert(theEvent != nil &&
"FindButtonGrabView, parameter 'theEvent' is nil");
1825 NSView<X11Window> *grabView = 0;
1826 NSView<X11Window> *buttonPressView = 0;
1828 for (NSView<X11Window> *view = fromView; view != nil; view = view.fParentView) {
1831 buttonPressView =
view;
1834 if (view.fPassiveGrabButton ==
kAnyButton || view.fPassiveGrabButton == btn) {
1836 if (view.fPassiveGrabKeyModifiers ==
kAnyModifier || (view.fPassiveGrabKeyModifiers & keyModifiers))
1846 }
else if (buttonPressView) {
1864 assert(eventView != nil &&
"FindKeyGrabView, parameter 'eventView' is nil");
1865 assert(theEvent != nil &&
"FindKeyGrabView, parameter 'theEvent' is nil");
1867 NSString *
const characters = [theEvent charactersIgnoringModifiers];
1868 assert(characters != nil &&
"FindKeyGrabView, [theEvent characters] returned nil");
1869 assert([characters
length] > 0 &&
"FindKeyGrabView, characters is an empty string");
1871 const unichar keyCode = [characters characterAtIndex : 0];
1872 const NSUInteger modifiers = [theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask;
1876 currentView = eventView;
1878 for (; currentView; currentView = currentView.fParentView) {
1879 if ([currentView findPassiveKeyGrab : keyCode modifiers : modifiers])
NSUInteger GetCocoaKeyModifiersFromROOTKeyModifiers(UInt_t rootKeyModifiers)
void GenerateCrossingEventForGrabView(EventQueue_t &queue, NSView< X11Window > *fromView, NSView< X11Window > *toView, NSView< X11Window > *grabView, Mask_t grabEventMask, NSEvent *theEvent)
const Mask_t kKeyReleaseMask
int GlobalXCocoaToROOT(CGFloat xCocoa)
void SendLeaveEvent(EventQueue_t &queue, NSView< X11Window > *view, NSEvent *theEvent, EXMagic detail)
void GenerateCrossingEventParentToChild(EventQueue_t &queue, NSView< X11Window > *parent, NSView< X11Window > *child, NSEvent *theEvent, EXMagic detail)
void GenerateConfigureNotifyEvent(NSView< X11Window > *view, const NSRect &newFrame)
void GeneratePointerMotionEventActiveGrab(NSEvent *theEvent)
Bool_t operator<(const TDatime &d1, const TDatime &d2)
NSView< X11Window > * FindViewForPointerEvent(NSEvent *pointerEvent)
void SendFocusOutEvent(EventQueue_t &queue, NSView< X11Window > *view, EXMagic mode)
void GeneratePointerMotionEvent(NSEvent *theEvent)
const Mask_t kButton2Mask
Int_t MapKeySymToKeyCode(Int_t keySym)
const Mask_t kKeyMod2Mask
const Mask_t kKeyShiftMask
Ancestry FindRelation(NSView< X11Window > *view1, NSView< X11Window > *view2, NSView< X11Window > **lca)
const Mask_t kKeyMod1Mask
void GenerateKeyReleaseEvent(NSView< X11Window > *eventView, NSEvent *theEvent)
const Mask_t kButtonMotionMask
const Mask_t kLeaveWindowMask
void SendLeaveEventClosedRange(EventQueue_t &queue, NSView< X11Window > *from, NSView< X11Window > *to, NSEvent *theEvent, EXMagic mode)
void MapUnicharToKeySym(unichar key, char *buf, Int_t len, UInt_t &rootKeySym)
NSView< X11Window > * FindViewToPropagateEvent(NSView< X11Window > *viewFrom, Mask_t checkMask)
unsigned GetKeyboardModifiersFromCocoaEvent(NSEvent *theEvent)
void GenerateButtonReleaseEventActiveGrab(NSView< X11Window > *eventView, NSEvent *theEvent, EMouseButton btn)
std::deque< Event_t > EventQueue_t
void GenerateKeyPressEventNoGrab(NSView< X11Window > *eventView, NSEvent *theEvent)
void FindKeyGrabView(NSView< X11Window > *eventView, NSEvent *theEvent)
NSView< X11Window > * fButtonGrabView
void GenerateButtonPressEvent(NSView< X11Window > *eventView, NSEvent *theEvent, EMouseButton btn)
void SendButtonPressEvent(EventQueue_t &queue, NSView< X11Window > *view, NSEvent *theEvent, EMouseButton btn)
void GenerateCrossingEventFromChild1ToChild2(EventQueue_t &queue, NSView< X11Window > *child1, NSView< X11Window > *child2, NSView< X11Window > *ancestor, NSEvent *theEvent, EXMagic detail)
const Mask_t kPointerMotionMask
NSView< X11Window > * fFocusView
void GenerateButtonReleaseEventNoGrab(NSView< X11Window > *eventView, NSEvent *theEvent, EMouseButton btn)
void GenerateCrossingEventChildToParent(EventQueue_t &queue, NSView< X11Window > *parent, NSView< X11Window > *child, NSEvent *theEvent, EXMagic detail)
void SendPointerMotionEvent(EventQueue_t &queue, NSView< X11Window > *view, NSEvent *theEvent)
NSPoint ConvertPointFromBaseToScreen(NSWindow *window, NSPoint windowPoint)
std::map< std::string, std::string >::const_iterator iter
PointerGrab fPointerGrabType
void SendKeyPressEvent(EventQueue_t &queue, NSView< X11Window > *view, NSView< X11Window > *childView, NSEvent *theEvent, NSPoint windowPoint)
const Mask_t kKeyLockMask
void SetInputFocus(NSView< X11Window > *focusView)
DerivedType * Get() const
NSPoint ConvertPointFromScreenToBase(NSPoint screenPoint, NSWindow *window)
EMouseButton fImplicitGrabButton
Time_t TimeForCocoaEvent(NSEvent *theEvent)
void GenerateCrossingEvents(EventQueue_t &queue, NSView< X11Window > *fromView, NSView< X11Window > *toView, NSEvent *theEvent, EXMagic detail)
void FindButtonGrab(NSView< X11Window > *fromView, NSEvent *theEvent, EMouseButton btn)
const Mask_t kButtonPressMask
NSView< X11Window > * FindViewUnderPointer()
NSPoint TranslateToScreen(NSView< X11Window > *from, NSPoint point)
const Mask_t kKeyPressMask
const Mask_t kButton3Mask
int GlobalYCocoaToROOT(CGFloat yCocoa)
Double_t length(const TVector2 &v)
void GenerateExposeEvent(NSView< X11Window > *view, const NSRect &exposedRect)
unsigned GetModifiersFromCocoaEvent(NSEvent *theEvent)
unsigned GetInputFocus() const
QuartzWindow * FindWindowUnderPointer()
void GenerateButtonPressEventActiveGrab(NSView< X11Window > *view, NSEvent *theEvent, EMouseButton btn)
void SendEnterEvent(EventQueue_t &queue, NSView< X11Window > *view, NSEvent *theEvent, EXMagic detail)
void GenerateDestroyNotify(unsigned winID)
Ancestry FindLowestCommonAncestor(NSView< X11Window > *view1, NSView< X11Window > *view2, NSView< X11Window > **lca)
void SendLeaveEventRange(EventQueue_t &queue, NSView< X11Window > *from, NSView< X11Window > *to, NSEvent *theEvent, EXMagic mode)
void SendEnterEventRange(EventQueue_t &queue, NSView< X11Window > *from, NSView< X11Window > *to, NSEvent *theEvent, EXMagic mode)
void GenerateKeyEventActiveGrab(NSView< X11Window > *eventView, NSEvent *theEvent)
NSView< X11Window > * fKeyGrabView
bool IsInBranch(NSView< X11Window > *parent, NSView< X11Window > *child, NSView< X11Window > *testView)
const Mask_t kEnterWindowMask
void GenerateButtonPressEventNoGrab(NSView< X11Window > *view, NSEvent *theEvent, EMouseButton btn)
void ConvertEventLocationToROOTXY(NSEvent *cocoaEvent, NSView< X11Window > *eventView, Event_t *rootEvent)
void SendFocusInEvent(EventQueue_t &queue, NSView< X11Window > *view, EXMagic mode)
void GenerateCrossingEventActiveGrab(NSEvent *theEvent)
virtual Bool_t HandleEvent(Event_t *)
const Mask_t kButtonReleaseMask
NSView< X11Window > * fViewUnderPointer
void GenerateCrossingEvent(NSEvent *theEvent)
UInt_t GetKeyboardModifiers()
void SendEnterEventClosedRange(EventQueue_t &queue, NSView< X11Window > *from, NSView< X11Window > *to, NSEvent *theEvent, EXMagic mode)
void GenerateKeyReleaseEventNoGrab(NSView< X11Window > *eventView, NSEvent *theEvent)
void GeneratePointerMotionEventNoGrab(NSEvent *theEvent)
const Mask_t kFocusChangeMask
void CheckUnmappedView(Window_t winID)
void GenerateCrossingEventNoGrab(NSEvent *theEvent)
void GenerateKeyPressEvent(NSView< X11Window > *eventView, NSEvent *theEvent)
Event_t NewX11EventFromCocoaEvent(unsigned windowID, NSEvent *theEvent)
void SendButtonReleaseEvent(EventQueue_t &queue, NSView< X11Window > *view, NSEvent *theEvent, EMouseButton btn)
const Mask_t kKeyControlMask
void GenerateKeyEventForView(NSView< X11Window > *view, NSEvent *theEvent)
bool IsParent(NSView< X11Window > *testParent, NSView< X11Window > *testChild)
const Mask_t kAnyModifier
const Mask_t kButton1Mask
void SetPointerGrab(NSView< X11Window > *grabView, unsigned eventMask, bool ownerEvents)
bool HasPointerGrab() const
void GenerateFocusChangeEvent(NSView< X11Window > *eventView)
void SendKeyReleaseEvent(EventQueue_t &queue, NSView< X11Window > *view, NSView< X11Window > *childView, NSEvent *theEvent, NSPoint windowPoint)
void GenerateButtonReleaseEvent(NSView< X11Window > *eventView, NSEvent *theEvent, EMouseButton btn)