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) 2023 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 static 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::SetClass()
194 void SetClass(const std::string& name, const std::string& className) override;
197 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
199 void Raise() override;
202 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
204 void Lower() override;
207 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
209 void Activate() override;
212 * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
214 void Maximize(bool maximize) override;
217 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
219 bool IsMaximized() const override;
222 * @copydoc Dali::Internal::Adaptor::WindowBase::SetMaximumSize()
224 void SetMaximumSize(Dali::Window::WindowSize size) override;
227 * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
229 void Minimize(bool minimize) override;
232 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
234 bool IsMinimized() const override;
237 * @copydoc Dali::Internal::Adaptor::WindowBase::SetMimimumSize()
239 void SetMimimumSize(Dali::Window::WindowSize size) override;
242 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
244 void SetAvailableAnlges(const std::vector<int>& angles) override;
247 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
249 void SetPreferredAngle(int angle) override;
252 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
254 void SetAcceptFocus(bool accept) override;
257 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
259 void Show() override;
262 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
264 void Hide() override;
267 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
269 unsigned int GetSupportedAuxiliaryHintCount() const override;
272 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
274 std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
277 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
279 unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
282 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
284 bool RemoveAuxiliaryHint(unsigned int id) override;
287 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
289 bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
292 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
294 std::string GetAuxiliaryHintValue(unsigned int id) const override;
297 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
299 unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
302 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
304 void SetInputRegion(const Rect<int>& inputRegion) override;
307 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
309 void SetType(Dali::WindowType type) override;
312 * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
314 Dali::WindowType GetType() const override;
317 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
319 Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
322 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
324 Dali::WindowNotificationLevel GetNotificationLevel() const override;
327 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
329 void SetOpaqueState(bool opaque) override;
332 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
334 Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
337 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
339 WindowScreenOffMode GetScreenOffMode() const override;
342 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
344 Dali::WindowOperationResult SetBrightness(int brightness) override;
347 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
349 int GetBrightness() const override;
352 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
354 bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
357 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
359 bool UngrabKey(Dali::KEY key) override;
362 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
364 bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
367 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
369 bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
372 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
374 void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
377 * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
379 int GetWindowRotationAngle() const override;
382 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
384 int GetScreenRotationAngle() override;
387 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
389 void SetWindowRotationAngle(int degree) override;
392 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
394 void WindowRotationCompleted(int degree, int width, int height) override;
397 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
399 void SetTransparency(bool transparent) override;
402 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
404 void SetParent(WindowBase* parentWinBase, bool belowParent) override;
407 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
409 int CreateFrameRenderedSyncFence() override;
412 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
414 int CreateFramePresentedSyncFence() override;
417 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
419 void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
422 * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
424 void InitializeIme() override;
427 * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
429 void ImeWindowReadyToRender() override;
432 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
434 void RequestMoveToServer() override;
437 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
439 void RequestResizeToServer(WindowResizeDirection direction) override;
442 * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
444 void EnableFloatingMode(bool enable) override;
447 * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
449 bool IsFloatingModeEnabled() const override;
452 * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
454 void IncludeInputRegion(const Rect<int>& inputRegion) override;
457 * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
459 void ExcludeInputRegion(const Rect<int>& inputRegion) override;
463 * Second stage initialization
465 void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
467 void SetWindowHints();
469 void EnableMultipleSelection();
471 void EnableWindowClose();
473 void EnableDragAndDrop();
480 * @brief Get the surface id if the surface parameter is not empty
481 * @param surface Any containing a surface id, or can be empty
482 * @return surface id, or zero if surface is empty
484 unsigned int GetSurfaceId(Any surface) const;
487 * @brief Create window
489 void CreateWindow(PositionSize positionSize, bool isTransparent);
493 WindowBaseX(const WindowBaseX&) = delete;
496 WindowBaseX& operator=(const WindowBaseX& rhs) = delete;
499 Dali::Vector<WindowSystemBase::EventHandler*> mEventHandlers;
500 ::Window mWindow; ///< Native window handle
501 bool mOwnSurface : 1; ///< Whether we own the surface (responsible for deleting it)
502 bool mIsTransparent; ///< Whether the window is transparent (32 bit or 24 bit)
503 bool mRotationAppSet : 1;
504 int mWindowRotationAngle;
507 } // namespace Adaptor
509 } // namespace Internal
513 #endif // DALI_INTERNAL_WINDOWSYSTEM_LIBUVX_WINDOW_BASE_X_H