Fix race-condition when window is resized or rotated.
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / macos / window-base-mac.h
1 #pragma once
2
3 /*
4  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 // INTERNAL INCLUDES
21 #include <dali/internal/window-system/common/window-base.h>
22 #include <memory>
23
24 namespace Dali::Internal::Adaptor
25 {
26 /**
27  * WindowBaseCocoa class provides an WindowBase Win32 implementation.
28  */
29 class WindowBaseCocoa : public WindowBase
30 {
31 public:
32   struct Impl;
33
34   /**
35    * @brief Constructor
36    */
37   WindowBaseCocoa(PositionSize positionSize, Any surface, bool isTransparent);
38
39   /**
40    * @brief Destructor
41    */
42   ~WindowBaseCocoa();
43
44 public:
45   /**
46    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
47    */
48   Any GetNativeWindow() override;
49
50   /**
51    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
52    */
53   int GetNativeWindowId() override;
54
55   /**
56    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowResourceId()
57    */
58   std::string GetNativeWindowResourceId() override;
59
60   /**
61   * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
62    */
63   EGLNativeWindowType CreateEglWindow(int width, int height) override;
64
65   /**
66    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
67    */
68   void DestroyEglWindow() override;
69
70   /**
71    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
72    */
73   void SetEglWindowRotation(int angle) override;
74
75   /**
76    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
77    */
78   void SetEglWindowBufferTransform(int angle) override;
79
80   /**
81    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
82    */
83   void SetEglWindowTransform(int angle) override;
84
85   /**
86    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
87    */
88   void ResizeEglWindow(PositionSize positionSize) override;
89
90   /**
91    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
92    */
93   bool IsEglWindowRotationSupported() override;
94
95   /**
96    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
97    */
98   void Move(PositionSize positionSize) override;
99
100   /**
101    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
102    */
103   void Resize(PositionSize positionSize) override;
104
105   /**
106    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
107    */
108   void MoveResize(PositionSize positionSize) override;
109
110   /**
111    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
112    */
113   void SetClass(const std::string& name, const std::string& className) override;
114
115   /**
116    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
117    */
118   void Raise() override;
119
120   /**
121    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
122    */
123   void Lower() override;
124
125   /**
126    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
127    */
128   void Activate() override;
129
130   /**
131    * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
132    */
133   void Maximize(bool maximize) override;
134
135   /**
136    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
137    */
138   bool IsMaximized() const override;
139
140   /**
141    * @copydoc Dali::Internal::Adaptor::WindowBase::SetMaximumSize()
142    */
143   void SetMaximumSize(Dali::Window::WindowSize size) override;
144
145   /**
146    * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
147    */
148   void Minimize(bool minimize) override;
149
150   /**
151    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
152    */
153   bool IsMinimized() const override;
154
155   /**
156    * @copydoc Dali::Internal::Adaptor::WindowBase::SetMimimumSize()
157    */
158   void SetMimimumSize(Dali::Window::WindowSize size) override;
159
160   /**
161    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
162    */
163   void SetAvailableAnlges(const std::vector<int>& angles) override;
164
165   /**
166    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
167    */
168   void SetPreferredAngle(int angle) override;
169
170   /**
171    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
172    */
173   void SetAcceptFocus(bool accept) override;
174
175   /**
176    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
177    */
178   void Show() override;
179
180   /**
181    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
182    */
183   void Hide() override;
184
185   /**
186    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
187    */
188   unsigned int GetSupportedAuxiliaryHintCount() const override;
189
190   /**
191    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
192    */
193   std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
194
195   /**
196    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
197    */
198   unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
199
200   /**
201    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
202    */
203   bool RemoveAuxiliaryHint(unsigned int id) override;
204
205   /**
206    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
207    */
208   bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
209
210   /**
211    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
212    */
213   std::string GetAuxiliaryHintValue(unsigned int id) const override;
214
215   /**
216    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
217    */
218   unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
219
220   /**
221    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
222    */
223   void SetInputRegion(const Rect<int>& inputRegion) override;
224
225   /**
226    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
227    */
228   void SetType(Dali::WindowType type) override;
229
230   /**
231    * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
232    */
233   Dali::WindowType GetType() const override;
234
235   /**
236    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
237    */
238   WindowOperationResult SetNotificationLevel(WindowNotificationLevel level) override;
239
240   /**
241    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
242    */
243   WindowNotificationLevel GetNotificationLevel() const override;
244
245   /**
246    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
247    */
248   void SetOpaqueState(bool opaque) override;
249
250   /**
251    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
252    */
253   WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
254
255   /**
256    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
257    */
258   WindowScreenOffMode GetScreenOffMode() const override;
259
260   /**
261    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
262    */
263   WindowOperationResult SetBrightness(int brightness) override;
264
265   /**
266    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
267    */
268   int GetBrightness() const override;
269
270   /**
271    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
272    */
273   bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
274
275   /**
276    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
277    */
278   bool UngrabKey(Dali::KEY key) override;
279
280   /**
281    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
282    */
283   bool GrabKeyList(
284     const Dali::Vector<Dali::KEY>&            key,
285     const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode,
286     Dali::Vector<bool>&                       result) override;
287
288   /**
289    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
290    */
291   bool UngrabKeyList(
292     const Dali::Vector<Dali::KEY>& key,
293     Dali::Vector<bool>&            result) override;
294
295   /**
296    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
297    */
298   void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
299
300   /**
301    * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
302    */
303   int GetWindowRotationAngle() const override;
304
305   /**
306    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
307    */
308   int GetScreenRotationAngle() override;
309
310   /**
311    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
312    */
313   void SetWindowRotationAngle(int degree) override;
314
315   /**
316    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
317    */
318   void WindowRotationCompleted(int degree, int width, int height) override;
319
320   /**
321    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
322    */
323   void SetTransparency(bool transparent) override;
324
325   /**
326    * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
327    */
328   void SetParent(WindowBase* parentWinBase, bool belowParent) override;
329
330   /**
331    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
332    */
333   int CreateFrameRenderedSyncFence() override;
334
335   /**
336    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
337    */
338   int CreateFramePresentedSyncFence() override;
339
340   /**
341    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
342    */
343   void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
344
345   /**
346    * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
347    */
348   void InitializeIme() override;
349
350   /**
351    * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
352    */
353   void ImeWindowReadyToRender() override;
354
355   /**
356    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
357    */
358   void RequestMoveToServer() override;
359
360   /**
361    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
362    */
363   void RequestResizeToServer(WindowResizeDirection direction) override;
364
365   /**
366    * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
367    */
368   void EnableFloatingMode(bool enable) override;
369
370   /**
371    * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
372    */
373   bool IsFloatingModeEnabled() const override;
374
375   /**
376    * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
377    */
378   void IncludeInputRegion(const Rect<int>& inputRegion) override;
379
380   /**
381    * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
382    */
383   void ExcludeInputRegion(const Rect<int>& inputRegion) override;
384
385 private:
386   // Undefined
387   WindowBaseCocoa(const WindowBaseCocoa&) = delete;
388
389   // Undefined
390   WindowBaseCocoa& operator=(const WindowBaseCocoa& rhs) = delete;
391
392 private:
393   std::unique_ptr<Impl> mImpl;
394 };
395
396 } // namespace Dali::Internal::Adaptor