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