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