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>
32 #ifdef DALI_ELDBUS_AVAILABLE
42 class WindowRenderSurface;
43 class WindowRenderSurfaceEcoreWl2;
46 * WindowBaseEcoreWl2 class provides an WindowBase Ecore-Wayland2 implementation.
48 class WindowBaseEcoreWl2 : public WindowBase
54 WindowBaseEcoreWl2(PositionSize positionSize, Any surface, bool isTransparent);
59 virtual ~WindowBaseEcoreWl2();
63 * @brief Called when the window iconify state is changed.
65 Eina_Bool OnIconifyStateChanged(void* data, int type, void* event);
68 * @brief Called when the window gains focus.
70 Eina_Bool OnFocusIn(void* data, int type, void* event);
73 * @brief Called when the window loses focus.
75 Eina_Bool OnFocusOut(void* data, int type, void* event);
78 * @brief Called when the output is transformed.
80 Eina_Bool OnOutputTransform(void* data, int type, void* event);
83 * @brief Called when the output transform should be ignored.
85 Eina_Bool OnIgnoreOutputTransform(void* data, int type, void* event);
88 * @brief Called when a rotation event is recevied.
90 void OnRotation(void* data, int type, void* event);
93 * @brief Called when a configure event is recevied.
95 void OnConfiguration(void* data, int type, void* event);
98 * @brief Called when a touch down is received.
100 void OnMouseButtonDown(void* data, int type, void* event);
103 * @brief Called when a touch up is received.
105 void OnMouseButtonUp(void* data, int type, void* event);
108 * @brief Called when a touch motion is received.
110 void OnMouseButtonMove(void* data, int type, void* event);
113 * @brief Called when a touch is canceled.
115 void OnMouseButtonCancel(void* data, int type, void* event);
118 * @brief Called when a mouse wheel is received.
120 void OnMouseWheel(void* data, int type, void* event);
123 * @brief Called when a detent rotation event is recevied.
125 void OnDetentRotation(void* data, int type, void* event);
128 * @brief Called when a key down is received.
130 void OnKeyDown(void* data, int type, void* event);
133 * @brief Called when a key up is received.
135 void OnKeyUp(void* data, int type, void* event);
138 * @brief Called when the source window notifies us the content in clipboard is selected.
140 void OnDataSend(void* data, int type, void* event);
143 * @brief Called when the source window sends us about the selected content.
145 void OnDataReceive(void* data, int type, void* event);
148 * @brief Called when a font name is changed.
150 void OnFontNameChanged();
153 * @brief Called when a font size is changed.
155 void OnFontSizeChanged();
158 * @brief Called when a transition effect-start/end event is received.
160 void OnTransitionEffectEvent(WindowEffectState state, WindowEffectType type);
163 * @brief Called when a keyboard repeat event is changed.
165 void OnKeyboardRepeatSettingsChanged();
168 * @brief Called when a window redraw is requested.
170 void OnEcoreEventWindowRedrawRequest();
173 * @brief Called when window's auxiliary is changed then display server send the changed message.
175 * @param[in] auxiliary's message data. It has key, value and integer list data.
177 void OnEcoreEventWindowAuxiliaryMessage(void* event);
179 #ifdef DALI_ELDBUS_AVAILABLE
181 * @brief Called when Ecore ElDBus accessibility event is received.
183 void OnEcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message);
187 * @brief Called when a keymap is changed.
189 void KeymapChanged(void* data, int type, void* event);
192 * @brief RegistryGlobalCallback
194 void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
197 * @brief RegistryGlobalCallbackRemove
199 void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id);
202 * @brief TizenPolicyNotificationChangeDone
204 void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state);
207 * @brief TizenPolicyScreenModeChangeDone
209 void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state);
212 * @brief DisplayPolicyBrightnessChangeDone
214 void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state);
217 * @brief Gets the key code by keyName.
219 void GetKeyCode(std::string keyName, int32_t& keyCode);
223 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
225 Any GetNativeWindow() override;
228 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
230 int GetNativeWindowId() override;
233 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowResourceId()
235 std::string GetNativeWindowResourceId() override;
238 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
240 EGLNativeWindowType CreateEglWindow(int width, int height) override;
243 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
245 void DestroyEglWindow() override;
248 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
250 void SetEglWindowRotation(int angle) override;
253 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
255 void SetEglWindowBufferTransform(int angle) override;
258 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
260 void SetEglWindowTransform(int angle) override;
263 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
265 void ResizeEglWindow(PositionSize positionSize) override;
268 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
270 bool IsEglWindowRotationSupported() override;
273 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
275 void Move(PositionSize positionSize) override;
278 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
280 void Resize(PositionSize positionSize) override;
283 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
285 void MoveResize(PositionSize positionSize) override;
288 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
290 void SetClass(const std::string& name, const std::string& className) override;
293 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
295 void Raise() override;
298 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
300 void Lower() override;
303 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
305 void Activate() override;
308 * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
310 void Maximize(bool maximize) override;
313 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
315 bool IsMaximized() const override;
318 * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
320 void Minimize(bool minimize) override;
323 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
325 bool IsMinimized() const override;
328 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
330 void SetAvailableAnlges(const std::vector<int>& angles) override;
333 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
335 void SetPreferredAngle(int angle) override;
338 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
340 void SetAcceptFocus(bool accept) override;
343 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
345 void Show() override;
348 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
350 void Hide() override;
353 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
355 unsigned int GetSupportedAuxiliaryHintCount() const override;
358 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
360 std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
363 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
365 unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
368 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
370 bool RemoveAuxiliaryHint(unsigned int id) override;
373 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
375 bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
378 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
380 std::string GetAuxiliaryHintValue(unsigned int id) const override;
383 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
385 unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
388 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
390 void SetInputRegion(const Rect<int>& inputRegion) override;
393 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
395 void SetType(Dali::WindowType type) override;
398 * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
400 Dali::WindowType GetType() const override;
403 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
405 Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
408 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
410 Dali::WindowNotificationLevel GetNotificationLevel() const override;
413 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
415 void SetOpaqueState(bool opaque) override;
418 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
420 Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
423 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
425 WindowScreenOffMode GetScreenOffMode() const override;
428 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
430 Dali::WindowOperationResult SetBrightness(int brightness) override;
433 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
435 int GetBrightness() const override;
438 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
440 bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
443 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
445 bool UngrabKey(Dali::KEY key) override;
448 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
450 bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
453 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
455 bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
458 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
460 void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
463 * @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
465 int GetOrientation() const override;
468 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
470 int GetScreenRotationAngle() override;
473 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
475 void SetWindowRotationAngle(int degree) override;
478 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
480 void WindowRotationCompleted(int degree, int width, int height) override;
483 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
485 void SetTransparency(bool transparent) override;
488 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
490 void SetParent(WindowBase* parentWinBase, bool belowParent) override;
493 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
495 int CreateFrameRenderedSyncFence() override;
498 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
500 int CreateFramePresentedSyncFence() override;
503 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
505 void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
508 * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
510 void InitializeIme() override;
513 * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
515 void ImeWindowReadyToRender() override;
518 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
520 void RequestMoveToServer() override;
523 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
525 void RequestResizeToServer(WindowResizeDirection direction) override;
528 * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
530 void EnableFloatingMode(bool enable) override;
533 * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
535 bool IsFloatingModeEnabled() const override;
538 * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
540 void IncludeInputRegion(const Rect<int>& inputRegion) override;
543 * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
545 void ExcludeInputRegion(const Rect<int>& inputRegion) override;
549 * Second stage initialization
551 void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
554 * Initialize Ecore ElDBus
556 void InitializeEcoreElDBus();
559 * @brief Create window
561 void CreateWindow(PositionSize positionSize);
564 * @brief Return the window's position and size to recalulate with the default system coordinates.
565 * It is used when window is moved or resized for native ecore wayland window system.
567 * @param[in] positionSize the window's current position and size with current oriented window's coordinates.
568 * @return the re-calculated window's position and size on the default system coordinates.
570 PositionSize RecalculatePositionSizeToSystem(PositionSize positionSize);
573 * @brief Return the window's position and size to recalulate with current oriented window's coordinates.
574 * It is used when window is moved or resized for dali and uppler layer framework.
576 * @param[in] positionSize the window's current position and size with the default system coordinates.
577 * @return the re-calculated window's position and size on current oriented window's coordinates.
579 PositionSize RecalculatePositionSizeToCurrentOrientation(PositionSize positionSize);
583 WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
586 WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
589 typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
590 Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
591 Ecore_Wl2_Window* mEcoreWindow;
593 wl_surface* mWlSurface;
594 #ifdef OVER_TIZEN_VERSION_7
595 zwp_input_panel_v1* mWlInputPanel;
597 wl_input_panel* mWlInputPanel;
599 wl_output* mWlOutput;
600 #ifdef OVER_TIZEN_VERSION_7
601 zwp_input_panel_surface_v1* mWlInputPanelSurface;
603 wl_input_panel_surface* mWlInputPanelSurface;
606 wl_egl_window* mEglWindow;
607 wl_display* mDisplay;
608 wl_event_queue* mEventQueue;
609 tizen_policy* mTizenPolicy;
610 tizen_display_policy* mTizenDisplayPolicy;
613 std::vector<std::string> mSupportedAuxiliaryHints;
615 // It is based on the default system coordinates.
616 Dali::PositionSize mWindowPositionSize;
618 AuxiliaryHints mAuxiliaryHints;
621 int mNotificationLevel;
624 int mWindowRotationAngle;
625 int mScreenRotationAngle;
626 int mSupportedPreProtation;
630 uint32_t mNotificationChangeState;
631 uint32_t mScreenOffModeChangeState;
632 uint32_t mBrightnessChangeState;
633 uint32_t mLastSubmittedMoveResizeSerial;
634 volatile uint32_t mMoveResizeSerial;
636 bool mNotificationLevelChangeDone;
637 bool mScreenOffModeChangeDone;
640 bool mBrightnessChangeDone;
642 #ifdef DALI_ELDBUS_AVAILABLE
643 Eldbus_Connection* mSystemConnection;
644 #endif // DALI_ELDBUS_AVAILABLE
647 } // namespace Adaptor
649 } // namespace Internal
653 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H