[AT-SPI] Add resource id to window attribute
[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) 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
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::GetNativeWindowResourceId()
128    */
129   std::string GetNativeWindowResourceId() override;
130
131   /**
132    * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
133    */
134   EGLNativeWindowType CreateEglWindow(int width, int height) override;
135
136   /**
137    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
138    */
139   void DestroyEglWindow() override;
140
141   /**
142    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
143    */
144   void SetEglWindowRotation(int angle) override;
145
146   /**
147    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
148    */
149   void SetEglWindowBufferTransform(int angle) override;
150
151   /**
152    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
153    */
154   void SetEglWindowTransform(int angle) override;
155
156   /**
157    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
158    */
159   void ResizeEglWindow(PositionSize positionSize) override;
160
161   /**
162    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
163    */
164   bool IsEglWindowRotationSupported() override;
165
166   /**
167    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
168    */
169   void Move(PositionSize positionSize) override;
170
171   /**
172    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
173    */
174   void Resize(PositionSize positionSize) override;
175
176   /**
177    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
178    */
179   void MoveResize(PositionSize positionSize) override;
180
181   /**
182    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
183    */
184   void SetClass(const std::string& name, const std::string& className) override;
185
186   /**
187    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
188    */
189   void Raise() override;
190
191   /**
192    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
193    */
194   void Lower() override;
195
196   /**
197    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
198    */
199   void Activate() override;
200
201   /**
202    * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
203    */
204   void Maximize(bool maximize) override;
205
206   /**
207    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
208    */
209   bool IsMaximized() const override;
210
211   /**
212    * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
213    */
214   void Minimize(bool minimize) override;
215
216   /**
217    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
218    */
219   bool IsMinimized() const override;
220
221   /**
222    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
223    */
224   void SetAvailableAnlges(const std::vector<int>& angles) override;
225
226   /**
227    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
228    */
229   void SetPreferredAngle(int angle) override;
230
231   /**
232    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
233    */
234   void SetAcceptFocus(bool accept) override;
235
236   /**
237    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
238    */
239   void Show() override;
240
241   /**
242    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
243    */
244   void Hide() override;
245
246   /**
247    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
248    */
249   unsigned int GetSupportedAuxiliaryHintCount() const override;
250
251   /**
252    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
253    */
254   std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
255
256   /**
257    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
258    */
259   unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
260
261   /**
262    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
263    */
264   bool RemoveAuxiliaryHint(unsigned int id) override;
265
266   /**
267    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
268    */
269   bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
270
271   /**
272    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
273    */
274   std::string GetAuxiliaryHintValue(unsigned int id) const override;
275
276   /**
277    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
278    */
279   unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
280
281   /**
282    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
283    */
284   void SetInputRegion(const Rect<int>& inputRegion) override;
285
286   /**
287    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
288    */
289   void SetType(Dali::WindowType type) override;
290
291   /**
292    * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
293    */
294   Dali::WindowType GetType() const override;
295
296   /**
297    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
298    */
299   Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
300
301   /**
302    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
303    */
304   Dali::WindowNotificationLevel GetNotificationLevel() const override;
305
306   /**
307    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
308    */
309   void SetOpaqueState(bool opaque) override;
310
311   /**
312    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
313    */
314   Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
315
316   /**
317    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
318    */
319   WindowScreenOffMode GetScreenOffMode() const override;
320
321   /**
322    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
323    */
324   Dali::WindowOperationResult SetBrightness(int brightness) override;
325
326   /**
327    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
328    */
329   int GetBrightness() const override;
330
331   /**
332    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
333    */
334   bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
335
336   /**
337    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
338    */
339   bool UngrabKey(Dali::KEY key) override;
340
341   /**
342    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
343    */
344   bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
345
346   /**
347    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
348    */
349   bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
350
351   /**
352    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
353    */
354   void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
355
356   /**
357    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
358    */
359   int GetScreenRotationAngle() override;
360
361   /**
362    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
363    */
364   void SetWindowRotationAngle(int degree) override;
365
366   /**
367    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
368    */
369   void WindowRotationCompleted(int degree, int width, int height) override;
370
371   /**
372    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
373    */
374   void SetTransparency(bool transparent) override;
375
376   /**
377    * @copydoc  Dali::Internal::Adaptor::WindowBase::SetParent()
378    */
379   void SetParent(WindowBase* parentWinBase, bool belowParent) override;
380
381   /**
382    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
383    */
384   int CreateFrameRenderedSyncFence() override;
385
386   /**
387    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
388    */
389   int CreateFramePresentedSyncFence() override;
390
391   /**
392    * @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
393    */
394   int GetOrientation() const override;
395
396   /**
397    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
398    */
399   void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
400
401   /**
402    * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
403    */
404   void InitializeIme() override;
405
406   /**
407    * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
408    */
409   void ImeWindowReadyToRender() override;
410
411   /**
412    *
413    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
414    */
415   void RequestMoveToServer() override;
416
417   /**
418    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
419    */
420   void RequestResizeToServer(WindowResizeDirection direction) override;
421
422   /**
423    * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
424    */
425   void EnableFloatingMode(bool enable) override;
426
427   /**
428    * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
429    */
430   bool IsFloatingModeEnabled() const override;
431
432   /**
433    * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
434    */
435   void IncludeInputRegion(const Rect<int>& inputRegion) override;
436
437   /**
438    * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
439    */
440   void ExcludeInputRegion(const Rect<int>& inputRegion) override;
441
442 private:
443   /**
444    * Second stage initialization
445    */
446   void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
447
448   /**
449    * @brief Get the surface id if the surface parameter is not empty
450    * @param surface Any containing a surface id, or can be empty
451    * @return surface id, or zero if surface is empty
452    */
453   unsigned int GetSurfaceId(Any surface) const;
454
455 protected:
456   // Undefined
457   WindowBaseAndroid(const WindowBaseAndroid&) = delete;
458
459   // Undefined
460   WindowBaseAndroid& operator=(const WindowBaseAndroid& rhs) = delete;
461
462 private:
463   ANativeWindow* mWindow;         ///< Native window handle
464   bool           mOwnSurface : 1; ///< Whether we own the surface (responsible for deleting it)
465   bool           mIsTransparent;  ///< Whether the window is transparent (32 bit or 24 bit)
466   bool           mRotationAppSet : 1;
467 };
468
469 } // namespace Adaptor
470
471 } // namespace Internal
472
473 } // namespace Dali
474
475 #endif // DALI_INTERNAL_WINDOWSYSTEM_ANDROID_WINDOW_BASE_ANDROID_H