Add Window::SetLayout method
[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::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 private:
513   /**
514    * Second stage initialization
515    */
516   void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
517
518   /**
519    * @brief Create window
520    */
521   void CreateWindow(PositionSize positionSize);
522
523 protected:
524   // Undefined
525   WindowBaseEcoreWl(const WindowBaseEcoreWl&) = delete;
526
527   // Undefined
528   WindowBaseEcoreWl& operator=(const WindowBaseEcoreWl& rhs) = delete;
529
530 private:
531   typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
532
533   Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
534
535   Ecore_Wl_Window*      mEcoreWindow;
536   wl_surface*           mWlSurface;
537   wl_egl_window*        mEglWindow;
538   wl_display*           mDisplay;
539   wl_event_queue*       mEventQueue;
540   tizen_policy*         mTizenPolicy;
541   tizen_display_policy* mTizenDisplayPolicy;
542
543   std::vector<std::string> mSupportedAuxiliaryHints;
544   AuxiliaryHints           mAuxiliaryHints;
545
546   int      mNotificationLevel;
547   uint32_t mNotificationChangeState;
548   bool     mNotificationLevelChangeDone;
549
550   int      mScreenOffMode;
551   uint32_t mScreenOffModeChangeState;
552   bool     mScreenOffModeChangeDone;
553
554   int      mBrightness;
555   uint32_t mBrightnessChangeState;
556   bool     mBrightnessChangeDone;
557
558   bool mOwnSurface;
559
560   int mWindowRotationAngle;
561   int mScreenRotationAngle;
562   int mSupportedPreProtation;
563 };
564
565 } // namespace Adaptor
566
567 } // namespace Internal
568
569 } // namespace Dali
570
571 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL_H