1 #ifndef DALI_INTERNAL_WINDOW_SYSTEM_X11_WINDOW_BASE_X_H
2 #define DALI_INTERNAL_WINDOW_SYSTEM_X11_WINDOW_BASE_X_H
5 * Copyright (c) 2024 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>
23 #include <dali/internal/window-system/x11/window-system-x.h>
25 using Dali::Internal::Adaptor::WindowSystem::WindowSystemX;
34 * WindowBaseX class provides an WindowBase X implementation.
36 class WindowBaseX : public WindowBase
42 WindowBaseX(PositionSize positionSize, Any surface, bool isTransparent);
47 virtual ~WindowBaseX();
51 * @brief Called when the window has been moved/resized
53 void OnConfigure(WindowSystemBase::EventBase* event);
56 * @brief Called when the window property is changed.
58 bool OnWindowPropertyChanged(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event);
61 * @brief Called when the window receives a delete request
63 void OnDeleteRequest();
66 * @brief Called when the window gains focus.
68 void OnFocusIn(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
71 * @brief Called when the window loses focus.
73 void OnFocusOut(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
76 * @brief Called when the window is damaged.
78 void OnWindowDamaged(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
81 * @brief Called when a touch down is received.
83 void OnMouseButtonDown(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
86 * @brief Called when a touch up is received.
88 void OnMouseButtonUp(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
91 * @brief Called when a touch motion is received.
93 void OnMouseButtonMove(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
96 * @brief Called when a mouse wheel is received.
98 void OnMouseWheel(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
101 * Create the dali key event from the X11 event
103 Integration::KeyEvent CreateKeyEvent(WindowSystemX::X11KeyEvent* keyEvent, Integration::KeyEvent::State state);
106 * @brief Called when a key down is received.
108 void OnKeyDown(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
111 * @brief Called when a key up is received.
113 void OnKeyUp(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
116 * @brief Called when the source window notifies us the content in clipboard is selected.
118 void OnSelectionClear(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
121 * @brief Called when the source window sends us about the selected content.
123 void OnSelectionNotify(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
127 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
129 Any GetNativeWindow() override;
132 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
134 int GetNativeWindowId() override;
137 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowResourceId()
139 std::string GetNativeWindowResourceId() override;
142 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
144 EGLNativeWindowType CreateEglWindow(int width, int height) override;
147 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
149 void DestroyEglWindow() override;
152 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
154 void SetEglWindowRotation(int angle) override;
157 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
159 void SetEglWindowBufferTransform(int angle) override;
162 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
164 void SetEglWindowTransform(int angle) override;
167 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
169 void ResizeEglWindow(PositionSize positionSize) override;
172 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
174 bool IsEglWindowRotationSupported() override;
177 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
179 void Move(PositionSize positionSize) override;
182 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
184 void Resize(PositionSize positionSize) override;
187 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
189 void MoveResize(PositionSize positionSize) override;
192 * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout()
194 void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override;
197 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
199 void SetClass(const std::string& name, const std::string& className) override;
202 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
204 void Raise() override;
207 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
209 void Lower() override;
212 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
214 void Activate() override;
217 * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
219 void Maximize(bool maximize) override;
222 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
224 bool IsMaximized() const override;
227 * @copydoc Dali::Internal::Adaptor::WindowBase::SetMaximumSize()
229 void SetMaximumSize(Dali::Window::WindowSize size) override;
232 * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
234 void Minimize(bool minimize) override;
237 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
239 bool IsMinimized() const override;
242 * @copydoc Dali::Internal::Adaptor::WindowBase::SetMimimumSize()
244 void SetMimimumSize(Dali::Window::WindowSize size) override;
247 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
249 void SetAvailableAnlges(const std::vector<int>& angles) override;
252 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
254 void SetPreferredAngle(int angle) override;
257 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
259 void SetAcceptFocus(bool accept) override;
262 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
264 void Show() override;
267 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
269 void Hide() override;
272 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
274 unsigned int GetSupportedAuxiliaryHintCount() const override;
277 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
279 std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
282 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
284 unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
287 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
289 bool RemoveAuxiliaryHint(unsigned int id) override;
292 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
294 bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
297 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
299 std::string GetAuxiliaryHintValue(unsigned int id) const override;
302 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
304 unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
307 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
309 void SetInputRegion(const Rect<int>& inputRegion) override;
312 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
314 void SetType(Dali::WindowType type) override;
317 * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
319 Dali::WindowType GetType() const override;
322 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
324 Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
327 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
329 Dali::WindowNotificationLevel GetNotificationLevel() const override;
332 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
334 void SetOpaqueState(bool opaque) override;
337 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
339 Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
342 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
344 WindowScreenOffMode GetScreenOffMode() const override;
347 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
349 Dali::WindowOperationResult SetBrightness(int brightness) override;
352 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
354 int GetBrightness() const override;
357 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
359 bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
362 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
364 bool UngrabKey(Dali::KEY key) override;
367 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
369 bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
372 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
374 bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
377 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
379 void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
382 * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
384 int GetWindowRotationAngle() const override;
387 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
389 int GetScreenRotationAngle() override;
392 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
394 void SetWindowRotationAngle(int degree) override;
397 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
399 void WindowRotationCompleted(int degree, int width, int height) override;
402 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
404 void SetTransparency(bool transparent) override;
407 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
409 void SetParent(WindowBase* parentWinBase, bool belowParent) override;
412 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
414 int CreateFrameRenderedSyncFence() override;
417 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
419 int CreateFramePresentedSyncFence() override;
422 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
424 void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
427 * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
429 void InitializeIme() override;
432 * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
434 void ImeWindowReadyToRender() override;
437 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
439 void RequestMoveToServer() override;
442 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
444 void RequestResizeToServer(WindowResizeDirection direction) override;
447 * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
449 void EnableFloatingMode(bool enable) override;
452 * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
454 bool IsFloatingModeEnabled() const override;
457 * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
459 void IncludeInputRegion(const Rect<int>& inputRegion) override;
462 * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
464 void ExcludeInputRegion(const Rect<int>& inputRegion) override;
467 * @copydoc Dali::Internal::Adaptor::WindowBase::PointerConstraintsLock()
469 bool PointerConstraintsLock() override;
472 * @copydoc Dali::Internal::Adaptor::WindowBase::PointerConstraintsUnlock()
474 bool PointerConstraintsUnlock() override;
477 * @copydoc Dali::Internal::Adaptor::WindowBase::LockedPointerRegionSet()
479 void LockedPointerRegionSet(int32_t x, int32_t y, int32_t width, int32_t height) override;
482 * @copydoc Dali::Internal::Adaptor::WindowBase::LockedPointerCursorPositionHintSet()
484 void LockedPointerCursorPositionHintSet(int32_t x, int32_t y) override;
487 * @copydoc Dali::Internal::Adaptor::WindowBase::PointerWarp()
489 bool PointerWarp(int32_t x, int32_t y) override;
492 * @copydoc Dali::Internal::Adaptor::WindowBase::CursorVisibleSet()
494 void CursorVisibleSet(bool visible) override;
497 * @copydoc Dali::Internal::Adaptor::WindowBase::KeyboardGrab()
499 bool KeyboardGrab(Device::Subclass::Type deviceSubclass) override;
502 * @copydoc Dali::Internal::Adaptor::WindowBase::KeyboardUnGrab()
504 bool KeyboardUnGrab() override;
507 * @copydoc Dali::Internal::Adaptor::WindowBase::SetFullScreen()
509 void SetFullScreen(bool fullscreen) override;
512 * @copydoc Dali::Internal::Adaptor::WindowBase::GetFullScreen()
514 bool GetFullScreen() override;
517 * @copydoc Dali::Internal::Adaptor::WindowBase::SetFrontBufferRendering()
519 void SetFrontBufferRendering(bool enable) override;
522 * @copydoc Dali::Internal::Adaptor::WindowBase::GetFrontBufferRendering()
524 bool GetFrontBufferRendering() override;
527 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowFrontBufferMode()
529 void SetEglWindowFrontBufferMode(bool enable) override;
533 * Second stage initialization
535 void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
537 void SetWindowHints();
539 void EnableMultipleSelection();
541 void EnableWindowClose();
543 void EnableDragAndDrop();
550 * @brief Get the surface id if the surface parameter is not empty
551 * @param surface Any containing a surface id, or can be empty
552 * @return surface id, or zero if surface is empty
554 unsigned int GetSurfaceId(Any surface) const;
557 * @brief Create window
559 void CreateWindow(PositionSize positionSize, bool isTransparent);
563 WindowBaseX(const WindowBaseX&) = delete;
566 WindowBaseX& operator=(const WindowBaseX& rhs) = delete;
569 Dali::Vector<WindowSystemBase::EventHandler*> mEventHandlers;
570 ::Window mWindow; ///< Native window handle
571 bool mOwnSurface : 1; ///< Whether we own the surface (responsible for deleting it)
572 bool mIsTransparent; ///< Whether the window is transparent (32 bit or 24 bit)
573 bool mRotationAppSet : 1;
574 int mWindowRotationAngle;
577 } // namespace Adaptor
579 } // namespace Internal
583 #endif // DALI_INTERNAL_WINDOWSYSTEM_LIBUVX_WINDOW_BASE_X_H