Free Electron
NativeEventContext.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __native_NativeEventContext_h__
8 #define __native_NativeEventContext_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 #define FE_WINDOW_EVENT_DEBUG FALSE
16 #define FE_COMMANDLINE_LENGTH 1024
17 
18 //* send mouse motion event even without buttons pressed
19 #define FE_POINTERMOTION FALSE
20 
21 
22 /**************************************************************************//**
23  @brief Implementation of an event loop using the raw native system
24 
25  @ingroup native
26 *//***************************************************************************/
27 class FE_DL_EXPORT NativeEventContext:
28  virtual public EventContextI,
29  virtual public HandlerI,
30  public Initialize<NativeEventContext>
31 {
32  public:
33  NativeEventContext(void);
34 virtual ~NativeEventContext(void);
35 virtual void initialize(void);
36 
37  //* As EventContextI
38 virtual void loop(BWORD dropout);
39 virtual void threadLock(void);
40 virtual void threadUnlock(void);
41 
42 virtual void setPointerMotion(BWORD active);
43 virtual BWORD pointerMotion(void) { return m_pointerMotion; }
44 
45 virtual Real multiplication(void) { return m_multiplication; }
46 
47 virtual void registerWindow(WindowI *window);
48 virtual void deregisterWindow(WindowI *window);
49 
50  //* As HandlerI
51 virtual void handleBind(sp<SignalerI> spSignalerI,
52  sp<Layout> spLayout);
53 virtual void handle(Record &record);
54 
55  //* As NativeEventContext
56  Result broadcastEvent(FE_WINDOW_HANDLE* pWindow);
57 
58 static U32 systemTimer(void);
59  void setTimer(U32 set) { m_timer=set; }
60  U32 getTimer(void) { return m_timer; }
61 
62  void accumulateTime(U32 exclusive,U32 inclusive);
63  void fps(F32 *exclusive,F32 *inclusive)
64  { *exclusive=m_fps_excl;
65  *inclusive=m_fps_incl; }
66 
67  void setCommandLine(char *line)
68  { strncpy(m_commandline,line,FE_COMMANDLINE_LENGTH);
69  m_commandline[FE_COMMANDLINE_LENGTH-1]=0; }
70 const char* commandLine(void) const { return m_commandline; }
71 
72  void endLoop(void) { m_endloop=true; }
73 
74  FE_DISPLAY_HANDLE displayHandle(void) { return m_pDisplayHandle; }
75 
76  WindowEvent& windowEvent(void) { return m_event; }
77 
78  void setLastWindowHandle(FE_WINDOW_HANDLE handle)
79  { m_lastWindowHandle=handle; }
80 
81  void notifyCreate(FE_WINDOW_HANDLE &windowHandle);
82 
83 #if FE_2DGL==FE_2D_GDI
84 static LRESULT CALLBACK wndProc(HWND hWND,UINT message,
85  WPARAM wParam,LPARAM lParam);
86 #endif
87 
88  private:
89  void nativeStartup(void);
90  void nativeShutdown(void);
91  void createEvent(void);
92 
93  Result bindScope(sp<Scope> spScope);
94 
95 //X U32 loadFont(FE_WINDOW_HANDLE &windowHandle);
96 //X void useLoadedFont(FE_WINDOW_HANDLE &windowHandle);
97 //X void calcFontHeight(FE_WINDOW_HANDLE &windowHandle);
98 
99  hp<SignalerI> m_hpSignalerI;
100  sp<Layout> m_spLayout;
101  WindowEvent m_poll;
102  WindowEvent m_event;
103  Record m_record;
104  List<WindowI*> m_windows;
105 
106  Accessor<FE_WINDOW_HANDLE*> m_aWindowHandle;
107 
108  Real m_multiplication;
109  BWORD m_endloop;
110  BWORD m_pointerMotion;
111  char m_commandline[FE_COMMANDLINE_LENGTH];
112 
113  U32 m_timer;
114  U32 m_time_incl;
115  U32 m_time_excl;
116  U32 m_frames;
117  F32 m_fps_incl;
118  F32 m_fps_excl;
119 
120  FE_DISPLAY_HANDLE m_pDisplayHandle;
121  FE_WINDOW_HANDLE m_lastWindowHandle;
122 
123 #if FE_2DGL==FE_2D_X_GFX
124  XFontStruct* m_pFontStruct;
125  Atom m_atom[2];
126  I32 m_threadLocks; // just tracking
127  I32 m_threadID; // just tracking
128 
129  public:
130  XFontStruct* loadXFont(Display* a_pDisplayHandle,
131  Real a_multiplication);
132 #elif FE_2DGL==FE_2D_GDI
133  WindowEvent::MouseButtons m_mousebuttons;
134 
135  public:
136  void setMouseButtons(
138  { m_mousebuttons=set; }
139  WindowEvent::MouseButtons mouseButtons(void) const
140  { return m_mousebuttons; }
141 #endif
142 };
143 
144 } /* namespace ext */
145 } /* namespace fe */
146 
147 #endif /* __native_NativeEventContext_h__ */
Fully Bidirectional Doubly-Linked List.
Definition: List.h:496
MouseButtons
State of the mouse buttons during an event.
Definition: WindowEvent.h:214
kernel
Definition: namespace.dox:3
Per-class participation in the Initialized <> mechanism.
Definition: Initialized.h:117
The main data access class for the data system.
Definition: Accessor.h:128
Implementation of an event loop using the raw native system.
Definition: NativeEventContext.h:27
General interface to a window.
Definition: WindowI.h:24
Interface to handle signals from an SignalerI.
Definition: HandlerI.h:22
Generalized windowing event.
Definition: WindowEvent.h:43
Interface for processing queued windowing events.
Definition: EventContextI.h:20
Result
Generalized return value indicating success or failure, and why.
Definition: Result.h:24
Reference to an instance of a Layout.
Definition: RecordSB.h:35
virtual BWORD pointerMotion(void)
check if pointer motion events are on
Definition: NativeEventContext.h:43