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