Logo ROOT   6.08/07
Reference Guide
X11Events.h
Go to the documentation of this file.
1 // @(#)root/graf2d:$Id$
2 // Author: Timur Pocheptsov 16/02/2012
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2012, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_X11Events
13 #define ROOT_X11Events
14 
15 #include <deque>
16 
17 #ifndef ROOT_GuiTypes
18 #include "GuiTypes.h"
19 #endif
20 
21 #include <Foundation/Foundation.h>
22 
23 //////////////////////////////////////////////////////////////////////////
24 // //
25 // EventTranslator class translates Cocoa events to 'ROOT's X11' events.//
26 // In 90% cases there is no direct mapping from Cocoa event to //
27 // X11 event: Cocoa events are more simple (from programmer's POV). //
28 // EventTranslator tries to emulate X11 behavior. //
29 // //
30 //////////////////////////////////////////////////////////////////////////
31 
32 class TGCocoa;
33 
34 @protocol X11Window;
35 
36 @class QuartzWindow;
37 @class NSEvent;
38 @class NSView;
39 
40 namespace ROOT {
41 namespace MacOSX {
42 namespace X11 {//X11 emulation for Cocoa.
43 
49 };
50 
51 typedef std::deque<Event_t> EventQueue_t;
52 
54  friend class ::TGCocoa;
55 public:
57 
58  void GenerateConfigureNotifyEvent(NSView<X11Window> *view, const NSRect &newFrame);
59  void GenerateDestroyNotify(unsigned winID);
60  void GenerateExposeEvent(NSView<X11Window> *view, const NSRect &exposedRect);
61 
62  void GenerateCrossingEvent(NSEvent *theEvent);
63  void GeneratePointerMotionEvent(NSEvent *theEvent);
64 
65  //TODO: instead of passing EMouseButton, use info from NSEvent???
66  void GenerateButtonPressEvent(NSView<X11Window> *eventView, NSEvent *theEvent, EMouseButton btn);
67  void GenerateButtonReleaseEvent(NSView<X11Window> *eventView, NSEvent *theEvent, EMouseButton btn);
68 
69  void GenerateKeyPressEvent(NSView<X11Window> *eventView, NSEvent *theEvent);
70  void GenerateKeyReleaseEvent(NSView<X11Window> *eventView, NSEvent *theEvent);
71 
72  void GenerateFocusChangeEvent(NSView<X11Window> *eventView);
73 
74  void SetPointerGrab(NSView<X11Window> *grabView, unsigned eventMask, bool ownerEvents);
75  void CancelPointerGrab();
76 
77  void SetInputFocus(NSView<X11Window> *focusView);
78  unsigned GetInputFocus()const;
79 
80  //Window winID was either deleted or unmapped.
81  //If it's a grab view or a parent of a grab view - cancel grab.
82  //If it's a "view under pointer" - reset view under pointer.
83  //If it's a focus view, cancel focus.
84  void CheckUnmappedView(Window_t winID);
85 
86  bool HasPointerGrab()const;
87 
88 private:
89 
90  //Used both by grab and non-grab case.
91  void GenerateCrossingEventNoGrab(NSEvent *theEvent);
92  void GenerateCrossingEventActiveGrab(NSEvent *theEvent);
93 
94  void GeneratePointerMotionEventNoGrab(NSEvent *theEvent);
95  void GeneratePointerMotionEventActiveGrab(NSEvent *theEvent);
96 
97  void GenerateButtonPressEventNoGrab(NSView<X11Window> *view, NSEvent *theEvent, EMouseButton btn);
98  void GenerateButtonPressEventActiveGrab(NSView<X11Window> *view, NSEvent *theEvent, EMouseButton btn);
99 
100  void GenerateButtonReleaseEventNoGrab(NSView<X11Window> *eventView, NSEvent *theEvent, EMouseButton btn);
101  void GenerateButtonReleaseEventActiveGrab(NSView<X11Window> *eventView, NSEvent *theEvent, EMouseButton btn);
102 
103  void GenerateKeyPressEventNoGrab(NSView<X11Window> *eventView, NSEvent *theEvent);
104  void GenerateKeyReleaseEventNoGrab(NSView<X11Window> *eventView, NSEvent *theEvent);
105 
106  void GenerateKeyEventActiveGrab(NSView<X11Window> *eventView, NSEvent *theEvent);//Both press/release events.
107  void GenerateKeyEventForView(NSView<X11Window> *view, NSEvent *theEvent);//Both press/release events.
108 
109  void FindButtonGrab(NSView<X11Window> *fromView, NSEvent *theEvent, EMouseButton btn);
110  void FindKeyGrabView(NSView<X11Window> *eventView, NSEvent *theEvent);
111 
112  NSView<X11Window> *fViewUnderPointer;
113 
115  unsigned fGrabEventMask;
117 
118 
119  NSView<X11Window> *fButtonGrabView;
120  NSView<X11Window> *fKeyGrabView;
121  NSView<X11Window> *fFocusView;
123 
124  EventQueue_t fEventQueue;
125 };
126 
127 void MapUnicharToKeySym(unichar key, char *buf, Int_t len, UInt_t &rootKeySym);
129 NSUInteger GetCocoaKeyModifiersFromROOTKeyModifiers(UInt_t rootKeyModifiers);
130 
131 UInt_t GetModifiers();//Mouse buttons + keyboard modifiers.
132 
133 }//X11
134 }//MacOSX
135 }//ROOT
136 
137 #endif
NSUInteger GetCocoaKeyModifiersFromROOTKeyModifiers(UInt_t rootKeyModifiers)
Definition: X11Events.mm:264
void GenerateConfigureNotifyEvent(NSView< X11Window > *view, const NSRect &newFrame)
Definition: X11Events.mm:1153
void GeneratePointerMotionEventActiveGrab(NSEvent *theEvent)
Definition: X11Events.mm:1548
UInt_t GetModifiers()
Definition: X11Events.mm:303
void GeneratePointerMotionEvent(NSEvent *theEvent)
Definition: X11Events.mm:1251
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
Int_t MapKeySymToKeyCode(Int_t keySym)
Definition: X11Events.mm:181
void GenerateKeyReleaseEvent(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1308
void MapUnicharToKeySym(unichar key, char *buf, Int_t len, UInt_t &rootKeySym)
Definition: X11Events.mm:98
void GenerateButtonReleaseEventActiveGrab(NSView< X11Window > *eventView, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1670
std::deque< Event_t > EventQueue_t
Definition: X11Events.h:51
int Int_t
Definition: RtypesCore.h:41
void GenerateKeyPressEventNoGrab(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1714
void FindKeyGrabView(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1863
NSView< X11Window > * fButtonGrabView
Definition: X11Events.h:119
void GenerateButtonPressEvent(NSView< X11Window > *eventView, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1264
NSView< X11Window > * fFocusView
Definition: X11Events.h:121
void GenerateButtonReleaseEventNoGrab(NSView< X11Window > *eventView, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1658
void SetInputFocus(NSView< X11Window > *focusView)
Definition: X11Events.mm:1439
void FindButtonGrab(NSView< X11Window > *fromView, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1815
EMouseButton
Definition: GuiTypes.h:215
void GenerateExposeEvent(NSView< X11Window > *view, const NSRect &exposedRect)
Definition: X11Events.mm:1180
void GenerateButtonPressEventActiveGrab(NSView< X11Window > *view, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1622
unsigned int UInt_t
Definition: RtypesCore.h:42
void GenerateDestroyNotify(unsigned winID)
void GenerateKeyEventActiveGrab(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1739
NSView< X11Window > * fKeyGrabView
Definition: X11Events.h:120
void GenerateButtonPressEventNoGrab(NSView< X11Window > *view, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1588
void GenerateCrossingEventActiveGrab(NSEvent *theEvent)
Definition: X11Events.mm:1220
NSView< X11Window > * fViewUnderPointer
Definition: X11Events.h:112
void GenerateCrossingEvent(NSEvent *theEvent)
Definition: X11Events.mm:1198
Handle_t Window_t
Definition: GuiTypes.h:30
void GenerateKeyReleaseEventNoGrab(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1773
This class implements TVirtualX interface for MacOS X, using Cocoa and Quartz 2D. ...
Definition: TGCocoa.h:58
void GeneratePointerMotionEventNoGrab(NSEvent *theEvent)
Definition: X11Events.mm:1529
void CheckUnmappedView(Window_t winID)
Definition: X11Events.mm:1482
void GenerateCrossingEventNoGrab(NSEvent *theEvent)
Definition: X11Events.mm:1209
void GenerateKeyPressEvent(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1292
void GenerateKeyEventForView(NSView< X11Window > *view, NSEvent *theEvent)
Definition: X11Events.mm:1791
void SetPointerGrab(NSView< X11Window > *grabView, unsigned eventMask, bool ownerEvents)
Definition: X11Events.mm:1346
void GenerateFocusChangeEvent(NSView< X11Window > *eventView)
Definition: X11Events.mm:1328
void GenerateButtonReleaseEvent(NSView< X11Window > *eventView, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1277