[dali_1.0.1] Merge branch 'tizen'
[platform/core/uifw/dali-adaptor.git] / adaptors / x11 / window-impl-x.cpp
1 /*
2  * Copyright (c) 2014 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 "window-impl.h"
20
21 // EXTERNAL HEADERS
22 #include <Ecore.h>
23 #include <Ecore_X.h>
24
25 #include <dali/integration-api/core.h>
26 #include <dali/integration-api/system-overlay.h>
27 #include <dali/public-api/render-tasks/render-task.h>
28 #include <dali/public-api/render-tasks/render-task-list.h>
29 #include <orientation.h>
30
31 // INTERNAL HEADERS
32 #include <window-render-surface.h>
33 #include <drag-and-drop-detector-impl.h>
34 #include <indicator-impl.h>
35 #include <window-visibility-observer.h>
36 #include <orientation-impl.h>
37
38 namespace
39 {
40 const float INDICATOR_ANIMATION_DURATION( 0.18f ); // 180 milli seconds
41 const float INDICATOR_SHOW_Y_POSITION( 0.0f );
42 const float INDICATOR_HIDE_Y_POSITION( -52.0f );
43 }
44
45 namespace Dali
46 {
47 namespace Internal
48 {
49 namespace Adaptor
50 {
51 #if defined(DEBUG_ENABLED)
52 Debug::Filter* gWindowLogFilter = Debug::Filter::New(Debug::Concise, false, "LOG_WINDOW");
53 #endif
54
55 /**
56  * TODO: Abstract Window class out and move this into a window implementation for Ecore
57  */
58 struct Window::EventHandler
59 {
60   /**
61    * Constructor
62    * @param[in]  window  A pointer to the window class.
63    */
64   EventHandler( Window* window )
65   : mWindow( window ),
66     mWindowPropertyHandler( ecore_event_handler_add( ECORE_X_EVENT_WINDOW_PROPERTY,  EcoreEventWindowPropertyChanged, this ) ),
67     mClientMessagehandler( ecore_event_handler_add( ECORE_X_EVENT_CLIENT_MESSAGE,  EcoreEventClientMessage, this ) ),
68     mEcoreWindow( 0 )
69   {
70     // store ecore window handle
71     ECore::WindowRenderSurface* x11Window( dynamic_cast< ECore::WindowRenderSurface * >( mWindow->mSurface ) );
72     if( x11Window )
73     {
74       mEcoreWindow = x11Window->GetXWindow();
75     }
76     DALI_ASSERT_ALWAYS( mEcoreWindow != 0 && "There is no ecore x window");
77
78     // set property on window to get deiconify approve client message
79     unsigned int tmp = 1;
80     ecore_x_window_prop_card32_set(mEcoreWindow,
81                              ECORE_X_ATOM_E_DEICONIFY_APPROVE,
82                              &tmp, 1);
83   }
84
85   /**
86    * Destructor
87    */
88   ~EventHandler()
89   {
90     if ( mWindowPropertyHandler )
91     {
92       ecore_event_handler_del( mWindowPropertyHandler );
93     }
94     if ( mClientMessagehandler )
95     {
96       ecore_event_handler_del( mClientMessagehandler );
97     }
98   }
99
100   // Static methods
101
102   /// Called when the window properties are changed.
103   static Eina_Bool EcoreEventWindowPropertyChanged( void* data, int type, void* event )
104   {
105     Ecore_X_Event_Window_Property* propertyChangedEvent( (Ecore_X_Event_Window_Property*)event );
106     EventHandler* handler( (EventHandler*)data );
107     Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
108
109     if ( handler && handler->mWindow )
110     {
111       WindowVisibilityObserver* observer( handler->mWindow->mAdaptor );
112       if ( observer && ( propertyChangedEvent->win == handler->mEcoreWindow ) )
113       {
114         Ecore_X_Window_State_Hint state( ecore_x_icccm_state_get( propertyChangedEvent->win ) );
115
116         switch ( state )
117         {
118           case ECORE_X_WINDOW_STATE_HINT_WITHDRAWN:
119           {
120             // Window was hidden.
121             observer->OnWindowHidden();
122             DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Withdrawn\n", handler->mEcoreWindow );
123             handled = ECORE_CALLBACK_DONE;
124           }
125           break;
126
127           case ECORE_X_WINDOW_STATE_HINT_ICONIC:
128           {
129             // Window was iconified (minimised).
130             observer->OnWindowHidden();
131             DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Iconfied\n", handler->mEcoreWindow );
132             handled = ECORE_CALLBACK_DONE;
133           }
134           break;
135
136           case ECORE_X_WINDOW_STATE_HINT_NORMAL:
137           {
138             // Window was shown.
139             observer->OnWindowShown();
140             DALI_LOG_INFO( gWindowLogFilter, Debug::General, "Window (%d) Shown\n", handler->mEcoreWindow );
141             handled = ECORE_CALLBACK_DONE;
142           }
143           break;
144
145           default:
146             // Ignore
147             break;
148         }
149       }
150     }
151
152     return handled;
153   }
154
155   /// Called when the window properties are changed.
156   static Eina_Bool EcoreEventClientMessage( void* data, int type, void* event )
157   {
158     Eina_Bool handled( ECORE_CALLBACK_PASS_ON );
159     Ecore_X_Event_Client_Message* clientMessageEvent( (Ecore_X_Event_Client_Message*)event );
160     EventHandler* handler( (EventHandler*)data );
161
162     if (clientMessageEvent->message_type == ECORE_X_ATOM_E_DEICONIFY_APPROVE)
163     {
164       ECore::WindowRenderSurface* x11Window( dynamic_cast< ECore::WindowRenderSurface * >( handler->mWindow->mSurface ) );
165       WindowVisibilityObserver* observer( handler->mWindow->mAdaptor );
166
167       if ( observer && ( (unsigned int)clientMessageEvent->data.l[0] == handler->mEcoreWindow ) )
168       {
169         if (clientMessageEvent->data.l[1] == 0) //wm sends request message using value 0
170         {
171           observer->OnWindowShown();
172
173           // request to approve the deiconify. render-surface should send proper event after real rendering
174           if(x11Window)
175           {
176             x11Window->RequestToApproveDeiconify();
177           }
178
179           handled = ECORE_CALLBACK_DONE;
180         }
181       }
182     }
183
184     return handled;
185   }
186
187   // Data
188   Window* mWindow;
189   Ecore_Event_Handler* mWindowPropertyHandler;
190   Ecore_Event_Handler* mClientMessagehandler;
191   Ecore_X_Window mEcoreWindow;
192 };
193
194
195 Window* Window::New(const PositionSize& posSize, const std::string& name, bool isTransparent)
196 {
197   Window* window = new Window();
198   window->mIsTransparent = isTransparent;
199   window->Initialize(posSize, name);
200   return window;
201 }
202
203 void Window::SetAdaptor(Dali::Adaptor& adaptor)
204 {
205   DALI_ASSERT_ALWAYS( !mStarted && "Adaptor already started" );
206   mStarted = true;
207
208   // Only create one overlay per window
209   Internal::Adaptor::Adaptor& adaptorImpl = Internal::Adaptor::Adaptor::GetImplementation(adaptor);
210   Integration::Core& core = adaptorImpl.GetCore();
211   mOverlay = &core.GetSystemOverlay();
212
213   Dali::RenderTaskList taskList = mOverlay->GetOverlayRenderTasks();
214   taskList.CreateTask();
215
216   mAdaptor = &adaptorImpl;
217   mAdaptor->AddObserver( *this );
218
219   // Can only create the detector when we know the Core has been instantiated.
220   mDragAndDropDetector = DragAndDropDetector::New();
221   mAdaptor->SetDragAndDropDetector( &GetImplementation( mDragAndDropDetector ) );
222
223   if( mOrientation )
224   {
225     mOrientation->SetAdaptor(adaptor);
226   }
227
228   if( mIndicator != NULL )
229   {
230     mIndicator->SetAdaptor(mAdaptor);
231   }
232 }
233
234 RenderSurface* Window::GetSurface()
235 {
236   return mSurface;
237 }
238
239 void Window::SetIndicatorStyle( Dali::Window::IndicatorStyle style )
240 {
241   mIndicatorStyle = style;
242 }
243
244 void Window::ShowIndicator( bool show )
245 {
246   DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "%s\n", show?"SHOW":"HIDE" );
247   DALI_ASSERT_DEBUG(mOverlay);
248
249   if(show)
250   {
251     mIndicatorVisible = Dali::Window::VISIBLE;
252   }
253   else
254   {
255     mIndicatorVisible = Dali::Window::INVISIBLE;
256   }
257
258   DoShowIndicator( mIndicatorOrientation );
259 }
260
261 void Window::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode )
262 {
263   DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "visible : %d\n", visibleMode );
264   DALI_ASSERT_DEBUG(mOverlay);
265
266   ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
267   DALI_ASSERT_DEBUG(x11Window);
268   Ecore_X_Window xWinId = x11Window->GetXWindow();
269
270   mIndicatorVisible = visibleMode;
271
272   if ( mIndicatorVisible == Dali::Window::VISIBLE )
273   {
274     // when the indicator is visible, set proper mode for indicator server according to bg mode
275     if ( mIndicatorOpacityMode == Dali::Window::OPAQUE )
276     {
277       ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_OPAQUE);
278     }
279     else if ( mIndicatorOpacityMode == Dali::Window::TRANSLUCENT )
280     {
281       ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT);
282     }
283 #if defined(DALI_PROFILE_MOBILE)
284     else if ( mIndicatorOpacityMode == Dali::Window::TRANSPARENT )
285     {
286       ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_BG_TRANSPARENT);
287     }
288 #endif
289   }
290   else
291   {
292     // when the indicator is not visible, set TRANSPARENT mode for indicator server
293     ecore_x_e_illume_indicator_opacity_set(xWinId, ECORE_X_ILLUME_INDICATOR_TRANSPARENT); // it means hidden indicator
294   }
295
296   DoShowIndicator( mIndicatorOrientation );
297 }
298
299 void Window::RotateIndicator(Dali::Window::WindowOrientation orientation)
300 {
301   DALI_LOG_TRACE_METHOD_FMT( gWindowLogFilter, "Orientation: %d\n", orientation );
302
303   DoRotateIndicator( orientation );
304 }
305
306 void Window::SetIndicatorBgOpacity( Dali::Window::IndicatorBgOpacity opacityMode )
307 {
308   mIndicatorOpacityMode = opacityMode;
309
310   if( mIndicator != NULL )
311   {
312     mIndicator->SetOpacityMode( opacityMode );
313   }
314 }
315
316 void Window::SetClass(std::string name, std::string klass)
317 {
318   // Get render surface's x11 window
319   if( mSurface )
320   {
321     ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
322     if( x11Window )
323     {
324       ecore_x_icccm_name_class_set( x11Window->GetXWindow(), name.c_str(), klass.c_str() );
325     }
326   }
327 }
328
329 Window::Window()
330 : mSurface(NULL),
331   mIndicatorStyle(Dali::Window::CHANGEABLE_COLOR),
332   mIndicatorVisible(Dali::Window::VISIBLE),
333   mIndicatorIsShown(false),
334   mShowRotatedIndicatorOnClose(false),
335   mStarted(false),
336   mIsTransparent(false),
337   mWMRotationAppSet(false),
338   mIndicator(NULL),
339   mIndicatorOrientation(Dali::Window::PORTRAIT),
340   mNextIndicatorOrientation(Dali::Window::PORTRAIT),
341   mIndicatorOpacityMode(Dali::Window::OPAQUE),
342   mOverlay(NULL),
343   mAdaptor(NULL)
344 {
345 }
346
347 Window::~Window()
348 {
349   delete mEventHandler;
350
351   if ( mAdaptor )
352   {
353     mAdaptor->RemoveObserver( *this );
354     mAdaptor->SetDragAndDropDetector( NULL );
355     mAdaptor = NULL;
356   }
357
358   delete mSurface;
359 }
360
361 void Window::Initialize(const PositionSize& windowPosition, const std::string& name)
362 {
363   // create an X11 window by default
364   Any surface;
365   Any display;
366   mSurface = new ECore::WindowRenderSurface( windowPosition, surface, display, name, mIsTransparent );
367   mOrientation = Orientation::New(this);
368
369   // create event handler for X11 window
370   mEventHandler = new EventHandler( this );
371 }
372
373 void Window::DoShowIndicator( Dali::Window::WindowOrientation lastOrientation )
374 {
375   if( mIndicator == NULL )
376   {
377     if( mIndicatorVisible != Dali::Window::INVISIBLE )
378     {
379       mIndicator = new Indicator( mAdaptor, mIndicatorOrientation, mIndicatorStyle, this );
380       mIndicator->SetOpacityMode( mIndicatorOpacityMode );
381       Dali::Actor actor = mIndicator->GetActor();
382       SetIndicatorActorRotation();
383       mOverlay->Add(actor);
384     }
385     // else don't create a hidden indicator
386   }
387   else // Already have indicator
388   {
389     if( mIndicatorVisible == Dali::Window::VISIBLE )
390     {
391       // If we are resuming, and rotation has changed,
392       if( mIndicatorIsShown == false && mIndicatorOrientation != mNextIndicatorOrientation )
393       {
394         // then close current indicator and open new one
395         mShowRotatedIndicatorOnClose = true;
396         mIndicator->Close(); // May synchronously call IndicatorClosed() callback & 1 level of recursion
397         // Don't show actor - will contain indicator for old orientation.
398       }
399     }
400   }
401
402   // set indicator visible mode
403   if( mIndicator != NULL )
404   {
405     mIndicator->SetVisible( mIndicatorVisible );
406   }
407
408   bool show = (mIndicatorVisible != Dali::Window::INVISIBLE );
409   SetIndicatorProperties( show, lastOrientation );
410   mIndicatorIsShown = show;
411 }
412
413 void Window::DoRotateIndicator( Dali::Window::WindowOrientation orientation )
414 {
415   if( mIndicatorIsShown )
416   {
417     mShowRotatedIndicatorOnClose = true;
418     mNextIndicatorOrientation = orientation;
419     mIndicator->Close(); // May synchronously call IndicatorClosed() callback
420   }
421   else
422   {
423     // Save orientation for when the indicator is next shown
424     mShowRotatedIndicatorOnClose = false;
425     mNextIndicatorOrientation = orientation;
426   }
427 }
428
429 void Window::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation )
430 {
431   ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
432   if( x11Window )
433   {
434     Ecore_X_Window win = x11Window->GetXWindow();
435
436     int show_state = static_cast<int>( isShow );
437     ecore_x_window_prop_property_set( win,
438                                       ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE,
439                                       ECORE_X_ATOM_CARDINAL, 32, &show_state, 1);
440
441     if ( isShow )
442     {
443       ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_ON);
444     }
445     else
446     {
447       ecore_x_e_illume_indicator_state_set(win, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
448     }
449   }
450 }
451
452 void Window::IndicatorTypeChanged(Indicator::Type type)
453 {
454   ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
455   if( x11Window )
456   {
457     Ecore_X_Window win = x11Window->GetXWindow();
458     switch(type)
459     {
460       case Indicator::INDICATOR_TYPE_1:
461         ecore_x_e_illume_indicator_type_set( win, ECORE_X_ILLUME_INDICATOR_TYPE_1 );
462         break;
463
464       case Indicator::INDICATOR_TYPE_2:
465         ecore_x_e_illume_indicator_type_set( win, ECORE_X_ILLUME_INDICATOR_TYPE_2 );
466         break;
467
468       case Indicator::INDICATOR_TYPE_UNKNOWN:
469       default:
470         break;
471     }
472   }
473 }
474
475 void Window::IndicatorClosed( Indicator* indicator )
476 {
477   DALI_LOG_TRACE_METHOD( gWindowLogFilter );
478
479   if( mShowRotatedIndicatorOnClose )
480   {
481     Dali::Window::WindowOrientation currentOrientation = mIndicatorOrientation;
482     mIndicator->Open(mNextIndicatorOrientation);
483     mIndicatorOrientation = mNextIndicatorOrientation;
484     SetIndicatorActorRotation();
485     DoShowIndicator(currentOrientation);
486   }
487 }
488
489 void Window::SetIndicatorActorRotation()
490 {
491   DALI_LOG_TRACE_METHOD( gWindowLogFilter );
492   DALI_ASSERT_DEBUG( mIndicator != NULL );
493
494   Dali::Actor actor = mIndicator->GetActor();
495   switch( mIndicatorOrientation )
496   {
497     case Dali::Window::PORTRAIT:
498       actor.SetParentOrigin( ParentOrigin::TOP_CENTER );
499       actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
500       actor.SetRotation( Degree(0), Vector3::ZAXIS );
501       break;
502     case Dali::Window::PORTRAIT_INVERSE:
503       actor.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
504       actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
505       actor.SetRotation( Degree(180), Vector3::ZAXIS );
506       break;
507     case Dali::Window::LANDSCAPE:
508       actor.SetParentOrigin( ParentOrigin::CENTER_LEFT );
509       actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
510       actor.SetRotation( Degree(270), Vector3::ZAXIS );
511       break;
512     case Dali::Window::LANDSCAPE_INVERSE:
513       actor.SetParentOrigin( ParentOrigin::CENTER_RIGHT );
514       actor.SetAnchorPoint(  AnchorPoint::TOP_CENTER );
515       actor.SetRotation( Degree(90), Vector3::ZAXIS );
516       break;
517   }
518 }
519
520 void Window::Raise()
521 {
522   ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
523   if( x11Window )
524   {
525     Ecore_X_Window win = x11Window->GetXWindow();
526     ecore_x_window_raise(win);
527   }
528 }
529
530 void Window::Lower()
531 {
532   ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
533   if( x11Window )
534   {
535     Ecore_X_Window win = x11Window->GetXWindow();
536     ecore_x_window_lower(win);
537   }
538 }
539
540 void Window::Activate()
541 {
542   ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
543   if( x11Window )
544   {
545     Ecore_X_Window win = x11Window->GetXWindow();
546     ecore_x_netwm_client_active_request(ecore_x_window_root_get(win), win, 1 /* request type, 1:application, 2:pager */, 0);
547   }
548 }
549
550 Dali::DragAndDropDetector Window::GetDragAndDropDetector() const
551 {
552   return mDragAndDropDetector;
553 }
554
555 void Window::OnStart()
556 {
557   DoShowIndicator( mIndicatorOrientation );
558 }
559
560 void Window::OnPause()
561 {
562 }
563
564 void Window::OnResume()
565 {
566   // resume indicator status
567   if( mIndicator != NULL )
568   {
569     // Restore own indicator opacity
570     // Send opacity mode to indicator service when app resumed
571     mIndicator->SetOpacityMode( mIndicatorOpacityMode );
572   }
573 }
574
575 void Window::OnStop()
576 {
577   if( mIndicator )
578   {
579     mIndicator->Close();
580   }
581
582   delete mIndicator;
583   mIndicator = NULL;
584 }
585
586 void Window::OnDestroy()
587 {
588   mAdaptor = NULL;
589 }
590
591 OrientationPtr Window::GetOrientation()
592 {
593   return mOrientation;
594 }
595
596 void Window::AddAvailableOrientation(Dali::Window::WindowOrientation orientation)
597 {
598   bool found = false;
599
600   for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
601   {
602     if(mAvailableOrientations[i] == orientation)
603     {
604       found = true;
605       break;
606     }
607   }
608
609   if( ! found )
610   {
611     mAvailableOrientations.push_back(orientation);
612     SetAvailableOrientations( mAvailableOrientations );
613   }
614 }
615
616 void Window::RemoveAvailableOrientation(Dali::Window::WindowOrientation orientation)
617 {
618   for( std::vector<Dali::Window::WindowOrientation>::iterator iter = mAvailableOrientations.begin();
619        iter != mAvailableOrientations.end(); ++iter )
620   {
621     if( *iter == orientation )
622     {
623       mAvailableOrientations.erase( iter );
624       break;
625     }
626   }
627   SetAvailableOrientations( mAvailableOrientations );
628 }
629
630 void Window::SetAvailableOrientations(const std::vector<Dali::Window::WindowOrientation>& orientations)
631 {
632   DALI_ASSERT_ALWAYS( mAvailableOrientations.size() <= 4 && "Incorrect number of available orientations" );
633
634   mAvailableOrientations = orientations;
635   ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
636   if( x11Window )
637   {
638     Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
639     if( ! mWMRotationAppSet )
640     {
641       mWMRotationAppSet = true;
642       ecore_x_e_window_rotation_app_set(ecoreWindow, EINA_TRUE);
643     }
644
645     int rotations[4];
646     for( std::size_t i=0; i<mAvailableOrientations.size(); i++ )
647     {
648       rotations[i] = static_cast<int>(mAvailableOrientations[i]);
649     }
650     ecore_x_e_window_rotation_available_rotations_set(ecoreWindow, rotations, mAvailableOrientations.size() );
651
652   }
653 }
654
655 const std::vector<Dali::Window::WindowOrientation>& Window::GetAvailableOrientations()
656 {
657   return mAvailableOrientations;
658 }
659
660 void Window::SetPreferredOrientation(Dali::Window::WindowOrientation orientation)
661 {
662   mPreferredOrientation = orientation;
663
664   ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
665   if( x11Window )
666   {
667     Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
668
669     if( ! mWMRotationAppSet )
670     {
671       mWMRotationAppSet = true;
672       ecore_x_e_window_rotation_app_set(ecoreWindow, EINA_TRUE);
673     }
674
675     ecore_x_e_window_rotation_preferred_rotation_set(ecoreWindow, orientation);
676   }
677 }
678
679 Dali::Window::WindowOrientation Window::GetPreferredOrientation()
680 {
681   return mPreferredOrientation;
682 }
683
684 void Window::RotationDone( int orientation, int width, int height )
685 {
686   // Tell window manager we're done
687   ECore::WindowRenderSurface* x11Window = dynamic_cast< ECore::WindowRenderSurface * >( mSurface );
688   if( x11Window )
689   {
690     Ecore_X_Window ecoreWindow = x11Window->GetXWindow();
691     Ecore_X_Window root = ecore_x_window_root_get(ecoreWindow);
692
693     /**
694      * send rotation done message to wm, even if window is already rotated.
695      * that's why wm must be wait for comming rotation done message
696      * after sending rotation request.
697      */
698     ecore_x_e_window_rotation_change_done_send(root, ecoreWindow, orientation, width, height);
699
700     /**
701      * set rotate window property
702      */
703     int angles[2] = { orientation, orientation };
704     ecore_x_window_prop_property_set( ecoreWindow,
705                                      ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE,
706                                      ECORE_X_ATOM_CARDINAL, 32, &angles, 2 );
707   }
708 }
709
710
711 } // Adaptor
712 } // Internal
713 } // Dali