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) 2021 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 <tizen-extension-client-protocol.h>
28 #include <wayland-egl.h>
29 #include <xkbcommon/xkbcommon.h>
31 #ifdef DALI_ELDBUS_AVAILABLE
41 class WindowRenderSurface;
42 class WindowRenderSurfaceEcoreWl2;
45 * WindowBaseEcoreWl2 class provides an WindowBase Ecore-Wayland2 implementation.
47 class WindowBaseEcoreWl2 : public WindowBase
53 WindowBaseEcoreWl2(PositionSize positionSize, Any surface, bool isTransparent);
58 virtual ~WindowBaseEcoreWl2();
62 * @brief Called when the window iconify state is changed.
64 Eina_Bool OnIconifyStateChanged(void* data, int type, void* event);
67 * @brief Called when the window gains focus.
69 Eina_Bool OnFocusIn(void* data, int type, void* event);
72 * @brief Called when the window loses focus.
74 Eina_Bool OnFocusOut(void* data, int type, void* event);
77 * @brief Called when the output is transformed.
79 Eina_Bool OnOutputTransform(void* data, int type, void* event);
82 * @brief Called when the output transform should be ignored.
84 Eina_Bool OnIgnoreOutputTransform(void* data, int type, void* event);
87 * @brief Called when a rotation event is recevied.
89 void OnRotation(void* data, int type, void* event);
92 * @brief Called when a configure event is recevied.
94 void OnConfiguration(void* data, int type, void* event);
97 * @brief Called when a touch down is received.
99 void OnMouseButtonDown(void* data, int type, void* event);
102 * @brief Called when a touch up is received.
104 void OnMouseButtonUp(void* data, int type, void* event);
107 * @brief Called when a touch motion is received.
109 void OnMouseButtonMove(void* data, int type, void* event);
112 * @brief Called when a touch is canceled.
114 void OnMouseButtonCancel(void* data, int type, void* event);
117 * @brief Called when a mouse wheel is received.
119 void OnMouseWheel(void* data, int type, void* event);
122 * @brief Called when a detent rotation event is recevied.
124 void OnDetentRotation(void* data, int type, void* event);
127 * @brief Called when a key down is received.
129 void OnKeyDown(void* data, int type, void* event);
132 * @brief Called when a key up is received.
134 void OnKeyUp(void* data, int type, void* event);
137 * @brief Called when the source window notifies us the content in clipboard is selected.
139 void OnDataSend(void* data, int type, void* event);
142 * @brief Called when the source window sends us about the selected content.
144 void OnDataReceive(void* data, int type, void* event);
147 * @brief Called when a font name is changed.
149 void OnFontNameChanged();
152 * @brief Called when a font size is changed.
154 void OnFontSizeChanged();
157 * @brief Called when a transition effect-start/end event is received.
159 void OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type);
162 * @brief Called when a keyboard repeat event is changed.
164 void OnKeyboardRepeatSettingsChanged();
167 * @brief Called when a window redraw is requested.
169 void OnEcoreEventWindowRedrawRequest();
171 #ifdef DALI_ELDBUS_AVAILABLE
173 * @brief Called when Ecore ElDBus accessibility event is received.
175 void OnEcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message);
179 * @brief Called when a keymap is changed.
181 void KeymapChanged(void* data, int type, void* event);
184 * @brief RegistryGlobalCallback
186 void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
189 * @brief RegistryGlobalCallbackRemove
191 void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id);
194 * @brief TizenPolicyNotificationChangeDone
196 void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state);
199 * @brief TizenPolicyScreenModeChangeDone
201 void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state);
204 * @brief DisplayPolicyBrightnessChangeDone
206 void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state);
209 * @brief Gets the key code by keyName.
211 void GetKeyCode(std::string keyName, int32_t& keyCode);
215 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
217 Any GetNativeWindow() override;
220 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
222 int GetNativeWindowId() override;
225 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
227 EGLNativeWindowType CreateEglWindow(int width, int height) override;
230 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
232 void DestroyEglWindow() override;
235 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
237 void SetEglWindowRotation(int angle) override;
240 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
242 void SetEglWindowBufferTransform(int angle) override;
245 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
247 void SetEglWindowTransform(int angle) override;
250 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
252 void ResizeEglWindow(PositionSize positionSize) override;
255 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
257 bool IsEglWindowRotationSupported() override;
260 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
262 void Move(PositionSize positionSize) override;
265 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
267 void Resize(PositionSize positionSize) override;
270 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
272 void MoveResize(PositionSize positionSize) override;
275 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
277 void SetClass(const std::string& name, const std::string& className) override;
280 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
282 void Raise() override;
285 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
287 void Lower() override;
290 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
292 void Activate() override;
295 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
297 void SetAvailableAnlges(const std::vector<int>& angles) override;
300 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
302 void SetPreferredAngle(int angle) override;
305 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
307 void SetAcceptFocus(bool accept) override;
310 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
312 void Show() override;
315 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
317 void Hide() override;
320 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
322 unsigned int GetSupportedAuxiliaryHintCount() const override;
325 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
327 std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
330 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
332 unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
335 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
337 bool RemoveAuxiliaryHint(unsigned int id) override;
340 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
342 bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
345 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
347 std::string GetAuxiliaryHintValue(unsigned int id) const override;
350 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
352 unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
355 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
357 void SetInputRegion(const Rect<int>& inputRegion) override;
360 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
362 void SetType(Dali::WindowType type) override;
365 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
367 bool SetNotificationLevel(Dali::WindowNotificationLevel level) override;
370 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
372 Dali::WindowNotificationLevel GetNotificationLevel() const override;
375 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
377 void SetOpaqueState(bool opaque) override;
380 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
382 bool SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
385 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
387 WindowScreenOffMode GetScreenOffMode() const override;
390 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
392 bool SetBrightness(int brightness) override;
395 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
397 int GetBrightness() const override;
400 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
402 bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
405 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
407 bool UngrabKey(Dali::KEY key) override;
410 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
412 bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
415 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
417 bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
420 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
422 void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
425 * @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
427 int GetOrientation() const override;
430 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
432 int GetScreenRotationAngle() override;
435 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
437 void SetWindowRotationAngle(int degree) override;
440 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
442 void WindowRotationCompleted(int degree, int width, int height) override;
445 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
447 void SetTransparency(bool transparent) override;
450 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
452 void SetParent(WindowBase* parentWinBase) override;
455 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
457 int CreateFrameRenderedSyncFence() override;
460 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
462 int CreateFramePresentedSyncFence() override;
466 * Second stage initialization
468 void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
471 * Initialize Ecore ElDBus
473 void InitializeEcoreElDBus();
476 * @brief Create window
478 void CreateWindow(PositionSize positionSize);
482 WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
485 WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
488 typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
490 Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
492 Ecore_Wl2_Window* mEcoreWindow;
493 wl_surface* mWlSurface;
494 wl_egl_window* mEglWindow;
495 wl_display* mDisplay;
496 wl_event_queue* mEventQueue;
497 tizen_policy* mTizenPolicy;
498 tizen_display_policy* mTizenDisplayPolicy;
501 std::vector<std::string> mSupportedAuxiliaryHints;
502 AuxiliaryHints mAuxiliaryHints;
504 int mNotificationLevel;
505 uint32_t mNotificationChangeState;
506 bool mNotificationLevelChangeDone;
509 uint32_t mScreenOffModeChangeState;
510 bool mScreenOffModeChangeDone;
513 uint32_t mBrightnessChangeState;
514 bool mBrightnessChangeDone;
517 Dali::PositionSize mWindowPositionSize;
521 volatile uint32_t mMoveResizeSerial;
522 uint32_t mLastSubmittedMoveResizeSerial;
524 int mWindowRotationAngle;
525 int mScreenRotationAngle;
526 int mSupportedPreProtation;
527 #ifdef DALI_ELDBUS_AVAILABLE
528 Eldbus_Connection* mSystemConnection;
529 #endif // DALI_ELDBUS_AVAILABLE
532 } // namespace Adaptor
534 } // namespace Internal
538 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H