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>
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 is canceled.
111 void OnMouseButtonCancel(void* data, int type, void* event);
114 * @brief Called when a mouse wheel is received.
116 void OnMouseWheel(void* data, int type, void* event);
119 * @brief Called when a detent rotation event is recevied.
121 void OnDetentRotation(void* data, int type, void* event);
124 * @brief Called when a key down is received.
126 void OnKeyDown(void* data, int type, void* event);
129 * @brief Called when a key up is received.
131 void OnKeyUp(void* data, int type, void* event);
134 * @brief Called when the source window notifies us the content in clipboard is selected.
136 void OnDataSend(void* data, int type, void* event);
139 * @brief Called when the source window sends us about the selected content.
141 void OnDataReceive(void* data, int type, void* event);
144 * @brief Called when a font name is changed.
146 void OnFontNameChanged();
149 * @brief Called when a font size is changed.
151 void OnFontSizeChanged();
154 * @brief Called when a transition effect-start/end event is received.
156 void OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type);
159 * @brief Called when a keyboard repeat event is changed.
161 void OnKeyboardRepeatSettingsChanged();
164 * @brief Called when a window redraw is requested.
166 void OnEcoreEventWindowRedrawRequest();
169 * @brief Called when window's auxiliary is changed then display server send the changed message.
171 * @param[in] auxiliary's message data. It has key, value and integer list data.
173 void OnEcoreEventWindowAuxiliaryMessage(void* event);
176 * @brief Called when a keymap is changed.
178 void KeymapChanged(void* data, int type, void* event);
181 * @brief RegistryGlobalCallback
183 void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
186 * @brief RegistryGlobalCallbackRemove
188 void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id);
191 * @brief TizenPolicyNotificationChangeDone
193 void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state);
196 * @brief TizenPolicyScreenModeChangeDone
198 void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state);
201 * @brief DisplayPolicyBrightnessChangeDone
203 void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state);
206 * @brief Gets the key code by keyName.
208 void GetKeyCode(std::string keyName, int32_t& keyCode);
212 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
214 Any GetNativeWindow() override;
217 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
219 int GetNativeWindowId() override;
222 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowResourceId()
224 std::string GetNativeWindowResourceId() override;
227 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
229 EGLNativeWindowType CreateEglWindow(int width, int height) override;
232 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
234 void DestroyEglWindow() override;
237 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
239 void SetEglWindowRotation(int angle) override;
242 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
244 void SetEglWindowBufferTransform(int angle) override;
247 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
249 void SetEglWindowTransform(int angle) override;
252 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
254 void ResizeEglWindow(PositionSize positionSize) override;
257 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
259 bool IsEglWindowRotationSupported() override;
262 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
264 void Move(PositionSize positionSize) override;
267 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
269 void Resize(PositionSize positionSize) override;
272 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
274 void MoveResize(PositionSize positionSize) override;
277 * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout()
279 void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override;
282 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
284 void SetClass(const std::string& name, const std::string& className) override;
287 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
289 void Raise() override;
292 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
294 void Lower() override;
297 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
299 void Activate() override;
302 * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
304 void Maximize(bool maximize) override;
307 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
309 bool IsMaximized() const override;
312 * @copydoc Dali::Internal::Adaptor::WindowBase::SetMaximumSize()
314 void SetMaximumSize(Dali::Window::WindowSize size) override;
317 * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
319 void Minimize(bool minimize) override;
322 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
324 bool IsMinimized() const override;
327 * @copydoc Dali::Internal::Adaptor::WindowBase::SetMimimumSize()
329 void SetMimimumSize(Dali::Window::WindowSize size) override;
332 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
334 void SetAvailableAnlges(const std::vector<int>& angles) override;
337 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
339 void SetPreferredAngle(int angle) override;
342 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
344 void SetAcceptFocus(bool accept) override;
347 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
349 void Show() override;
352 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
354 void Hide() override;
357 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
359 unsigned int GetSupportedAuxiliaryHintCount() const override;
362 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
364 std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
367 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
369 unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
372 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
374 bool RemoveAuxiliaryHint(unsigned int id) override;
377 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
379 bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
382 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
384 std::string GetAuxiliaryHintValue(unsigned int id) const override;
387 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
389 unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
392 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
394 void SetInputRegion(const Rect<int>& inputRegion) override;
397 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
399 void SetType(Dali::WindowType type) override;
402 * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
404 Dali::WindowType GetType() const override;
407 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
409 Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
412 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
414 Dali::WindowNotificationLevel GetNotificationLevel() const override;
417 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
419 void SetOpaqueState(bool opaque) override;
422 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
424 Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
427 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
429 WindowScreenOffMode GetScreenOffMode() const override;
432 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
434 Dali::WindowOperationResult SetBrightness(int brightness) override;
437 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
439 int GetBrightness() const override;
442 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
444 bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
447 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
449 bool UngrabKey(Dali::KEY key) override;
452 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
454 bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
457 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
459 bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
462 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
464 void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
467 * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
469 int GetWindowRotationAngle() const override;
472 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
474 int GetScreenRotationAngle() override;
477 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
479 void SetWindowRotationAngle(int degree) override;
482 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
484 void WindowRotationCompleted(int degree, int width, int height) override;
487 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
489 void SetTransparency(bool transparent) override;
492 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
494 void SetParent(WindowBase* parentWinBase, bool belowParent) override;
497 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
499 int CreateFrameRenderedSyncFence() override;
502 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
504 int CreateFramePresentedSyncFence() override;
507 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
509 void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
512 * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
514 void InitializeIme() override;
517 * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
519 void ImeWindowReadyToRender() override;
522 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
524 void RequestMoveToServer() override;
527 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
529 void RequestResizeToServer(WindowResizeDirection direction) override;
532 * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
534 void EnableFloatingMode(bool enable) override;
537 * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
539 bool IsFloatingModeEnabled() const override;
542 * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
544 void IncludeInputRegion(const Rect<int>& inputRegion) override;
547 * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
549 void ExcludeInputRegion(const Rect<int>& inputRegion) override;
553 * Second stage initialization
555 void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
558 * @brief Create window
560 void CreateWindow(PositionSize positionSize);
563 * @brief Return the window's position and size to recalulate with the default system coordinates.
564 * It is used when window is moved or resized for native ecore wayland window system.
566 * @param[in] positionSize the window's current position and size with current oriented window's coordinates.
567 * @return the re-calculated window's position and size on the default system coordinates.
569 PositionSize RecalculatePositionSizeToSystem(PositionSize positionSize);
572 * @brief Return the window's position and size to recalulate with current oriented window's coordinates.
573 * It is used when window is moved or resized for dali and uppler layer framework.
575 * @param[in] positionSize the window's current position and size with the default system coordinates.
576 * @return the re-calculated window's position and size on current oriented window's coordinates.
578 PositionSize RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize);
582 WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
585 WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
588 typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
589 Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
590 Ecore_Wl2_Window* mEcoreWindow;
592 wl_surface* mWlSurface;
593 #ifdef OVER_TIZEN_VERSION_7
594 zwp_input_panel_v1* mWlInputPanel;
596 wl_input_panel* mWlInputPanel;
598 wl_output* mWlOutput;
599 #ifdef OVER_TIZEN_VERSION_7
600 zwp_input_panel_surface_v1* mWlInputPanelSurface;
602 wl_input_panel_surface* mWlInputPanelSurface;
605 wl_egl_window* mEglWindow;
606 wl_display* mDisplay;
607 wl_event_queue* mEventQueue;
608 tizen_policy* mTizenPolicy;
609 tizen_display_policy* mTizenDisplayPolicy;
612 std::vector<std::string> mSupportedAuxiliaryHints;
614 // It is based on the default system coordinates.
615 Dali::PositionSize mWindowPositionSize;
617 AuxiliaryHints mAuxiliaryHints;
620 int mNotificationLevel;
623 int mWindowRotationAngle;
624 int mScreenRotationAngle;
625 int mSupportedPreProtation;
627 uint32_t mNotificationChangeState;
628 uint32_t mScreenOffModeChangeState;
629 uint32_t mBrightnessChangeState;
630 uint32_t mLastSubmittedMoveResizeSerial;
631 volatile uint32_t mMoveResizeSerial;
633 bool mNotificationLevelChangeDone;
634 bool mScreenOffModeChangeDone;
637 bool mBrightnessChangeDone;
640 } // namespace Adaptor
642 } // namespace Internal
646 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H