[dali_2.3.24] Merge branch 'devel/master'
[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) 2023 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::GetNativeWindowResourceId()
116    */
117   std::string GetNativeWindowResourceId() override;
118
119   /**
120    * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
121    */
122   EGLNativeWindowType CreateEglWindow(int width, int height) override;
123
124   /**
125    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
126    */
127   void DestroyEglWindow() override;
128
129   /**
130    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
131    */
132   void SetEglWindowRotation(int angle) override;
133
134   /**
135    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
136    */
137   void SetEglWindowBufferTransform(int angle) override;
138
139   /**
140    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
141    */
142   void SetEglWindowTransform(int angle) override;
143
144   /**
145    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
146    */
147   void ResizeEglWindow(PositionSize positionSize) override;
148
149   /**
150    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
151    */
152   bool IsEglWindowRotationSupported() override;
153
154   /**
155    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
156    */
157   void Move(PositionSize positionSize) override;
158
159   /**
160    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
161    */
162   void Resize(PositionSize positionSize) override;
163
164   /**
165    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
166    */
167   void MoveResize(PositionSize positionSize) override;
168
169   /**
170    * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout()
171    */
172   void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override;
173
174   /**
175    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
176    */
177   void SetClass(const std::string& name, const std::string& className) override;
178
179   /**
180    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
181    */
182   void Raise() override;
183
184   /**
185    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
186    */
187   void Lower() override;
188
189   /**
190    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
191    */
192   void Activate() override;
193
194   /**
195    * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
196    */
197   void Maximize(bool maximize) override;
198
199   /**
200    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
201    */
202   bool IsMaximized() const override;
203
204   /**
205    * @copydoc Dali::Internal::Adaptor::WindowBase::SetMaximumSize()
206    */
207   void SetMaximumSize(Dali::Window::WindowSize size) override;
208
209   /**
210    * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
211    */
212   void Minimize(bool minimize) override;
213
214   /**
215    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
216    */
217   bool IsMinimized() const override;
218
219   /**
220    * @copydoc Dali::Internal::Adaptor::WindowBase::SetMimimumSize()
221    */
222   void SetMimimumSize(Dali::Window::WindowSize size) override;
223
224   /**
225    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
226    */
227   void SetAvailableAnlges(const std::vector<int>& angles) override;
228
229   /**
230    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
231    */
232   void SetPreferredAngle(int angle) override;
233
234   /**
235    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
236    */
237   void SetAcceptFocus(bool accept) override;
238
239   /**
240    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
241    */
242   void Show() override;
243
244   /**
245    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
246    */
247   void Hide() override;
248
249   /**
250    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
251    */
252   unsigned int GetSupportedAuxiliaryHintCount() const override;
253
254   /**
255    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
256    */
257   std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
258
259   /**
260    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
261    */
262   unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
263
264   /**
265    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
266    */
267   bool RemoveAuxiliaryHint(unsigned int id) override;
268
269   /**
270    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
271    */
272   bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
273
274   /**
275    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
276    */
277   std::string GetAuxiliaryHintValue(unsigned int id) const override;
278
279   /**
280    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
281    */
282   unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
283
284   /**
285    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
286    */
287   void SetInputRegion(const Rect<int>& inputRegion) override;
288
289   /**
290    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
291    */
292   void SetType(Dali::WindowType type) override;
293
294   /**
295    * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
296    */
297   Dali::WindowType GetType() const override;
298
299   /**
300    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
301    */
302   Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
303
304   /**
305    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
306    */
307   Dali::WindowNotificationLevel GetNotificationLevel() const override;
308
309   /**
310    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
311    */
312   void SetOpaqueState(bool opaque) override;
313
314   /**
315    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
316    */
317   Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
318
319   /**
320    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
321    */
322   WindowScreenOffMode GetScreenOffMode() const override;
323
324   /**
325    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
326    */
327   Dali::WindowOperationResult SetBrightness(int brightness) override;
328
329   /**
330    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
331    */
332   int GetBrightness() const override;
333
334   /**
335    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
336    */
337   bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
338
339   /**
340    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
341    */
342   bool UngrabKey(Dali::KEY key) override;
343
344   /**
345    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
346    */
347   bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
348
349   /**
350    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
351    */
352   bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
353
354   /**
355    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
356    */
357   void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
358
359   /**
360    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
361    */
362   int GetScreenRotationAngle() override;
363
364   /**
365    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
366    */
367   void SetWindowRotationAngle(int degree) override;
368
369   /**
370    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
371    */
372   void WindowRotationCompleted(int degree, int width, int height) override;
373
374   /**
375    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
376    */
377   void SetTransparency(bool transparent) override;
378
379   /**
380    * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
381    */
382   int GetWindowRotationAngle() const override;
383
384   /**
385    * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
386    */
387   void SetParent(WindowBase* parentWinBase, bool belowParent) override;
388
389   /**
390    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
391    */
392   int CreateFrameRenderedSyncFence() override;
393
394   /**
395    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
396    */
397   int CreateFramePresentedSyncFence() override;
398
399   /**
400    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
401    */
402   void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
403
404   /**
405    * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
406    */
407   void InitializeIme() override;
408
409   /**
410    * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
411    */
412   void ImeWindowReadyToRender() override;
413
414   /**
415    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
416    */
417   void RequestMoveToServer() override;
418
419   /**
420    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
421    */
422   void RequestResizeToServer(WindowResizeDirection direction) override;
423
424   /**
425    * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
426    */
427   void EnableFloatingMode(bool enable) override;
428
429   /**
430    * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
431    */
432   bool IsFloatingModeEnabled() const override;
433
434   /**
435    * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
436    */
437   void IncludeInputRegion(const Rect<int>& inputRegion) override;
438
439   /**
440    * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
441    */
442   void ExcludeInputRegion(const Rect<int>& inputRegion) override;
443
444   /**
445    * @copydoc Dali::Internal::Adaptor::WindowBase::PointerConstraintsLock()
446    */
447   bool PointerConstraintsLock() override;
448
449   /**
450    * @copydoc Dali::Internal::Adaptor::WindowBase::PointerConstraintsUnlock()
451    */
452   bool PointerConstraintsUnlock() override;
453
454   /**
455    * @copydoc Dali::Internal::Adaptor::WindowBase::LockedPointerRegionSet()
456    */
457   void LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height) override;
458
459   /**
460    * @copydoc Dali::Internal::Adaptor::WindowBase::LockedPointerCursorPositionHintSet()
461    */
462   void LockedPointerCursorPositionHintSet(int32_t x, int32_t y) override;
463
464   /**
465    * @copydoc Dali::Internal::Adaptor::WindowBase::PointerWarp()
466    */
467   bool PointerWarp(int32_t x, int32_t y) override;
468
469   /**
470    * @copydoc Dali::Internal::Adaptor::WindowBase::CursorVisibleSet()
471    */
472   void CursorVisibleSet(bool visible) override;
473
474   /**
475    * @copydoc Dali::Internal::Adaptor::WindowBase::KeyboardGrab()
476    */
477   bool KeyboardGrab(Device::Subclass::Type deviceSubclass) override;
478
479   /**
480    * @copydoc Dali::Internal::Adaptor::WindowBase::KeyboardUnGrab()
481    */
482   bool KeyboardUnGrab() override;
483
484   /**
485    * @copydoc Dali::Internal::Adaptor::WindowBase::SetFullScreen()
486    */
487   void SetFullScreen(bool fullscreen) override;
488
489   /**
490    * @copydoc Dali::Internal::Adaptor::WindowBase::GetFullScreen()
491    */
492   bool GetFullScreen() override;
493
494   /**
495    * @copydoc Dali::Internal::Adaptor::WindowBase::SetFrontBufferRendering()
496    */
497   void SetFrontBufferRendering(bool enable) override;
498
499   /**
500    * @copydoc Dali::Internal::Adaptor::WindowBase::GetFrontBufferRendering()
501    */
502   bool GetFrontBufferRendering() override;
503
504   /**
505    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowFrontBufferMode()
506    */
507   void SetEglWindowFrontBufferMode(bool enable) override;
508
509 private:
510   /**
511    * Second stage initialization
512    */
513   void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
514
515   /**
516    * @brief Get the surface id if the surface parameter is not empty
517    * @param surface Any containing a surface id, or can be empty
518    * @return surface id, or zero if surface is empty
519    */
520   uintptr_t GetSurfaceId(Any surface) const;
521
522   /**
523    * @brief Create window
524    */
525   void CreateWinWindow(PositionSize positionSize, bool isTransparent);
526
527   /**
528    * @brief Sets up an already created window.
529    */
530   void SetWinWindow(uintptr_t surfaceId);
531
532 private:
533   // Undefined
534   WindowBaseWin(const WindowBaseWin&) = delete;
535
536   // Undefined
537   WindowBaseWin& operator=(const WindowBaseWin& rhs) = delete;
538
539 private:
540   void EventEntry(TWinEventInfo* event);
541
542 private:
543   WinWindowHandle mWin32Window;       ///< Native window handle
544   bool            mOwnSurface : 1;    ///< Whether we own the surface (responsible for deleting it)
545   bool            mIsTransparent : 1; ///< Whether the window is transparent (32 bit or 24 bit)
546   bool            mRotationAppSet : 1;
547
548   WindowsPlatform::WindowImpl mWindowImpl;
549 };
550
551 } // namespace Adaptor
552
553 } // namespace Internal
554
555 } // namespace Dali
556
557 #endif // DALI_INTERNAL_WINDOWSYSTEM_WINDOW_BASE_WIN_H