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