1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/internal/window-system/common/window-base.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>
32 #ifdef DALI_ELDBUS_AVAILABLE
42 class WindowRenderSurface;
43 class WindowRenderSurfaceEcoreWl2;
46 * WindowBaseEcoreWl2 class provides an WindowBase Ecore-Wayland2 implementation.
48 class WindowBaseEcoreWl2 : public WindowBase
54 WindowBaseEcoreWl2(PositionSize positionSize, Any surface, bool isTransparent);
59 virtual ~WindowBaseEcoreWl2();
63 * @brief Called when the window iconify state is changed.
65 Eina_Bool OnIconifyStateChanged(void* data, int type, void* event);
68 * @brief Called when the window gains focus.
70 Eina_Bool OnFocusIn(void* data, int type, void* event);
73 * @brief Called when the window loses focus.
75 Eina_Bool OnFocusOut(void* data, int type, void* event);
78 * @brief Called when the output is transformed.
80 Eina_Bool OnOutputTransform(void* data, int type, void* event);
83 * @brief Called when the output transform should be ignored.
85 Eina_Bool OnIgnoreOutputTransform(void* data, int type, void* event);
88 * @brief Called when a rotation event is recevied.
90 void OnRotation(void* data, int type, void* event);
93 * @brief Called when a configure event is recevied.
95 void OnConfiguration(void* data, int type, void* event);
98 * @brief Called when a touch down is received.
100 void OnMouseButtonDown(void* data, int type, void* event);
103 * @brief Called when a touch up is received.
105 void OnMouseButtonUp(void* data, int type, void* event);
108 * @brief Called when a touch motion is received.
110 void OnMouseButtonMove(void* data, int type, void* event);
113 * @brief Called when a touch is canceled.
115 void OnMouseButtonCancel(void* data, int type, void* event);
118 * @brief Called when a mouse wheel is received.
120 void OnMouseWheel(void* data, int type, void* event);
123 * @brief Called when a detent rotation event is recevied.
125 void OnDetentRotation(void* data, int type, void* event);
128 * @brief Called when a key down is received.
130 void OnKeyDown(void* data, int type, void* event);
133 * @brief Called when a key up is received.
135 void OnKeyUp(void* data, int type, void* event);
138 * @brief Called when the source window notifies us the content in clipboard is selected.
140 void OnDataSend(void* data, int type, void* event);
143 * @brief Called when the source window sends us about the selected content.
145 void OnDataReceive(void* data, int type, void* event);
148 * @brief Called when a font name is changed.
150 void OnFontNameChanged();
153 * @brief Called when a font size is changed.
155 void OnFontSizeChanged();
158 * @brief Called when a transition effect-start/end event is received.
160 void OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type);
163 * @brief Called when a keyboard repeat event is changed.
165 void OnKeyboardRepeatSettingsChanged();
168 * @brief Called when a window redraw is requested.
170 void OnEcoreEventWindowRedrawRequest();
173 * @brief Called when window's auxiliary is changed then display server send the changed message.
175 * @param[in] auxiliary's message data. It has key, value and integer list data.
177 void OnEcoreEventWindowAuxiliaryMessage(void* event);
180 #ifdef DALI_ELDBUS_AVAILABLE
182 * @brief Called when Ecore ElDBus accessibility event is received.
184 void OnEcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message);
188 * @brief Called when a keymap is changed.
190 void KeymapChanged(void* data, int type, void* event);
193 * @brief RegistryGlobalCallback
195 void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
198 * @brief RegistryGlobalCallbackRemove
200 void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id);
203 * @brief TizenPolicyNotificationChangeDone
205 void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state);
208 * @brief TizenPolicyScreenModeChangeDone
210 void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state);
213 * @brief DisplayPolicyBrightnessChangeDone
215 void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state);
218 * @brief Gets the key code by keyName.
220 void GetKeyCode(std::string keyName, int32_t& keyCode);
224 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
226 Any GetNativeWindow() override;
229 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
231 int GetNativeWindowId() override;
234 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
236 EGLNativeWindowType CreateEglWindow(int width, int height) override;
239 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
241 void DestroyEglWindow() override;
244 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
246 void SetEglWindowRotation(int angle) override;
249 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
251 void SetEglWindowBufferTransform(int angle) override;
254 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
256 void SetEglWindowTransform(int angle) override;
259 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
261 void ResizeEglWindow(PositionSize positionSize) override;
264 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
266 bool IsEglWindowRotationSupported() override;
269 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
271 void Move(PositionSize positionSize) override;
274 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
276 void Resize(PositionSize positionSize) override;
279 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
281 void MoveResize(PositionSize positionSize) override;
284 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
286 void SetClass(const std::string& name, const std::string& className) override;
289 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
291 void Raise() override;
294 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
296 void Lower() override;
299 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
301 void Activate() override;
304 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
306 void SetAvailableAnlges(const std::vector<int>& angles) override;
309 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
311 void SetPreferredAngle(int angle) override;
314 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
316 void SetAcceptFocus(bool accept) override;
319 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
321 void Show() override;
324 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
326 void Hide() override;
329 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
331 unsigned int GetSupportedAuxiliaryHintCount() const override;
334 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
336 std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
339 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
341 unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
344 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
346 bool RemoveAuxiliaryHint(unsigned int id) override;
349 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
351 bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
354 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
356 std::string GetAuxiliaryHintValue(unsigned int id) const override;
359 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
361 unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
364 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
366 void SetInputRegion(const Rect<int>& inputRegion) override;
369 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
371 void SetType(Dali::WindowType type) override;
374 * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
376 Dali::WindowType GetType() const override;
379 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
381 Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
384 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
386 Dali::WindowNotificationLevel GetNotificationLevel() const override;
389 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
391 void SetOpaqueState(bool opaque) override;
394 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
396 Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
399 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
401 WindowScreenOffMode GetScreenOffMode() const override;
404 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
406 Dali::WindowOperationResult SetBrightness(int brightness) override;
409 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
411 int GetBrightness() const override;
414 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
416 bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
419 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
421 bool UngrabKey(Dali::KEY key) override;
424 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
426 bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
429 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
431 bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
434 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
436 void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
439 * @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
441 int GetOrientation() const override;
444 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
446 int GetScreenRotationAngle() override;
449 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
451 void SetWindowRotationAngle(int degree) override;
454 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
456 void WindowRotationCompleted(int degree, int width, int height) override;
459 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
461 void SetTransparency(bool transparent) override;
464 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
466 void SetParent(WindowBase* parentWinBase, bool belowParent) override;
469 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
471 int CreateFrameRenderedSyncFence() override;
474 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
476 int CreateFramePresentedSyncFence() override;
479 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
481 void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
484 * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
486 void InitializeIme() override;
489 * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
491 void ImeWindowReadyToRender() override;
494 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
496 void RequestMoveToServer() override;
499 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
501 void RequestResizeToServer(WindowResizeDirection direction) override;
504 * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
506 void EnableFloatingMode(bool enable) override;
509 * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
511 bool IsFloatingModeEnabled() const override;
514 * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
516 void IncludeInputRegion(const Rect<int>& inputRegion) override;
519 * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
521 void ExcludeInputRegion(const Rect<int>& inputRegion) override;
525 * Second stage initialization
527 void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
530 * Initialize Ecore ElDBus
532 void InitializeEcoreElDBus();
535 * @brief Create window
537 void CreateWindow(PositionSize positionSize);
541 WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
544 WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
547 typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
548 Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
549 Ecore_Wl2_Window* mEcoreWindow;
551 wl_surface* mWlSurface;
552 zwp_input_panel_v1* mWlInputPanel;
553 wl_output* mWlOutput;
554 zwp_input_panel_surface_v1* mWlInputPanelSurface;
556 wl_egl_window* mEglWindow;
557 wl_display* mDisplay;
558 wl_event_queue* mEventQueue;
559 tizen_policy* mTizenPolicy;
560 tizen_display_policy* mTizenDisplayPolicy;
563 std::vector<std::string> mSupportedAuxiliaryHints;
565 Dali::PositionSize mWindowPositionSize;
566 AuxiliaryHints mAuxiliaryHints;
569 int mNotificationLevel;
572 int mWindowRotationAngle;
573 int mScreenRotationAngle;
574 int mSupportedPreProtation;
576 uint32_t mNotificationChangeState;
577 uint32_t mScreenOffModeChangeState;
578 uint32_t mBrightnessChangeState;
579 uint32_t mLastSubmittedMoveResizeSerial;
580 volatile uint32_t mMoveResizeSerial;
582 bool mNotificationLevelChangeDone;
583 bool mScreenOffModeChangeDone;
586 bool mBrightnessChangeDone;
588 #ifdef DALI_ELDBUS_AVAILABLE
589 Eldbus_Connection* mSystemConnection;
590 #endif // DALI_ELDBUS_AVAILABLE
593 } // namespace Adaptor
595 } // namespace Internal
599 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H