Add Window::SetLayout method
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-base.h
1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_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 // EXTERNAL INCLUDES
22 #include <dali/integration-api/events/key-event-integ.h>
23 #include <dali/integration-api/events/point.h>
24 #include <dali/integration-api/events/wheel-event-integ.h>
25 #include <cstdint>
26 #include <string>
27 #include <vector>
28
29 // INTERNAL INCLUDES
30 #include <dali/devel-api/adaptor-framework/window-devel.h>
31 #include <dali/internal/graphics/gles/egl-implementation.h>
32 #include <dali/internal/window-system/common/damage-observer.h>
33 #include <dali/internal/window-system/common/rotation-event.h>
34 #include <dali/public-api/adaptor-framework/key-grab.h>
35 #include <dali/public-api/adaptor-framework/style-change.h>
36 #include <dali/public-api/adaptor-framework/window-enumerations.h>
37 #include <dali/public-api/adaptor-framework/window.h>
38
39 namespace Dali
40 {
41 namespace Internal
42 {
43 namespace Adaptor
44 {
45 /**
46  * WindowBase interface
47  */
48 class WindowBase
49 {
50 public:
51   /**
52    * @brief Struct used to retrieve accessibility information
53    */
54   struct AccessibilityInfo
55   {
56     int gestureValue;
57     int startX;
58     int startY;
59     int endX;
60     int endY;
61     int state;
62     int eventTime;
63   };
64
65   // Window
66   typedef Signal<void(bool)>                                IconifySignalType;
67   typedef Signal<void(bool)>                                MaximizeSignalType;
68   typedef Signal<void(bool)>                                FocusSignalType;
69   typedef Signal<void()>                                    OutputSignalType;
70   typedef Signal<void()>                                    DeleteSignalType;
71   typedef Signal<void(const DamageArea&)>                   DamageSignalType;
72   typedef Signal<void(const RotationEvent&)>                RotationSignalType;
73   typedef Signal<void(WindowEffectState, WindowEffectType)> TransitionEffectEventSignalType;
74   typedef Signal<void()>                                    KeyboardRepeatSettingsChangedSignalType;
75   typedef Signal<void()>                                    WindowRedrawRequestSignalType;
76   typedef Signal<void(Dali::PositionSize&)>                 UpdatePositionSizeType;
77   typedef Signal<void(const std::string&, const std::string&, const Property::Array&)>             AuxiliaryMessageSignalType;
78
79   // Input events
80   typedef Signal<void(Integration::Point&, uint32_t)> TouchEventSignalType;
81   typedef Signal<void(Integration::WheelEvent&)>      WheelEventSignalType;
82   typedef Signal<void(Integration::KeyEvent&)>        KeyEventSignalType;
83
84   // Clipboard
85   typedef Signal<void(void*)> SelectionSignalType;
86
87   // Accessibility
88   typedef Signal<void(StyleChange::Type)>        StyleSignalType;
89
90   /**
91    * @brief Default constructor
92    */
93   WindowBase();
94
95   /**
96    * @brief Destructor
97    */
98   virtual ~WindowBase();
99
100 public:
101   /**
102    * @brief Get the native window handle
103    * @return The native window handle
104    */
105   virtual Any GetNativeWindow() = 0;
106
107   /**
108    * @brief Get the native window id
109    * @return The native window id
110    */
111   virtual int GetNativeWindowId() = 0;
112
113   /**
114    * @brief Get the native window resource id assinged by window manager
115    * @return The native window resource id
116    */
117   virtual std::string GetNativeWindowResourceId() = 0;
118
119   /**
120    * @brief Create the egl window
121    */
122   virtual EGLNativeWindowType CreateEglWindow(int width, int height) = 0;
123
124   /**
125    * @brief Destroy the egl window
126    */
127   virtual void DestroyEglWindow() = 0;
128
129   /**
130    * @brief Set the egl window rotation
131    */
132   virtual void SetEglWindowRotation(int angle) = 0;
133
134   /**
135    * @brief Set the egl window buffer transform
136    */
137   virtual void SetEglWindowBufferTransform(int angle) = 0;
138
139   /**
140    * @brief Set the egl window transform
141    */
142   virtual void SetEglWindowTransform(int angle) = 0;
143
144   /**
145    * @brief Resize the egl window
146    */
147   virtual void ResizeEglWindow(Dali::PositionSize positionSize) = 0;
148
149   /**
150    * @brief Returns whether the egl window support rotation or not
151    */
152   virtual bool IsEglWindowRotationSupported() = 0;
153
154   /**
155    * @brief Move the window
156    */
157   virtual void Move(Dali::PositionSize positionSize) = 0;
158
159   /**
160    * @brief Resize the window
161    */
162   virtual void Resize(Dali::PositionSize positionSize) = 0;
163
164   /**
165    * @brief Move and resize the window
166    */
167   virtual void MoveResize(Dali::PositionSize positionSize) = 0;
168
169   /**
170    * @copydoc Dali::Window::SetLayout()
171    */
172   virtual void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) = 0;
173
174   /**
175    * @copydoc Dali::Window::SetClass()
176    */
177   virtual void SetClass(const std::string& name, const std::string& className) = 0;
178
179   /**
180    * @copydoc Dali::Window::Raise()
181    */
182   virtual void Raise() = 0;
183
184   /**
185    * @copydoc Dali::Window::Lower()
186    */
187   virtual void Lower() = 0;
188
189   /**
190    * @copydoc Dali::Window::Activate()
191    */
192   virtual void Activate() = 0;
193
194   /**
195    * @copydoc Dali::DevelWindow::Maximize()
196    */
197   virtual void Maximize(bool maximize) = 0;
198
199   /**
200    * @copydoc Dali::DevelWindow::IsMaximized()
201    */
202   virtual bool IsMaximized() const = 0;
203
204   /**
205    * @copydoc Dali::DevelWindow::SetMaximumSize()
206    */
207   virtual void SetMaximumSize(Dali::Window::WindowSize size) = 0;
208
209   /**
210    * @copydoc Dali::DevelWindow::Minimize()
211    */
212   virtual void Minimize(bool minimize) = 0;
213
214   /**
215    * @copydoc Dali::DevelWindow::IsMinimized()
216    */
217   virtual bool IsMinimized() const = 0;
218
219   /**
220    * @copydoc Dali::DevelWindow::SetMimimumSize()
221    */
222   virtual void SetMimimumSize(Dali::Window::WindowSize size) = 0;
223
224   /**
225    * @copydoc Dali::Window::SetAvailableOrientations()
226    */
227   virtual void SetAvailableAnlges(const std::vector<int>& angles) = 0;
228
229   /**
230    * @copydoc Dali::Window::SetPreferredOrientation()
231    */
232   virtual void SetPreferredAngle(int angle) = 0;
233
234   /**
235    * @copydoc Dali::Window::SetAcceptFocus()
236    */
237   virtual void SetAcceptFocus(bool accept) = 0;
238
239   /**
240    * @copydoc Dali::Window::Show()
241    */
242   virtual void Show() = 0;
243
244   /**
245    * @copydoc Dali::Window::Hide()
246    */
247   virtual void Hide() = 0;
248
249   /**
250    * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
251    */
252   virtual unsigned int GetSupportedAuxiliaryHintCount() const = 0;
253
254   /**
255    * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
256    */
257   virtual std::string GetSupportedAuxiliaryHint(unsigned int index) const = 0;
258
259   /**
260    * @copydoc Dali::Window::AddAuxiliaryHint()
261    */
262   virtual unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) = 0;
263
264   /**
265    * @copydoc Dali::Window::RemoveAuxiliaryHint()
266    */
267   virtual bool RemoveAuxiliaryHint(unsigned int id) = 0;
268
269   /**
270    * @copydoc Dali::Window::SetAuxiliaryHintValue()
271    */
272   virtual bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) = 0;
273
274   /**
275    * @copydoc Dali::Window::GetAuxiliaryHintValue()
276    */
277   virtual std::string GetAuxiliaryHintValue(unsigned int id) const = 0;
278
279   /**
280    * @copydoc Dali::Window::GetAuxiliaryHintId()
281    */
282   virtual unsigned int GetAuxiliaryHintId(const std::string& hint) const = 0;
283
284   /**
285    * @copydoc Dali::Window::SetInputRegion()
286    */
287   virtual void SetInputRegion(const Rect<int>& inputRegion) = 0;
288
289   /**
290    * @copydoc Dali::Window::SetType()
291    */
292   virtual void SetType(Dali::WindowType type) = 0;
293
294   /**
295    * @copydoc Dali::Window::GetType()
296    */
297   virtual Dali::WindowType GetType() const = 0;
298
299   /**
300    * @copydoc Dali::Window::SetNotificationLevel()
301    */
302   virtual Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) = 0;
303
304   /**
305    * @copydoc Dali::Window::GetNotificationLevel()
306    */
307   virtual Dali::WindowNotificationLevel GetNotificationLevel() const = 0;
308
309   /**
310    * @copydoc Dali::Window::SetOpaqueState()
311    */
312   virtual void SetOpaqueState(bool opaque) = 0;
313
314   /**
315    * @copydoc Dali::Window::SetScreenOffMode()
316    */
317   virtual Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) = 0;
318
319   /**
320    * @copydoc Dali::Window::GetScreenOffMode()
321    */
322   virtual WindowScreenOffMode GetScreenOffMode() const = 0;
323
324   /**
325    * @copydoc Dali::Window::SetBrightness()
326    */
327   virtual Dali::WindowOperationResult SetBrightness(int brightness) = 0;
328
329   /**
330    * @copydoc Dali::Window::GetBrightness()
331    */
332   virtual int GetBrightness() const = 0;
333
334   /**
335    * @copydoc Dali::KeyGrab::GrabKey()
336    */
337   virtual bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) = 0;
338
339   /**
340    * @copydoc Dali::KeyGrab::UngrabKey()
341    */
342   virtual bool UngrabKey(Dali::KEY key) = 0;
343
344   /**
345    * @copydoc Dali::KeyGrab::GrabKeyList()
346    */
347   virtual bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) = 0;
348
349   /**
350    * @copydoc Dali::KeyGrab::UngrabKeyList()
351    */
352   virtual bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) = 0;
353
354   /**
355    * @brief Get DPI
356    * @param[out] dpiHorizontal set to the horizontal dpi
357    * @param[out] dpiVertical set to the vertical dpi
358    */
359   virtual void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) = 0;
360
361   /**
362    * @brief Return the angle of the window's rotation.
363    * @return The window orientation
364    */
365   virtual int GetWindowRotationAngle() const = 0;
366
367   /**
368    * @brief Get the angle of screen rotation for the window
369    * @return The screen orientation
370    */
371   virtual int GetScreenRotationAngle() = 0;
372
373   /**
374    * @brief Set the screen rotation angle of the window
375    */
376   virtual void SetWindowRotationAngle(int degree) = 0;
377
378   /**
379    * @brief Inform the window rotation is completed
380    */
381   virtual void WindowRotationCompleted(int degree, int width, int height) = 0;
382
383   /**
384    * @brief starts the window is moved by display server
385    */
386   virtual void RequestMoveToServer() = 0;
387
388   /**
389    * @brief starts the window is resized by display server
390    *
391    * @param[in] direction It is direction of the started edge/side.
392    */
393   virtual void RequestResizeToServer(WindowResizeDirection direction) = 0;
394
395   /**
396    * @brief Enables the floating mode of window.
397    *
398    * The floating mode is to support making partial size window easliy.
399    * It is useful to make popup style window
400    * and this window is always upper than the other normal window.
401    *
402    * A special display server(as a Tizen display server) supports this mode.
403    *
404    * @param[in] enable Enable floating mode or not.
405    */
406   virtual void EnableFloatingMode(bool enable) = 0;
407
408   /**
409    * @brief Gets whether floating mode is enabled or not.
410    */
411   virtual bool IsFloatingModeEnabled() const = 0;
412
413   /**
414    * @copydoc Dali::Window::SetTransparency()
415    */
416   virtual void SetTransparency(bool transparent) = 0;
417
418   /**
419    * @copydoc Dali::Window::SetParent()
420    */
421   virtual void SetParent(WindowBase* parentWinBase, bool belowParent) = 0;
422
423   /**
424    * @brief Create a sync fence that can tell the frame is rendered by the graphics driver.
425    * @return The file descriptor that tells when it is rendered.
426    */
427   virtual int CreateFrameRenderedSyncFence() = 0;
428
429   /**
430    * @brief Create a sync fence that can tell the frame is presented by the display server.
431    * @return The file descriptor that tells when it is presented.
432    */
433   virtual int CreateFramePresentedSyncFence() = 0;
434
435   /**
436    * @copydoc Dali::Window::SetPositionSizeWithAngle()
437    */
438   virtual void SetPositionSizeWithAngle(PositionSize positionSize, int angle) = 0;
439
440   /**
441    * @brief Initialize for Ime window.
442    * It should be called when the window is only used for Ime keyboard window.
443    */
444   virtual void InitializeIme() = 0;
445
446   /**
447    * @brief Send the signal to display server for Ime Window is ready to render.
448    * It is used for compositing by display server.
449    */
450   virtual void ImeWindowReadyToRender() = 0;
451
452   /**
453    * @brief Includes input region.
454    * @param[in] inputRegion The added region to accept input events.
455    */
456   virtual void IncludeInputRegion(const Rect<int>& inputRegion) = 0;
457
458   /**
459    * @brief Excludes input region.
460    * @param[in] inputRegion The subtracted region to except input events.
461    */
462   virtual void ExcludeInputRegion(const Rect<int>& inputRegion) = 0;
463
464   // Signals
465
466   /**
467    * @brief This signal is emitted when the window becomes iconified or deiconified.
468    */
469   IconifySignalType& IconifyChangedSignal();
470
471   /**
472    * @brief This signal is emitted when the window becomes maximized or unmaximized.
473    */
474   MaximizeSignalType& MaximizeChangedSignal();
475
476   /**
477    * @brief This signal is emitted when the window focus is changed.
478    */
479   FocusSignalType& FocusChangedSignal();
480
481   /**
482    * @brief This signal is emitted when the output is transformed.
483    */
484   OutputSignalType& OutputTransformedSignal();
485
486   /**
487    * @brief This signal is emitted when the window receives a delete request.
488    */
489   DeleteSignalType& DeleteRequestSignal();
490
491   /**
492    * @brief This signal is emitted when the window is damaged.
493    */
494   DamageSignalType& WindowDamagedSignal();
495
496   /**
497    * @brief This signal is emitted when a rotation event is recevied.
498    */
499   RotationSignalType& RotationSignal();
500
501   /**
502    * @brief This signal is emitted when a touch event is received.
503    */
504   TouchEventSignalType& TouchEventSignal();
505
506   /**
507    * @brief This signal is emitted when a mouse wheel is received.
508    */
509   WheelEventSignalType& WheelEventSignal();
510
511   /**
512    * @brief This signal is emitted when a key event is received.
513    */
514   KeyEventSignalType& KeyEventSignal();
515
516   /**
517    * @brief This signal is emitted when the source window notifies us the content in clipboard is selected.
518    */
519   SelectionSignalType& SelectionDataSendSignal();
520
521   /**
522    * @brief This signal is emitted when the source window sends us about the selected content.
523    */
524   SelectionSignalType& SelectionDataReceivedSignal();
525
526   /**
527    * @brief This signal is emitted when the style is changed.
528    */
529   StyleSignalType& StyleChangedSignal();
530
531   /**
532    * @brief This signal is emitted when window's transition animation is started or ended.
533    */
534   TransitionEffectEventSignalType& TransitionEffectEventSignal();
535
536   /**
537    * @brief This signal is emitted when the keyboard repeat is changed.
538    */
539   KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal();
540
541   /**
542    * @brief This signal is emitted when the window redraw is requested.
543    */
544   WindowRedrawRequestSignalType& WindowRedrawRequestSignal();
545
546   /**
547    * @brief This signal is emitted when the window is resized or moved by display server.
548    */
549   UpdatePositionSizeType& UpdatePositionSizeSignal();
550
551   /**
552    * @brief This signal is emitted when the window is received the auxiliary message from display server.
553    */
554   AuxiliaryMessageSignalType& AuxiliaryMessageSignal();
555
556 protected:
557   // Undefined
558   WindowBase(const WindowBase&) = delete;
559
560   // Undefined
561   WindowBase& operator=(const WindowBase& rhs) = delete;
562
563 protected:
564   IconifySignalType                       mIconifyChangedSignal;
565   MaximizeSignalType                      mMaximizeChangedSignal;
566   FocusSignalType                         mFocusChangedSignal;
567   OutputSignalType                        mOutputTransformedSignal;
568   DeleteSignalType                        mDeleteRequestSignal;
569   DamageSignalType                        mWindowDamagedSignal;
570   RotationSignalType                      mRotationSignal;
571   TouchEventSignalType                    mTouchEventSignal;
572   WheelEventSignalType                    mWheelEventSignal;
573   KeyEventSignalType                      mKeyEventSignal;
574   SelectionSignalType                     mSelectionDataSendSignal;
575   SelectionSignalType                     mSelectionDataReceivedSignal;
576   StyleSignalType                         mStyleChangedSignal;
577   TransitionEffectEventSignalType         mTransitionEffectEventSignal;
578   KeyboardRepeatSettingsChangedSignalType mKeyboardRepeatSettingsChangedSignal;
579   WindowRedrawRequestSignalType           mWindowRedrawRequestSignal;
580   UpdatePositionSizeType                  mUpdatePositionSizeSignal;
581   AuxiliaryMessageSignalType              mAuxiliaryMessageSignal;
582 };
583
584 } // namespace Adaptor
585
586 } // namespace Internal
587
588 } // namespace Dali
589
590 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H