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 );
181 * @brief Called when Ecore ElDBus quick panel event for accessibility is received.
183 void OnEcoreElDBusAccessibilityQuickpanelChanged( 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 );
218 * @brief Gets the key code by keyName.
220 void GetKeyCode( std::string keyName, int32_t& keyCode );
225 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
227 Any GetNativeWindow() override;
230 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
232 int GetNativeWindowId() override;
235 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
237 EGLNativeWindowType CreateEglWindow( int width, int height ) override;
240 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
242 void DestroyEglWindow() override;
245 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
247 void SetEglWindowRotation( int angle ) override;
250 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
252 void SetEglWindowBufferTransform( int angle ) override;
255 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
257 void SetEglWindowTransform( int angle ) override;
260 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
262 void ResizeEglWindow( PositionSize positionSize ) override;
265 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
267 bool IsEglWindowRotationSupported() override;
270 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
272 void Move( PositionSize positionSize ) override;
275 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
277 void Resize( PositionSize positionSize ) override;
280 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
282 void MoveResize( PositionSize positionSize ) override;
285 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
287 void SetClass( const std::string& name, const std::string& className ) override;
290 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
292 void Raise() override;
295 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
297 void Lower() override;
300 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
302 void Activate() override;
305 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
307 void SetAvailableAnlges( const std::vector< int >& angles ) override;
310 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
312 void SetPreferredAngle( int angle ) override;
315 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
317 void SetAcceptFocus( bool accept ) override;
320 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
322 void Show() override;
325 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
327 void Hide() override;
330 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
332 unsigned int GetSupportedAuxiliaryHintCount() const override;
335 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
337 std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
340 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
342 unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
345 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
347 bool RemoveAuxiliaryHint( unsigned int id ) override;
350 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
352 bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
355 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
357 std::string GetAuxiliaryHintValue( unsigned int id ) const override;
360 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
362 unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
365 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
367 void SetInputRegion( const Rect< int >& inputRegion ) override;
370 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
372 void SetType( Dali::Window::Type type ) override;
375 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
377 bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override;
380 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
382 Dali::Window::NotificationLevel::Type GetNotificationLevel() const override;
385 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
387 void SetOpaqueState( bool opaque ) override;
390 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
392 bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override;
395 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
397 Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override;
400 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
402 bool SetBrightness( int brightness ) override;
405 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
407 int GetBrightness() const override;
410 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
412 bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
415 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
417 bool UngrabKey( Dali::KEY key ) override;
420 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
422 bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
425 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
427 bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
430 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
432 void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
435 * @brief Return the orientation of the surface.
436 * @return The orientation
438 virtual int GetOrientation() const override;
441 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
443 int GetScreenRotationAngle() override;
446 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
448 void SetWindowRotationAngle( int degree ) override;
451 * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
453 virtual int GetWindowRotationAngle() override;
456 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
458 void WindowRotationCompleted( int degree, int width, int height ) override;
461 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
463 void SetTransparency( bool transparent ) override;
466 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
468 void SetParent( WindowBase* parentWinBase ) override;
471 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
473 int CreateFrameRenderedSyncFence() override;
476 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
478 int CreateFramePresentedSyncFence() override;
483 * Second stage initialization
485 void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
488 * Initialize Ecore ElDBus
490 void InitializeEcoreElDBus();
493 * @brief Create window
495 void CreateWindow( PositionSize positionSize );
500 WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
503 WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
507 typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
509 Dali::Vector< Ecore_Event_Handler* > mEcoreEventHandler;
511 Ecore_Wl2_Window* mEcoreWindow;
512 wl_surface* mWlSurface;
513 wl_egl_window* mEglWindow;
514 wl_display* mDisplay;
515 wl_event_queue* mEventQueue;
516 tizen_policy* mTizenPolicy;
517 tizen_display_policy* mTizenDisplayPolicy;
520 std::vector< std::string > mSupportedAuxiliaryHints;
521 AuxiliaryHints mAuxiliaryHints;
523 int mNotificationLevel;
524 uint32_t mNotificationChangeState;
525 bool mNotificationLevelChangeDone;
528 uint32_t mScreenOffModeChangeState;
529 bool mScreenOffModeChangeDone;
532 uint32_t mBrightnessChangeState;
533 bool mBrightnessChangeDone;
536 Dali::PositionSize mWindowPositionSize;
540 volatile uint32_t mMoveResizeSerial;
541 uint32_t mLastSubmittedMoveResizeSerial;
543 int mWindowRotationAngle;
544 int mScreenRotationAngle;
545 int mSupportedPreProtation;
546 #ifdef DALI_ELDBUS_AVAILABLE
547 Eldbus_Connection* mSystemConnection;
548 #endif // DALI_ELDBUS_AVAILABLE
551 } // namespace Adaptor
553 } // namespace internal
557 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H