1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL_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_Wayland.h>
27 #include <tizen-extension-client-protocol.h>
28 #include <wayland-egl.h>
30 #ifdef DALI_ELDBUS_AVAILABLE
40 class WindowRenderSurface;
41 class WindowRenderSurfaceEcoreWl;
44 * WindowBaseEcoreWl class provides an WindowBase Ecore-Wayland implementation.
46 class WindowBaseEcoreWl : public WindowBase
52 WindowBaseEcoreWl(PositionSize positionSize, Any surface, bool isTransparent);
57 virtual ~WindowBaseEcoreWl();
61 * @brief Called when the window iconify state is changed.
63 Eina_Bool OnIconifyStateChanged(void* data, int type, void* event);
66 * @brief Called when the window gains focus.
68 Eina_Bool OnFocusIn(void* data, int type, void* event);
71 * @brief Called when the window loses focus.
73 Eina_Bool OnFocusOut(void* data, int type, void* event);
76 * @brief Called when the output is transformed.
78 Eina_Bool OnOutputTransform(void* data, int type, void* event);
81 * @brief Called when the output transform should be ignored.
83 Eina_Bool OnIgnoreOutputTransform(void* data, int type, void* event);
86 * @brief Called when a rotation event is recevied.
88 void OnRotation(void* data, int type, void* event);
91 * @brief Called when a touch down is received.
93 void OnMouseButtonDown(void* data, int type, void* event);
96 * @brief Called when a touch up is received.
98 void OnMouseButtonUp(void* data, int type, void* event);
101 * @brief Called when a touch motion is received.
103 void OnMouseButtonMove(void* data, int type, void* event);
106 * @brief Called when a touch is canceled.
108 void OnMouseButtonCancel(void* data, int type, void* event);
111 * @brief Called when a mouse wheel is received.
113 void OnMouseWheel(void* data, int type, void* event);
116 * @brief Called when a detent rotation event is recevied.
118 void OnDetentRotation(void* data, int type, void* event);
121 * @brief Called when a key down is received.
123 void OnKeyDown(void* data, int type, void* event);
126 * @brief Called when a key up is received.
128 void OnKeyUp(void* data, int type, void* event);
131 * @brief Called when the source window notifies us the content in clipboard is selected.
133 void OnDataSend(void* data, int type, void* event);
136 * @brief Called when the source window sends us about the selected content.
138 void OnDataReceive(void* data, int type, void* event);
141 * @brief Called when a font name is changed.
143 void OnFontNameChanged();
146 * @brief Called when a font size is changed.
148 void OnFontSizeChanged();
150 #ifdef DALI_ELDBUS_AVAILABLE
152 * @brief Called when Ecore ElDBus accessibility event is received.
154 void OnEcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message);
158 * @brief RegistryGlobalCallback
160 void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
163 * @brief RegistryGlobalCallbackRemove
165 void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id);
168 * @brief TizenPolicyNotificationChangeDone
170 void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state);
173 * @brief TizenPolicyScreenModeChangeDone
175 void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state);
178 * @brief DisplayPolicyBrightnessChangeDone
180 void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state);
184 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
186 Any GetNativeWindow() override;
189 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
191 int GetNativeWindowId() override;
194 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowResourceId()
196 std::string GetNativeWindowResourceId() override;
199 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
201 EGLNativeWindowType CreateEglWindow(int width, int height) override;
204 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
206 void DestroyEglWindow() override;
209 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
211 void SetEglWindowRotation(int angle) override;
214 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
216 void SetEglWindowBufferTransform(int angle) override;
219 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
221 void SetEglWindowTransform(int angle) override;
224 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
226 void ResizeEglWindow(PositionSize positionSize) override;
229 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
231 bool IsEglWindowRotationSupported() override;
234 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
236 void Move(PositionSize positionSize) override;
239 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
241 void Resize(PositionSize positionSize) override;
244 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
246 void MoveResize(PositionSize positionSize) override;
249 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
251 void SetClass(const std::string& name, const std::string& className) override;
254 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
256 void Raise() override;
259 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
261 void Lower() override;
264 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
266 void Activate() override;
269 * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
271 void Maximize(bool maximize) override;
274 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
276 bool IsMaximized() const override;
279 * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
281 void Minimize(bool minimize) override;
284 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
286 bool IsMinimized() const override;
289 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
291 void SetAvailableAnlges(const std::vector<int>& angles) override;
294 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
296 void SetPreferredAngle(int angle) override;
299 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
301 void SetAcceptFocus(bool accept) override;
304 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
306 void Show() override;
309 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
311 void Hide() override;
314 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
316 unsigned int GetSupportedAuxiliaryHintCount() const override;
319 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
321 std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
324 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
326 unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
329 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
331 bool RemoveAuxiliaryHint(unsigned int id) override;
334 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
336 bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
339 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
341 std::string GetAuxiliaryHintValue(unsigned int id) const override;
344 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
346 unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
349 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
351 void SetInputRegion(const Rect<int>& inputRegion) override;
354 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
356 void SetType(Dali::WindowType type) override;
359 * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
361 Dali::WindowType GetType() const override;
364 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
366 Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
369 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
371 Dali::WindowNotificationLevel GetNotificationLevel() const override;
374 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
376 void SetOpaqueState(bool opaque) override;
379 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
381 Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
384 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
386 WindowScreenOffMode GetScreenOffMode() const override;
389 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
391 Dali::WindowOperationResult SetBrightness(int brightness) override;
394 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
396 int GetBrightness() const override;
399 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
401 bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
404 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
406 bool UngrabKey(Dali::KEY key) override;
409 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
411 bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
414 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
416 bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
419 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
421 void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
424 * @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
426 int GetOrientation() const override;
429 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
431 int GetScreenRotationAngle() override;
434 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
436 void SetWindowRotationAngle(int degree) override;
439 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
441 void WindowRotationCompleted(int degree, int width, int height) override;
444 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
446 void SetTransparency(bool transparent) override;
449 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
451 void SetParent(WindowBase* parentWinBase, bool belowParent) override;
454 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
456 int CreateFrameRenderedSyncFence() override;
459 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
461 int CreateFramePresentedSyncFence() override;
464 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
466 void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
469 * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
471 void InitializeIme() override;
474 * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
476 void ImeWindowReadyToRender() override;
479 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
481 void RequestMoveToServer() override;
484 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
486 void RequestResizeToServer(WindowResizeDirection direction) override;
489 * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
491 void EnableFloatingMode(bool enable) override;
494 * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
496 bool IsFloatingModeEnabled() const override;
499 * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
501 void IncludeInputRegion(const Rect<int>& inputRegion) override;
504 * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
506 void ExcludeInputRegion(const Rect<int>& inputRegion) override;
510 * Second stage initialization
512 void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
515 * Initialize Ecore ElDBus
517 void InitializeEcoreElDBus();
520 * @brief Create window
522 void CreateWindow(PositionSize positionSize);
526 WindowBaseEcoreWl(const WindowBaseEcoreWl&) = delete;
529 WindowBaseEcoreWl& operator=(const WindowBaseEcoreWl& rhs) = delete;
532 typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
534 Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
536 Ecore_Wl_Window* mEcoreWindow;
537 wl_surface* mWlSurface;
538 wl_egl_window* mEglWindow;
539 wl_display* mDisplay;
540 wl_event_queue* mEventQueue;
541 tizen_policy* mTizenPolicy;
542 tizen_display_policy* mTizenDisplayPolicy;
544 std::vector<std::string> mSupportedAuxiliaryHints;
545 AuxiliaryHints mAuxiliaryHints;
547 int mNotificationLevel;
548 uint32_t mNotificationChangeState;
549 bool mNotificationLevelChangeDone;
552 uint32_t mScreenOffModeChangeState;
553 bool mScreenOffModeChangeDone;
556 uint32_t mBrightnessChangeState;
557 bool mBrightnessChangeDone;
561 int mWindowRotationAngle;
562 int mScreenRotationAngle;
563 int mSupportedPreProtation;
564 #ifdef DALI_ELDBUS_AVAILABLE
565 Eldbus_Connection* mSystemConnection;
566 #endif // DALI_ELDBUS_AVAILABLE
569 } // namespace Adaptor
571 } // namespace Internal
575 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL_H