[Tizen] Add InsetsChangedSignal to WindowBaseEcoreWl2
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl2 / window-base-ecore-wl2.h
1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_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
24 // EXTERNAL HEADERS
25 #include <Ecore.h>
26 #include <Ecore_Wl2.h>
27 #include <input-method-client-protocol.h>
28 #include <tizen-extension-client-protocol.h>
29 #include <wayland-egl.h>
30 #include <xkbcommon/xkbcommon.h>
31
32 namespace Dali
33 {
34 namespace Internal
35 {
36 namespace Adaptor
37 {
38 class WindowRenderSurface;
39 class WindowRenderSurfaceEcoreWl2;
40
41 /**
42  * WindowBaseEcoreWl2 class provides an WindowBase Ecore-Wayland2 implementation.
43  */
44 class WindowBaseEcoreWl2 : public WindowBase
45 {
46 public:
47   /**
48    * @brief Constructor
49    */
50   WindowBaseEcoreWl2(PositionSize positionSize, Any surface, bool isTransparent);
51
52   /**
53    * @brief Destructor
54    */
55   virtual ~WindowBaseEcoreWl2();
56
57 public:
58   /**
59    * @brief Called when the window iconify state is changed.
60    */
61   Eina_Bool OnIconifyStateChanged(void* data, int type, void* event);
62
63   /**
64    * @brief Called when the window gains focus.
65    */
66   Eina_Bool OnFocusIn(void* data, int type, void* event);
67
68   /**
69    * @brief Called when the window loses focus.
70    */
71   Eina_Bool OnFocusOut(void* data, int type, void* event);
72
73   /**
74    * @brief Called when the output is transformed.
75    */
76   Eina_Bool OnOutputTransform(void* data, int type, void* event);
77
78   /**
79    * @brief Called when the output transform should be ignored.
80    */
81   Eina_Bool OnIgnoreOutputTransform(void* data, int type, void* event);
82
83   /**
84    * @brief Called when a rotation event is recevied.
85    */
86   void OnRotation(void* data, int type, void* event);
87
88   /**
89    * @brief Called when a configure event is recevied.
90    */
91   void OnConfiguration(void* data, int type, void* event);
92
93   /**
94    * @brief Called when a touch down is received.
95    */
96   void OnMouseButtonDown(void* data, int type, void* event);
97
98   /**
99    * @brief Called when a touch up is received.
100    */
101   void OnMouseButtonUp(void* data, int type, void* event);
102
103   /**
104    * @brief Called when a touch motion is received.
105    */
106   void OnMouseButtonMove(void* data, int type, void* event);
107
108   /**
109    * @brief Called when a touch is canceled.
110    */
111   void OnMouseButtonCancel(void* data, int type, void* event);
112
113   /**
114    * @brief Called when a mouse wheel is received.
115    */
116   void OnMouseWheel(void* data, int type, void* event);
117
118   /**
119    * @brief Called when a mouse in or out is received.
120    */
121   void OnMouseInOut(void* data, int type, void* event, Dali::DevelWindow::MouseInOutEvent::Type action);
122
123   /**
124    * @brief Called when a detent rotation event is recevied.
125    */
126   void OnDetentRotation(void* data, int type, void* event);
127
128   /**
129    * @brief Called when a key down is received.
130    */
131   void OnKeyDown(void* data, int type, void* event);
132
133   /**
134    * @brief Called when a key up is received.
135    */
136   void OnKeyUp(void* data, int type, void* event);
137
138   /**
139    * @brief Called when the source window notifies us the content in clipboard is selected.
140    */
141   void OnDataSend(void* data, int type, void* event);
142
143   /**
144    * @brief Called when the source window sends us about the selected content.
145    */
146   void OnDataReceive(void* data, int type, void* event);
147
148   /**
149    * @brief Called when a font name is changed.
150    */
151   void OnFontNameChanged();
152
153   /**
154    * @brief Called when a font size is changed.
155    */
156   void OnFontSizeChanged();
157
158   /**
159    * @brief Called when a transition effect-start/end event is received.
160    */
161   void OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type);
162
163   /**
164    * @brief Called when a keyboard repeat event is changed.
165    */
166   void OnKeyboardRepeatSettingsChanged();
167
168   /**
169    * @brief Called when a window redraw is requested.
170    */
171   void OnEcoreEventWindowRedrawRequest();
172
173   /**
174    * @brief Called when a conformant is changed.
175    */
176   void OnEcoreEventConformantChange(void* event);
177
178   /**
179    * @brief Called when window's auxiliary is changed then display server send the changed message.
180    *
181    * @param[in] auxiliary's message data. It has key, value and integer list data.
182    */
183   void OnEcoreEventWindowAuxiliaryMessage(void* event);
184
185   /**
186    * @brief Called when window has been moved by then display server.
187    * To move the window by display server, RequestMoveToServer() should be called.
188    * After the moving job is completed, this function will be called.
189    *
190    * @param[in] the completed event's data. It has the latest window geometry data.
191    */
192   void OnMoveCompleted(void* event);
193
194   /**
195    * @brief Called when window has been resized by then display server.
196    * To resize the window by display server, RequestResizeToServer() should be called.
197    * After the resizing job is completed, this function will be called.
198    *
199    * @param[in] the completed event's data. It has the latest window geometry data.
200    */
201   void OnResizeCompleted(void* event);
202
203   /**
204    * @brief Called when a keymap is changed.
205    */
206   void KeymapChanged(void* data, int type, void* event);
207
208   /**
209    * @brief RegistryGlobalCallback
210    */
211   void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
212
213   /**
214    * @brief RegistryGlobalCallbackRemove
215    */
216   void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id);
217
218   /**
219    * @brief TizenPolicyConformantArea
220    */
221   void TizenPolicyConformantArea(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h);
222
223   /**
224    * @brief TizenPolicyNotificationChangeDone
225    */
226   void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state);
227
228   /**
229    * @brief TizenPolicyScreenModeChangeDone
230    */
231   void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state);
232
233   /**
234    * @brief DisplayPolicyBrightnessChangeDone
235    */
236   void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state);
237
238   /**
239    * @brief Gets the key code by keyName.
240    */
241   void GetKeyCode(std::string keyName, int32_t& keyCode);
242
243 public:
244   /**
245    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
246    */
247   Any GetNativeWindow() override;
248
249   /**
250    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
251    */
252   int GetNativeWindowId() override;
253
254   /**
255    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowResourceId()
256    */
257   std::string GetNativeWindowResourceId() override;
258
259   /**
260    * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
261    */
262   EGLNativeWindowType CreateEglWindow(int width, int height) override;
263
264   /**
265    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
266    */
267   void DestroyEglWindow() override;
268
269   /**
270    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
271    */
272   void SetEglWindowRotation(int angle) override;
273
274   /**
275    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
276    */
277   void SetEglWindowBufferTransform(int angle) override;
278
279   /**
280    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
281    */
282   void SetEglWindowTransform(int angle) override;
283
284   /**
285    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
286    */
287   void ResizeEglWindow(PositionSize positionSize) override;
288
289   /**
290    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
291    */
292   bool IsEglWindowRotationSupported() override;
293
294   /**
295    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
296    */
297   void Move(PositionSize positionSize) override;
298
299   /**
300    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
301    */
302   void Resize(PositionSize positionSize) override;
303
304   /**
305    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
306    */
307   void MoveResize(PositionSize positionSize) override;
308
309   /**
310    * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout()
311    */
312   void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override;
313
314   /**
315    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
316    */
317   void SetClass(const std::string& name, const std::string& className) override;
318
319   /**
320    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
321    */
322   void Raise() override;
323
324   /**
325    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
326    */
327   void Lower() override;
328
329   /**
330    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
331    */
332   void Activate() override;
333
334   /**
335    * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
336    */
337   void Maximize(bool maximize) override;
338
339   /**
340    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
341    */
342   bool IsMaximized() const override;
343
344   /**
345    * @copydoc Dali::Internal::Adaptor::WindowBase::SetMaximumSize()
346    */
347   void SetMaximumSize(Dali::Window::WindowSize size) override;
348
349   /**
350    * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
351    */
352   void Minimize(bool minimize) override;
353
354   /**
355    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
356    */
357   bool IsMinimized() const override;
358
359   /**
360    * @copydoc Dali::Internal::Adaptor::WindowBase::SetMimimumSize()
361    */
362   void SetMimimumSize(Dali::Window::WindowSize size) override;
363
364   /**
365    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
366    */
367   void SetAvailableAnlges(const std::vector<int>& angles) override;
368
369   /**
370    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
371    */
372   void SetPreferredAngle(int angle) override;
373
374   /**
375    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
376    */
377   void SetAcceptFocus(bool accept) override;
378
379   /**
380    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
381    */
382   void Show() override;
383
384   /**
385    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
386    */
387   void Hide() override;
388
389   /**
390    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
391    */
392   unsigned int GetSupportedAuxiliaryHintCount() const override;
393
394   /**
395    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
396    */
397   std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
398
399   /**
400    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
401    */
402   unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
403
404   /**
405    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
406    */
407   bool RemoveAuxiliaryHint(unsigned int id) override;
408
409   /**
410    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
411    */
412   bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
413
414   /**
415    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
416    */
417   std::string GetAuxiliaryHintValue(unsigned int id) const override;
418
419   /**
420    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
421    */
422   unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
423
424   /**
425    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
426    */
427   void SetInputRegion(const Rect<int>& inputRegion) override;
428
429   /**
430    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
431    */
432   void SetType(Dali::WindowType type) override;
433
434   /**
435    * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
436    */
437   Dali::WindowType GetType() const override;
438
439   /**
440    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
441    */
442   Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
443
444   /**
445    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
446    */
447   Dali::WindowNotificationLevel GetNotificationLevel() const override;
448
449   /**
450    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
451    */
452   void SetOpaqueState(bool opaque) override;
453
454   /**
455    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
456    */
457   Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
458
459   /**
460    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
461    */
462   WindowScreenOffMode GetScreenOffMode() const override;
463
464   /**
465    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
466    */
467   Dali::WindowOperationResult SetBrightness(int brightness) override;
468
469   /**
470    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
471    */
472   int GetBrightness() const override;
473
474   /**
475    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
476    */
477   bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
478
479   /**
480    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
481    */
482   bool UngrabKey(Dali::KEY key) override;
483
484   /**
485    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
486    */
487   bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
488
489   /**
490    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
491    */
492   bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
493
494   /**
495    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
496    */
497   void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
498
499   /**
500    * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
501    */
502   int GetWindowRotationAngle() const override;
503
504   /**
505    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
506    */
507   int GetScreenRotationAngle() override;
508
509   /**
510    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
511    */
512   void SetWindowRotationAngle(int degree) override;
513
514   /**
515    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
516    */
517   void WindowRotationCompleted(int degree, int width, int height) override;
518
519   /**
520    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
521    */
522   void SetTransparency(bool transparent) override;
523
524   /**
525    * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
526    */
527   void SetParent(WindowBase* parentWinBase, bool belowParent) override;
528
529   /**
530    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
531    */
532   int CreateFrameRenderedSyncFence() override;
533
534   /**
535    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
536    */
537   int CreateFramePresentedSyncFence() override;
538
539   /**
540    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
541    */
542   void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
543
544   /**
545    * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
546    */
547   void InitializeIme() override;
548
549   /**
550    * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
551    */
552   void ImeWindowReadyToRender() override;
553
554   /**
555    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
556    */
557   void RequestMoveToServer() override;
558
559   /**
560    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
561    */
562   void RequestResizeToServer(WindowResizeDirection direction) override;
563
564   /**
565    * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
566    */
567   void EnableFloatingMode(bool enable) override;
568
569   /**
570    * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
571    */
572   bool IsFloatingModeEnabled() const override;
573
574   /**
575    * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
576    */
577   void IncludeInputRegion(const Rect<int>& inputRegion) override;
578
579   /**
580    * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
581    */
582   void ExcludeInputRegion(const Rect<int>& inputRegion) override;
583
584 private:
585   /**
586    * Second stage initialization
587    */
588   void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
589
590   /**
591    * @brief Create window
592    */
593   void CreateWindow(PositionSize positionSize);
594
595   /**
596    * @brief Return the window's position and size to recalulate with the default system coordinates.
597    * It is used when window is moved or resized for native ecore wayland window system.
598    *
599    * @param[in] positionSize the window's current position and size with current oriented window's coordinates.
600    * @return the re-calculated window's position and size on the default system coordinates.
601    */
602   PositionSize RecalculatePositionSizeToSystem(PositionSize positionSize);
603
604   /**
605    * @brief Return the window's position and size to recalulate with current oriented window's coordinates.
606    * It is used when window is moved or resized for dali and uppler layer framework.
607    *
608    * @param[in] positionSize the window's current position and size with the default system coordinates.
609    * @return the re-calculated window's position and size on current oriented window's coordinates.
610    */
611   PositionSize RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize);
612
613   /**
614    * @brief Return the rect value to recalulate with the default system coordinates.
615    *
616    * Some native window APIs work the geometry value based on the default system coordinates.
617    * IncludeInputRegion() and ExcludeInputRegion() are one of them.
618    * When the window is rotated, current window's geometry already were set with the rotated angle.
619    * If IncludeInputRegion() or ExcludeInputRegion() are called with rotated angle by application,
620    * the rect's area should be re-calcuated on the default system coordinates.
621    *
622    * @param[in] rect the window's current position and size with current window rotation angle.
623    * @return the re-calculated rect on the default system coordinates.
624    */
625   Rect<int> RecalculateInputRect(const Rect<int>& rect);
626
627 protected:
628   // Undefined
629   WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
630
631   // Undefined
632   WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
633
634 private:
635   typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
636   Dali::Vector<Ecore_Event_Handler*>                        mEcoreEventHandler;
637   Ecore_Wl2_Window*                                         mEcoreWindow;
638
639   wl_surface* mWlSurface;
640 #ifdef OVER_TIZEN_VERSION_7
641   zwp_input_panel_v1* mWlInputPanel;
642 #else
643   wl_input_panel*         mWlInputPanel;
644 #endif
645   wl_output* mWlOutput;
646 #ifdef OVER_TIZEN_VERSION_7
647   zwp_input_panel_surface_v1* mWlInputPanelSurface;
648 #else
649   wl_input_panel_surface* mWlInputPanelSurface;
650 #endif
651
652   wl_egl_window*        mEglWindow;
653   wl_display*           mDisplay;
654   wl_event_queue*       mEventQueue;
655   tizen_policy*         mTizenPolicy;
656   tizen_display_policy* mTizenDisplayPolicy;
657   xkb_keymap*           mKeyMap;
658
659   std::vector<std::string> mSupportedAuxiliaryHints;
660
661   // It is based on the default system coordinates.
662   Dali::PositionSize mWindowPositionSize;
663
664   AuxiliaryHints mAuxiliaryHints;
665
666   WindowType mType;
667   int        mNotificationLevel;
668   int        mScreenOffMode;
669   int        mBrightness;
670   int        mWindowRotationAngle;
671   int        mScreenRotationAngle;
672   int        mSupportedPreProtation;
673
674   uint32_t          mNotificationChangeState;
675   uint32_t          mScreenOffModeChangeState;
676   uint32_t          mBrightnessChangeState;
677   uint32_t          mLastSubmittedMoveResizeSerial;
678   volatile uint32_t mMoveResizeSerial;
679
680   bool mNotificationLevelChangeDone;
681   bool mScreenOffModeChangeDone;
682   bool mVisible : 1;
683   bool mOwnSurface;
684   bool mBrightnessChangeDone;
685 };
686
687 } // namespace Adaptor
688
689 } // namespace Internal
690
691 } // namespace Dali
692
693 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H