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