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