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