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>
29 #include <xkbcommon/xkbcommon.h>
31 #ifdef DALI_ELDBUS_AVAILABLE
42 class WindowRenderSurface;
43 class WindowRenderSurfaceEcoreWl2;
46 * WindowBaseEcoreWl2 class provides an WindowBase Ecore-Wayland2 implementation.
48 class WindowBaseEcoreWl2 : public WindowBase
55 WindowBaseEcoreWl2( PositionSize positionSize, Any surface, bool isTransparent );
60 virtual ~WindowBaseEcoreWl2();
65 * @brief Called when the window iconify state is changed.
67 Eina_Bool OnIconifyStateChanged( void* data, int type, void* event );
70 * @brief Called when the window gains focus.
72 Eina_Bool OnFocusIn( void* data, int type, void* event );
75 * @brief Called when the window loses focus.
77 Eina_Bool OnFocusOut( void* data, int type, void* event );
80 * @brief Called when the output is transformed.
82 Eina_Bool OnOutputTransform( void* data, int type, void* event );
85 * @brief Called when the output transform should be ignored.
87 Eina_Bool OnIgnoreOutputTransform( void* data, int type, void* event );
90 * @brief Called when a rotation event is recevied.
92 void OnRotation( void* data, int type, void* event );
95 * @brief Called when a configure event is recevied.
97 void OnConfiguration( void* data, int type, void* event );
100 * @brief Called when a touch down is received.
102 void OnMouseButtonDown( void* data, int type, void* event );
105 * @brief Called when a touch up is received.
107 void OnMouseButtonUp( void* data, int type, void* event );
110 * @brief Called when a touch motion is received.
112 void OnMouseButtonMove( void* data, int type, void* event );
115 * @brief Called when a touch is canceled.
117 void OnMouseButtonCancel( void* data, int type, void* event );
120 * @brief Called when a mouse wheel is received.
122 void OnMouseWheel( void* data, int type, void* event );
125 * @brief Called when a detent rotation event is recevied.
127 void OnDetentRotation( void* data, int type, void* event );
130 * @brief Called when a key down is received.
132 void OnKeyDown( void* data, int type, void* event );
135 * @brief Called when a key up is received.
137 void OnKeyUp( void* data, int type, void* event );
140 * @brief Called when the source window notifies us the content in clipboard is selected.
142 void OnDataSend( void* data, int type, void* event );
145 * @brief Called when the source window sends us about the selected content.
147 void OnDataReceive( void* data, int type, void* event );
150 * @brief Called when a font name is changed.
152 void OnFontNameChanged();
155 * @brief Called when a font size is changed.
157 void OnFontSizeChanged();
160 * @brief Called when a transition effect-start/end event is received.
162 void OnTransitionEffectEvent( DevelWindow::EffectState state, DevelWindow::EffectType type );
165 * @brief Called when a keyboard repeat event is changed.
167 void OnKeyboardRepeatSettingsChanged();
170 * @brief Called when a window redraw is requested.
172 void OnEcoreEventWindowRedrawRequest();
174 #ifdef DALI_ELDBUS_AVAILABLE
176 * @brief Called when Ecore ElDBus accessibility event is received.
178 void OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message );
182 * @brief Called when a keymap is changed.
184 void KeymapChanged(void *data, int type, void *event);
187 * @brief RegistryGlobalCallback
189 void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version );
192 * @brief RegistryGlobalCallbackRemove
194 void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id );
197 * @brief TizenPolicyNotificationChangeDone
199 void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state );
202 * @brief TizenPolicyScreenModeChangeDone
204 void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state );
207 * @brief DisplayPolicyBrightnessChangeDone
209 void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state );
213 * @brief Gets the key code by keyName.
215 void GetKeyCode( std::string keyName, int32_t& keyCode );
220 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
222 Any GetNativeWindow() override;
225 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
227 int GetNativeWindowId() override;
230 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
232 EGLNativeWindowType CreateEglWindow( int width, int height ) override;
235 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
237 void DestroyEglWindow() override;
240 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
242 void SetEglWindowRotation( int angle ) override;
245 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
247 void SetEglWindowBufferTransform( int angle ) override;
250 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
252 void SetEglWindowTransform( int angle ) override;
255 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
257 void ResizeEglWindow( PositionSize positionSize ) override;
260 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
262 bool IsEglWindowRotationSupported() override;
265 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
267 void Move( PositionSize positionSize ) override;
270 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
272 void Resize( PositionSize positionSize ) override;
275 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
277 void MoveResize( PositionSize positionSize ) override;
280 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
282 void SetClass( const std::string& name, const std::string& className ) override;
285 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
287 void Raise() override;
290 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
292 void Lower() override;
295 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
297 void Activate() override;
300 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
302 void SetAvailableAnlges( const std::vector< int >& angles ) override;
305 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
307 void SetPreferredAngle( int angle ) override;
310 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
312 void SetAcceptFocus( bool accept ) override;
315 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
317 void Show() override;
320 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
322 void Hide() override;
325 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
327 unsigned int GetSupportedAuxiliaryHintCount() const override;
330 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
332 std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
335 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
337 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
340 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
342 bool RemoveAuxiliaryHint( unsigned int id ) override;
345 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
347 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
350 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
352 std::string GetAuxiliaryHintValue( unsigned int id ) const override;
355 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
357 unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
360 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
362 void SetInputRegion( const Rect< int >& inputRegion ) override;
365 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
367 void SetType( Dali::Window::Type type ) override;
370 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
372 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override;
375 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
377 Dali::Window::NotificationLevel::Type GetNotificationLevel() const override;
380 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
382 void SetOpaqueState( bool opaque ) override;
385 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
387 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override;
390 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
392 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override;
395 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
397 bool SetBrightness( int brightness ) override;
400 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
402 int GetBrightness() const override;
405 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
407 bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
410 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
412 bool UngrabKey( Dali::KEY key ) override;
415 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
417 bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
420 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
422 bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
425 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
427 void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
430 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
432 int GetScreenRotationAngle() override;
435 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
437 void SetWindowRotationAngle( int degree ) override;
440 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
442 void WindowRotationCompleted( int degree, int width, int height ) override;
445 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
447 void SetTransparency( bool transparent ) override;
450 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
452 void SetParent( WindowBase* parentWinBase ) override;
455 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
457 int CreateFrameRenderedSyncFence() override;
460 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
462 int CreateFramePresentedSyncFence() override;
467 * Second stage initialization
469 void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
472 * Initialize Ecore ElDBus
474 void InitializeEcoreElDBus();
477 * @brief Create window
479 void CreateWindow( PositionSize positionSize );
484 WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
487 WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
491 typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
493 Dali::Vector< Ecore_Event_Handler* > mEcoreEventHandler;
495 Ecore_Wl2_Window* mEcoreWindow;
496 wl_surface* mWlSurface;
497 wl_egl_window* mEglWindow;
498 wl_display* mDisplay;
499 wl_event_queue* mEventQueue;
500 tizen_policy* mTizenPolicy;
501 tizen_display_policy* mTizenDisplayPolicy;
504 std::vector< std::string > mSupportedAuxiliaryHints;
505 AuxiliaryHints mAuxiliaryHints;
507 int mNotificationLevel;
508 uint32_t mNotificationChangeState;
509 bool mNotificationLevelChangeDone;
512 uint32_t mScreenOffModeChangeState;
513 bool mScreenOffModeChangeDone;
516 uint32_t mBrightnessChangeState;
517 bool mBrightnessChangeDone;
520 Dali::PositionSize mWindowPositionSize;
524 volatile uint32_t mMoveResizeSerial;
525 uint32_t mLastSubmittedMoveResizeSerial;
527 #ifdef DALI_ELDBUS_AVAILABLE
528 Eldbus_Connection* mSystemConnection;
529 #endif // DALI_ELDBUS_AVAILABLE
532 } // namespace Adaptor
534 } // namespace internal
538 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H