Add auxiliary message for window
[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) 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
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
180 #ifdef DALI_ELDBUS_AVAILABLE
181   /**
182    * @brief Called when Ecore ElDBus accessibility event is received.
183    */
184   void OnEcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message);
185 #endif
186
187   /**
188    * @brief Called when a keymap is changed.
189    */
190   void KeymapChanged(void* data, int type, void* event);
191
192   /**
193    * @brief RegistryGlobalCallback
194    */
195   void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
196
197   /**
198    * @brief RegistryGlobalCallbackRemove
199    */
200   void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id);
201
202   /**
203    * @brief TizenPolicyNotificationChangeDone
204    */
205   void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state);
206
207   /**
208    * @brief TizenPolicyScreenModeChangeDone
209    */
210   void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state);
211
212   /**
213    * @brief DisplayPolicyBrightnessChangeDone
214    */
215   void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state);
216
217   /**
218    * @brief Gets the key code by keyName.
219    */
220   void GetKeyCode(std::string keyName, int32_t& keyCode);
221
222 public:
223   /**
224    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
225    */
226   Any GetNativeWindow() override;
227
228   /**
229    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
230    */
231   int GetNativeWindowId() override;
232
233   /**
234    * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
235    */
236   EGLNativeWindowType CreateEglWindow(int width, int height) override;
237
238   /**
239    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
240    */
241   void DestroyEglWindow() override;
242
243   /**
244    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
245    */
246   void SetEglWindowRotation(int angle) override;
247
248   /**
249    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
250    */
251   void SetEglWindowBufferTransform(int angle) override;
252
253   /**
254    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
255    */
256   void SetEglWindowTransform(int angle) override;
257
258   /**
259    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
260    */
261   void ResizeEglWindow(PositionSize positionSize) override;
262
263   /**
264    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
265    */
266   bool IsEglWindowRotationSupported() override;
267
268   /**
269    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
270    */
271   void Move(PositionSize positionSize) override;
272
273   /**
274    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
275    */
276   void Resize(PositionSize positionSize) override;
277
278   /**
279    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
280    */
281   void MoveResize(PositionSize positionSize) override;
282
283   /**
284    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
285    */
286   void SetClass(const std::string& name, const std::string& className) override;
287
288   /**
289    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
290    */
291   void Raise() override;
292
293   /**
294    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
295    */
296   void Lower() override;
297
298   /**
299    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
300    */
301   void Activate() override;
302
303   /**
304    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
305    */
306   void SetAvailableAnlges(const std::vector<int>& angles) override;
307
308   /**
309    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
310    */
311   void SetPreferredAngle(int angle) override;
312
313   /**
314    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
315    */
316   void SetAcceptFocus(bool accept) override;
317
318   /**
319    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
320    */
321   void Show() override;
322
323   /**
324    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
325    */
326   void Hide() override;
327
328   /**
329    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
330    */
331   unsigned int GetSupportedAuxiliaryHintCount() const override;
332
333   /**
334    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
335    */
336   std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
337
338   /**
339    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
340    */
341   unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
342
343   /**
344    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
345    */
346   bool RemoveAuxiliaryHint(unsigned int id) override;
347
348   /**
349    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
350    */
351   bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
352
353   /**
354    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
355    */
356   std::string GetAuxiliaryHintValue(unsigned int id) const override;
357
358   /**
359    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
360    */
361   unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
362
363   /**
364    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
365    */
366   void SetInputRegion(const Rect<int>& inputRegion) override;
367
368   /**
369    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
370    */
371   void SetType(Dali::WindowType type) override;
372
373   /**
374    * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
375    */
376   Dali::WindowType GetType() const override;
377
378   /**
379    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
380    */
381   Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
382
383   /**
384    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
385    */
386   Dali::WindowNotificationLevel GetNotificationLevel() const override;
387
388   /**
389    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
390    */
391   void SetOpaqueState(bool opaque) override;
392
393   /**
394    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
395    */
396   Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
397
398   /**
399    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
400    */
401   WindowScreenOffMode GetScreenOffMode() const override;
402
403   /**
404    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
405    */
406   Dali::WindowOperationResult SetBrightness(int brightness) override;
407
408   /**
409    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
410    */
411   int GetBrightness() const override;
412
413   /**
414    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
415    */
416   bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
417
418   /**
419    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
420    */
421   bool UngrabKey(Dali::KEY key) override;
422
423   /**
424    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
425    */
426   bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
427
428   /**
429    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
430    */
431   bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
432
433   /**
434    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
435    */
436   void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
437
438   /**
439    * @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
440    */
441   int GetOrientation() const override;
442
443   /**
444    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
445    */
446   int GetScreenRotationAngle() override;
447
448   /**
449    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
450    */
451   void SetWindowRotationAngle(int degree) override;
452
453   /**
454    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
455    */
456   void WindowRotationCompleted(int degree, int width, int height) override;
457
458   /**
459    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
460    */
461   void SetTransparency(bool transparent) override;
462
463   /**
464    * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
465    */
466   void SetParent(WindowBase* parentWinBase, bool belowParent) override;
467
468   /**
469    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
470    */
471   int CreateFrameRenderedSyncFence() override;
472
473   /**
474    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
475    */
476   int CreateFramePresentedSyncFence() override;
477
478   /**
479    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
480    */
481   void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
482
483   /**
484    * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
485    */
486   void InitializeIme() override;
487
488   /**
489    * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
490    */
491   void ImeWindowReadyToRender() override;
492
493   /**
494    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
495    */
496   void RequestMoveToServer() override;
497
498   /**
499    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
500    */
501   void RequestResizeToServer(WindowResizeDirection direction) override;
502
503   /**
504    * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
505    */
506   void EnableFloatingMode(bool enable) override;
507
508   /**
509    * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
510    */
511   bool IsFloatingModeEnabled() const override;
512
513   /**
514    * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
515    */
516   void IncludeInputRegion(const Rect<int>& inputRegion) override;
517
518   /**
519    * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
520    */
521   void ExcludeInputRegion(const Rect<int>& inputRegion) override;
522
523 private:
524   /**
525    * Second stage initialization
526    */
527   void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
528
529   /**
530    * Initialize Ecore ElDBus
531    */
532   void InitializeEcoreElDBus();
533
534   /**
535    * @brief Create window
536    */
537   void CreateWindow(PositionSize positionSize);
538
539 protected:
540   // Undefined
541   WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
542
543   // Undefined
544   WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
545
546 private:
547   typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
548   Dali::Vector<Ecore_Event_Handler*>                        mEcoreEventHandler;
549   Ecore_Wl2_Window*                                         mEcoreWindow;
550
551   wl_surface*             mWlSurface;
552   wl_input_panel*         mWlInputPanel;
553   wl_output*              mWlOutput;
554   wl_input_panel_surface* mWlInputPanelSurface;
555
556   wl_egl_window*        mEglWindow;
557   wl_display*           mDisplay;
558   wl_event_queue*       mEventQueue;
559   tizen_policy*         mTizenPolicy;
560   tizen_display_policy* mTizenDisplayPolicy;
561   xkb_keymap*           mKeyMap;
562
563   std::vector<std::string> mSupportedAuxiliaryHints;
564
565   Dali::PositionSize mWindowPositionSize;
566   AuxiliaryHints     mAuxiliaryHints;
567
568   WindowType mType;
569   int        mNotificationLevel;
570   int        mScreenOffMode;
571   int        mBrightness;
572   int        mWindowRotationAngle;
573   int        mScreenRotationAngle;
574   int        mSupportedPreProtation;
575
576   uint32_t          mNotificationChangeState;
577   uint32_t          mScreenOffModeChangeState;
578   uint32_t          mBrightnessChangeState;
579   uint32_t          mLastSubmittedMoveResizeSerial;
580   volatile uint32_t mMoveResizeSerial;
581
582   bool mNotificationLevelChangeDone;
583   bool mScreenOffModeChangeDone;
584   bool mVisible : 1;
585   bool mOwnSurface;
586   bool mBrightnessChangeDone;
587
588 #ifdef DALI_ELDBUS_AVAILABLE
589   Eldbus_Connection* mSystemConnection;
590 #endif // DALI_ELDBUS_AVAILABLE
591 };
592
593 } // namespace Adaptor
594
595 } // namespace Internal
596
597 } // namespace Dali
598
599 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H