ROOT  6.06/09
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 //////////////////////////////////////////////////////////////////////////
22 // //
23 // EventTranslator class translates Cocoa events to 'ROOT's X11' events.//
24 // In 90% cases there is no direct mapping from Cocoa event to //
25 // X11 event: Cocoa events are more simple (from programmer's POV). //
26 // EventTranslator tries to emulate X11 behavior. //
27 // //
28 //////////////////////////////////////////////////////////////////////////
29 
30 class TGCocoa;
31 
32 @protocol X11Window;
33 
34 @class QuartzWindow;
35 @class NSEvent;
36 @class NSView;
37 
38 namespace ROOT {
39 namespace MacOSX {
40 namespace X11 {//X11 emulation for Cocoa.
41 
47 };
48 
49 typedef std::deque<Event_t> EventQueue_t;
50 
52  friend class ::TGCocoa;
53 public:
55 
56  void GenerateConfigureNotifyEvent(NSView<X11Window> *view, const NSRect &newFrame);
57  void GenerateDestroyNotify(unsigned winID);
58  void GenerateExposeEvent(NSView<X11Window> *view, const NSRect &exposedRect);
59 
60  void GenerateCrossingEvent(NSEvent *theEvent);
61  void GeneratePointerMotionEvent(NSEvent *theEvent);
62 
63  //TODO: instead of passing EMouseButton, use info from NSEvent???
64  void GenerateButtonPressEvent(NSView<X11Window> *eventView, NSEvent *theEvent, EMouseButton btn);
65  void GenerateButtonReleaseEvent(NSView<X11Window> *eventView, NSEvent *theEvent, EMouseButton btn);
66 
67  void GenerateKeyPressEvent(NSView<X11Window> *eventView, NSEvent *theEvent);
68  void GenerateKeyReleaseEvent(NSView<X11Window> *eventView, NSEvent *theEvent);
69 
70  void GenerateFocusChangeEvent(NSView<X11Window> *eventView);
71 
72  void SetPointerGrab(NSView<X11Window> *grabView, unsigned eventMask, bool ownerEvents);
73  void CancelPointerGrab();
74 
75  void SetInputFocus(NSView<X11Window> *focusView);
76  unsigned GetInputFocus()const;
77 
78  //Window winID was either deleted or unmapped.
79  //If it's a grab view or a parent of a grab view - cancel grab.
80  //If it's a "view under pointer" - reset view under pointer.
81  //If it's a focus view, cancel focus.
82  void CheckUnmappedView(Window_t winID);
83 
84  bool HasPointerGrab()const;
85 
86 private:
87 
88  //Used both by grab and non-grab case.
89  void GenerateCrossingEventNoGrab(NSEvent *theEvent);
90  void GenerateCrossingEventActiveGrab(NSEvent *theEvent);
91 
92  void GeneratePointerMotionEventNoGrab(NSEvent *theEvent);
93  void GeneratePointerMotionEventActiveGrab(NSEvent *theEvent);
94 
95  void GenerateButtonPressEventNoGrab(NSView<X11Window> *view, NSEvent *theEvent, EMouseButton btn);
96  void GenerateButtonPressEventActiveGrab(NSView<X11Window> *view, NSEvent *theEvent, EMouseButton btn);
97 
98  void GenerateButtonReleaseEventNoGrab(NSView<X11Window> *eventView, NSEvent *theEvent, EMouseButton btn);
99  void GenerateButtonReleaseEventActiveGrab(NSView<X11Window> *eventView, NSEvent *theEvent, EMouseButton btn);
100 
101  void GenerateKeyPressEventNoGrab(NSView<X11Window> *eventView, NSEvent *theEvent);
102  void GenerateKeyReleaseEventNoGrab(NSView<X11Window> *eventView, NSEvent *theEvent);
103 
104  void GenerateKeyEventActiveGrab(NSView<X11Window> *eventView, NSEvent *theEvent);//Both press/release events.
105  void GenerateKeyEventForView(NSView<X11Window> *view, NSEvent *theEvent);//Both press/release events.
106 
107  void FindButtonGrab(NSView<X11Window> *fromView, NSEvent *theEvent, EMouseButton btn);
108  void FindKeyGrabView(NSView<X11Window> *eventView, NSEvent *theEvent);
109 
110  NSView<X11Window> *fViewUnderPointer;
111 
113  unsigned fGrabEventMask;
115 
116 
117  NSView<X11Window> *fButtonGrabView;
118  NSView<X11Window> *fKeyGrabView;
119  NSView<X11Window> *fFocusView;
121 
122  EventQueue_t fEventQueue;
123 };
124 
125 void MapUnicharToKeySym(unichar key, char *buf, Int_t len, UInt_t &rootKeySym);
127 NSUInteger GetCocoaKeyModifiersFromROOTKeyModifiers(UInt_t rootKeyModifiers);
128 
129 UInt_t GetModifiers();//Mouse buttons + keyboard modifiers.
130 
131 }//X11
132 }//MacOSX
133 }//ROOT
134 
135 #endif
NSUInteger GetCocoaKeyModifiersFromROOTKeyModifiers(UInt_t rootKeyModifiers)
Definition: X11Events.mm:263
void GenerateConfigureNotifyEvent(NSView< X11Window > *view, const NSRect &newFrame)
Definition: X11Events.mm:1152
void GeneratePointerMotionEventActiveGrab(NSEvent *theEvent)
Definition: X11Events.mm:1547
UInt_t GetModifiers()
Definition: X11Events.mm:302
void GeneratePointerMotionEvent(NSEvent *theEvent)
Definition: X11Events.mm:1250
Namespace for new ROOT classes and functions.
Definition: ROOT.py:1
Int_t MapKeySymToKeyCode(Int_t keySym)
Definition: X11Events.mm:180
void GenerateKeyReleaseEvent(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1307
void MapUnicharToKeySym(unichar key, char *buf, Int_t len, UInt_t &rootKeySym)
Definition: X11Events.mm:97
void GenerateButtonReleaseEventActiveGrab(NSView< X11Window > *eventView, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1669
std::deque< Event_t > EventQueue_t
Definition: X11Events.h:49
int Int_t
Definition: RtypesCore.h:41
void GenerateKeyPressEventNoGrab(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1713
void FindKeyGrabView(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1862
NSView< X11Window > * fButtonGrabView
Definition: X11Events.h:117
void GenerateButtonPressEvent(NSView< X11Window > *eventView, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1263
NSView< X11Window > * fFocusView
Definition: X11Events.h:119
void GenerateButtonReleaseEventNoGrab(NSView< X11Window > *eventView, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1657
void SetInputFocus(NSView< X11Window > *focusView)
Definition: X11Events.mm:1438
void FindButtonGrab(NSView< X11Window > *fromView, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1814
EMouseButton
Definition: GuiTypes.h:215
void GenerateExposeEvent(NSView< X11Window > *view, const NSRect &exposedRect)
Definition: X11Events.mm:1179
void GenerateButtonPressEventActiveGrab(NSView< X11Window > *view, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1621
unsigned int UInt_t
Definition: RtypesCore.h:42
void GenerateDestroyNotify(unsigned winID)
void GenerateKeyEventActiveGrab(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1738
NSView< X11Window > * fKeyGrabView
Definition: X11Events.h:118
void GenerateButtonPressEventNoGrab(NSView< X11Window > *view, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1587
void GenerateCrossingEventActiveGrab(NSEvent *theEvent)
Definition: X11Events.mm:1219
NSView< X11Window > * fViewUnderPointer
Definition: X11Events.h:110
void GenerateCrossingEvent(NSEvent *theEvent)
Definition: X11Events.mm:1197
Handle_t Window_t
Definition: GuiTypes.h:30
void GenerateKeyReleaseEventNoGrab(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1772
This class implements TVirtualX interface for MacOS X, using Cocoa and Quartz 2D. ...
Definition: TGCocoa.h:64
void GeneratePointerMotionEventNoGrab(NSEvent *theEvent)
Definition: X11Events.mm:1528
void CheckUnmappedView(Window_t winID)
Definition: X11Events.mm:1481
void GenerateCrossingEventNoGrab(NSEvent *theEvent)
Definition: X11Events.mm:1208
void GenerateKeyPressEvent(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1291
void GenerateKeyEventForView(NSView< X11Window > *view, NSEvent *theEvent)
Definition: X11Events.mm:1790
void SetPointerGrab(NSView< X11Window > *grabView, unsigned eventMask, bool ownerEvents)
Definition: X11Events.mm:1345
void GenerateFocusChangeEvent(NSView< X11Window > *eventView)
Definition: X11Events.mm:1327
void GenerateButtonReleaseEvent(NSView< X11Window > *eventView, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1276