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 );
164 #ifdef DALI_ELDBUS_AVAILABLE
166 * @brief Called when Ecore ElDBus accessibility event is received.
168 void OnEcoreElDBusAccessibilityNotification( void* context, const Eldbus_Message* message );
172 * @brief Called when a keymap is changed.
174 void KeymapChanged(void *data, int type, void *event);
177 * @brief RegistryGlobalCallback
179 void RegistryGlobalCallback( void* data, struct wl_registry *registry, uint32_t name, const char* interface, uint32_t version );
182 * @brief RegistryGlobalCallbackRemove
184 void RegistryGlobalCallbackRemove( void* data, struct wl_registry* registry, uint32_t id );
187 * @brief TizenPolicyNotificationChangeDone
189 void TizenPolicyNotificationChangeDone(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, int32_t level, uint32_t state );
192 * @brief TizenPolicyScreenModeChangeDone
194 void TizenPolicyScreenModeChangeDone( void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t mode, uint32_t state );
197 * @brief DisplayPolicyBrightnessChangeDone
199 void DisplayPolicyBrightnessChangeDone( void* data, struct tizen_display_policy *displayPolicy, struct wl_surface* surface, int32_t brightness, uint32_t state );
203 * @brief Gets the key code by keyName.
205 void GetKeyCode( std::string keyName, int32_t& keyCode );
210 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
212 virtual Any GetNativeWindow() override;
215 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
217 virtual int GetNativeWindowId() override;
220 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
222 virtual EGLNativeWindowType CreateEglWindow( int width, int height ) override;
225 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
227 virtual void DestroyEglWindow() override;
230 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
232 virtual void SetEglWindowRotation( int angle ) override;
235 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
237 virtual void SetEglWindowBufferTransform( int angle ) override;
240 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
242 virtual void SetEglWindowTransform( int angle ) override;
245 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
247 virtual void ResizeEglWindow( PositionSize positionSize ) override;
250 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
252 virtual bool IsEglWindowRotationSupported() override;
255 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
257 virtual void Move( PositionSize positionSize ) override;
260 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
262 virtual void Resize( PositionSize positionSize ) override;
265 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
267 virtual void MoveResize( PositionSize positionSize ) override;
270 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
272 virtual void SetClass( const std::string& name, const std::string& className ) override;
275 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
277 virtual void Raise() override;
280 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
282 virtual void Lower() override;
285 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
287 virtual void Activate() override;
290 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
292 virtual void SetAvailableAnlges( const std::vector< int >& angles ) override;
295 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
297 virtual void SetPreferredAngle( int angle ) override;
300 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
302 virtual void SetAcceptFocus( bool accept ) override;
305 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
307 virtual void Show() override;
310 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
312 virtual void Hide() override;
315 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
317 virtual unsigned int GetSupportedAuxiliaryHintCount() const override;
320 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
322 virtual std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
325 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
327 virtual unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
330 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
332 virtual bool RemoveAuxiliaryHint( unsigned int id ) override;
335 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
337 virtual bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
340 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
342 virtual std::string GetAuxiliaryHintValue( unsigned int id ) const override;
345 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
347 virtual unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
350 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
352 virtual void SetInputRegion( const Rect< int >& inputRegion ) override;
355 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
357 virtual void SetType( Dali::Window::Type type ) override;
360 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
362 virtual bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override;
365 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
367 virtual Dali::Window::NotificationLevel::Type GetNotificationLevel() const override;
370 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
372 virtual void SetOpaqueState( bool opaque ) override;
375 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
377 virtual bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override;
380 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
382 virtual Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override;
385 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
387 virtual bool SetBrightness( int brightness ) override;
390 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
392 virtual int GetBrightness() const override;
395 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
397 virtual bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
400 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
402 virtual bool UngrabKey( Dali::KEY key ) override;
405 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
407 virtual bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
410 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
412 virtual bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
415 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
417 virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
420 * @brief Return the orientation of the surface.
421 * @return The orientation
423 virtual int GetOrientation() const override;
426 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
428 virtual int GetScreenRotationAngle() override;
431 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
433 virtual void SetWindowRotationAngle( int degree ) override;
436 * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
438 virtual int GetWindowRotationAngle() override;
441 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
443 virtual void WindowRotationCompleted( int degree, int width, int height ) override;
446 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
448 virtual void SetTransparency( bool transparent ) override;
451 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
453 virtual void SetParent( WindowBase* parentWinBase ) override;
458 * Second stage initialization
460 void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
463 * Initialize Ecore ElDBus
465 void InitializeEcoreElDBus();
468 * @brief Create window
470 void CreateWindow( PositionSize positionSize );
475 WindowBaseEcoreWl2(const WindowBaseEcoreWl2&) = delete;
478 WindowBaseEcoreWl2& operator=(const WindowBaseEcoreWl2& rhs) = delete;
482 typedef std::vector< std::pair< std::string, std::string > > AuxiliaryHints;
484 Dali::Vector< Ecore_Event_Handler* > mEcoreEventHandler;
486 Ecore_Wl2_Window* mEcoreWindow;
487 wl_surface* mWlSurface;
488 wl_egl_window* mEglWindow;
489 wl_display* mDisplay;
490 wl_event_queue* mEventQueue;
491 tizen_policy* mTizenPolicy;
492 tizen_display_policy* mTizenDisplayPolicy;
495 std::vector< std::string > mSupportedAuxiliaryHints;
496 AuxiliaryHints mAuxiliaryHints;
498 int mNotificationLevel;
499 uint32_t mNotificationChangeState;
500 bool mNotificationLevelChangeDone;
503 uint32_t mScreenOffModeChangeState;
504 bool mScreenOffModeChangeDone;
507 uint32_t mBrightnessChangeState;
508 bool mBrightnessChangeDone;
511 Dali::PositionSize mWindowPositionSize;
515 volatile uint32_t mMoveResizeSerial;
516 uint32_t mLastSubmittedMoveResizeSerial;
518 int mWindowRotationAngle;
519 int mScreenRotationAngle;
520 int mSupportedPreProtation;
522 // Temporary solution to fix window rotation and window hide
523 // It will be removed when EFL patch is completed.
524 int mAvaiableWindowOrientations[4];
525 #ifdef DALI_ELDBUS_AVAILABLE
526 Eldbus_Connection* mSystemConnection;
527 #endif // DALI_ELDBUS_AVAILABLE
530 } // namespace Adaptor
532 } // namespace internal
536 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_WINDOW_BASE_ECORE_WL2_H