Logo ROOT  
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 #include "GuiTypes.h"
18 
19 #include <Foundation/Foundation.h>
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  void GenerateButtonPressEvent(NSView<X11Window> *eventView, NSEvent *theEvent, EMouseButton btn);
64  void GenerateButtonReleaseEvent(NSView<X11Window> *eventView, NSEvent *theEvent, EMouseButton btn);
65 
66  void GenerateKeyPressEvent(NSView<X11Window> *eventView, NSEvent *theEvent);
67  void GenerateKeyReleaseEvent(NSView<X11Window> *eventView, NSEvent *theEvent);
68 
70 
71  void SetPointerGrab(NSView<X11Window> *grabView, unsigned eventMask, bool ownerEvents);
72  void CancelPointerGrab();
73 
74  void SetInputFocus(NSView<X11Window> *focusView);
75  unsigned GetInputFocus()const;
76 
77  //Window winID was either deleted or unmapped.
78  //If it's a grab view or a parent of a grab view - cancel grab.
79  //If it's a "view under pointer" - reset view under pointer.
80  //If it's a focus view, cancel focus.
81  void CheckUnmappedView(Window_t winID);
82 
83  bool HasPointerGrab()const;
84 
85 private:
86 
87  //Used both by grab and non-grab case.
88  void GenerateCrossingEventNoGrab(NSEvent *theEvent);
89  void GenerateCrossingEventActiveGrab(NSEvent *theEvent);
90 
91  void GeneratePointerMotionEventNoGrab(NSEvent *theEvent);
92  void GeneratePointerMotionEventActiveGrab(NSEvent *theEvent);
93 
94  void GenerateButtonPressEventNoGrab(NSView<X11Window> *view, NSEvent *theEvent, EMouseButton btn);
95  void GenerateButtonPressEventActiveGrab(NSView<X11Window> *view, NSEvent *theEvent, EMouseButton btn);
96 
97  void GenerateButtonReleaseEventNoGrab(NSView<X11Window> *eventView, NSEvent *theEvent, EMouseButton btn);
98  void GenerateButtonReleaseEventActiveGrab(NSView<X11Window> *eventView, NSEvent *theEvent, EMouseButton btn);
99 
100  void GenerateKeyPressEventNoGrab(NSView<X11Window> *eventView, NSEvent *theEvent);
101  void GenerateKeyReleaseEventNoGrab(NSView<X11Window> *eventView, NSEvent *theEvent);
102 
103  void GenerateKeyEventActiveGrab(NSView<X11Window> *eventView, NSEvent *theEvent);//Both press/release events.
104  void GenerateKeyEventForView(NSView<X11Window> *view, NSEvent *theEvent);//Both press/release events.
105 
106  void FindButtonGrab(NSView<X11Window> *fromView, NSEvent *theEvent, EMouseButton btn);
107  void FindKeyGrabView(NSView<X11Window> *eventView, NSEvent *theEvent);
108 
110 
112  unsigned fGrabEventMask;
114 
115 
120 
122 };
123 
124 void MapUnicharToKeySym(unichar key, char *buf, Int_t len, UInt_t &rootKeySym);
126 NSUInteger GetCocoaKeyModifiersFromROOTKeyModifiers(UInt_t rootKeyModifiers);
127 
128 UInt_t GetModifiers();//Mouse buttons + keyboard modifiers.
129 
130 }//X11
131 }//MacOSX
132 }//ROOT
133 
134 #endif
ROOT::MacOSX::X11::EventTranslator::GenerateKeyEventActiveGrab
void GenerateKeyEventActiveGrab(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1722
X11Window-p
Definition: X11Drawable.h:65
ROOT::MacOSX::X11::EventTranslator::GenerateDestroyNotify
void GenerateDestroyNotify(unsigned winID)
ROOT::MacOSX::X11::EventTranslator::HasPointerGrab
bool HasPointerGrab() const
Definition: X11Events.mm:1238
ROOT::MacOSX::X11::EventTranslator::SetInputFocus
void SetInputFocus(NSView< X11Window > *focusView)
Definition: X11Events.mm:1431
NSView
ROOT::MacOSX::X11::EventTranslator::fKeyGrabView
NSView< X11Window > * fKeyGrabView
Definition: X11Events.h:117
ROOT::MacOSX::X11::EventTranslator::fOwnerEvents
bool fOwnerEvents
Definition: X11Events.h:113
ROOT::MacOSX::X11::EventTranslator::GenerateButtonPressEventNoGrab
void GenerateButtonPressEventNoGrab(NSView< X11Window > *view, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1575
ROOT::MacOSX::X11::EventTranslator::GenerateCrossingEventActiveGrab
void GenerateCrossingEventActiveGrab(NSEvent *theEvent)
Definition: X11Events.mm:1213
ROOT::MacOSX::X11::EventTranslator::GenerateExposeEvent
void GenerateExposeEvent(NSView< X11Window > *view, const NSRect &exposedRect)
Definition: X11Events.mm:1174
ROOT::MacOSX::X11::EventTranslator::CancelPointerGrab
void CancelPointerGrab()
Definition: X11Events.mm:1380
ROOT::MacOSX::X11::EventTranslator::CheckUnmappedView
void CheckUnmappedView(Window_t winID)
Definition: X11Events.mm:1474
Int_t
int Int_t
Definition: RtypesCore.h:45
ROOT::MacOSX::X11::EventTranslator::GeneratePointerMotionEventNoGrab
void GeneratePointerMotionEventNoGrab(NSEvent *theEvent)
Definition: X11Events.mm:1518
EMouseButton
EMouseButton
Definition: GuiTypes.h:213
ROOT::MacOSX::X11::EventTranslator::GenerateButtonReleaseEvent
void GenerateButtonReleaseEvent(NSView< X11Window > *eventView, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1270
ROOT::MacOSX::X11::PointerGrab
PointerGrab
Definition: X11Events.h:42
ROOT::MacOSX::X11::EventTranslator::GetInputFocus
unsigned GetInputFocus() const
Definition: X11Events.mm:1447
ROOT::MacOSX::X11::GetCocoaKeyModifiersFromROOTKeyModifiers
NSUInteger GetCocoaKeyModifiersFromROOTKeyModifiers(UInt_t rootKeyModifiers)
Definition: X11Events.mm:261
ROOT::MacOSX::X11::EventTranslator::fViewUnderPointer
NSView< X11Window > * fViewUnderPointer
Definition: X11Events.h:109
ROOT::MacOSX::X11::EventTranslator::GenerateCrossingEvent
void GenerateCrossingEvent(NSEvent *theEvent)
Definition: X11Events.mm:1192
ROOT::MacOSX::X11::EventTranslator::GenerateKeyReleaseEventNoGrab
void GenerateKeyReleaseEventNoGrab(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1755
ROOT::MacOSX::X11::EventTranslator::GeneratePointerMotionEventActiveGrab
void GeneratePointerMotionEventActiveGrab(NSEvent *theEvent)
Definition: X11Events.mm:1537
ROOT::MacOSX::X11::kPGPassiveGrab
@ kPGPassiveGrab
Definition: X11Events.h:46
ROOT::MacOSX::X11::EventTranslator::GenerateKeyPressEvent
void GenerateKeyPressEvent(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1285
ROOT::MacOSX::X11::GetModifiers
UInt_t GetModifiers()
Definition: X11Events.mm:300
ROOT::MacOSX::X11::EventTranslator::GenerateKeyReleaseEvent
void GenerateKeyReleaseEvent(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1301
ROOT::MacOSX::X11::EventTranslator::GenerateCrossingEventNoGrab
void GenerateCrossingEventNoGrab(NSEvent *theEvent)
Definition: X11Events.mm:1202
ROOT::MacOSX::X11::MapUnicharToKeySym
void MapUnicharToKeySym(unichar key, char *buf, Int_t len, UInt_t &rootKeySym)
Definition: X11Events.mm:98
TGCocoa
Definition: TGCocoa.h:58
GuiTypes.h
ROOT::MacOSX::X11::EventTranslator::GenerateKeyEventForView
void GenerateKeyEventForView(NSView< X11Window > *view, NSEvent *theEvent)
Definition: X11Events.mm:1772
ROOT::MacOSX::X11::EventTranslator::GenerateKeyPressEventNoGrab
void GenerateKeyPressEventNoGrab(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1699
ROOT::MacOSX::X11::EventTranslator::fGrabEventMask
unsigned fGrabEventMask
Definition: X11Events.h:112
ROOT::MacOSX::X11::EventTranslator::SetPointerGrab
void SetPointerGrab(NSView< X11Window > *grabView, unsigned eventMask, bool ownerEvents)
Definition: X11Events.mm:1339
Window_t
Handle_t Window_t
Definition: GuiTypes.h:28
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
ROOT::MacOSX::X11::EventTranslator::GenerateFocusChangeEvent
void GenerateFocusChangeEvent(NSView< X11Window > *eventView)
Definition: X11Events.mm:1321
ROOT::MacOSX::X11::EventTranslator::fButtonGrabView
NSView< X11Window > * fButtonGrabView
Definition: X11Events.h:116
ROOT::MacOSX::X11::EventTranslator::EventTranslator
EventTranslator()
Definition: X11Events.mm:1135
ROOT::MacOSX::X11::kPGImplicitGrab
@ kPGImplicitGrab
Definition: X11Events.h:44
ROOT::MacOSX::X11::EventTranslator::GenerateConfigureNotifyEvent
void GenerateConfigureNotifyEvent(NSView< X11Window > *view, const NSRect &newFrame)
Definition: X11Events.mm:1149
ROOT::MacOSX::X11::EventTranslator::GenerateButtonReleaseEventNoGrab
void GenerateButtonReleaseEventNoGrab(NSView< X11Window > *eventView, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1643
ROOT::MacOSX::X11::EventTranslator::GeneratePointerMotionEvent
void GeneratePointerMotionEvent(NSEvent *theEvent)
Definition: X11Events.mm:1244
ROOT::MacOSX::X11::EventTranslator::fPointerGrabType
PointerGrab fPointerGrabType
Definition: X11Events.h:111
ROOT::MacOSX::X11::EventTranslator::GenerateButtonReleaseEventActiveGrab
void GenerateButtonReleaseEventActiveGrab(NSView< X11Window > *eventView, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1655
ROOT::MacOSX::X11::EventQueue_t
std::deque< Event_t > EventQueue_t
Definition: X11Events.h:49
ROOT::MacOSX::X11::EventTranslator::fEventQueue
EventQueue_t fEventQueue
Definition: X11Events.h:121
ROOT::MacOSX::X11::EventTranslator::GenerateButtonPressEvent
void GenerateButtonPressEvent(NSView< X11Window > *eventView, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1257
ROOT::MacOSX::X11::EventTranslator::FindKeyGrabView
void FindKeyGrabView(NSView< X11Window > *eventView, NSEvent *theEvent)
Definition: X11Events.mm:1843
ROOT::MacOSX::X11::kPGActiveGrab
@ kPGActiveGrab
Definition: X11Events.h:45
ROOT::MacOSX::X11::EventTranslator::GenerateButtonPressEventActiveGrab
void GenerateButtonPressEventActiveGrab(NSView< X11Window > *view, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1609
ROOT::MacOSX::X11::EventTranslator
Definition: X11Events.h:51
ROOT::MacOSX::X11::kPGNoGrab
@ kPGNoGrab
Definition: X11Events.h:43
ROOT
VSD Structures.
Definition: StringConv.hxx:21
ROOT::MacOSX::X11::EventTranslator::FindButtonGrab
void FindButtonGrab(NSView< X11Window > *fromView, NSEvent *theEvent, EMouseButton btn)
Definition: X11Events.mm:1795
ROOT::MacOSX::X11::MapKeySymToKeyCode
Int_t MapKeySymToKeyCode(Int_t keySym)
Definition: X11Events.mm:178
ROOT::MacOSX::X11
Definition: CocoaGuiTypes.h:10
ROOT::MacOSX::X11::EventTranslator::fImplicitGrabButton
EMouseButton fImplicitGrabButton
Definition: X11Events.h:119
ROOT::MacOSX::X11::EventTranslator::fFocusView
NSView< X11Window > * fFocusView
Definition: X11Events.h:118
QuartzWindow
Definition: QuartzWindow.h:56