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) 2023 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>
38 class WindowRenderSurface;
39 class WindowRenderSurfaceEcoreWl2;
42 * WindowBaseEcoreWl2 class provides an WindowBase Ecore-Wayland2 implementation.
44 class WindowBaseEcoreWl2 : public WindowBase
50 WindowBaseEcoreWl2(PositionSize positionSize, Any surface, bool isTransparent);
55 virtual ~WindowBaseEcoreWl2();
59 * @brief Called when the window iconify state is changed.
61 Eina_Bool OnIconifyStateChanged(void* data, int type, void* event);
64 * @brief Called when the window gains focus.
66 Eina_Bool OnFocusIn(void* data, int type, void* event);
69 * @brief Called when the window loses focus.
71 Eina_Bool OnFocusOut(void* data, int type, void* event);
74 * @brief Called when the output is transformed.
76 Eina_Bool OnOutputTransform(void* data, int type, void* event);
79 * @brief Called when the output transform should be ignored.
81 Eina_Bool OnIgnoreOutputTransform(void* data, int type, void* event);
84 * @brief Called when a rotation event is recevied.
86 void OnRotation(void* data, int type, void* event);
89 * @brief Called when a configure event is recevied.
91 void OnConfiguration(void* data, int type, void* event);
94 * @brief Called when a touch down is received.
96 void OnMouseButtonDown(void* data, int type, void* event);
99 * @brief Called when a touch up is received.
101 void OnMouseButtonUp(void* data, int type, void* event);
104 * @brief Called when a touch motion is received.
106 void OnMouseButtonMove(void* data, int type, void* event);
109 * @brief Called when a touch motion is received.
111 void OnMouseButtonRelativeMove(void* data, int type, void* event);
114 * @brief Called when a touch is canceled.
116 void OnMouseButtonCancel(void* data, int type, void* event);
119 * @brief Called when a pointer is locked or unlocked.
121 void OnPointerConstraints(void* data, int type, void* event);
124 * @brief Called when a mouse wheel is received.
126 void OnMouseWheel(void* data, int type, void* event);
129 * @brief Called when a mouse in or out is received.
131 void OnMouseInOut(void* data, int type, void* event, Dali::DevelWindow::MouseInOutEvent::Type action);
134 * @brief Called when a detent rotation event is recevied.
136 void OnDetentRotation(void* data, int type, void* event);
139 * @brief Called when a key down is received.
141 void OnKeyDown(void* data, int type, void* event);
144 * @brief Called when a key up is received.
146 void OnKeyUp(void* data, int type, void* event);
149 * @brief Called when the source window notifies us the content in clipboard is selected.
151 void OnDataSend(void* data, int type, void* event);
154 * @brief Called when the source window sends us about the selected content.
156 void OnDataReceive(void* data, int type, void* event);
159 * @brief Called when a font name is changed.
161 void OnFontNameChanged();
164 * @brief Called when a font size is changed.
166 void OnFontSizeChanged();
169 * @brief Called when a transition effect-start/end event is received.
171 void OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type);
174 * @brief Called when a keyboard repeat event is changed.
176 void OnKeyboardRepeatSettingsChanged();
179 * @brief Called when a window redraw is requested.
181 void OnEcoreEventWindowRedrawRequest();
184 * @brief Called when a conformant is changed.
186 void OnEcoreEventConformantChange(void* event);
189 * @brief Called when window's auxiliary is changed then display server send the changed message.
191 * @param[in] auxiliary's message data. It has key, value and integer list data.
193 void OnEcoreEventWindowAuxiliaryMessage(void* event);
196 * @brief Called when window has been moved by then display server.
197 * To move the window by display server, RequestMoveToServer() should be called.
198 * After the moving job is completed, this function will be called.
200 * @param[in] the completed event's data. It has the latest window geometry data.
202 void OnMoveCompleted(void* event);
205 * @brief Called when window has been resized by then display server.
206 * To resize the window by display server, RequestResizeToServer() should be called.
207 * After the resizing job is completed, this function will be called.
209 * @param[in] the completed event's data. It has the latest window geometry data.
211 void OnResizeCompleted(void* event);
214 * @brief Called when a keymap is changed.
216 void KeymapChanged(void* data, int type, void* event);
219 * @brief RegistryGlobalCallback
221 void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
224 * @brief RegistryGlobalCallbackRemove
226 void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id);
229 * @brief TizenPolicyConformantArea
231 void TizenPolicyConformantArea(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h);
234 * @brief TizenPolicyNotificationChangeDone
236 void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state);
239 * @brief TizenPolicyScreenModeChangeDone
241 void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state);
244 * @brief DisplayPolicyBrightnessChangeDone
246 void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state);
249 * @brief Gets the key code by keyName.
251 void GetKeyCode(std::string keyName, int32_t& keyCode);
255 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
257 Any GetNativeWindow() override;
260 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
262 int GetNativeWindowId() override;
265 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowResourceId()
267 std::string GetNativeWindowResourceId() override;
270 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
272 EGLNativeWindowType CreateEglWindow(int width, int height) override;
275 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
277 void DestroyEglWindow() override;
280 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
282 void SetEglWindowRotation(int angle) override;
285 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
287 void SetEglWindowBufferTransform(int angle) override;
290 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
292 void SetEglWindowTransform(int angle) override;
295 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
297 void ResizeEglWindow(PositionSize positionSize) override;
300 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
302 bool IsEglWindowRotationSupported() override;
305 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
307 void Move(PositionSize positionSize) override;
310 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
312 void Resize(PositionSize positionSize) override;
315 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
317 void MoveResize(PositionSize positionSize) override;
320 * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout()
322 void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override;
325 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
327 void SetClass(const std::string& name, const std::string& className) override;
330 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
332 void Raise() override;
335 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
337 void Lower() override;
340 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
342 void Activate() override;
345 * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
347 void Maximize(bool maximize) override;
350 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
352 bool IsMaximized() const override;
355 * @copydoc Dali::Internal::Adaptor::WindowBase::SetMaximumSize()
357 void SetMaximumSize(Dali::Window::WindowSize size) override;
360 * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
362 void Minimize(bool minimize) override;
365 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
367 bool IsMinimized() const override;
370 * @copydoc Dali::Internal::Adaptor::WindowBase::SetMimimumSize()
372 void SetMimimumSize(Dali::Window::WindowSize size) override;
375 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
377 void SetAvailableAnlges(const std::vector<int>& angles) override;
380 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
382 void SetPreferredAngle(int angle) override;
385 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
387 void SetAcceptFocus(bool accept) override;
390 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
392 void Show() override;
395 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
397 void Hide() override;
400 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
402 unsigned int GetSupportedAuxiliaryHintCount() const override;
405 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
407 std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
410 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
412 unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
415 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
417 bool RemoveAuxiliaryHint(unsigned int id) override;
420 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
422 bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
425 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
427 std::string GetAuxiliaryHintValue(unsigned int id) const override;
430 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
432 unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
435 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
437 void SetInputRegion(const Rect<int>& inputRegion) override;
440 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
442 void SetType(Dali::WindowType type) override;
445 * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
447 Dali::WindowType GetType() const override;
450 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
452 Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
455 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
457 Dali::WindowNotificationLevel GetNotificationLevel() const override;
460 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
462 void SetOpaqueState(bool opaque) override;
465 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
467 Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
470 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
472 WindowScreenOffMode GetScreenOffMode() const override;
475 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
477 Dali::WindowOperationResult SetBrightness(int brightness) override;
480 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
482 int GetBrightness() const override;
485 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
487 bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
490 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
492 bool UngrabKey(Dali::KEY key) override;
495 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
497 bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
500 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
502 bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
505 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
507 void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
510 * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
512 int GetWindowRotationAngle() const override;
515 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
517 int GetScreenRotationAngle() override;
520 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
522 void SetWindowRotationAngle(int degree) override;
525 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
527 void WindowRotationCompleted(int degree, int width, int height) override;
530 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
532 void SetTransparency(bool transparent) override;
535 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
537 void SetParent(WindowBase* parentWinBase, bool belowParent) override;
540 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
542 int CreateFrameRenderedSyncFence() override;
545 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
547 int CreateFramePresentedSyncFence() override;
550 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
552 void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
555 * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
557 void InitializeIme() override;
560 * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
562 void ImeWindowReadyToRender() override;
565 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
567 void RequestMoveToServer() override;
570 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
572 void RequestResizeToServer(WindowResizeDirection direction) override;
575 * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
577 void EnableFloatingMode(bool enable) override;
580 * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
582 bool IsFloatingModeEnabled() const override;
585 * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
587 void IncludeInputRegion(const Rect<int>& inputRegion) override;
590 * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
592 void ExcludeInputRegion(const Rect<int>& inputRegion) override;
595 * @copydoc Dali::Internal::Adaptor::WindowBase::PointerConstraintsLock()
597 bool PointerConstraintsLock() override;
600 * @copydoc Dali::Internal::Adaptor::WindowBase::PointerConstraintsUnlock()
602 bool PointerConstraintsUnlock() override;
605 * @copydoc Dali::Internal::Adaptor::WindowBase::LockedPointerRegionSet()
607 void LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height) override;
610 * @copydoc Dali::Internal::Adaptor::WindowBase::LockedPointerCursorPositionHintSet()
612 void LockedPointerCursorPositionHintSet(int32_t x, int32_t y) override;
615 * @copydoc Dali::Internal::Adaptor::WindowBase::PointerWarp()
617 bool PointerWarp(int32_t x, int32_t y) override;
620 * @copydoc Dali::Internal::Adaptor::WindowBase::CursorVisibleSet()
622 void CursorVisibleSet(bool visible) override;
625 * @copydoc Dali::Internal::Adaptor::WindowBase::KeyboardGrab()
627 bool KeyboardGrab(Device::Subclass::Type deviceSubclass) override;
630 * @copydoc Dali::Internal::Adaptor::WindowBase::KeyboardUnGrab()
632 bool KeyboardUnGrab() override;
635 * @copydoc Dali::Internal::Adaptor::WindowBase::SetFullScreen()
637 void SetFullScreen(bool fullscreen) override;
640 * @copydoc Dali::Internal::Adaptor::WindowBase::GetFullScreen()
642 bool GetFullScreen() override;
646 * Second stage initialization
648 void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
651 * @brief Create window
653 void CreateWindow(PositionSize positionSize);
656 * @brief Return the window's position and size to recalulate with the default system coordinates.
657 * It is used when window is moved or resized for native ecore wayland window system.
659 * @param[in] positionSize the window's current position and size with current oriented window's coordinates.
660 * @return the re-calculated window's position and size on the default system coordinates.
662 PositionSize RecalculatePositionSizeToSystem(PositionSize positionSize);
665 * @brief Return the window's position and size to recalulate with current oriented window's coordinates.
666 * It is used when window is moved or resized for dali and uppler layer framework.
668 * @param[in] positionSize the window's current position and size with the default system coordinates.
669 * @return the re-calculated window's position and size on current oriented window's coordinates.
671 PositionSize RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize);
675 WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
678 WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
681 typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
682 Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
683 Ecore_Wl2_Window* mEcoreWindow;
685 wl_surface* mWlSurface;
686 #ifdef OVER_TIZEN_VERSION_7
687 zwp_input_panel_v1* mWlInputPanel;
689 wl_input_panel* mWlInputPanel;
691 wl_output* mWlOutput;
692 #ifdef OVER_TIZEN_VERSION_7
693 zwp_input_panel_surface_v1* mWlInputPanelSurface;
695 wl_input_panel_surface* mWlInputPanelSurface;
698 wl_egl_window* mEglWindow;
699 wl_display* mDisplay;
700 wl_event_queue* mEventQueue;
701 tizen_policy* mTizenPolicy;
702 tizen_display_policy* mTizenDisplayPolicy;
705 std::vector<std::string> mSupportedAuxiliaryHints;
707 // It is based on the default system coordinates.
708 Dali::PositionSize mWindowPositionSize;
710 AuxiliaryHints mAuxiliaryHints;
713 int mNotificationLevel;
716 int mWindowRotationAngle;
717 int mScreenRotationAngle;
718 int mSupportedPreProtation;
720 uint32_t mNotificationChangeState;
721 uint32_t mScreenOffModeChangeState;
722 uint32_t mBrightnessChangeState;
723 uint32_t mLastSubmittedMoveResizeSerial;
724 volatile uint32_t mMoveResizeSerial;
726 bool mNotificationLevelChangeDone;
727 bool mScreenOffModeChangeDone;
730 bool mBrightnessChangeDone;
731 bool mIsIMEWindowInitialized;
734 } // namespace Adaptor
736 } // namespace Internal
740 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H