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) 2021 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();
172 #ifdef DALI_ELDBUS_AVAILABLE
174 * @brief Called when Ecore ElDBus accessibility event is received.
176 void OnEcoreElDBusAccessibilityNotification(void* context, const Eldbus_Message* message);
180 * @brief Called when a keymap is changed.
182 void KeymapChanged(void* data, int type, void* event);
185 * @brief RegistryGlobalCallback
187 void RegistryGlobalCallback(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version);
190 * @brief RegistryGlobalCallbackRemove
192 void RegistryGlobalCallbackRemove(void* data, struct wl_registry* registry, uint32_t id);
195 * @brief TizenPolicyNotificationChangeDone
197 void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state);
200 * @brief TizenPolicyScreenModeChangeDone
202 void TizenPolicyScreenModeChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state);
205 * @brief DisplayPolicyBrightnessChangeDone
207 void DisplayPolicyBrightnessChangeDone(void* data, struct tizen_display_policy* displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state);
210 * @brief Gets the key code by keyName.
212 void GetKeyCode(std::string keyName, int32_t& keyCode);
216 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
218 Any GetNativeWindow() override;
221 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
223 int GetNativeWindowId() override;
226 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
228 EGLNativeWindowType CreateEglWindow(int width, int height) override;
231 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
233 void DestroyEglWindow() override;
236 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
238 void SetEglWindowRotation(int angle) override;
241 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
243 void SetEglWindowBufferTransform(int angle) override;
246 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
248 void SetEglWindowTransform(int angle) override;
251 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
253 void ResizeEglWindow(PositionSize positionSize) override;
256 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
258 bool IsEglWindowRotationSupported() override;
261 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
263 void Move(PositionSize positionSize) override;
266 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
268 void Resize(PositionSize positionSize) override;
271 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
273 void MoveResize(PositionSize positionSize) override;
276 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
278 void SetClass(const std::string& name, const std::string& className) override;
281 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
283 void Raise() override;
286 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
288 void Lower() override;
291 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
293 void Activate() override;
296 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
298 void SetAvailableAnlges(const std::vector<int>& angles) override;
301 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
303 void SetPreferredAngle(int angle) override;
306 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
308 void SetAcceptFocus(bool accept) override;
311 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
313 void Show() override;
316 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
318 void Hide() override;
321 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
323 unsigned int GetSupportedAuxiliaryHintCount() const override;
326 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
328 std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
331 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
333 unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
336 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
338 bool RemoveAuxiliaryHint(unsigned int id) override;
341 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
343 bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
346 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
348 std::string GetAuxiliaryHintValue(unsigned int id) const override;
351 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
353 unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
356 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
358 void SetInputRegion(const Rect<int>& inputRegion) override;
361 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
363 void SetType(Dali::WindowType type) override;
366 * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
368 Dali::WindowType GetType() const override;
371 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
373 Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
376 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
378 Dali::WindowNotificationLevel GetNotificationLevel() const override;
381 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
383 void SetOpaqueState(bool opaque) override;
386 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
388 Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
391 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
393 WindowScreenOffMode GetScreenOffMode() const override;
396 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
398 Dali::WindowOperationResult SetBrightness(int brightness) override;
401 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
403 int GetBrightness() const override;
406 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
408 bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
411 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
413 bool UngrabKey(Dali::KEY key) override;
416 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
418 bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
421 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
423 bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
426 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
428 void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
431 * @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
433 int GetOrientation() const override;
436 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
438 int GetScreenRotationAngle() override;
441 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
443 void SetWindowRotationAngle(int degree) override;
446 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
448 void WindowRotationCompleted(int degree, int width, int height) override;
451 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
453 void SetTransparency(bool transparent) override;
456 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
458 void SetParent(WindowBase* parentWinBase) override;
461 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
463 int CreateFrameRenderedSyncFence() override;
466 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
468 int CreateFramePresentedSyncFence() override;
471 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
473 void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
476 * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
478 void InitializeIme() override;
481 * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
483 void ImeWindowReadyToRender() override;
486 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
488 void RequestMoveToServer() override;
491 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
493 void RequestResizeToServer(WindowResizeDirection direction) override;
496 * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
498 void EnableFloatingMode(bool enable) override;
501 * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
503 bool IsFloatingModeEnabled() const override;
507 * Second stage initialization
509 void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
512 * Initialize Ecore ElDBus
514 void InitializeEcoreElDBus();
517 * @brief Create window
519 void CreateWindow(PositionSize positionSize);
523 WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
526 WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
529 typedef std::vector<std::pair<std::string, std::string> > AuxiliaryHints;
530 Dali::Vector<Ecore_Event_Handler*> mEcoreEventHandler;
531 Ecore_Wl2_Window* mEcoreWindow;
533 wl_surface* mWlSurface;
534 wl_input_panel* mWlInputPanel;
535 wl_output* mWlOutput;
536 wl_input_panel_surface* mWlInputPanelSurface;
538 wl_egl_window* mEglWindow;
539 wl_display* mDisplay;
540 wl_event_queue* mEventQueue;
541 tizen_policy* mTizenPolicy;
542 tizen_display_policy* mTizenDisplayPolicy;
545 std::vector<std::string> mSupportedAuxiliaryHints;
547 Dali::PositionSize mWindowPositionSize;
548 AuxiliaryHints mAuxiliaryHints;
551 int mNotificationLevel;
554 int mWindowRotationAngle;
555 int mScreenRotationAngle;
556 int mSupportedPreProtation;
558 uint32_t mNotificationChangeState;
559 uint32_t mScreenOffModeChangeState;
560 uint32_t mBrightnessChangeState;
561 uint32_t mLastSubmittedMoveResizeSerial;
562 volatile uint32_t mMoveResizeSerial;
564 bool mNotificationLevelChangeDone;
565 bool mScreenOffModeChangeDone;
568 bool mBrightnessChangeDone;
570 #ifdef DALI_ELDBUS_AVAILABLE
571 Eldbus_Connection* mSystemConnection;
572 #endif // DALI_ELDBUS_AVAILABLE
575 } // namespace Adaptor
577 } // namespace Internal
581 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H