Add Window::SetLayout method
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / ubuntu-x11 / window-base-ecore-x.h
1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_ECOREX_WINDOW_BASE_ECORE_X_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_ECOREX_WINDOW_BASE_ECORE_X_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 <dali/internal/system/linux/dali-ecore-x.h>
26 #include <dali/internal/system/linux/dali-ecore.h>
27
28 namespace Dali
29 {
30 namespace Internal
31 {
32 namespace Adaptor
33 {
34 /**
35  * WindowBaseEcoreX class provides an WindowBase EcoreX implementation.
36  */
37 class WindowBaseEcoreX : public WindowBase
38 {
39 public:
40   /**
41    * @brief Constructor
42    */
43   WindowBaseEcoreX(PositionSize positionSize, Any surface, bool isTransparent);
44
45   /**
46    * @brief Destructor
47    */
48   virtual ~WindowBaseEcoreX();
49
50 public:
51   /**
52    * @brief Called when the window configuration is changed.
53    */
54   void OnWindowConfigure(void* event);
55
56   /**
57    * @brief Called when the window property is changed.
58    */
59   Eina_Bool OnWindowPropertyChanged(void* data, int type, void* event);
60
61   /**
62    * @brief Called when the window receives a delete request
63    */
64   void OnDeleteRequest();
65
66   /**
67    * @brief Called when the window gains focus.
68    */
69   void OnFocusIn(void* data, int type, void* event);
70
71   /**
72    * @brief Called when the window loses focus.
73    */
74   void OnFocusOut(void* data, int type, void* event);
75
76   /**
77    * @brief Called when the window is damaged.
78    */
79   void OnWindowDamaged(void* data, int type, void* event);
80
81   /**
82    * @brief Called when a touch down is received.
83    */
84   void OnMouseButtonDown(void* data, int type, void* event);
85
86   /**
87    * @brief Called when a touch up is received.
88    */
89   void OnMouseButtonUp(void* data, int type, void* event);
90
91   /**
92    * @brief Called when a touch motion is received.
93    */
94   void OnMouseButtonMove(void* data, int type, void* event);
95
96   /**
97    * @brief Called when a mouse wheel is received.
98    */
99   void OnMouseWheel(void* data, int type, void* event);
100
101   /**
102    * @brief Called when a key down is received.
103    */
104   void OnKeyDown(void* data, int type, void* event);
105
106   /**
107    * @brief Called when a key up is received.
108    */
109   void OnKeyUp(void* data, int type, void* event);
110
111   /**
112    * @brief Called when the source window notifies us the content in clipboard is selected.
113    */
114   void OnSelectionClear(void* data, int type, void* event);
115
116   /**
117    * @brief Called when the source window sends us about the selected content.
118    */
119   void OnSelectionNotify(void* data, int type, void* event);
120
121 public:
122   /**
123    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
124    */
125   Any GetNativeWindow() override;
126
127   /**
128    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
129    */
130   int GetNativeWindowId() override;
131
132   /**
133    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowResourceId()
134    */
135   std::string GetNativeWindowResourceId() override;
136
137   /**
138    * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
139    */
140   EGLNativeWindowType CreateEglWindow(int width, int height) override;
141
142   /**
143    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
144    */
145   void DestroyEglWindow() override;
146
147   /**
148    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
149    */
150   void SetEglWindowRotation(int angle) override;
151
152   /**
153    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
154    */
155   void SetEglWindowBufferTransform(int angle) override;
156
157   /**
158    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
159    */
160   void SetEglWindowTransform(int angle) override;
161
162   /**
163    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
164    */
165   void ResizeEglWindow(PositionSize positionSize) override;
166
167   /**
168    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
169    */
170   bool IsEglWindowRotationSupported() override;
171
172   /**
173    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
174    */
175   void Move(PositionSize positionSize) override;
176
177   /**
178    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
179    */
180   void Resize(PositionSize positionSize) override;
181
182   /**
183    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
184    */
185   void MoveResize(PositionSize positionSize) override;
186
187   /**
188    * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout()
189    */
190   void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override;
191
192   /**
193    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
194    */
195   void SetClass(const std::string& name, const std::string& className) override;
196
197   /**
198    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
199    */
200   void Raise() override;
201
202   /**
203    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
204    */
205   void Lower() override;
206
207   /**
208    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
209    */
210   void Activate() override;
211
212   /**
213    * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
214    */
215   void Maximize(bool maximize) override;
216
217   /**
218    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
219    */
220   bool IsMaximized() const override;
221
222   /**
223    * @copydoc Dali::Internal::Adaptor::WindowBase::SetMaximumSize()
224    */
225   void SetMaximumSize(Dali::Window::WindowSize size) override;
226
227   /**
228    * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
229    */
230   void Minimize(bool minimize) override;
231
232   /**
233    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
234    */
235   bool IsMinimized() const override;
236
237   /**
238    * @copydoc Dali::Internal::Adaptor::WindowBase::SetMimimumSize()
239    */
240   void SetMimimumSize(Dali::Window::WindowSize size) override;
241
242   /**
243    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
244    */
245   void SetAvailableAnlges(const std::vector<int>& angles) override;
246
247   /**
248    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
249    */
250   void SetPreferredAngle(int angle) override;
251
252   /**
253    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
254    */
255   void SetAcceptFocus(bool accept) override;
256
257   /**
258    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
259    */
260   void Show() override;
261
262   /**
263    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
264    */
265   void Hide() override;
266
267   /**
268    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
269    */
270   unsigned int GetSupportedAuxiliaryHintCount() const override;
271
272   /**
273    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
274    */
275   std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
276
277   /**
278    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
279    */
280   unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
281
282   /**
283    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
284    */
285   bool RemoveAuxiliaryHint(unsigned int id) override;
286
287   /**
288    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
289    */
290   bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
291
292   /**
293    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
294    */
295   std::string GetAuxiliaryHintValue(unsigned int id) const override;
296
297   /**
298    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
299    */
300   unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
301
302   /**
303    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
304    */
305   void SetInputRegion(const Rect<int>& inputRegion) override;
306
307   /**
308    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
309    */
310   void SetType(Dali::WindowType type) override;
311
312   /**
313    * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
314    */
315   Dali::WindowType GetType() const override;
316
317   /**
318    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
319    */
320   Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
321
322   /**
323    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
324    */
325   Dali::WindowNotificationLevel GetNotificationLevel() const override;
326
327   /**
328    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
329    */
330   void SetOpaqueState(bool opaque) override;
331
332   /**
333    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
334    */
335   Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
336
337   /**
338    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
339    */
340   WindowScreenOffMode GetScreenOffMode() const override;
341
342   /**
343    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
344    */
345   Dali::WindowOperationResult SetBrightness(int brightness) override;
346
347   /**
348    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
349    */
350   int GetBrightness() const override;
351
352   /**
353    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
354    */
355   bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
356
357   /**
358    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
359    */
360   bool UngrabKey(Dali::KEY key) override;
361
362   /**
363    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
364    */
365   bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
366
367   /**
368    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
369    */
370   bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
371
372   /**
373    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
374    */
375   void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
376
377   /**
378    * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
379    */
380   int GetWindowRotationAngle() const override;
381
382   /**
383    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
384    */
385   int GetScreenRotationAngle() override;
386
387   /**
388    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
389    */
390   void SetWindowRotationAngle(int degree) override;
391
392   /**
393    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
394    */
395   void WindowRotationCompleted(int degree, int width, int height) override;
396
397   /**
398    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
399    */
400   void SetTransparency(bool transparent) override;
401
402   /**
403    * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
404    */
405   void SetParent(WindowBase* parentWinBase, bool belowParent) override;
406
407   /**
408    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
409    */
410   int CreateFrameRenderedSyncFence() override;
411
412   /**
413    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
414    */
415   int CreateFramePresentedSyncFence() override;
416
417   /**
418    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
419    */
420   void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
421
422   /**
423    * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
424    */
425   void InitializeIme() override;
426
427   /**
428    * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
429    */
430   void ImeWindowReadyToRender() override;
431
432   /**
433    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
434    */
435   void RequestMoveToServer() override;
436
437   /**
438    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
439    */
440   void RequestResizeToServer(WindowResizeDirection direction) override;
441
442   /**
443    * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
444    */
445   void EnableFloatingMode(bool enable) override;
446
447   /**
448    * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
449    */
450   bool IsFloatingModeEnabled() const override;
451
452   /**
453    * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
454    */
455   void IncludeInputRegion(const Rect<int>& inputRegion) override;
456
457   /**
458    * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
459    */
460   void ExcludeInputRegion(const Rect<int>& inputRegion) override;
461
462 private:
463   /**
464    * Second stage initialization
465    */
466   void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
467
468   /**
469    * @brief Get the surface id if the surface parameter is not empty
470    * @param surface Any containing a surface id, or can be empty
471    * @return surface id, or zero if surface is empty
472    */
473   unsigned int GetSurfaceId(Any surface) const;
474
475   /**
476    * @brief Create window
477    */
478   void CreateWindow(PositionSize positionSize, bool isTransparent);
479
480 protected:
481   // Undefined
482   WindowBaseEcoreX(const WindowBaseEcoreX&) = delete;
483
484   // Undefined
485   WindowBaseEcoreX& operator=(const WindowBaseEcoreX& rhs) = delete;
486
487 private:
488   Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
489   Ecore_X_Window                     mEcoreWindow;    ///< Native window handle
490   bool                               mOwnSurface : 1; ///< Whether we own the surface (responsible for deleting it)
491   bool                               mIsTransparent;  ///< Whether the window is transparent (32 bit or 24 bit)
492   bool                               mRotationAppSet : 1;
493   int                                mWindowRotationAngle;
494 };
495
496 } // namespace Adaptor
497
498 } // namespace Internal
499
500 } // namespace Dali
501
502 #endif // DALI_INTERNAL_WINDOWSYSTEM_ECOREX_WINDOW_BASE_ECORE_X_H