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