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