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 a conformant is changed.
176 void OnEcoreEventConformantChange(void* event);
179 * @brief Called when window's auxiliary is changed then display server send the changed message.
181 * @param[in] auxiliary's message data. It has key, value and integer list data.
183 void OnEcoreEventWindowAuxiliaryMessage(void* event);
186 * @brief Called when window has been moved by then display server.
187 * To move the window by display server, RequestMoveToServer() should be called.
188 * After the moving job is completed, this function will be called.
190 * @param[in] the completed event's data. It has the latest window geometry data.
192 void OnMoveCompleted(void* event);
195 * @brief Called when window has been resized by then display server.
196 * To resize the window by display server, RequestResizeToServer() should be called.
197 * After the resizing job is completed, this function will be called.
199 * @param[in] the completed event's data. It has the latest window geometry data.
201 void OnResizeCompleted(void* event);
204 * @brief Called when a keymap is changed.
206 void KeymapChanged(void* data, int type, void* event);
209 * @brief RegistryGlobalCallback
211 void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
214 * @brief RegistryGlobalCallbackRemove
216 void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id);
219 * @brief TizenPolicyConformantArea
221 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);
224 * @brief TizenPolicyNotificationChangeDone
226 void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state);
229 * @brief TizenPolicyScreenModeChangeDone
231 void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state);
234 * @brief DisplayPolicyBrightnessChangeDone
236 void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state);
239 * @brief Gets the key code by keyName.
241 void GetKeyCode(std::string keyName, int32_t& keyCode);
245 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
247 Any GetNativeWindow() override;
250 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
252 int GetNativeWindowId() override;
255 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowResourceId()
257 std::string GetNativeWindowResourceId() override;
260 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
262 EGLNativeWindowType CreateEglWindow(int width, int height) override;
265 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
267 void DestroyEglWindow() override;
270 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
272 void SetEglWindowRotation(int angle) override;
275 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
277 void SetEglWindowBufferTransform(int angle) override;
280 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
282 void SetEglWindowTransform(int angle) override;
285 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
287 void ResizeEglWindow(PositionSize positionSize) override;
290 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
292 bool IsEglWindowRotationSupported() override;
295 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
297 void Move(PositionSize positionSize) override;
300 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
302 void Resize(PositionSize positionSize) override;
305 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
307 void MoveResize(PositionSize positionSize) override;
310 * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout()
312 void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override;
315 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
317 void SetClass(const std::string& name, const std::string& className) override;
320 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
322 void Raise() override;
325 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
327 void Lower() override;
330 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
332 void Activate() override;
335 * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
337 void Maximize(bool maximize) override;
340 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
342 bool IsMaximized() const override;
345 * @copydoc Dali::Internal::Adaptor::WindowBase::SetMaximumSize()
347 void SetMaximumSize(Dali::Window::WindowSize size) override;
350 * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
352 void Minimize(bool minimize) override;
355 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
357 bool IsMinimized() const override;
360 * @copydoc Dali::Internal::Adaptor::WindowBase::SetMimimumSize()
362 void SetMimimumSize(Dali::Window::WindowSize size) override;
365 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
367 void SetAvailableAnlges(const std::vector<int>& angles) override;
370 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
372 void SetPreferredAngle(int angle) override;
375 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
377 void SetAcceptFocus(bool accept) override;
380 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
382 void Show() override;
385 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
387 void Hide() override;
390 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
392 unsigned int GetSupportedAuxiliaryHintCount() const override;
395 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
397 std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
400 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
402 unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
405 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
407 bool RemoveAuxiliaryHint(unsigned int id) override;
410 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
412 bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
415 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
417 std::string GetAuxiliaryHintValue(unsigned int id) const override;
420 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
422 unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
425 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
427 void SetInputRegion(const Rect<int>& inputRegion) override;
430 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
432 void SetType(Dali::WindowType type) override;
435 * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
437 Dali::WindowType GetType() const override;
440 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
442 Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
445 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
447 Dali::WindowNotificationLevel GetNotificationLevel() const override;
450 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
452 void SetOpaqueState(bool opaque) override;
455 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
457 Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
460 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
462 WindowScreenOffMode GetScreenOffMode() const override;
465 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
467 Dali::WindowOperationResult SetBrightness(int brightness) override;
470 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
472 int GetBrightness() const override;
475 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
477 bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
480 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
482 bool UngrabKey(Dali::KEY key) override;
485 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
487 bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
490 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
492 bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
495 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
497 void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
500 * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
502 int GetWindowRotationAngle() const override;
505 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
507 int GetScreenRotationAngle() override;
510 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
512 void SetWindowRotationAngle(int degree) override;
515 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
517 void WindowRotationCompleted(int degree, int width, int height) override;
520 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
522 void SetTransparency(bool transparent) override;
525 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
527 void SetParent(WindowBase* parentWinBase, bool belowParent) override;
530 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
532 int CreateFrameRenderedSyncFence() override;
535 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
537 int CreateFramePresentedSyncFence() override;
540 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
542 void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
545 * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
547 void InitializeIme() override;
550 * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
552 void ImeWindowReadyToRender() override;
555 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
557 void RequestMoveToServer() override;
560 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
562 void RequestResizeToServer(WindowResizeDirection direction) override;
565 * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
567 void EnableFloatingMode(bool enable) override;
570 * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
572 bool IsFloatingModeEnabled() const override;
575 * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
577 void IncludeInputRegion(const Rect<int>& inputRegion) override;
580 * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
582 void ExcludeInputRegion(const Rect<int>& inputRegion) override;
586 * Second stage initialization
588 void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
591 * @brief Create window
593 void CreateWindow(PositionSize positionSize);
596 * @brief Return the window's position and size to recalulate with the default system coordinates.
597 * It is used when window is moved or resized for native ecore wayland window system.
599 * @param[in] positionSize the window's current position and size with current oriented window's coordinates.
600 * @return the re-calculated window's position and size on the default system coordinates.
602 PositionSize RecalculatePositionSizeToSystem(PositionSize positionSize);
605 * @brief Return the window's position and size to recalulate with current oriented window's coordinates.
606 * It is used when window is moved or resized for dali and uppler layer framework.
608 * @param[in] positionSize the window's current position and size with the default system coordinates.
609 * @return the re-calculated window's position and size on current oriented window's coordinates.
611 PositionSize RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize);
614 * @brief Return the rect value to recalulate with the default system coordinates.
616 * Some native window APIs work the geometry value based on the default system coordinates.
617 * IncludeInputRegion() and ExcludeInputRegion() are one of them.
618 * When the window is rotated, current window's geometry already were set with the rotated angle.
619 * If IncludeInputRegion() or ExcludeInputRegion() are called with rotated angle by application,
620 * the rect's area should be re-calcuated on the default system coordinates.
622 * @param[in] rect the window's current position and size with current window rotation angle.
623 * @return the re-calculated rect on the default system coordinates.
625 Rect<int> RecalculateInputRect(const Rect<int>& rect);
629 WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
632 WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
635 typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
636 Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
637 Ecore_Wl2_Window* mEcoreWindow;
639 wl_surface* mWlSurface;
640 #ifdef OVER_TIZEN_VERSION_7
641 zwp_input_panel_v1* mWlInputPanel;
643 wl_input_panel* mWlInputPanel;
645 wl_output* mWlOutput;
646 #ifdef OVER_TIZEN_VERSION_7
647 zwp_input_panel_surface_v1* mWlInputPanelSurface;
649 wl_input_panel_surface* mWlInputPanelSurface;
652 wl_egl_window* mEglWindow;
653 wl_display* mDisplay;
654 wl_event_queue* mEventQueue;
655 tizen_policy* mTizenPolicy;
656 tizen_display_policy* mTizenDisplayPolicy;
659 std::vector<std::string> mSupportedAuxiliaryHints;
661 // It is based on the default system coordinates.
662 Dali::PositionSize mWindowPositionSize;
664 AuxiliaryHints mAuxiliaryHints;
667 int mNotificationLevel;
670 int mWindowRotationAngle;
671 int mScreenRotationAngle;
672 int mSupportedPreProtation;
674 uint32_t mNotificationChangeState;
675 uint32_t mScreenOffModeChangeState;
676 uint32_t mBrightnessChangeState;
677 uint32_t mLastSubmittedMoveResizeSerial;
678 volatile uint32_t mMoveResizeSerial;
680 bool mNotificationLevelChangeDone;
681 bool mScreenOffModeChangeDone;
684 bool mBrightnessChangeDone;
687 } // namespace Adaptor
689 } // namespace Internal
693 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H