Add front buffer rendering APIs in Dali::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) 2023 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::SetLayout()
239    */
240   void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override;
241
242   /**
243    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
244    */
245   void SetClass(const std::string& name, const std::string& className) override;
246
247   /**
248    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
249    */
250   void Raise() override;
251
252   /**
253    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
254    */
255   void Lower() override;
256
257   /**
258    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
259    */
260   void Activate() override;
261
262   /**
263    * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
264    */
265   void Maximize(bool maximize) override;
266
267   /**
268    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
269    */
270   bool IsMaximized() const override;
271
272   /**
273    * @copydoc Dali::Internal::Adaptor::WindowBase::SetMaximumSize()
274    */
275   void SetMaximumSize(Dali::Window::WindowSize size) override;
276
277   /**
278    * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
279    */
280   void Minimize(bool minimize) override;
281
282   /**
283    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
284    */
285   bool IsMinimized() const override;
286
287   /**
288    * @copydoc Dali::Internal::Adaptor::WindowBase::SetMimimumSize()
289    */
290   void SetMimimumSize(Dali::Window::WindowSize size) override;
291
292   /**
293    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
294    */
295   void SetAvailableAnlges(const std::vector<int>& angles) override;
296
297   /**
298    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
299    */
300   void SetPreferredAngle(int angle) override;
301
302   /**
303    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
304    */
305   void SetAcceptFocus(bool accept) override;
306
307   /**
308    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
309    */
310   void Show() override;
311
312   /**
313    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
314    */
315   void Hide() override;
316
317   /**
318    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
319    */
320   unsigned int GetSupportedAuxiliaryHintCount() const override;
321
322   /**
323    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
324    */
325   std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
326
327   /**
328    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
329    */
330   unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
331
332   /**
333    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
334    */
335   bool RemoveAuxiliaryHint(unsigned int id) override;
336
337   /**
338    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
339    */
340   bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
341
342   /**
343    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
344    */
345   std::string GetAuxiliaryHintValue(unsigned int id) const override;
346
347   /**
348    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
349    */
350   unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
351
352   /**
353    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
354    */
355   void SetInputRegion(const Rect<int>& inputRegion) override;
356
357   /**
358    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
359    */
360   void SetType(Dali::WindowType type) override;
361
362   /**
363    * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
364    */
365   Dali::WindowType GetType() const override;
366
367   /**
368    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
369    */
370   Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
371
372   /**
373    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
374    */
375   Dali::WindowNotificationLevel GetNotificationLevel() const override;
376
377   /**
378    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
379    */
380   void SetOpaqueState(bool opaque) override;
381
382   /**
383    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
384    */
385   Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
386
387   /**
388    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
389    */
390   WindowScreenOffMode GetScreenOffMode() const override;
391
392   /**
393    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
394    */
395   Dali::WindowOperationResult SetBrightness(int brightness) override;
396
397   /**
398    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
399    */
400   int GetBrightness() const override;
401
402   /**
403    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
404    */
405   bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
406
407   /**
408    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
409    */
410   bool UngrabKey(Dali::KEY key) override;
411
412   /**
413    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
414    */
415   bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
416
417   /**
418    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
419    */
420   bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
421
422   /**
423    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
424    */
425   void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
426
427   /**
428    * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
429    */
430   int GetWindowRotationAngle() const override;
431
432   /**
433    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
434    */
435   int GetScreenRotationAngle() override;
436
437   /**
438    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
439    */
440   void SetWindowRotationAngle(int degree) override;
441
442   /**
443    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
444    */
445   void WindowRotationCompleted(int degree, int width, int height) override;
446
447   /**
448    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
449    */
450   void SetTransparency(bool transparent) override;
451
452   /**
453    * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
454    */
455   void SetParent(WindowBase* parentWinBase, bool belowParent) override;
456
457   /**
458    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
459    */
460   int CreateFrameRenderedSyncFence() override;
461
462   /**
463    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
464    */
465   int CreateFramePresentedSyncFence() override;
466
467   /**
468    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
469    */
470   void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
471
472   /**
473    * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
474    */
475   void InitializeIme() override;
476
477   /**
478    * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
479    */
480   void ImeWindowReadyToRender() override;
481
482   /**
483    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
484    */
485   void RequestMoveToServer() override;
486
487   /**
488    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
489    */
490   void RequestResizeToServer(WindowResizeDirection direction) override;
491
492   /**
493    * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
494    */
495   void EnableFloatingMode(bool enable) override;
496
497   /**
498    * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
499    */
500   bool IsFloatingModeEnabled() const override;
501
502   /**
503    * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
504    */
505   void IncludeInputRegion(const Rect<int>& inputRegion) override;
506
507   /**
508    * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
509    */
510   void ExcludeInputRegion(const Rect<int>& inputRegion) override;
511
512   /**
513    * @copydoc Dali::Internal::Adaptor::WindowBase::PointerConstraintsLock()
514    */
515   bool PointerConstraintsLock() override;
516
517   /**
518    * @copydoc Dali::Internal::Adaptor::WindowBase::PointerConstraintsUnlock()
519    */
520   bool PointerConstraintsUnlock() override;
521
522   /**
523    * @copydoc Dali::Internal::Adaptor::WindowBase::LockedPointerRegionSet()
524    */
525   void LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height) override;
526
527   /**
528    * @copydoc Dali::Internal::Adaptor::WindowBase::LockedPointerCursorPositionHintSet()
529    */
530   void LockedPointerCursorPositionHintSet(int32_t x, int32_t y) override;
531
532   /**
533    * @copydoc Dali::Internal::Adaptor::WindowBase::PointerWarp()
534    */
535   bool PointerWarp(int32_t x, int32_t y) override;
536
537   /**
538    * @copydoc Dali::Internal::Adaptor::WindowBase::CursorVisibleSet()
539    */
540   void CursorVisibleSet(bool visible) override;
541
542   /**
543    * @copydoc Dali::Internal::Adaptor::WindowBase::KeyboardGrab()
544    */
545   bool KeyboardGrab(Device::Subclass::Type deviceSubclass) override;
546
547   /**
548    * @copydoc Dali::Internal::Adaptor::WindowBase::KeyboardUnGrab()
549    */
550   bool KeyboardUnGrab() override;
551
552   /**
553    * @copydoc Dali::Internal::Adaptor::WindowBase::SetFullScreen()
554    */
555   void SetFullScreen(bool fullscreen) override;
556
557   /**
558    * @copydoc Dali::Internal::Adaptor::WindowBase::GetFullScreen()
559    */
560   bool GetFullScreen() override;
561
562   /**
563    * @copydoc Dali::Internal::Adaptor::WindowBase::SetFrontBufferRendering()
564    */
565   void SetFrontBufferRendering(bool enable) override;
566
567   /**
568    * @copydoc Dali::Internal::Adaptor::WindowBase::GetFrontBufferRendering()
569    */
570   bool GetFrontBufferRendering() override;
571
572   /**
573    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowFrontBufferMode()
574    */
575   void SetEglWindowFrontBufferMode(bool enable) override;
576
577 private:
578   /**
579    * Second stage initialization
580    */
581   void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
582
583   /**
584    * @brief Create window
585    */
586   void CreateWindow(PositionSize positionSize);
587
588 protected:
589   // Undefined
590   WindowBaseEcoreWl(const WindowBaseEcoreWl&) = delete;
591
592   // Undefined
593   WindowBaseEcoreWl& operator=(const WindowBaseEcoreWl& rhs) = delete;
594
595 private:
596   typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
597
598   Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
599
600   Ecore_Wl_Window*      mEcoreWindow;
601   wl_surface*           mWlSurface;
602   wl_egl_window*        mEglWindow;
603   wl_display*           mDisplay;
604   wl_event_queue*       mEventQueue;
605   tizen_policy*         mTizenPolicy;
606   tizen_display_policy* mTizenDisplayPolicy;
607
608   std::vector<std::string> mSupportedAuxiliaryHints;
609   AuxiliaryHints           mAuxiliaryHints;
610
611   int      mNotificationLevel;
612   uint32_t mNotificationChangeState;
613   bool     mNotificationLevelChangeDone;
614
615   int      mScreenOffMode;
616   uint32_t mScreenOffModeChangeState;
617   bool     mScreenOffModeChangeDone;
618
619   int      mBrightness;
620   uint32_t mBrightnessChangeState;
621   bool     mBrightnessChangeDone;
622
623   bool mOwnSurface;
624
625   int mWindowRotationAngle;
626   int mScreenRotationAngle;
627   int mSupportedPreProtation;
628 };
629
630 } // namespace Adaptor
631
632 } // namespace Internal
633
634 } // namespace Dali
635
636 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL_H