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) 2022 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 property is changed.
53 bool OnWindowPropertyChanged(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event);
56 * @brief Called when the window receives a delete request
58 void OnDeleteRequest();
61 * @brief Called when the window gains focus.
63 void OnFocusIn(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
66 * @brief Called when the window loses focus.
68 void OnFocusOut(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
71 * @brief Called when the window is damaged.
73 void OnWindowDamaged(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
76 * @brief Called when a touch down is received.
78 void OnMouseButtonDown(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
81 * @brief Called when a touch up is received.
83 void OnMouseButtonUp(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
86 * @brief Called when a touch motion is received.
88 void OnMouseButtonMove(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
91 * @brief Called when a mouse wheel is received.
93 void OnMouseWheel(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
96 * Create the dali key event from the X11 event
98 static Integration::KeyEvent CreateKeyEvent(WindowSystemX::X11KeyEvent* keyEvent, Integration::KeyEvent::State state);
101 * @brief Called when a key down is received.
103 void OnKeyDown(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
106 * @brief Called when a key up is received.
108 void OnKeyUp(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
111 * @brief Called when the source window notifies us the content in clipboard is selected.
113 void OnSelectionClear(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
116 * @brief Called when the source window sends us about the selected content.
118 void OnSelectionNotify(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event);
122 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
124 Any GetNativeWindow() override;
127 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
129 int GetNativeWindowId() override;
132 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowResourceId()
134 std::string GetNativeWindowResourceId() override;
137 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
139 EGLNativeWindowType CreateEglWindow(int width, int height) override;
142 * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
144 void DestroyEglWindow() override;
147 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
149 void SetEglWindowRotation(int angle) override;
152 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
154 void SetEglWindowBufferTransform(int angle) override;
157 * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
159 void SetEglWindowTransform(int angle) override;
162 * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
164 void ResizeEglWindow(PositionSize positionSize) override;
167 * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
169 bool IsEglWindowRotationSupported() override;
172 * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
174 void Move(PositionSize positionSize) override;
177 * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
179 void Resize(PositionSize positionSize) override;
182 * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
184 void MoveResize(PositionSize positionSize) override;
187 * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
189 void SetClass(const std::string& name, const std::string& className) override;
192 * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
194 void Raise() override;
197 * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
199 void Lower() override;
202 * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
204 void Activate() override;
207 * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
209 void Maximize(bool maximize) override;
212 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
214 bool IsMaximized() const override;
217 * @copydoc Dali::Internal::Adaptor::WindowBase::SetMaximumSize()
219 void SetMaximumSize(Dali::Window::WindowSize size) override;
222 * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
224 void Minimize(bool minimize) override;
227 * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
229 bool IsMinimized() const override;
232 * @copydoc Dali::Internal::Adaptor::WindowBase::SetMimimumSize()
234 void SetMimimumSize(Dali::Window::WindowSize size) override;
237 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
239 void SetAvailableAnlges(const std::vector<int>& angles) override;
242 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
244 void SetPreferredAngle(int angle) override;
247 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
249 void SetAcceptFocus(bool accept) override;
252 * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
254 void Show() override;
257 * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
259 void Hide() override;
262 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
264 unsigned int GetSupportedAuxiliaryHintCount() const override;
267 * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
269 std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
272 * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
274 unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
277 * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
279 bool RemoveAuxiliaryHint(unsigned int id) override;
282 * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
284 bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
287 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
289 std::string GetAuxiliaryHintValue(unsigned int id) const override;
292 * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
294 unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
297 * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
299 void SetInputRegion(const Rect<int>& inputRegion) override;
302 * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
304 void SetType(Dali::WindowType type) override;
307 * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
309 Dali::WindowType GetType() const override;
312 * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
314 Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
317 * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
319 Dali::WindowNotificationLevel GetNotificationLevel() const override;
322 * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
324 void SetOpaqueState(bool opaque) override;
327 * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
329 Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
332 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
334 WindowScreenOffMode GetScreenOffMode() const override;
337 * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
339 Dali::WindowOperationResult SetBrightness(int brightness) override;
342 * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
344 int GetBrightness() const override;
347 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
349 bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
352 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
354 bool UngrabKey(Dali::KEY key) override;
357 * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
359 bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
362 * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
364 bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
367 * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
369 void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
372 * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
374 int GetWindowRotationAngle() const override;
377 * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
379 int GetScreenRotationAngle() override;
382 * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
384 void SetWindowRotationAngle(int degree) override;
387 * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
389 void WindowRotationCompleted(int degree, int width, int height) override;
392 * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
394 void SetTransparency(bool transparent) override;
397 * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
399 void SetParent(WindowBase* parentWinBase, bool belowParent) override;
402 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
404 int CreateFrameRenderedSyncFence() override;
407 * @copydoc Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
409 int CreateFramePresentedSyncFence() override;
412 * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
414 void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
417 * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
419 void InitializeIme() override;
422 * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
424 void ImeWindowReadyToRender() override;
427 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
429 void RequestMoveToServer() override;
432 * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
434 void RequestResizeToServer(WindowResizeDirection direction) override;
437 * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
439 void EnableFloatingMode(bool enable) override;
442 * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
444 bool IsFloatingModeEnabled() const override;
447 * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
449 void IncludeInputRegion(const Rect<int>& inputRegion) override;
452 * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
454 void ExcludeInputRegion(const Rect<int>& inputRegion) override;
458 * Second stage initialization
460 void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
462 void SetWindowHints();
464 void EnableMultipleSelection();
466 void EnableWindowClose();
468 void EnableDragAndDrop();
475 * @brief Get the surface id if the surface parameter is not empty
476 * @param surface Any containing a surface id, or can be empty
477 * @return surface id, or zero if surface is empty
479 unsigned int GetSurfaceId(Any surface) const;
482 * @brief Create window
484 void CreateWindow(PositionSize positionSize, bool isTransparent);
488 WindowBaseX(const WindowBaseX&) = delete;
491 WindowBaseX& operator=(const WindowBaseX& rhs) = delete;
494 Dali::Vector<WindowSystemBase::EventHandler*> mEventHandlers;
495 ::Window mWindow; ///< Native window handle
496 bool mOwnSurface : 1; ///< Whether we own the surface (responsible for deleting it)
497 bool mIsTransparent; ///< Whether the window is transparent (32 bit or 24 bit)
498 bool mRotationAppSet : 1;
499 int mWindowRotationAngle;
502 } // namespace Adaptor
504 } // namespace Internal
508 #endif // DALI_INTERNAL_WINDOWSYSTEM_LIBUVX_WINDOW_BASE_X_H