Merge "Add Maximize/Minimized in Window" 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::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::Maximize()
304    */
305   void Maximize(bool maximize) override;
306
307   /**
308    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
309    */
310   bool IsMaximized() const override;
311
312   /**
313    * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
314    */
315   void Minimize(bool minimize) override;
316
317   /**
318    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
319    */
320   bool IsMinimized() const override;
321
322   /**
323    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
324    */
325   void SetAvailableAnlges(const std::vector<int>& angles) override;
326
327   /**
328    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
329    */
330   void SetPreferredAngle(int angle) override;
331
332   /**
333    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
334    */
335   void SetAcceptFocus(bool accept) override;
336
337   /**
338    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
339    */
340   void Show() override;
341
342   /**
343    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
344    */
345   void Hide() override;
346
347   /**
348    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
349    */
350   unsigned int GetSupportedAuxiliaryHintCount() const override;
351
352   /**
353    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
354    */
355   std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
356
357   /**
358    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
359    */
360   unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
361
362   /**
363    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
364    */
365   bool RemoveAuxiliaryHint(unsigned int id) override;
366
367   /**
368    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
369    */
370   bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
371
372   /**
373    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
374    */
375   std::string GetAuxiliaryHintValue(unsigned int id) const override;
376
377   /**
378    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
379    */
380   unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
381
382   /**
383    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
384    */
385   void SetInputRegion(const Rect<int>& inputRegion) override;
386
387   /**
388    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
389    */
390   void SetType(Dali::WindowType type) override;
391
392   /**
393    * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
394    */
395   Dali::WindowType GetType() const override;
396
397   /**
398    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
399    */
400   Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
401
402   /**
403    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
404    */
405   Dali::WindowNotificationLevel GetNotificationLevel() const override;
406
407   /**
408    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
409    */
410   void SetOpaqueState(bool opaque) override;
411
412   /**
413    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
414    */
415   Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
416
417   /**
418    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
419    */
420   WindowScreenOffMode GetScreenOffMode() const override;
421
422   /**
423    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
424    */
425   Dali::WindowOperationResult SetBrightness(int brightness) override;
426
427   /**
428    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
429    */
430   int GetBrightness() const override;
431
432   /**
433    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
434    */
435   bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
436
437   /**
438    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
439    */
440   bool UngrabKey(Dali::KEY key) override;
441
442   /**
443    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
444    */
445   bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
446
447   /**
448    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
449    */
450   bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
451
452   /**
453    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
454    */
455   void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
456
457   /**
458    * @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
459    */
460   int GetOrientation() const override;
461
462   /**
463    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
464    */
465   int GetScreenRotationAngle() override;
466
467   /**
468    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
469    */
470   void SetWindowRotationAngle(int degree) override;
471
472   /**
473    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
474    */
475   void WindowRotationCompleted(int degree, int width, int height) override;
476
477   /**
478    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
479    */
480   void SetTransparency(bool transparent) override;
481
482   /**
483    * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
484    */
485   void SetParent(WindowBase* parentWinBase, bool belowParent) override;
486
487   /**
488    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
489    */
490   int CreateFrameRenderedSyncFence() override;
491
492   /**
493    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
494    */
495   int CreateFramePresentedSyncFence() override;
496
497   /**
498    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
499    */
500   void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
501
502   /**
503    * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
504    */
505   void InitializeIme() override;
506
507   /**
508    * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
509    */
510   void ImeWindowReadyToRender() override;
511
512   /**
513    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
514    */
515   void RequestMoveToServer() override;
516
517   /**
518    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
519    */
520   void RequestResizeToServer(WindowResizeDirection direction) override;
521
522   /**
523    * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
524    */
525   void EnableFloatingMode(bool enable) override;
526
527   /**
528    * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
529    */
530   bool IsFloatingModeEnabled() const override;
531
532   /**
533    * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
534    */
535   void IncludeInputRegion(const Rect<int>& inputRegion) override;
536
537   /**
538    * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
539    */
540   void ExcludeInputRegion(const Rect<int>& inputRegion) override;
541
542 private:
543   /**
544    * Second stage initialization
545    */
546   void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
547
548   /**
549    * Initialize Ecore ElDBus
550    */
551   void InitializeEcoreElDBus();
552
553   /**
554    * @brief Create window
555    */
556   void CreateWindow(PositionSize positionSize);
557
558 protected:
559   // Undefined
560   WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
561
562   // Undefined
563   WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
564
565 private:
566   typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
567   Dali::Vector<Ecore_Event_Handler*>                        mEcoreEventHandler;
568   Ecore_Wl2_Window*                                         mEcoreWindow;
569
570   wl_surface* mWlSurface;
571 #ifdef OVER_TIZEN_VERSION_7
572   zwp_input_panel_v1* mWlInputPanel;
573 #else
574   wl_input_panel* mWlInputPanel;
575 #endif
576   wl_output* mWlOutput;
577 #ifdef OVER_TIZEN_VERSION_7
578   zwp_input_panel_surface_v1* mWlInputPanelSurface;
579 #else
580   wl_input_panel_surface* mWlInputPanelSurface;
581 #endif
582
583   wl_egl_window*        mEglWindow;
584   wl_display*           mDisplay;
585   wl_event_queue*       mEventQueue;
586   tizen_policy*         mTizenPolicy;
587   tizen_display_policy* mTizenDisplayPolicy;
588   xkb_keymap*           mKeyMap;
589
590   std::vector<std::string> mSupportedAuxiliaryHints;
591
592   Dali::PositionSize mWindowPositionSize;
593   AuxiliaryHints     mAuxiliaryHints;
594
595   WindowType mType;
596   int        mNotificationLevel;
597   int        mScreenOffMode;
598   int        mBrightness;
599   int        mWindowRotationAngle;
600   int        mScreenRotationAngle;
601   int        mSupportedPreProtation;
602
603   uint32_t          mNotificationChangeState;
604   uint32_t          mScreenOffModeChangeState;
605   uint32_t          mBrightnessChangeState;
606   uint32_t          mLastSubmittedMoveResizeSerial;
607   volatile uint32_t mMoveResizeSerial;
608
609   bool mNotificationLevelChangeDone;
610   bool mScreenOffModeChangeDone;
611   bool mVisible : 1;
612   bool mOwnSurface;
613   bool mBrightnessChangeDone;
614
615 #ifdef DALI_ELDBUS_AVAILABLE
616   Eldbus_Connection* mSystemConnection;
617 #endif // DALI_ELDBUS_AVAILABLE
618 };
619
620 } // namespace Adaptor
621
622 } // namespace Internal
623
624 } // namespace Dali
625
626 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H