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