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::CreateEglWindow()
235 EGLNativeWindowType CreateEglWindow(int width, int height) override;
238 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
240 void DestroyEglWindow() override;
243 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
245 void SetEglWindowRotation(int angle) override;
248 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
250 void SetEglWindowBufferTransform(int angle) override;
253 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
255 void SetEglWindowTransform(int angle) override;
258 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
260 void ResizeEglWindow(PositionSize positionSize) override;
263 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
265 bool IsEglWindowRotationSupported() override;
268 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
270 void Move(PositionSize positionSize) override;
273 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
275 void Resize(PositionSize positionSize) override;
278 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
280 void MoveResize(PositionSize positionSize) override;
283 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
285 void SetClass(const std::string& name, const std::string& className) override;
288 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
290 void Raise() override;
293 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
295 void Lower() override;
298 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
300 void Activate() override;
303 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
305 void SetAvailableAnlges(const std::vector<int>& angles) override;
308 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
310 void SetPreferredAngle(int angle) override;
313 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
315 void SetAcceptFocus(bool accept) override;
318 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
320 void Show() override;
323 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
325 void Hide() override;
328 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
330 unsigned int GetSupportedAuxiliaryHintCount() const override;
333 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
335 std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
338 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
340 unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
343 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
345 bool RemoveAuxiliaryHint(unsigned int id) override;
348 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
350 bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
353 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
355 std::string GetAuxiliaryHintValue(unsigned int id) const override;
358 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
360 unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
363 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
365 void SetInputRegion(const Rect<int>& inputRegion) override;
368 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
370 void SetType(Dali::WindowType type) override;
373 * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
375 Dali::WindowType GetType() const override;
378 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
380 Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
383 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
385 Dali::WindowNotificationLevel GetNotificationLevel() const override;
388 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
390 void SetOpaqueState(bool opaque) override;
393 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
395 Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
398 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
400 WindowScreenOffMode GetScreenOffMode() const override;
403 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
405 Dali::WindowOperationResult SetBrightness(int brightness) override;
408 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
410 int GetBrightness() const override;
413 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
415 bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
418 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
420 bool UngrabKey(Dali::KEY key) override;
423 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
425 bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
428 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
430 bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
433 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
435 void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
438 * @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
440 int GetOrientation() const override;
443 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
445 int GetScreenRotationAngle() override;
448 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
450 void SetWindowRotationAngle(int degree) override;
453 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
455 void WindowRotationCompleted(int degree, int width, int height) override;
458 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
460 void SetTransparency(bool transparent) override;
463 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
465 void SetParent(WindowBase* parentWinBase, bool belowParent) override;
468 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
470 int CreateFrameRenderedSyncFence() override;
473 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
475 int CreateFramePresentedSyncFence() override;
478 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
480 void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
483 * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
485 void InitializeIme() override;
488 * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
490 void ImeWindowReadyToRender() override;
493 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
495 void RequestMoveToServer() override;
498 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
500 void RequestResizeToServer(WindowResizeDirection direction) override;
503 * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
505 void EnableFloatingMode(bool enable) override;
508 * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
510 bool IsFloatingModeEnabled() const override;
513 * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
515 void IncludeInputRegion(const Rect<int>& inputRegion) override;
518 * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
520 void ExcludeInputRegion(const Rect<int>& inputRegion) override;
524 * Second stage initialization
526 void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
529 * Initialize Ecore ElDBus
531 void InitializeEcoreElDBus();
534 * @brief Create window
536 void CreateWindow(PositionSize positionSize);
540 WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
543 WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
546 typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
547 Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
548 Ecore_Wl2_Window* mEcoreWindow;
550 wl_surface* mWlSurface;
551 #ifdef OVER_TIZEN_VERSION_7
552 zwp_input_panel_v1* mWlInputPanel;
554 wl_input_panel* mWlInputPanel;
556 wl_output* mWlOutput;
557 #ifdef OVER_TIZEN_VERSION_7
558 zwp_input_panel_surface_v1* mWlInputPanelSurface;
560 wl_input_panel_surface* mWlInputPanelSurface;
563 wl_egl_window* mEglWindow;
564 wl_display* mDisplay;
565 wl_event_queue* mEventQueue;
566 tizen_policy* mTizenPolicy;
567 tizen_display_policy* mTizenDisplayPolicy;
570 std::vector<std::string> mSupportedAuxiliaryHints;
572 Dali::PositionSize mWindowPositionSize;
573 AuxiliaryHints mAuxiliaryHints;
576 int mNotificationLevel;
579 int mWindowRotationAngle;
580 int mScreenRotationAngle;
581 int mSupportedPreProtation;
583 uint32_t mNotificationChangeState;
584 uint32_t mScreenOffModeChangeState;
585 uint32_t mBrightnessChangeState;
586 uint32_t mLastSubmittedMoveResizeSerial;
587 volatile uint32_t mMoveResizeSerial;
589 bool mNotificationLevelChangeDone;
590 bool mScreenOffModeChangeDone;
593 bool mBrightnessChangeDone;
595 #ifdef DALI_ELDBUS_AVAILABLE
596 Eldbus_Connection* mSystemConnection;
597 #endif // DALI_ELDBUS_AVAILABLE
600 } // namespace Adaptor
602 } // namespace Internal
606 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H