Merge "Add an API for getting web view when request is intercepted." into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / x11 / window-base-x.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/window-system/x11/window-base-x.h>
20
21 // INTERNAL HEADERS
22 #include <dali/internal/window-system/common/window-impl.h>
23 #include <dali/internal/window-system/common/window-render-surface.h>
24 #include <dali/internal/window-system/common/window-system.h>
25 #include <dali/internal/window-system/x11/window-system-x.h>
26
27 // EXTERNAL_HEADERS
28 #include <dali/integration-api/debug.h>
29 #include <dali/public-api/events/mouse-button.h>
30 #include <dali/public-api/object/any.h>
31
32 using Dali::Internal::Adaptor::WindowSystem::WindowSystemX;
33
34 namespace Dali
35 {
36 namespace Internal
37 {
38 namespace Adaptor
39 {
40 namespace
41 {
42 const std::string            DEFAULT_DEVICE_NAME     = "";
43 const Device::Class::Type    DEFAULT_DEVICE_CLASS    = Device::Class::NONE;
44 const Device::Subclass::Type DEFAULT_DEVICE_SUBCLASS = Device::Subclass::NONE;
45
46 const unsigned int PRIMARY_TOUCH_BUTTON_ID(1);
47
48 #if defined(DEBUG_ENABLED)
49 Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_WINDOW_BASE");
50 #endif
51
52 /////////////////////////////////////////////////////////////////////////////////////////////////
53 // Window Callbacks
54 /////////////////////////////////////////////////////////////////////////////////////////////////
55
56 static bool EventWindowPropertyChanged(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
57 {
58   WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
59   if(windowBase)
60   {
61     return windowBase->OnWindowPropertyChanged(data, type, event);
62   }
63
64   return false;
65 }
66
67 /**
68  * Called when the window receives a delete request
69  */
70 static bool EventWindowDeleteRequest(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
71 {
72   WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
73   if(windowBase)
74   {
75     windowBase->OnDeleteRequest();
76   }
77   return true;
78 }
79
80 /**
81  * Called when the window gains focus.
82  */
83 static bool EventWindowFocusIn(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
84 {
85   WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
86   if(windowBase)
87   {
88     windowBase->OnFocusIn(data, type, event);
89   }
90   return false;
91 }
92
93 /**
94  * Called when the window loses focus.
95  */
96 static bool EventWindowFocusOut(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
97 {
98   WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
99   if(windowBase)
100   {
101     windowBase->OnFocusOut(data, type, event);
102   }
103   return false;
104 }
105
106 /**
107  * Called when the window is damaged.
108  */
109 static bool EventWindowDamaged(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
110 {
111   WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
112   if(windowBase)
113   {
114     windowBase->OnWindowDamaged(data, type, event);
115   }
116
117   return false;
118 }
119
120 /////////////////////////////////////////////////////////////////////////////////////////////////
121 // Selection Callbacks
122 /////////////////////////////////////////////////////////////////////////////////////////////////
123
124 /**
125  * Called when the source window notifies us the content in clipboard is selected.
126  */
127 static bool EventSelectionClear(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
128 {
129   WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
130   if(windowBase)
131   {
132     windowBase->OnSelectionClear(data, type, event);
133   }
134   return false;
135 }
136
137 /**
138  * Called when the source window sends us about the selected content.
139  * For example, when dragged items are dragged INTO our window or when items are selected in the clipboard.
140  */
141 static bool EventSelectionNotify(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
142 {
143   WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
144   if(windowBase)
145   {
146     windowBase->OnSelectionNotify(data, type, event);
147   }
148   return false;
149 }
150
151 /////////////////////////////////////////////////////////////////////////////////////////////////
152 // Touch Callbacks
153 /////////////////////////////////////////////////////////////////////////////////////////////////
154
155 /**
156  * Called when a touch down is received.
157  */
158 static bool EventMouseButtonDown(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
159 {
160   WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
161   if(windowBase)
162   {
163     windowBase->OnMouseButtonDown(data, type, event);
164   }
165   return false;
166 }
167
168 /**
169  * Called when a touch up is received.
170  */
171 static bool EventMouseButtonUp(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
172 {
173   WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
174   if(windowBase)
175   {
176     windowBase->OnMouseButtonUp(data, type, event);
177   }
178   return false;
179 }
180
181 /**
182  * Called when a touch motion is received.
183  */
184 static bool EventMouseButtonMove(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
185 {
186   WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
187   if(windowBase)
188   {
189     windowBase->OnMouseButtonMove(data, type, event);
190   }
191   return false;
192 }
193
194 /////////////////////////////////////////////////////////////////////////////////////////////////
195 // Wheel Callbacks
196 /////////////////////////////////////////////////////////////////////////////////////////////////
197
198 /**
199  * Called when a mouse wheel is received.
200  */
201 static bool EventMouseWheel(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
202 {
203   WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
204   if(windowBase)
205   {
206     windowBase->OnMouseWheel(data, type, event);
207   }
208   return false;
209 }
210
211 /////////////////////////////////////////////////////////////////////////////////////////////////
212 // Key Callbacks
213 /////////////////////////////////////////////////////////////////////////////////////////////////
214
215 /**
216  * Called when a key down is received.
217  */
218 static bool EventKeyDown(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
219 {
220   WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
221   if(windowBase)
222   {
223     windowBase->OnKeyDown(data, type, event);
224   }
225   return false;
226 }
227
228 /**
229  * Called when a key up is received.
230  */
231 static bool EventKeyUp(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
232 {
233   WindowBaseX* windowBase = static_cast<WindowBaseX*>(data);
234   if(windowBase)
235   {
236     windowBase->OnKeyUp(data, type, event);
237   }
238   return false;
239 }
240
241 } // unnamed namespace
242
243 WindowBaseX::WindowBaseX(Dali::PositionSize positionSize, Any surface, bool isTransparent)
244 : mEventHandlers(),
245   mWindow(0),
246   mOwnSurface(false),
247   mIsTransparent(false), // Should only be set to true once we actually create a transparent window regardless of what isTransparent is.
248   mRotationAppSet(false),
249   mWindowRotationAngle(0)
250 {
251   Initialize(positionSize, surface, isTransparent);
252 }
253
254 WindowBaseX::~WindowBaseX()
255 {
256   DeleteEvents();
257   mEventHandlers.Clear();
258
259   if(mOwnSurface)
260   {
261     XDestroyWindow(WindowSystem::GetImplementation().GetXDisplay(), mWindow);
262
263     /**** @todo Should not be destroyed here! ****/
264     WindowSystem::Shutdown();
265   }
266 }
267
268 void WindowBaseX::Initialize(PositionSize positionSize, Any surface, bool isTransparent)
269 {
270   // see if there is a surface in Any surface
271   unsigned int surfaceId = GetSurfaceId(surface);
272
273   // if the surface is empty, create a new one.
274   if(surfaceId == 0)
275   {
276     /**** @todo Should be created from somewhere else! ****/
277     WindowSystem::Initialize();
278
279     // we own the surface about to created
280     mOwnSurface = true;
281     CreateWindow(positionSize, isTransparent);
282   }
283   else
284   {
285     // XLib should already be initialized so no point in calling XInitThreads
286     mWindow = static_cast<::Window>(surfaceId);
287   }
288
289   auto& windowSystem = WindowSystem::GetImplementation();
290
291   char* id = NULL;
292   if((id = getenv("DESKTOP_STARTUP_ID")))
293   {
294     windowSystem.SetStringProperty(mWindow, WindowSystemX::ATOM_NET_STARTUP_ID, std::string(id));
295   }
296
297   windowSystem.SetWindowHints(mWindow, true);
298   windowSystem.Sync();
299
300   EnableMultipleSelection();
301   EnableWindowClose();
302   EnableDragAndDrop();
303
304   SetupEvents();
305 }
306
307 void WindowBaseX::SetWindowHints()
308 {
309 }
310
311 void WindowBaseX::EnableMultipleSelection()
312 {
313   WindowSystem::GetImplementation().InputMultiSelect(mWindow);
314 }
315
316 void WindowBaseX::EnableWindowClose()
317 {
318   WindowSystem::GetImplementation().SetProtocol(mWindow, WindowSystemX::ATOM_WM_DELETE_WINDOW, true);
319 }
320
321 void WindowBaseX::EnableDragAndDrop()
322 {
323   WindowSystem::GetImplementation().EnableDragAndDrop(mWindow, true);
324 }
325
326 void WindowBaseX::SetupEvents()
327 {
328   auto& windowSystem = WindowSystem::GetImplementation();
329   windowSystem.AddEventHandler(WindowSystemBase::Event::PROPERTY_NOTIFY, EventWindowPropertyChanged, this);
330   windowSystem.AddEventHandler(WindowSystemBase::Event::DELETE_REQUEST, EventWindowDeleteRequest, this);
331   windowSystem.AddEventHandler(WindowSystemBase::Event::FOCUS_IN, EventWindowFocusIn, this);
332   windowSystem.AddEventHandler(WindowSystemBase::Event::FOCUS_OUT, EventWindowFocusOut, this);
333   windowSystem.AddEventHandler(WindowSystemBase::Event::DAMAGE, EventWindowDamaged, this);
334   windowSystem.AddEventHandler(WindowSystemBase::Event::MOUSE_BUTTON_DOWN, EventMouseButtonDown, this);
335   windowSystem.AddEventHandler(WindowSystemBase::Event::MOUSE_BUTTON_UP, EventMouseButtonUp, this);
336   windowSystem.AddEventHandler(WindowSystemBase::Event::MOUSE_OUT, EventMouseButtonUp, this);
337   windowSystem.AddEventHandler(WindowSystemBase::Event::MOUSE_MOVE, EventMouseButtonMove, this);
338   windowSystem.AddEventHandler(WindowSystemBase::Event::MOUSE_WHEEL, EventMouseWheel, this);
339   windowSystem.AddEventHandler(WindowSystemBase::Event::KEY_DOWN, EventKeyDown, this);
340   windowSystem.AddEventHandler(WindowSystemBase::Event::KEY_UP, EventKeyUp, this);
341   windowSystem.AddEventHandler(WindowSystemBase::Event::SELECTION_CLEAR, EventSelectionClear, this);
342   windowSystem.AddEventHandler(WindowSystemBase::Event::SELECTION_NOTIFY, EventSelectionNotify, this);
343 }
344
345 void WindowBaseX::DeleteEvents()
346 {
347 }
348
349 bool WindowBaseX::OnWindowPropertyChanged(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
350 {
351   bool handled(false);
352
353   auto propertyNotifyEvent = static_cast<WindowSystem::WindowSystemX::X11PropertyNotifyEvent*>(event);
354   if(propertyNotifyEvent->window == mWindow)
355   {
356     WindowSystemX::WindowState state = WindowSystem::GetImplementation().GetWindowState(mWindow);
357
358     switch(state)
359     {
360       case WindowSystemX::WindowState::WITHDRAWN:
361       {
362         // Window was hidden.
363         mIconifyChangedSignal.Emit(true);
364         handled = true;
365         break;
366       }
367       case WindowSystemX::WindowState::ICONIC:
368       {
369         // Window was iconified (minimised).
370         mIconifyChangedSignal.Emit(true);
371         handled = true;
372         break;
373       }
374       case WindowSystemX::WindowState::NORMAL:
375       {
376         // Window was shown.
377         mIconifyChangedSignal.Emit(false);
378         handled = true;
379         break;
380       }
381       default:
382       {
383         // Ignore
384         break;
385       }
386     }
387   }
388
389   return handled;
390 }
391
392 void WindowBaseX::OnDeleteRequest()
393 {
394   mDeleteRequestSignal.Emit();
395 }
396
397 void WindowBaseX::OnFocusIn(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event)
398 {
399   auto x11Event = static_cast<WindowSystemX::X11Event*>(event);
400
401   if(x11Event->window == mWindow)
402   {
403     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window::OnFocusIn\n");
404
405     mFocusChangedSignal.Emit(true);
406   }
407 }
408
409 void WindowBaseX::OnFocusOut(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event)
410 {
411   auto x11Event = static_cast<WindowSystemX::X11Event*>(event);
412   // If the window loses focus then hide the keyboard.
413   if(x11Event->window == mWindow)
414   {
415     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window::FocusOut\n");
416
417     mFocusChangedSignal.Emit(false);
418   }
419 }
420
421 void WindowBaseX::OnWindowDamaged(void* data, WindowSystemBase::Event, WindowSystemBase::EventBase* event)
422 {
423   auto windowExposeEvent = static_cast<WindowSystemX::X11ExposeEvent*>(event);
424   if(windowExposeEvent->window == mWindow)
425   {
426     DamageArea area;
427     area.x      = windowExposeEvent->x;
428     area.y      = windowExposeEvent->y;
429     area.width  = windowExposeEvent->width;
430     area.height = windowExposeEvent->height;
431
432     mWindowDamagedSignal.Emit(area);
433   }
434 }
435
436 void WindowBaseX::OnMouseButtonDown(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
437 {
438   auto touchEvent = static_cast<WindowSystemX::X11MouseEvent*>(event);
439
440   if(touchEvent->window == mWindow)
441   {
442     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window::ButtonDown\n");
443     PointState::Type state(PointState::DOWN);
444
445     Integration::Point point;
446     point.SetDeviceId(touchEvent->device);
447     point.SetState(state);
448     point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
449     point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radiusX, touchEvent->multi.radiusY));
450     point.SetPressure(touchEvent->multi.pressure);
451     point.SetAngle(Degree(touchEvent->multi.angle));
452     if(touchEvent->buttons)
453     {
454       point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
455     }
456
457     mTouchEventSignal.Emit(point, touchEvent->timestamp);
458   }
459 }
460
461 void WindowBaseX::OnMouseButtonUp(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
462 {
463   auto touchEvent = static_cast<WindowSystemX::X11MouseEvent*>(event);
464
465   if(touchEvent->window == mWindow)
466   {
467     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "Window::ButtonUp\n");
468     Integration::Point point;
469     point.SetDeviceId(touchEvent->device);
470     point.SetState(PointState::UP);
471     point.SetScreenPosition(Vector2(touchEvent->x, touchEvent->y));
472     point.SetRadius(touchEvent->multi.radius, Vector2(touchEvent->multi.radiusX, touchEvent->multi.radiusY));
473     point.SetPressure(touchEvent->multi.pressure);
474     point.SetAngle(Degree(static_cast<float>(touchEvent->multi.angle)));
475     if(touchEvent->buttons)
476     {
477       point.SetMouseButton(static_cast<MouseButton::Type>(touchEvent->buttons));
478     }
479
480     mTouchEventSignal.Emit(point, touchEvent->timestamp);
481   }
482 }
483
484 void WindowBaseX::OnMouseButtonMove(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
485 {
486   auto touchEvent = static_cast<WindowSystemX::X11MouseEvent*>(event);
487
488   if(touchEvent->window == mWindow)
489   {
490     Integration::Point point;
491     point.SetDeviceId(touchEvent->device);
492     point.SetState(PointState::MOTION);
493     point.SetScreenPosition(Vector2(static_cast<float>(touchEvent->x), static_cast<float>(touchEvent->y)));
494     point.SetRadius(static_cast<float>(touchEvent->multi.radius), Vector2(static_cast<float>(touchEvent->multi.radiusX), static_cast<float>(touchEvent->multi.radiusY)));
495     point.SetPressure(static_cast<float>(touchEvent->multi.pressure));
496     point.SetAngle(Degree(static_cast<float>(touchEvent->multi.angle)));
497
498     mTouchEventSignal.Emit(point, touchEvent->timestamp);
499   }
500 }
501
502 void WindowBaseX::OnMouseWheel(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
503 {
504   auto mouseWheelEvent = static_cast<WindowSystemX::X11MouseWheelEvent*>(event);
505
506   if(mouseWheelEvent->window == mWindow)
507   {
508     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseX::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent->direction, mouseWheelEvent->modifiers, mouseWheelEvent->x, mouseWheelEvent->y, mouseWheelEvent->z);
509
510     Integration::WheelEvent wheelEvent(Integration::WheelEvent::MOUSE_WHEEL, mouseWheelEvent->direction, mouseWheelEvent->modifiers, Vector2(static_cast<float>(mouseWheelEvent->x), static_cast<float>(mouseWheelEvent->y)), mouseWheelEvent->z, mouseWheelEvent->timestamp);
511
512     mWheelEventSignal.Emit(wheelEvent);
513   }
514 }
515
516 Integration::KeyEvent WindowBaseX::CreateKeyEvent(WindowSystemX::X11KeyEvent* keyEvent, Integration::KeyEvent::State state)
517 {
518   std::string keyName(keyEvent->keyname);
519   std::string logicalKey("");
520   std::string keyString("");
521   std::string compose("");
522
523   // Ensure key compose string is not NULL as keys like SHIFT or arrow have a null string.
524   if(!keyEvent->compose.empty())
525   {
526     compose   = keyEvent->compose;
527     keyString = keyEvent->compose;
528   }
529   // Ensure key symbol is not NULL as keys like SHIFT have a null string.
530   if(!keyEvent->key.empty())
531   {
532     logicalKey = keyEvent->key;
533   }
534
535   int           keyCode = keyEvent->keyCode;
536   int           modifier(keyEvent->modifiers);
537   unsigned long time(keyEvent->timestamp);
538
539   Integration::KeyEvent daliKeyEvent{keyName, logicalKey, keyString, keyCode, modifier, time, state, compose, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS};
540   return daliKeyEvent;
541 }
542
543 void WindowBaseX::OnKeyDown(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
544 {
545   auto keyEvent = static_cast<WindowSystemX::X11KeyEvent*>(event);
546
547   if(keyEvent->window == mWindow)
548   {
549     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, "WindowBaseX::OnKeyDown\n");
550
551     auto daliKeyEvent = CreateKeyEvent(keyEvent, Integration::KeyEvent::DOWN);
552
553     mKeyEventSignal.Emit(daliKeyEvent);
554   }
555 }
556
557 void WindowBaseX::OnKeyUp(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
558 {
559   auto keyEvent = static_cast<WindowSystemX::X11KeyEvent*>(event);
560
561   if(keyEvent->window == mWindow)
562   {
563     DALI_LOG_INFO(gWindowBaseLogFilter, Debug::General, " WindowBaseX::OnKeyUp\n");
564
565     auto daliKeyEvent = CreateKeyEvent(keyEvent, Integration::KeyEvent::UP);
566
567     mKeyEventSignal.Emit(daliKeyEvent);
568   }
569 }
570
571 void WindowBaseX::OnSelectionClear(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
572 {
573 }
574
575 void WindowBaseX::OnSelectionNotify(void* data, WindowSystemBase::Event type, WindowSystemBase::EventBase* event)
576 {
577 }
578
579 Any WindowBaseX::GetNativeWindow()
580 {
581   return mWindow;
582 }
583
584 int WindowBaseX::GetNativeWindowId()
585 {
586   return mWindow;
587 }
588
589 std::string WindowBaseX::GetNativeWindowResourceId()
590 {
591   return std::string();
592 }
593
594 EGLNativeWindowType WindowBaseX::CreateEglWindow(int width, int height)
595 {
596   return reinterpret_cast<EGLNativeWindowType>(mWindow);
597 }
598
599 void WindowBaseX::DestroyEglWindow()
600 {
601 }
602
603 void WindowBaseX::SetEglWindowRotation(int angle)
604 {
605 }
606
607 void WindowBaseX::SetEglWindowBufferTransform(int angle)
608 {
609 }
610
611 void WindowBaseX::SetEglWindowTransform(int angle)
612 {
613 }
614
615 void WindowBaseX::ResizeEglWindow(PositionSize positionSize)
616 {
617 }
618
619 bool WindowBaseX::IsEglWindowRotationSupported()
620 {
621   return false;
622 }
623
624 void WindowBaseX::Move(PositionSize positionSize)
625 {
626   WindowSystem::GetImplementation().Move(mWindow, positionSize.x, positionSize.y);
627 }
628
629 void WindowBaseX::Resize(PositionSize positionSize)
630 {
631   WindowSystem::GetImplementation().Resize(mWindow, positionSize.width, positionSize.height);
632 }
633
634 void WindowBaseX::MoveResize(PositionSize positionSize)
635 {
636   WindowSystem::GetImplementation().MoveResize(mWindow, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
637 }
638
639 void WindowBaseX::SetClass(const std::string& name, const std::string& className)
640 {
641   WindowSystem::GetImplementation().SetClass(mWindow, name, className);
642 }
643
644 void WindowBaseX::Raise()
645 {
646   WindowSystem::GetImplementation().Raise(mWindow);
647 }
648
649 void WindowBaseX::Lower()
650 {
651   WindowSystem::GetImplementation().Lower(mWindow);
652 }
653
654 void WindowBaseX::Activate()
655 {
656   WindowSystem::GetImplementation().Activate(mWindow);
657 }
658
659 void WindowBaseX::Maximize(bool maximize)
660 {
661 }
662
663 bool WindowBaseX::IsMaximized() const
664 {
665   return false;
666 }
667
668 void WindowBaseX::Minimize(bool minimize)
669 {
670 }
671
672 bool WindowBaseX::IsMinimized() const
673 {
674   return false;
675 }
676
677 void WindowBaseX::SetMimimumSize(Dali::Window::WindowSize size)
678 {
679 }
680
681 void WindowBaseX::SetMaximumSize(Dali::Window::WindowSize size)
682 {
683 }
684
685 void WindowBaseX::SetAvailableAnlges(const std::vector<int>& angles)
686 {
687 }
688
689 void WindowBaseX::SetPreferredAngle(int angle)
690 {
691 }
692
693 void WindowBaseX::SetAcceptFocus(bool accept)
694 {
695 }
696
697 void WindowBaseX::Show()
698 {
699   WindowSystem::GetImplementation().Show(mWindow);
700 }
701
702 void WindowBaseX::Hide()
703 {
704   WindowSystem::GetImplementation().Hide(mWindow);
705 }
706
707 unsigned int WindowBaseX::GetSupportedAuxiliaryHintCount() const
708 {
709   return 0;
710 }
711
712 std::string WindowBaseX::GetSupportedAuxiliaryHint(unsigned int index) const
713 {
714   return std::string();
715 }
716
717 unsigned int WindowBaseX::AddAuxiliaryHint(const std::string& hint, const std::string& value)
718 {
719   return 0;
720 }
721
722 bool WindowBaseX::RemoveAuxiliaryHint(unsigned int id)
723 {
724   return false;
725 }
726
727 bool WindowBaseX::SetAuxiliaryHintValue(unsigned int id, const std::string& value)
728 {
729   return false;
730 }
731
732 std::string WindowBaseX::GetAuxiliaryHintValue(unsigned int id) const
733 {
734   return std::string();
735 }
736
737 unsigned int WindowBaseX::GetAuxiliaryHintId(const std::string& hint) const
738 {
739   return 0;
740 }
741
742 void WindowBaseX::SetInputRegion(const Rect<int>& inputRegion)
743 {
744 }
745
746 void WindowBaseX::SetType(Dali::WindowType type)
747 {
748 }
749
750 Dali::WindowType WindowBaseX::GetType() const
751 {
752   return Dali::WindowType::NORMAL;
753 }
754
755 Dali::WindowOperationResult WindowBaseX::SetNotificationLevel(Dali::WindowNotificationLevel level)
756 {
757   return Dali::WindowOperationResult::NOT_SUPPORTED;
758 }
759
760 Dali::WindowNotificationLevel WindowBaseX::GetNotificationLevel() const
761 {
762   return Dali::WindowNotificationLevel::NONE;
763 }
764
765 void WindowBaseX::SetOpaqueState(bool opaque)
766 {
767 }
768
769 Dali::WindowOperationResult WindowBaseX::SetScreenOffMode(WindowScreenOffMode screenOffMode)
770 {
771   return Dali::WindowOperationResult::NOT_SUPPORTED;
772 }
773
774 WindowScreenOffMode WindowBaseX::GetScreenOffMode() const
775 {
776   return WindowScreenOffMode::TIMEOUT;
777 }
778
779 Dali::WindowOperationResult WindowBaseX::SetBrightness(int brightness)
780 {
781   return Dali::WindowOperationResult::NOT_SUPPORTED;
782 }
783
784 int WindowBaseX::GetBrightness() const
785 {
786   return 0;
787 }
788
789 bool WindowBaseX::GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode)
790 {
791   return false;
792 }
793
794 bool WindowBaseX::UngrabKey(Dali::KEY key)
795 {
796   return false;
797 }
798
799 bool WindowBaseX::GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result)
800 {
801   return false;
802 }
803
804 bool WindowBaseX::UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result)
805 {
806   return false;
807 }
808
809 void WindowBaseX::GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical)
810 {
811   // 1 inch = 25.4 millimeters
812   WindowSystem::GetImplementation().GetDPI(dpiHorizontal, dpiVertical);
813 }
814
815 int WindowBaseX::GetOrientation() const
816 {
817   return 0;
818 }
819
820 int WindowBaseX::GetScreenRotationAngle()
821 {
822   return 0;
823 }
824
825 void WindowBaseX::SetWindowRotationAngle(int degree)
826 {
827   mWindowRotationAngle = degree;
828 }
829
830 void WindowBaseX::WindowRotationCompleted(int degree, int width, int height)
831 {
832 }
833
834 void WindowBaseX::SetTransparency(bool transparent)
835 {
836 }
837
838 unsigned int WindowBaseX::GetSurfaceId(Any surface) const
839 {
840   unsigned int surfaceId = 0;
841
842   if(surface.Empty() == false)
843   {
844     // check we have a valid type
845     DALI_ASSERT_ALWAYS(((surface.GetType() == typeid(::Window))) && "Surface type is invalid");
846
847     surfaceId = static_cast<unsigned int>(AnyCast<::Window>(surface));
848   }
849   return surfaceId;
850 }
851
852 void WindowBaseX::CreateWindow(PositionSize positionSize, bool isTransparent)
853 {
854   int depth = 3;
855
856   if(isTransparent)
857   {
858     // create 32 bit window
859     depth = 4;
860
861     mIsTransparent = true;
862   }
863   mWindow = WindowSystem::GetImplementation().CreateWindow(depth, positionSize.x, positionSize.y, positionSize.width, positionSize.height);
864
865   if(mWindow == 0)
866   {
867     DALI_ASSERT_ALWAYS(0 && "Failed to create X window");
868   }
869 }
870
871 void WindowBaseX::SetParent(WindowBase* parentWinBase, bool belowParent)
872 {
873   if(parentWinBase)
874   {
875     WindowBaseX* windowBaseX  = static_cast<WindowBaseX*>(parentWinBase);
876     ::Window     parentWindow = windowBaseX->mWindow;
877     WindowSystem::GetImplementation().SetTransientForHint(mWindow, parentWindow);
878   }
879   else
880   {
881     WindowSystem::GetImplementation().UnsetTransientFor(mWindow);
882   }
883 }
884
885 int WindowBaseX::CreateFrameRenderedSyncFence()
886 {
887   return -1;
888 }
889
890 int WindowBaseX::CreateFramePresentedSyncFence()
891 {
892   return -1;
893 }
894
895 void WindowBaseX::SetPositionSizeWithAngle(PositionSize positionSize, int angle)
896 {
897 }
898
899 void WindowBaseX::InitializeIme()
900 {
901 }
902
903 void WindowBaseX::ImeWindowReadyToRender()
904 {
905 }
906
907 void WindowBaseX::RequestMoveToServer()
908 {
909 }
910
911 void WindowBaseX::RequestResizeToServer(WindowResizeDirection direction)
912 {
913 }
914
915 void WindowBaseX::EnableFloatingMode(bool enable)
916 {
917 }
918
919 bool WindowBaseX::IsFloatingModeEnabled() const
920 {
921   return false;
922 }
923
924 void WindowBaseX::IncludeInputRegion(const Rect<int>& inputRegion)
925 {
926 }
927
928 void WindowBaseX::ExcludeInputRegion(const Rect<int>& inputRegion)
929 {
930 }
931
932 } // namespace Adaptor
933
934 } // namespace Internal
935
936 } // namespace Dali