1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL_H
5 * Copyright (c) 2018 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_Wayland.h>
27 #include <tizen-extension-client-protocol.h>
28 #include <wayland-egl.h>
30 #ifdef DALI_ELDBUS_AVAILABLE
41 class WindowRenderSurface;
42 class WindowRenderSurfaceEcoreWl;
45 * WindowBaseEcoreWl class provides an WindowBase Ecore-Wayland implementation.
47 class WindowBaseEcoreWl : public WindowBase
54 WindowBaseEcoreWl( PositionSize positionSize, Any surface, bool isTransparent );
59 virtual ~WindowBaseEcoreWl();
64 * @brief Called when the window iconify state is changed.
66 Eina_Bool OnIconifyStateChanged( void* data, int type, void* event );
69 * @brief Called when the window gains focus.
71 Eina_Bool OnFocusIn( void* data, int type, void* event );
74 * @brief Called when the window loses focus.
76 Eina_Bool OnFocusOut( void* data, int type, void* event );
79 * @brief Called when the output is transformed.
81 Eina_Bool OnOutputTransform( void* data, int type, void* event );
84 * @brief Called when the output transform should be ignored.
86 Eina_Bool OnIgnoreOutputTransform( void* data, int type, void* event );
89 * @brief Called when a rotation event is recevied.
91 void OnRotation( 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 detent rotation event is recevied.
121 void OnDetentRotation( void* data, int type, void* event );
124 * @brief Called when a key down is received.
126 void OnKeyDown( void* data, int type, void* event );
129 * @brief Called when a key up is received.
131 void OnKeyUp( void* data, int type, void* event );
134 * @brief Called when the source window notifies us the content in clipboard is selected.
136 void OnDataSend( void* data, int type, void* event );
139 * @brief Called when the source window sends us about the selected content.
141 void OnDataReceive( void* data, int type, void* event );
144 * @brief Called when a font name is changed.
146 void OnFontNameChanged();
149 * @brief Called when a font size is changed.
151 void OnFontSizeChanged();
153 #ifdef DALI_ELDBUS_AVAILABLE
155 * @brief Called when Ecore ElDBus accessibility event is received.
157 void OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message );
161 * @brief RegistryGlobalCallback
163 void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version );
166 * @brief RegistryGlobalCallbackRemove
168 void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id );
171 * @brief TizenPolicyNotificationChangeDone
173 void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state );
176 * @brief TizenPolicyScreenModeChangeDone
178 void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state );
181 * @brief DisplayPolicyBrightnessChangeDone
183 void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state );
188 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
190 virtual Any GetNativeWindow() override;
193 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
195 virtual int GetNativeWindowId() override;
198 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
200 virtual EGLNativeWindowType CreateEglWindow( int width, int height ) override;
203 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
205 virtual void DestroyEglWindow() override;
208 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
210 virtual void SetEglWindowRotation( int angle ) override;
213 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
215 virtual void SetEglWindowBufferTransform( int angle ) override;
218 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
220 virtual void SetEglWindowTransform( int angle ) override;
223 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
225 virtual void ResizeEglWindow( PositionSize positionSize ) override;
228 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
230 virtual bool IsEglWindowRotationSupported() override;
233 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
235 virtual void Move( PositionSize positionSize ) override;
238 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
240 virtual void Resize( PositionSize positionSize ) override;
243 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
245 virtual void MoveResize( PositionSize positionSize ) override;
248 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
250 virtual void SetClass( const std::string& name, const std::string& className ) override;
253 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
255 virtual void Raise() override;
258 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
260 virtual void Lower() override;
263 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
265 virtual void Activate() override;
268 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableOrientations()
270 virtual void SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations ) override;
273 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredOrientation()
275 virtual void SetPreferredOrientation( Dali::Window::WindowOrientation orientation ) override;
278 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
280 virtual void SetAcceptFocus( bool accept ) override;
283 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
285 virtual void Show() override;
288 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
290 virtual void Hide() override;
293 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
295 virtual unsigned int GetSupportedAuxiliaryHintCount() const override;
298 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
300 virtual std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
303 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
305 virtual unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
308 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
310 virtual bool RemoveAuxiliaryHint( unsigned int id ) override;
313 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
315 virtual bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
318 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
320 virtual std::string GetAuxiliaryHintValue( unsigned int id ) const override;
323 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
325 virtual unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
328 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
330 virtual void SetInputRegion( const Rect< int >& inputRegion ) override;
333 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
335 virtual void SetType( Dali::Window::Type type ) override;
338 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
340 virtual bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override;
343 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
345 virtual Dali::Window::NotificationLevel::Type GetNotificationLevel() const override;
348 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
350 virtual void SetOpaqueState( bool opaque ) override;
353 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
355 virtual bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override;
358 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
360 virtual Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override;
363 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
365 virtual bool SetBrightness( int brightness ) override;
368 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
370 virtual int GetBrightness() const override;
373 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
375 virtual bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
378 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
380 virtual bool UngrabKey( Dali::KEY key ) override;
383 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
385 virtual bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
388 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
390 virtual bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
393 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
395 virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
398 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
400 virtual int GetScreenRotationAngle() override;
403 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
405 virtual void SetWindowRotationAngle( int degree ) override;
408 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
410 virtual void WindowRotationCompleted( int degree, int width, int height ) override;
413 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
415 virtual void SetTransparency( bool transparent ) override;
418 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
420 virtual void SetParent( Any parent ) override;
423 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMatchedWindow()
425 virtual bool IsMatchedWindow( Any window ) override;
430 * Second stage initialization
432 void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
435 * Initialize Ecore ElDBus
437 void InitializeEcoreElDBus();
440 * @brief Create window
442 void CreateWindow( PositionSize positionSize );
447 WindowBaseEcoreWl(const WindowBaseEcoreWl&) = delete;
450 WindowBaseEcoreWl& operator=(const WindowBaseEcoreWl& rhs) = delete;
454 typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
456 Dali::Vector< Ecore_Event_Handler* > mEcoreEventHandler;
458 Ecore_Wl_Window* mEcoreWindow;
459 wl_surface* mWlSurface;
460 wl_egl_window* mEglWindow;
461 wl_display* mDisplay;
462 wl_event_queue* mEventQueue;
463 tizen_policy* mTizenPolicy;
464 tizen_display_policy* mTizenDisplayPolicy;
466 std::vector< std::string > mSupportedAuxiliaryHints;
467 AuxiliaryHints mAuxiliaryHints;
469 int mNotificationLevel;
470 uint32_t mNotificationChangeState;
471 bool mNotificationLevelChangeDone;
474 uint32_t mScreenOffModeChangeState;
475 bool mScreenOffModeChangeDone;
478 uint32_t mBrightnessChangeState;
479 bool mBrightnessChangeDone;
483 #ifdef DALI_ELDBUS_AVAILABLE
484 Eldbus_Connection* mSystemConnection;
485 #endif // DALI_ELDBUS_AVAILABLE
489 } // namespace Adaptor
491 } // namespace internal
495 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL_H