Merge "Enable atspi" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl2 / window-base-ecore-wl2.h
1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/window-system/common/window-base.h>
23
24 // EXTERNAL HEADERS
25 #include <Ecore.h>
26 #include <Ecore_Wl2.h>
27 #include <tizen-extension-client-protocol.h>
28 #include <wayland-egl.h>
29 #include <xkbcommon/xkbcommon.h>
30
31 #ifdef DALI_ELDBUS_AVAILABLE
32 #include <Eldbus.h>
33 #endif
34
35 namespace Dali
36 {
37 namespace Internal
38 {
39 namespace Adaptor
40 {
41 class WindowRenderSurface;
42 class WindowRenderSurfaceEcoreWl2;
43
44 /**
45  * WindowBaseEcoreWl2 class provides an WindowBase Ecore-Wayland2 implementation.
46  */
47 class WindowBaseEcoreWl2 : public WindowBase
48 {
49 public:
50   /**
51    * @brief Constructor
52    */
53   WindowBaseEcoreWl2(PositionSize positionSize, Any surface, bool isTransparent);
54
55   /**
56    * @brief Destructor
57    */
58   virtual ~WindowBaseEcoreWl2();
59
60 public:
61   /**
62    * @brief Called when the window iconify state is changed.
63    */
64   Eina_Bool OnIconifyStateChanged(void* data, int type, void* event);
65
66   /**
67    * @brief Called when the window gains focus.
68    */
69   Eina_Bool OnFocusIn(void* data, int type, void* event);
70
71   /**
72    * @brief Called when the window loses focus.
73    */
74   Eina_Bool OnFocusOut(void* data, int type, void* event);
75
76   /**
77    * @brief Called when the output is transformed.
78    */
79   Eina_Bool OnOutputTransform(void* data, int type, void* event);
80
81   /**
82    * @brief Called when the output transform should be ignored.
83    */
84   Eina_Bool OnIgnoreOutputTransform(void* data, int type, void* event);
85
86   /**
87    * @brief Called when a rotation event is recevied.
88    */
89   void OnRotation(void* data, int type, void* event);
90
91   /**
92    * @brief Called when a configure event is recevied.
93    */
94   void OnConfiguration(void* data, int type, void* event);
95
96   /**
97    * @brief Called when a touch down is received.
98    */
99   void OnMouseButtonDown(void* data, int type, void* event);
100
101   /**
102    * @brief Called when a touch up is received.
103    */
104   void OnMouseButtonUp(void* data, int type, void* event);
105
106   /**
107    * @brief Called when a touch motion is received.
108    */
109   void OnMouseButtonMove(void* data, int type, void* event);
110
111   /**
112    * @brief Called when a touch is canceled.
113    */
114   void OnMouseButtonCancel(void* data, int type, void* event);
115
116   /**
117    * @brief Called when a mouse wheel is received.
118    */
119   void OnMouseWheel(void* data, int type, void* event);
120
121   /**
122    * @brief Called when a detent rotation event is recevied.
123    */
124   void OnDetentRotation(void* data, int type, void* event);
125
126   /**
127    * @brief Called when a key down is received.
128    */
129   void OnKeyDown(void* data, int type, void* event);
130
131   /**
132    * @brief Called when a key up is received.
133    */
134   void OnKeyUp(void* data, int type, void* event);
135
136   /**
137    * @brief Called when the source window notifies us the content in clipboard is selected.
138    */
139   void OnDataSend(void* data, int type, void* event);
140
141   /**
142    * @brief Called when the source window sends us about the selected content.
143    */
144   void OnDataReceive(void* data, int type, void* event);
145
146   /**
147    * @brief Called when a font name is changed.
148    */
149   void OnFontNameChanged();
150
151   /**
152    * @brief Called when a font size is changed.
153    */
154   void OnFontSizeChanged();
155
156   /**
157    * @brief Called when a transition effect-start/end event is received.
158    */
159   void OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type);
160
161   /**
162    * @brief Called when a keyboard repeat event is changed.
163    */
164   void OnKeyboardRepeatSettingsChanged();
165
166   /**
167    * @brief Called when a window redraw is requested.
168    */
169   void OnEcoreEventWindowRedrawRequest();
170
171 #ifdef DALI_ELDBUS_AVAILABLE
172   /**
173    * @brief Called when Ecore ElDBus accessibility event is received.
174    */
175   void OnEcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message);
176 #endif
177
178   /**
179    * @brief Called when a keymap is changed.
180    */
181   void KeymapChanged(void* data, int type, void* event);
182
183   /**
184    * @brief RegistryGlobalCallback
185    */
186   void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
187
188   /**
189    * @brief RegistryGlobalCallbackRemove
190    */
191   void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id);
192
193   /**
194    * @brief TizenPolicyNotificationChangeDone
195    */
196   void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state);
197
198   /**
199    * @brief TizenPolicyScreenModeChangeDone
200    */
201   void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state);
202
203   /**
204    * @brief DisplayPolicyBrightnessChangeDone
205    */
206   void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state);
207
208   /**
209    * @brief Gets the key code by keyName.
210    */
211   void GetKeyCode(std::string keyName, int32_t& keyCode);
212
213 public:
214   /**
215    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
216    */
217   Any GetNativeWindow() override;
218
219   /**
220    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
221    */
222   int GetNativeWindowId() override;
223
224   /**
225    * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
226    */
227   EGLNativeWindowType CreateEglWindow(int width, int height) override;
228
229   /**
230    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
231    */
232   void DestroyEglWindow() override;
233
234   /**
235    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
236    */
237   void SetEglWindowRotation(int angle) override;
238
239   /**
240    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
241    */
242   void SetEglWindowBufferTransform(int angle) override;
243
244   /**
245    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
246    */
247   void SetEglWindowTransform(int angle) override;
248
249   /**
250    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
251    */
252   void ResizeEglWindow(PositionSize positionSize) override;
253
254   /**
255    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
256    */
257   bool IsEglWindowRotationSupported() override;
258
259   /**
260    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
261    */
262   void Move(PositionSize positionSize) override;
263
264   /**
265    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
266    */
267   void Resize(PositionSize positionSize) override;
268
269   /**
270    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
271    */
272   void MoveResize(PositionSize positionSize) override;
273
274   /**
275    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
276    */
277   void SetClass(const std::string& name, const std::string& className) override;
278
279   /**
280    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
281    */
282   void Raise() override;
283
284   /**
285    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
286    */
287   void Lower() override;
288
289   /**
290    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
291    */
292   void Activate() override;
293
294   /**
295    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
296    */
297   void SetAvailableAnlges(const std::vector<int>& angles) override;
298
299   /**
300    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
301    */
302   void SetPreferredAngle(int angle) override;
303
304   /**
305    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
306    */
307   void SetAcceptFocus(bool accept) override;
308
309   /**
310    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
311    */
312   void Show() override;
313
314   /**
315    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
316    */
317   void Hide() override;
318
319   /**
320    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
321    */
322   unsigned int GetSupportedAuxiliaryHintCount() const override;
323
324   /**
325    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
326    */
327   std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
328
329   /**
330    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
331    */
332   unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
333
334   /**
335    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
336    */
337   bool RemoveAuxiliaryHint(unsigned int id) override;
338
339   /**
340    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
341    */
342   bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
343
344   /**
345    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
346    */
347   std::string GetAuxiliaryHintValue(unsigned int id) const override;
348
349   /**
350    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
351    */
352   unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
353
354   /**
355    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
356    */
357   void SetInputRegion(const Rect<int>& inputRegion) override;
358
359   /**
360    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
361    */
362   void SetType(Dali::WindowType type) override;
363
364   /**
365    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
366    */
367   bool SetNotificationLevel(Dali::WindowNotificationLevel level) override;
368
369   /**
370    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
371    */
372   Dali::WindowNotificationLevel GetNotificationLevel() const override;
373
374   /**
375    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
376    */
377   void SetOpaqueState(bool opaque) override;
378
379   /**
380    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
381    */
382   bool SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
383
384   /**
385    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
386    */
387   WindowScreenOffMode GetScreenOffMode() const override;
388
389   /**
390    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
391    */
392   bool SetBrightness(int brightness) override;
393
394   /**
395    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
396    */
397   int GetBrightness() const override;
398
399   /**
400    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
401    */
402   bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
403
404   /**
405    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
406    */
407   bool UngrabKey(Dali::KEY key) override;
408
409   /**
410    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
411    */
412   bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
413
414   /**
415    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
416    */
417   bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
418
419   /**
420    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
421    */
422   void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
423
424   /**
425    * @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
426    */
427   int GetOrientation() const override;
428
429   /**
430    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
431    */
432   int GetScreenRotationAngle() override;
433
434   /**
435    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
436    */
437   void SetWindowRotationAngle(int degree) override;
438
439   /**
440    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
441    */
442   void WindowRotationCompleted(int degree, int width, int height) override;
443
444   /**
445    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
446    */
447   void SetTransparency(bool transparent) override;
448
449   /**
450    * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
451    */
452   void SetParent(WindowBase* parentWinBase) override;
453
454   /**
455    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
456    */
457   int CreateFrameRenderedSyncFence() override;
458
459   /**
460    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
461    */
462   int CreateFramePresentedSyncFence() override;
463
464 private:
465   /**
466    * Second stage initialization
467    */
468   void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
469
470   /**
471    * Initialize Ecore ElDBus
472    */
473   void InitializeEcoreElDBus();
474
475   /**
476    * @brief Create window
477    */
478   void CreateWindow(PositionSize positionSize);
479
480 protected:
481   // Undefined
482   WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
483
484   // Undefined
485   WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
486
487 private:
488   typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
489
490   Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
491
492   Ecore_Wl2_Window*     mEcoreWindow;
493   wl_surface*           mWlSurface;
494   wl_egl_window*        mEglWindow;
495   wl_display*           mDisplay;
496   wl_event_queue*       mEventQueue;
497   tizen_policy*         mTizenPolicy;
498   tizen_display_policy* mTizenDisplayPolicy;
499   xkb_keymap*           mKeyMap;
500
501   std::vector<std::string> mSupportedAuxiliaryHints;
502   AuxiliaryHints           mAuxiliaryHints;
503
504   int      mNotificationLevel;
505   uint32_t mNotificationChangeState;
506   bool     mNotificationLevelChangeDone;
507
508   int      mScreenOffMode;
509   uint32_t mScreenOffModeChangeState;
510   bool     mScreenOffModeChangeDone;
511
512   int      mBrightness;
513   uint32_t mBrightnessChangeState;
514   bool     mBrightnessChangeDone;
515
516   bool               mVisible : 1;
517   Dali::PositionSize mWindowPositionSize;
518
519   bool mOwnSurface;
520
521   volatile uint32_t mMoveResizeSerial;
522   uint32_t          mLastSubmittedMoveResizeSerial;
523
524   int mWindowRotationAngle;
525   int mScreenRotationAngle;
526   int mSupportedPreProtation;
527 #ifdef DALI_ELDBUS_AVAILABLE
528   Eldbus_Connection* mSystemConnection;
529 #endif // DALI_ELDBUS_AVAILABLE
530 };
531
532 } // namespace Adaptor
533
534 } // namespace Internal
535
536 } // namespace Dali
537
538 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H