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 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 mouse in or out is received.
121 void OnMouseInOut(void* data, int type, void* event, Dali::DevelWindow::MouseInOutEvent::Type action);
124 * @brief Called when a detent rotation event is recevied.
126 void OnDetentRotation(void* data, int type, void* event);
129 * @brief Called when a key down is received.
131 void OnKeyDown(void* data, int type, void* event);
134 * @brief Called when a key up is received.
136 void OnKeyUp(void* data, int type, void* event);
139 * @brief Called when the source window notifies us the content in clipboard is selected.
141 void OnDataSend(void* data, int type, void* event);
144 * @brief Called when the source window sends us about the selected content.
146 void OnDataReceive(void* data, int type, void* event);
149 * @brief Called when a font name is changed.
151 void OnFontNameChanged();
154 * @brief Called when a font size is changed.
156 void OnFontSizeChanged();
159 * @brief Called when a transition effect-start/end event is received.
161 void OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type);
164 * @brief Called when a keyboard repeat event is changed.
166 void OnKeyboardRepeatSettingsChanged();
169 * @brief Called when a window redraw is requested.
171 void OnEcoreEventWindowRedrawRequest();
174 * @brief Called when window's auxiliary is changed then display server send the changed message.
176 * @param[in] auxiliary's message data. It has key, value and integer list data.
178 void OnEcoreEventWindowAuxiliaryMessage(void* event);
181 * @brief Called when window has been moved by then display server.
182 * To move the window by display server, RequestMoveToServer() should be called.
183 * After the moving job is completed, this function will be called.
185 * @param[in] the completed event's data. It has the latest window geometry data.
187 void OnMoveCompleted(void* event);
190 * @brief Called when window has been resized by then display server.
191 * To resize the window by display server, RequestResizeToServer() should be called.
192 * After the resizing job is completed, this function will be called.
194 * @param[in] the completed event's data. It has the latest window geometry data.
196 void OnResizeCompleted(void* event);
199 * @brief Called when a keymap is changed.
201 void KeymapChanged(void* data, int type, void* event);
204 * @brief RegistryGlobalCallback
206 void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
209 * @brief RegistryGlobalCallbackRemove
211 void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id);
214 * @brief TizenPolicyNotificationChangeDone
216 void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state);
219 * @brief TizenPolicyScreenModeChangeDone
221 void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state);
224 * @brief DisplayPolicyBrightnessChangeDone
226 void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state);
229 * @brief Gets the key code by keyName.
231 void GetKeyCode(std::string keyName, int32_t& keyCode);
235 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
237 Any GetNativeWindow() override;
240 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
242 int GetNativeWindowId() override;
245 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowResourceId()
247 std::string GetNativeWindowResourceId() override;
250 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
252 EGLNativeWindowType CreateEglWindow(int width, int height) override;
255 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
257 void DestroyEglWindow() override;
260 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
262 void SetEglWindowRotation(int angle) override;
265 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
267 void SetEglWindowBufferTransform(int angle) override;
270 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
272 void SetEglWindowTransform(int angle) override;
275 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
277 void ResizeEglWindow(PositionSize positionSize) override;
280 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
282 bool IsEglWindowRotationSupported() override;
285 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
287 void Move(PositionSize positionSize) override;
290 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
292 void Resize(PositionSize positionSize) override;
295 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
297 void MoveResize(PositionSize positionSize) override;
300 * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout()
302 void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override;
305 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
307 void SetClass(const std::string& name, const std::string& className) override;
310 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
312 void Raise() override;
315 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
317 void Lower() override;
320 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
322 void Activate() override;
325 * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
327 void Maximize(bool maximize) override;
330 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
332 bool IsMaximized() const override;
335 * @copydoc Dali::Internal::Adaptor::WindowBase::SetMaximumSize()
337 void SetMaximumSize(Dali::Window::WindowSize size) override;
340 * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
342 void Minimize(bool minimize) override;
345 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
347 bool IsMinimized() const override;
350 * @copydoc Dali::Internal::Adaptor::WindowBase::SetMimimumSize()
352 void SetMimimumSize(Dali::Window::WindowSize size) override;
355 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
357 void SetAvailableAnlges(const std::vector<int>& angles) override;
360 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
362 void SetPreferredAngle(int angle) override;
365 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
367 void SetAcceptFocus(bool accept) override;
370 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
372 void Show() override;
375 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
377 void Hide() override;
380 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
382 unsigned int GetSupportedAuxiliaryHintCount() const override;
385 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
387 std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
390 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
392 unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
395 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
397 bool RemoveAuxiliaryHint(unsigned int id) override;
400 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
402 bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
405 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
407 std::string GetAuxiliaryHintValue(unsigned int id) const override;
410 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
412 unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
415 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
417 void SetInputRegion(const Rect<int>& inputRegion) override;
420 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
422 void SetType(Dali::WindowType type) override;
425 * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
427 Dali::WindowType GetType() const override;
430 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
432 Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
435 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
437 Dali::WindowNotificationLevel GetNotificationLevel() const override;
440 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
442 void SetOpaqueState(bool opaque) override;
445 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
447 Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
450 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
452 WindowScreenOffMode GetScreenOffMode() const override;
455 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
457 Dali::WindowOperationResult SetBrightness(int brightness) override;
460 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
462 int GetBrightness() const override;
465 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
467 bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
470 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
472 bool UngrabKey(Dali::KEY key) override;
475 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
477 bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
480 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
482 bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
485 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
487 void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
490 * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
492 int GetWindowRotationAngle() const override;
495 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
497 int GetScreenRotationAngle() override;
500 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
502 void SetWindowRotationAngle(int degree) override;
505 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
507 void WindowRotationCompleted(int degree, int width, int height) override;
510 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
512 void SetTransparency(bool transparent) override;
515 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
517 void SetParent(WindowBase* parentWinBase, bool belowParent) override;
520 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
522 int CreateFrameRenderedSyncFence() override;
525 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
527 int CreateFramePresentedSyncFence() override;
530 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
532 void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
535 * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
537 void InitializeIme() override;
540 * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
542 void ImeWindowReadyToRender() override;
545 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
547 void RequestMoveToServer() override;
550 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
552 void RequestResizeToServer(WindowResizeDirection direction) override;
555 * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
557 void EnableFloatingMode(bool enable) override;
560 * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
562 bool IsFloatingModeEnabled() const override;
565 * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
567 void IncludeInputRegion(const Rect<int>& inputRegion) override;
570 * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
572 void ExcludeInputRegion(const Rect<int>& inputRegion) override;
576 * Second stage initialization
578 void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
581 * @brief Create window
583 void CreateWindow(PositionSize positionSize);
586 * @brief Return the window's position and size to recalulate with the default system coordinates.
587 * It is used when window is moved or resized for native ecore wayland window system.
589 * @param[in] positionSize the window's current position and size with current oriented window's coordinates.
590 * @return the re-calculated window's position and size on the default system coordinates.
592 PositionSize RecalculatePositionSizeToSystem(PositionSize positionSize);
595 * @brief Return the window's position and size to recalulate with current oriented window's coordinates.
596 * It is used when window is moved or resized for dali and uppler layer framework.
598 * @param[in] positionSize the window's current position and size with the default system coordinates.
599 * @return the re-calculated window's position and size on current oriented window's coordinates.
601 PositionSize RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize);
604 * @brief Return the rect value to recalulate with the default system coordinates.
606 * Some native window APIs work the geometry value based on the default system coordinates.
607 * IncludeInputRegion() and ExcludeInputRegion() are one of them.
608 * When the window is rotated, current window's geometry already were set with the rotated angle.
609 * If IncludeInputRegion() or ExcludeInputRegion() are called with rotated angle by application,
610 * the rect's area should be re-calcuated on the default system coordinates.
612 * @param[in] rect the window's current position and size with current window rotation angle.
613 * @return the re-calculated rect on the default system coordinates.
615 Rect<int> RecalculateInputRect(const Rect<int>& rect);
619 WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
622 WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
625 typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
626 Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
627 Ecore_Wl2_Window* mEcoreWindow;
629 wl_surface* mWlSurface;
630 #ifdef OVER_TIZEN_VERSION_7
631 zwp_input_panel_v1* mWlInputPanel;
633 wl_input_panel* mWlInputPanel;
635 wl_output* mWlOutput;
636 #ifdef OVER_TIZEN_VERSION_7
637 zwp_input_panel_surface_v1* mWlInputPanelSurface;
639 wl_input_panel_surface* mWlInputPanelSurface;
642 wl_egl_window* mEglWindow;
643 wl_display* mDisplay;
644 wl_event_queue* mEventQueue;
645 tizen_policy* mTizenPolicy;
646 tizen_display_policy* mTizenDisplayPolicy;
649 std::vector<std::string> mSupportedAuxiliaryHints;
651 // It is based on the default system coordinates.
652 Dali::PositionSize mWindowPositionSize;
654 AuxiliaryHints mAuxiliaryHints;
657 int mNotificationLevel;
660 int mWindowRotationAngle;
661 int mScreenRotationAngle;
662 int mSupportedPreProtation;
664 uint32_t mNotificationChangeState;
665 uint32_t mScreenOffModeChangeState;
666 uint32_t mBrightnessChangeState;
667 uint32_t mLastSubmittedMoveResizeSerial;
668 volatile uint32_t mMoveResizeSerial;
670 bool mNotificationLevelChangeDone;
671 bool mScreenOffModeChangeDone;
674 bool mBrightnessChangeDone;
677 } // namespace Adaptor
679 } // namespace Internal
683 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H