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