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) 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_Wl2.h>
27 #include <tizen-extension-client-protocol.h>
28 #include <wayland-egl.h>
30 #ifdef DALI_ELDBUS_AVAILABLE
41 class WindowRenderSurface;
42 class WindowRenderSurfaceEcoreWl2;
45 * WindowBaseEcoreWl2 class provides an WindowBase Ecore-Wayland2 implementation.
47 class WindowBaseEcoreWl2 : public WindowBase
54 WindowBaseEcoreWl2( PositionSize positionSize, Any surface, bool isTransparent );
59 virtual ~WindowBaseEcoreWl2();
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 configure event is recevied.
96 void OnConfiguration( void* data, int type, void* event );
99 * @brief Called when a touch down is received.
101 void OnMouseButtonDown( void* data, int type, void* event );
104 * @brief Called when a touch up is received.
106 void OnMouseButtonUp( void* data, int type, void* event );
109 * @brief Called when a touch motion is received.
111 void OnMouseButtonMove( void* data, int type, void* event );
114 * @brief Called when a touch is canceled.
116 void OnMouseButtonCancel( void* data, int type, void* event );
119 * @brief Called when a mouse wheel is received.
121 void OnMouseWheel( void* data, int type, void* event );
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();
158 #ifdef DALI_ELDBUS_AVAILABLE
160 * @brief Called when Ecore ElDBus accessibility event is received.
162 void OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message );
166 * @brief RegistryGlobalCallback
168 void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version );
171 * @brief RegistryGlobalCallbackRemove
173 void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id );
176 * @brief TizenPolicyNotificationChangeDone
178 void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state );
181 * @brief TizenPolicyScreenModeChangeDone
183 void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state );
186 * @brief DisplayPolicyBrightnessChangeDone
188 void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state );
193 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
195 virtual Any GetNativeWindow() override;
198 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
200 virtual int GetNativeWindowId() override;
203 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
205 virtual EGLNativeWindowType CreateEglWindow( int width, int height ) override;
208 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
210 virtual void DestroyEglWindow() override;
213 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
215 virtual void SetEglWindowRotation( int angle ) override;
218 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
220 virtual void SetEglWindowBufferTransform( int angle ) override;
223 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
225 virtual void SetEglWindowTransform( int angle ) override;
228 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
230 virtual void ResizeEglWindow( PositionSize positionSize ) override;
233 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
235 virtual bool IsEglWindowRotationSupported() override;
238 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
240 virtual void Move( PositionSize positionSize ) override;
243 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
245 virtual void Resize( PositionSize positionSize ) override;
248 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
250 virtual void MoveResize( PositionSize positionSize ) override;
253 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
255 virtual void SetClass( const std::string& name, const std::string& className ) override;
258 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
260 virtual void Raise() override;
263 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
265 virtual void Lower() override;
268 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
270 virtual void Activate() override;
273 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableOrientations()
275 virtual void SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations ) override;
278 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredOrientation()
280 virtual void SetPreferredOrientation( Dali::Window::WindowOrientation orientation ) override;
283 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
285 virtual void SetAcceptFocus( bool accept ) override;
288 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
290 virtual void Show() override;
293 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
295 virtual void Hide() override;
298 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
300 virtual unsigned int GetSupportedAuxiliaryHintCount() const override;
303 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
305 virtual std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
308 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
310 virtual unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
313 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
315 virtual bool RemoveAuxiliaryHint( unsigned int id ) override;
318 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
320 virtual bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
323 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
325 virtual std::string GetAuxiliaryHintValue( unsigned int id ) const override;
328 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
330 virtual unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
333 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
335 virtual void SetInputRegion( const Rect< int >& inputRegion ) override;
338 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
340 virtual void SetType( Dali::Window::Type type ) override;
343 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
345 virtual bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override;
348 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
350 virtual Dali::Window::NotificationLevel::Type GetNotificationLevel() const override;
353 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
355 virtual void SetOpaqueState( bool opaque ) override;
358 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
360 virtual bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override;
363 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
365 virtual Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override;
368 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
370 virtual bool SetBrightness( int brightness ) override;
373 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
375 virtual int GetBrightness() const override;
378 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
380 virtual bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
383 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
385 virtual bool UngrabKey( Dali::KEY key ) override;
388 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
390 virtual bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
393 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
395 virtual bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
398 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
400 virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
403 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
405 virtual int GetScreenRotationAngle() override;
408 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
410 virtual void SetWindowRotationAngle( int degree ) override;
413 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
415 virtual void WindowRotationCompleted( int degree, int width, int height ) override;
418 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
420 virtual void SetTransparency( bool transparent ) override;
423 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
425 virtual void SetParent( Any parent ) override;
428 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMatchedWindow()
430 virtual bool IsMatchedWindow( Any window ) override;
435 * Second stage initialization
437 void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
440 * Initialize Ecore ElDBus
442 void InitializeEcoreElDBus();
445 * @brief Create window
447 void CreateWindow( PositionSize positionSize );
452 WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
455 WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
459 typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
461 Dali::Vector< Ecore_Event_Handler* > mEcoreEventHandler;
463 Ecore_Wl2_Window* mEcoreWindow;
464 wl_surface* mWlSurface;
465 wl_egl_window* mEglWindow;
466 wl_display* mDisplay;
467 wl_event_queue* mEventQueue;
468 tizen_policy* mTizenPolicy;
469 tizen_display_policy* mTizenDisplayPolicy;
471 std::vector< std::string > mSupportedAuxiliaryHints;
472 AuxiliaryHints mAuxiliaryHints;
474 int mNotificationLevel;
475 uint32_t mNotificationChangeState;
476 bool mNotificationLevelChangeDone;
479 uint32_t mScreenOffModeChangeState;
480 bool mScreenOffModeChangeDone;
483 uint32_t mBrightnessChangeState;
484 bool mBrightnessChangeDone;
488 volatile uint32_t mMoveResizeSerial;
489 uint32_t mLastSubmittedMoveResizeSerial;
491 #ifdef DALI_ELDBUS_AVAILABLE
492 Eldbus_Connection* mSystemConnection;
493 #endif // DALI_ELDBUS_AVAILABLE
496 } // namespace Adaptor
498 } // namespace internal
502 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H