[Tizen] Add window move/resize completed signal
[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 window's auxiliary is changed then display server send the changed message.
175    *
176    * @param[in] auxiliary's message data. It has key, value and integer list data.
177    */
178   void OnEcoreEventWindowAuxiliaryMessage(void* event);
179
180   /**
181    * @brief Called when window has been moved by then display server.
182    * To move the window by display server, RequestMoveToServer() should be called.
183    * After the moving job is completed, this function will be called.
184    *
185    * @param[in] the completed event's data. It has the latest window geometry data.
186    */
187   void OnMoveCompleted(void* event);
188
189   /**
190    * @brief Called when window has been resized by then display server.
191    * To resize the window by display server, RequestResizeToServer() should be called.
192    * After the resizing job is completed, this function will be called.
193    *
194    * @param[in] the completed event's data. It has the latest window geometry data.
195    */
196   void OnResizeCompleted(void* event);
197
198   /**
199    * @brief Called when a keymap is changed.
200    */
201   void KeymapChanged(void* data, int type, void* event);
202
203   /**
204    * @brief RegistryGlobalCallback
205    */
206   void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
207
208   /**
209    * @brief RegistryGlobalCallbackRemove
210    */
211   void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id);
212
213   /**
214    * @brief TizenPolicyNotificationChangeDone
215    */
216   void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state);
217
218   /**
219    * @brief TizenPolicyScreenModeChangeDone
220    */
221   void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state);
222
223   /**
224    * @brief DisplayPolicyBrightnessChangeDone
225    */
226   void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state);
227
228   /**
229    * @brief Gets the key code by keyName.
230    */
231   void GetKeyCode(std::string keyName, int32_t& keyCode);
232
233 public:
234   /**
235    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
236    */
237   Any GetNativeWindow() override;
238
239   /**
240    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
241    */
242   int GetNativeWindowId() override;
243
244   /**
245    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowResourceId()
246    */
247   std::string GetNativeWindowResourceId() override;
248
249   /**
250    * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
251    */
252   EGLNativeWindowType CreateEglWindow(int width, int height) override;
253
254   /**
255    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
256    */
257   void DestroyEglWindow() override;
258
259   /**
260    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
261    */
262   void SetEglWindowRotation(int angle) override;
263
264   /**
265    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
266    */
267   void SetEglWindowBufferTransform(int angle) override;
268
269   /**
270    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
271    */
272   void SetEglWindowTransform(int angle) override;
273
274   /**
275    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
276    */
277   void ResizeEglWindow(PositionSize positionSize) override;
278
279   /**
280    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
281    */
282   bool IsEglWindowRotationSupported() override;
283
284   /**
285    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
286    */
287   void Move(PositionSize positionSize) override;
288
289   /**
290    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
291    */
292   void Resize(PositionSize positionSize) override;
293
294   /**
295    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
296    */
297   void MoveResize(PositionSize positionSize) override;
298
299   /**
300    * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout()
301    */
302   void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override;
303
304   /**
305    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
306    */
307   void SetClass(const std::string& name, const std::string& className) override;
308
309   /**
310    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
311    */
312   void Raise() override;
313
314   /**
315    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
316    */
317   void Lower() override;
318
319   /**
320    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
321    */
322   void Activate() override;
323
324   /**
325    * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
326    */
327   void Maximize(bool maximize) override;
328
329   /**
330    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
331    */
332   bool IsMaximized() const override;
333
334   /**
335    * @copydoc Dali::Internal::Adaptor::WindowBase::SetMaximumSize()
336    */
337   void SetMaximumSize(Dali::Window::WindowSize size) override;
338
339   /**
340    * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
341    */
342   void Minimize(bool minimize) override;
343
344   /**
345    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
346    */
347   bool IsMinimized() const override;
348
349   /**
350    * @copydoc Dali::Internal::Adaptor::WindowBase::SetMimimumSize()
351    */
352   void SetMimimumSize(Dali::Window::WindowSize size) override;
353
354   /**
355    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
356    */
357   void SetAvailableAnlges(const std::vector<int>& angles) override;
358
359   /**
360    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
361    */
362   void SetPreferredAngle(int angle) override;
363
364   /**
365    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
366    */
367   void SetAcceptFocus(bool accept) override;
368
369   /**
370    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
371    */
372   void Show() override;
373
374   /**
375    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
376    */
377   void Hide() override;
378
379   /**
380    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
381    */
382   unsigned int GetSupportedAuxiliaryHintCount() const override;
383
384   /**
385    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
386    */
387   std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
388
389   /**
390    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
391    */
392   unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
393
394   /**
395    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
396    */
397   bool RemoveAuxiliaryHint(unsigned int id) override;
398
399   /**
400    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
401    */
402   bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
403
404   /**
405    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
406    */
407   std::string GetAuxiliaryHintValue(unsigned int id) const override;
408
409   /**
410    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
411    */
412   unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
413
414   /**
415    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
416    */
417   void SetInputRegion(const Rect<int>& inputRegion) override;
418
419   /**
420    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
421    */
422   void SetType(Dali::WindowType type) override;
423
424   /**
425    * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
426    */
427   Dali::WindowType GetType() const override;
428
429   /**
430    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
431    */
432   Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
433
434   /**
435    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
436    */
437   Dali::WindowNotificationLevel GetNotificationLevel() const override;
438
439   /**
440    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
441    */
442   void SetOpaqueState(bool opaque) override;
443
444   /**
445    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
446    */
447   Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
448
449   /**
450    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
451    */
452   WindowScreenOffMode GetScreenOffMode() const override;
453
454   /**
455    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
456    */
457   Dali::WindowOperationResult SetBrightness(int brightness) override;
458
459   /**
460    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
461    */
462   int GetBrightness() const override;
463
464   /**
465    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
466    */
467   bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
468
469   /**
470    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
471    */
472   bool UngrabKey(Dali::KEY key) override;
473
474   /**
475    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
476    */
477   bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
478
479   /**
480    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
481    */
482   bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
483
484   /**
485    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
486    */
487   void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
488
489   /**
490    * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
491    */
492   int GetWindowRotationAngle() const override;
493
494   /**
495    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
496    */
497   int GetScreenRotationAngle() override;
498
499   /**
500    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
501    */
502   void SetWindowRotationAngle(int degree) override;
503
504   /**
505    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
506    */
507   void WindowRotationCompleted(int degree, int width, int height) override;
508
509   /**
510    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
511    */
512   void SetTransparency(bool transparent) override;
513
514   /**
515    * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
516    */
517   void SetParent(WindowBase* parentWinBase, bool belowParent) override;
518
519   /**
520    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
521    */
522   int CreateFrameRenderedSyncFence() override;
523
524   /**
525    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
526    */
527   int CreateFramePresentedSyncFence() override;
528
529   /**
530    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
531    */
532   void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
533
534   /**
535    * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
536    */
537   void InitializeIme() override;
538
539   /**
540    * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
541    */
542   void ImeWindowReadyToRender() override;
543
544   /**
545    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
546    */
547   void RequestMoveToServer() override;
548
549   /**
550    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
551    */
552   void RequestResizeToServer(WindowResizeDirection direction) override;
553
554   /**
555    * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
556    */
557   void EnableFloatingMode(bool enable) override;
558
559   /**
560    * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
561    */
562   bool IsFloatingModeEnabled() const override;
563
564   /**
565    * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
566    */
567   void IncludeInputRegion(const Rect<int>& inputRegion) override;
568
569   /**
570    * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
571    */
572   void ExcludeInputRegion(const Rect<int>& inputRegion) override;
573
574 private:
575   /**
576    * Second stage initialization
577    */
578   void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
579
580   /**
581    * @brief Create window
582    */
583   void CreateWindow(PositionSize positionSize);
584
585   /**
586    * @brief Return the window's position and size to recalulate with the default system coordinates.
587    * It is used when window is moved or resized for native ecore wayland window system.
588    *
589    * @param[in] positionSize the window's current position and size with current oriented window's coordinates.
590    * @return the re-calculated window's position and size on the default system coordinates.
591    */
592   PositionSize RecalculatePositionSizeToSystem(PositionSize positionSize);
593
594   /**
595    * @brief Return the window's position and size to recalulate with current oriented window's coordinates.
596    * It is used when window is moved or resized for dali and uppler layer framework.
597    *
598    * @param[in] positionSize the window's current position and size with the default system coordinates.
599    * @return the re-calculated window's position and size on current oriented window's coordinates.
600    */
601   PositionSize RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize);
602
603   /**
604    * @brief Return the rect value to recalulate with the default system coordinates.
605    *
606    * Some native window APIs work the geometry value based on the default system coordinates.
607    * IncludeInputRegion() and ExcludeInputRegion() are one of them.
608    * When the window is rotated, current window's geometry already were set with the rotated angle.
609    * If IncludeInputRegion() or ExcludeInputRegion() are called with rotated angle by application,
610    * the rect's area should be re-calcuated on the default system coordinates.
611    *
612    * @param[in] rect the window's current position and size with current window rotation angle.
613    * @return the re-calculated rect on the default system coordinates.
614    */
615   Rect<int> RecalculateInputRect(const Rect<int>& rect);
616
617 protected:
618   // Undefined
619   WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
620
621   // Undefined
622   WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
623
624 private:
625   typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
626   Dali::Vector<Ecore_Event_Handler*>                        mEcoreEventHandler;
627   Ecore_Wl2_Window*                                         mEcoreWindow;
628
629   wl_surface* mWlSurface;
630 #ifdef OVER_TIZEN_VERSION_7
631   zwp_input_panel_v1* mWlInputPanel;
632 #else
633   wl_input_panel*         mWlInputPanel;
634 #endif
635   wl_output* mWlOutput;
636 #ifdef OVER_TIZEN_VERSION_7
637   zwp_input_panel_surface_v1* mWlInputPanelSurface;
638 #else
639   wl_input_panel_surface* mWlInputPanelSurface;
640 #endif
641
642   wl_egl_window*        mEglWindow;
643   wl_display*           mDisplay;
644   wl_event_queue*       mEventQueue;
645   tizen_policy*         mTizenPolicy;
646   tizen_display_policy* mTizenDisplayPolicy;
647   xkb_keymap*           mKeyMap;
648
649   std::vector<std::string> mSupportedAuxiliaryHints;
650
651   // It is based on the default system coordinates.
652   Dali::PositionSize mWindowPositionSize;
653
654   AuxiliaryHints mAuxiliaryHints;
655
656   WindowType mType;
657   int        mNotificationLevel;
658   int        mScreenOffMode;
659   int        mBrightness;
660   int        mWindowRotationAngle;
661   int        mScreenRotationAngle;
662   int        mSupportedPreProtation;
663
664   uint32_t          mNotificationChangeState;
665   uint32_t          mScreenOffModeChangeState;
666   uint32_t          mBrightnessChangeState;
667   uint32_t          mLastSubmittedMoveResizeSerial;
668   volatile uint32_t mMoveResizeSerial;
669
670   bool mNotificationLevelChangeDone;
671   bool mScreenOffModeChangeDone;
672   bool mVisible : 1;
673   bool mOwnSurface;
674   bool mBrightnessChangeDone;
675 };
676
677 } // namespace Adaptor
678
679 } // namespace Internal
680
681 } // namespace Dali
682
683 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H