[4.0] Add hide ime operate when exit or return key pressed
[platform/core/uifw/dali-adaptor.git] / adaptors / ecore / wayland / event-handler-ecore-wl.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 683f66f..4634859
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,6 +19,9 @@
 #include <events/event-handler.h>
 
 // EXTERNAL INCLUDES
+// Ecore is littered with C style cast
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
 #include <Ecore.h>
 #include <Ecore_Input.h>
 #include <ecore-wl-render-surface.h>
@@ -36,6 +39,7 @@
 #endif // DALI_ELDBUS_AVAILABLE
 
 #include <dali/public-api/common/vector-wrapper.h>
+#include <dali/public-api/events/device.h>
 #include <dali/public-api/events/touch-point.h>
 #include <dali/public-api/events/key-event.h>
 #include <dali/public-api/events/wheel-event.h>
@@ -44,7 +48,6 @@
 #include <dali/integration-api/events/touch-event-integ.h>
 #include <dali/integration-api/events/hover-event-integ.h>
 #include <dali/integration-api/events/wheel-event-integ.h>
-#include <dali/devel-api/events/key-event-devel.h>
 
 // INTERNAL INCLUDES
 #include <events/gesture-manager.h>
@@ -88,6 +91,110 @@ const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 );
 
 const unsigned int BYTES_PER_CHARACTER_FOR_ATTRIBUTES = 3;
 
+#ifdef DALI_ELDBUS_AVAILABLE
+// DBus gesture string matching lists.
+// TODO: This needs moving to its own module.
+const char * ElDBusAccessibilityFingerCountStrings[] =
+{
+  "OneFinger",
+  "TwoFingers",
+  "ThreeFingers"
+};
+const unsigned int FingerCountStringsTotal = sizeof( ElDBusAccessibilityFingerCountStrings ) / sizeof( ElDBusAccessibilityFingerCountStrings[0] );
+enum GestureType
+{
+  GESTURE_TYPE_NONE,
+  GESTURE_TYPE_HOVER,
+  GESTURE_TYPE_SINGLE_TAP,
+  GESTURE_TYPE_DOUBLE_TAP,
+  GESTURE_TYPE_TRIPLE_TAP
+};
+struct GestureTypeTable
+{
+  const char* name;
+  const GestureType type;
+};
+GestureTypeTable ElDBusAccessibilityFullEventTypeStrings[] =
+{
+  { "Hover",     GESTURE_TYPE_HOVER      },
+  { "SingleTap", GESTURE_TYPE_SINGLE_TAP },
+  { "DoubleTap", GESTURE_TYPE_DOUBLE_TAP },
+  { "TripleTap", GESTURE_TYPE_TRIPLE_TAP }
+};
+const unsigned int FullEventTypeStringsTotal = sizeof( ElDBusAccessibilityFullEventTypeStrings ) / sizeof( ElDBusAccessibilityFullEventTypeStrings[0] );
+enum SubGestureType
+{
+  SUB_GESTURE_TYPE_NONE,
+  SUB_GESTURE_TYPE_FLICK
+};
+struct SubGestureTypeTable
+{
+  const char* name;
+  const SubGestureType type;
+};
+SubGestureTypeTable ElDBusAccessibilityDirectionalEventTypeStrings[] =
+{
+  { "Flick", SUB_GESTURE_TYPE_FLICK }
+};
+const unsigned int DirectionalEventTypeStringsTotal = sizeof( ElDBusAccessibilityDirectionalEventTypeStrings ) / sizeof( ElDBusAccessibilityDirectionalEventTypeStrings[0] );
+enum GestureDirection
+{
+  GESTURE_DIRECTION_NONE,
+  GESTURE_DIRECTION_UP,
+  GESTURE_DIRECTION_DOWN,
+  GESTURE_DIRECTION_LEFT,
+  GESTURE_DIRECTION_RIGHT,
+  GESTURE_DIRECTION_UP_RETURN,
+  GESTURE_DIRECTION_DOWN_RETURN,
+  GESTURE_DIRECTION_LEFT_RETURN,
+  GESTURE_DIRECTION_RIGHT_RETURN
+};
+struct GestureDirectionTable
+{
+    const char* name;
+    const GestureDirection direction;
+};
+GestureDirectionTable ElDBusAccessibilityDirectionStrings[] =
+{
+  { "Up",           GESTURE_DIRECTION_UP           },
+  { "Down",         GESTURE_DIRECTION_DOWN         },
+  { "Left",         GESTURE_DIRECTION_LEFT         },
+  { "Right",        GESTURE_DIRECTION_RIGHT        },
+  { "UpReturn",     GESTURE_DIRECTION_UP_RETURN    },
+  { "DownReturn",   GESTURE_DIRECTION_DOWN_RETURN  },
+  { "LeftReturn",   GESTURE_DIRECTION_LEFT_RETURN  },
+  { "RightReturn",  GESTURE_DIRECTION_RIGHT_RETURN }
+};
+const unsigned int DirectionStringsTotal = sizeof( ElDBusAccessibilityDirectionStrings ) / sizeof( ElDBusAccessibilityDirectionStrings[0] );
+#endif // DALI_ELDBUS_AVAILABLE
+
+/**
+ * EcoreInputModifierToEcoreIMFLock function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Locks enums.
+ * @param[in] modifier the Ecore_Event_Modifier input.
+ * @return the Ecore_IMF_Keyboard_Locks output.
+ */
+Ecore_IMF_Keyboard_Locks EcoreInputModifierToEcoreIMFLock( unsigned int modifier )
+{
+    unsigned int lock( ECORE_IMF_KEYBOARD_LOCK_NONE ); // If no other matches, returns NONE.
+
+    if( modifier & ECORE_EVENT_LOCK_NUM )
+    {
+      lock |= ECORE_IMF_KEYBOARD_LOCK_NUM; // Num lock is active.
+    }
+
+    if( modifier & ECORE_EVENT_LOCK_CAPS )
+    {
+      lock |= ECORE_IMF_KEYBOARD_LOCK_CAPS; // Caps lock is active.
+    }
+
+    if( modifier & ECORE_EVENT_LOCK_SCROLL )
+    {
+      lock |= ECORE_IMF_KEYBOARD_LOCK_SCROLL; // Scroll lock is active.
+    }
+
+    return static_cast<Ecore_IMF_Keyboard_Locks>( lock );
+}
+
 /**
  * Ecore_Event_Modifier enums in Ecore_Input.h do not match Ecore_IMF_Keyboard_Modifiers in Ecore_IMF.h.
  * This function converts from Ecore_Event_Modifier to Ecore_IMF_Keyboard_Modifiers enums.
@@ -96,7 +203,7 @@ const unsigned int BYTES_PER_CHARACTER_FOR_ATTRIBUTES = 3;
  */
 Ecore_IMF_Keyboard_Modifiers EcoreInputModifierToEcoreIMFModifier(unsigned int ecoreModifier)
 {
-   int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE );  // If no other matches returns NONE.
+   unsigned int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE );  // If no other matches returns NONE.
 
 
    if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT )  // enums from ecore_input/Ecore_Input.h
@@ -171,7 +278,7 @@ const char * DALI_VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE = "db/setting/accessi
 /**
  * Get the device name from the provided ecore key event
  */
-void GetDeviceName(  Ecore_Event_Key* keyEvent, std::string& result )
+void GetDeviceName( Ecore_Event_Key* keyEvent, std::string& result )
 {
   const char* ecoreDeviceName = ecore_device_name_get( keyEvent->dev );
 
@@ -182,52 +289,124 @@ void GetDeviceName(  Ecore_Event_Key* keyEvent, std::string& result )
 }
 
 /**
- * Get the device class from the provided ecore key event
+ * Get the device class from the provided ecore event
  */
-void GetDeviceClass(  Ecore_Event_Key* keyEvent, DevelKeyEvent::DeviceClass::Type& deviceClass )
+void GetDeviceClass( Ecore_Device_Class ecoreDeviceClass, Device::Class::Type& deviceClass )
 {
-  Ecore_Device_Class ecoreDeviceClass = ecore_device_class_get( keyEvent->dev );
-
   switch( ecoreDeviceClass )
   {
     case ECORE_DEVICE_CLASS_SEAT:
     {
-      deviceClass = DevelKeyEvent::DeviceClass::USER;
+      deviceClass = Device::Class::USER;
       break;
     }
     case ECORE_DEVICE_CLASS_KEYBOARD:
     {
-      deviceClass = DevelKeyEvent::DeviceClass::KEYBOARD;
+      deviceClass = Device::Class::KEYBOARD;
       break;
     }
     case ECORE_DEVICE_CLASS_MOUSE:
     {
-      deviceClass = DevelKeyEvent::DeviceClass::MOUSE;
+      deviceClass = Device::Class::MOUSE;
       break;
     }
     case ECORE_DEVICE_CLASS_TOUCH:
     {
-      deviceClass = DevelKeyEvent::DeviceClass::TOUCH;
+      deviceClass = Device::Class::TOUCH;
       break;
     }
     case ECORE_DEVICE_CLASS_PEN:
     {
-      deviceClass = DevelKeyEvent::DeviceClass::PEN;
+      deviceClass = Device::Class::PEN;
       break;
     }
     case ECORE_DEVICE_CLASS_POINTER:
     {
-      deviceClass = DevelKeyEvent::DeviceClass::POINTER;
+      deviceClass = Device::Class::POINTER;
       break;
     }
     case ECORE_DEVICE_CLASS_GAMEPAD:
     {
-      deviceClass = DevelKeyEvent::DeviceClass::GAMEPAD;
+      deviceClass = Device::Class::GAMEPAD;
       break;
     }
     default:
     {
-      deviceClass = DevelKeyEvent::DeviceClass::NONE;
+      deviceClass = Device::Class::NONE;
+      break;
+    }
+  }
+}
+
+void GetDeviceSubclass( Ecore_Device_Subclass ecoreDeviceSubclass, Device::Subclass::Type& deviceSubclass )
+{
+  switch( ecoreDeviceSubclass )
+  {
+    case ECORE_DEVICE_SUBCLASS_FINGER:
+    {
+      deviceSubclass = Device::Subclass::FINGER;
+      break;
+    }
+    case ECORE_DEVICE_SUBCLASS_FINGERNAIL:
+    {
+      deviceSubclass = Device::Subclass::FINGERNAIL;
+      break;
+    }
+    case ECORE_DEVICE_SUBCLASS_KNUCKLE:
+    {
+      deviceSubclass = Device::Subclass::KNUCKLE;
+      break;
+    }
+    case ECORE_DEVICE_SUBCLASS_PALM:
+    {
+      deviceSubclass = Device::Subclass::PALM;
+      break;
+    }
+    case ECORE_DEVICE_SUBCLASS_HAND_SIZE:
+    {
+      deviceSubclass = Device::Subclass::HAND_SIDE;
+      break;
+    }
+    case ECORE_DEVICE_SUBCLASS_HAND_FLAT:
+    {
+      deviceSubclass = Device::Subclass::HAND_FLAT;
+      break;
+    }
+    case ECORE_DEVICE_SUBCLASS_PEN_TIP:
+    {
+      deviceSubclass = Device::Subclass::PEN_TIP;
+      break;
+    }
+    case ECORE_DEVICE_SUBCLASS_TRACKPAD:
+    {
+      deviceSubclass = Device::Subclass::TRACKPAD;
+      break;
+    }
+    case ECORE_DEVICE_SUBCLASS_TRACKPOINT:
+    {
+      deviceSubclass = Device::Subclass::TRACKPOINT;
+      break;
+    }
+    case ECORE_DEVICE_SUBCLASS_TRACKBALL:
+    {
+      deviceSubclass = Device::Subclass::TRACKBALL;
+      break;
+    }
+#ifdef OVER_TIZEN_VERSION_4
+    case ECORE_DEVICE_SUBCLASS_REMOCON:
+    {
+      deviceSubclass = Device::Subclass::REMOCON;
+      break;
+    }
+    case ECORE_DEVICE_SUBCLASS_VIRTUAL_KEYBOARD:
+    {
+      deviceSubclass = Device::Subclass::VIRTUAL_KEYBOARD;
+      break;
+    }
+#endif
+    default:
+    {
+      deviceSubclass = Device::Subclass::NONE;
       break;
     }
   }
@@ -246,7 +425,10 @@ struct EventHandler::Impl
   Impl( EventHandler* handler, Ecore_Wl_Window* window )
   : mHandler( handler ),
     mEcoreEventHandler(),
-    mWindow( window )
+    mWindow( window ),
+    mRotationAngle( 0 ),
+    mWindowWidth( 0 ),
+    mWindowHeight( 0 )
 #ifdef DALI_ELDBUS_AVAILABLE
   , mSystemConnection( NULL )
 #endif // DALI_ELDBUS_AVAILABLE
@@ -258,7 +440,6 @@ struct EventHandler::Impl
       mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_DOWN,   EcoreEventMouseButtonDown,   handler ) );
       mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_UP,     EcoreEventMouseButtonUp,     handler ) );
       mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_MOVE,          EcoreEventMouseButtonMove,   handler ) );
-      mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_OUT,           EcoreEventMouseButtonUp,     handler ) ); // process mouse out event like up event
       mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_EVENT_MOUSE_BUTTON_CANCEL, EcoreEventMouseButtonCancel, handler ) );
 
       // Register Mouse wheel events
@@ -350,6 +531,12 @@ struct EventHandler::Impl
         state = PointState::INTERRUPTED;
       }
 
+      Device::Class::Type deviceClass;
+      Device::Subclass::Type deviceSubclass;
+
+      GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
+      GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
+
       Integration::Point point;
       point.SetDeviceId( touchEvent->multi.device );
       point.SetState( state );
@@ -357,6 +544,9 @@ struct EventHandler::Impl
       point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
       point.SetPressure( touchEvent->multi.pressure );
       point.SetAngle( Degree( touchEvent->multi.angle ) );
+      point.SetDeviceClass( deviceClass );
+      point.SetDeviceSubclass( deviceSubclass );
+
       handler->SendEvent( point, touchEvent->timestamp );
     }
 
@@ -373,6 +563,12 @@ struct EventHandler::Impl
 
     if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
     {
+      Device::Class::Type deviceClass;
+      Device::Subclass::Type deviceSubclass;
+
+      GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
+      GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
+
       Integration::Point point;
       point.SetDeviceId( touchEvent->multi.device );
       point.SetState( PointState::UP );
@@ -380,6 +576,9 @@ struct EventHandler::Impl
       point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
       point.SetPressure( touchEvent->multi.pressure );
       point.SetAngle( Degree( touchEvent->multi.angle ) );
+      point.SetDeviceClass( deviceClass );
+      point.SetDeviceSubclass( deviceSubclass );
+
       handler->SendEvent( point, touchEvent->timestamp );
     }
 
@@ -396,6 +595,12 @@ struct EventHandler::Impl
 
     if ( touchEvent->window == (unsigned int)ecore_wl_window_id_get(handler->mImpl->mWindow) )
     {
+      Device::Class::Type deviceClass;
+      Device::Subclass::Type deviceSubclass;
+
+      GetDeviceClass( ecore_device_class_get( touchEvent->dev ), deviceClass );
+      GetDeviceSubclass( ecore_device_subclass_get( touchEvent->dev ), deviceSubclass );
+
       Integration::Point point;
       point.SetDeviceId( touchEvent->multi.device );
       point.SetState( PointState::MOTION );
@@ -403,6 +608,9 @@ struct EventHandler::Impl
       point.SetRadius( touchEvent->multi.radius, Vector2( touchEvent->multi.radius_x, touchEvent->multi.radius_y ) );
       point.SetPressure( touchEvent->multi.pressure );
       point.SetAngle( Degree( touchEvent->multi.angle ) );
+      point.SetDeviceClass( deviceClass );
+      point.SetDeviceSubclass( deviceSubclass );
+
       handler->SendEvent( point, touchEvent->timestamp );
     }
 
@@ -420,9 +628,8 @@ struct EventHandler::Impl
     if( touchEvent->window == (unsigned int)ecore_wl_window_id_get( handler->mImpl->mWindow ) )
     {
       Integration::Point point;
-      point.SetDeviceId( touchEvent->multi.device );
       point.SetState( PointState::INTERRUPTED );
-      point.SetScreenPosition( Vector2( 0.0f, 0.0f ) );
+      point.SetScreenPosition( Vector2( touchEvent->x, touchEvent->y ) );
       handler->SendEvent( point, touchEvent->timestamp );
 
       DALI_LOG_INFO( gImfLogging, Debug::General, "EVENT EcoreEventMouseButtonCancel\n" );
@@ -484,24 +691,38 @@ struct EventHandler::Impl
         ecoreKeyDownEvent.compose   = keyEvent->compose;
         ecoreKeyDownEvent.timestamp = keyEvent->timestamp;
         ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
-        ecoreKeyDownEvent.locks     = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
-#ifdef ECORE_IMF_1_13
-        ecoreKeyDownEvent.dev_name  = "";
-        ecoreKeyDownEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD;
-        ecoreKeyDownEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE;
-#endif // ECORE_IMF_1_13
-
-        eventHandled = ecore_imf_context_filter_event( imfContext,
-                                                       ECORE_IMF_EVENT_KEY_DOWN,
-                                                       (Ecore_IMF_Event *) &ecoreKeyDownEvent );
+        ecoreKeyDownEvent.locks     = EcoreInputModifierToEcoreIMFLock( keyEvent->modifiers );
+        ecoreKeyDownEvent.dev_name  = ecore_device_name_get( keyEvent->dev );
+        ecoreKeyDownEvent.dev_class = static_cast<Ecore_IMF_Device_Class>( ecore_device_class_get( keyEvent->dev ) );
+        ecoreKeyDownEvent.dev_subclass = static_cast<Ecore_IMF_Device_Subclass>( ecore_device_subclass_get( keyEvent->dev ) );
+
+        std::string checkDevice;
+        GetDeviceName( keyEvent, checkDevice );
+
+        // If the device is IME and the focused key is the direction keys, then we should send a key event to move a key cursor.
+        if( ( checkDevice == "ime" ) && ( ( !strncmp( keyEvent->keyname, "Left",  4 ) ) ||
+                                          ( !strncmp( keyEvent->keyname, "Right", 5 ) ) ||
+                                          ( !strncmp( keyEvent->keyname, "Up",    2 ) ) ||
+                                          ( !strncmp( keyEvent->keyname, "Down",  4 ) ) ) )
+        {
+          eventHandled = 0;
+        }
+        else
+        {
+          eventHandled = ecore_imf_context_filter_event( imfContext,
+                                                         ECORE_IMF_EVENT_KEY_DOWN,
+                                                         (Ecore_IMF_Event *) &ecoreKeyDownEvent );
+        }
 
         // If the event has not been handled by IMF then check if we should reset our IMF context
         if( !eventHandled )
         {
           if ( !strcmp( keyEvent->keyname, "Escape"   ) ||
                !strcmp( keyEvent->keyname, "Return"   ) ||
-               !strcmp( keyEvent->keyname, "KP_Enter" ) )
+               !strcmp( keyEvent->keyname, "KP_Enter" ) ||
+               !strcmp( keyEvent->keyname, "XF86Exit" ) )
           {
+            ecore_imf_context_input_panel_hide( imfContext );
             ecore_imf_context_reset( imfContext );
           }
         }
@@ -529,14 +750,16 @@ struct EventHandler::Impl
         }
 
         std::string deviceName;
-        DevelKeyEvent::DeviceClass::Type deviceClass;
+        Device::Class::Type deviceClass;
+        Device::Subclass::Type deviceSubclass;
 
         GetDeviceName( keyEvent, deviceName );
-        GetDeviceClass( keyEvent, deviceClass );
+        GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
+        GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
 
         DALI_LOG_INFO( gImfLogging, Debug::Verbose, "EVENT EcoreEventKeyDown - >>EcoreEventKeyDown deviceName(%s) deviceClass(%d)\n", deviceName.c_str(), deviceClass );
 
-        Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, deviceName, deviceClass );
+        Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, deviceName, deviceClass, deviceSubclass );
         handler->SendEvent( keyEvent );
       }
     }
@@ -575,12 +798,10 @@ struct EventHandler::Impl
         ecoreKeyUpEvent.compose   = keyEvent->compose;
         ecoreKeyUpEvent.timestamp = keyEvent->timestamp;
         ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier ( keyEvent->modifiers );
-        ecoreKeyUpEvent.locks     = (Ecore_IMF_Keyboard_Locks) ECORE_IMF_KEYBOARD_LOCK_NONE;
-#ifdef ECORE_IMF_1_13
-        ecoreKeyUpEvent.dev_name  = "";
-        ecoreKeyUpEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD;
-        ecoreKeyUpEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE;
-#endif // ECORE_IMF_1_13
+        ecoreKeyUpEvent.locks     = EcoreInputModifierToEcoreIMFLock( keyEvent->modifiers );
+        ecoreKeyUpEvent.dev_name  = ecore_device_name_get( keyEvent->dev );
+        ecoreKeyUpEvent.dev_class = static_cast<Ecore_IMF_Device_Class>( ecore_device_class_get( keyEvent->dev ) );
+        ecoreKeyUpEvent.dev_subclass = static_cast<Ecore_IMF_Device_Subclass>( ecore_device_subclass_get( keyEvent->dev ) );
 
         eventHandled = ecore_imf_context_filter_event( imfContext,
                                                        ECORE_IMF_EVENT_KEY_UP,
@@ -609,12 +830,14 @@ struct EventHandler::Impl
         }
 
         std::string deviceName;
-        DevelKeyEvent::DeviceClass::Type deviceClass;
+        Device::Class::Type deviceClass;
+        Device::Subclass::Type deviceSubclass;
 
         GetDeviceName( keyEvent, deviceName );
-        GetDeviceClass( keyEvent, deviceClass );
+        GetDeviceClass( ecore_device_class_get( keyEvent->dev ), deviceClass );
+        GetDeviceSubclass( ecore_device_subclass_get( keyEvent->dev ), deviceSubclass );
 
-        Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, deviceName, deviceClass );
+        Integration::KeyEvent keyEvent(keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, deviceName, deviceClass, deviceSubclass );
         handler->SendEvent( keyEvent );
       }
     }
@@ -1173,8 +1396,18 @@ struct EventHandler::Impl
     RotationEvent rotationEvent;
     rotationEvent.angle = ev->angle;
     rotationEvent.winResize = 0;
-    rotationEvent.width = ev->w;
-    rotationEvent.height = ev->h;
+
+    if( ev->angle == 0 || ev->angle == 180 )
+    {
+      rotationEvent.width = ev->w;
+      rotationEvent.height = ev->h;
+    }
+    else
+    {
+      rotationEvent.width = ev->h;
+      rotationEvent.height = ev->w;
+    }
+
     handler->SendRotationPrepareEvent( rotationEvent );
 
     return ECORE_CALLBACK_PASS_ON;
@@ -1217,10 +1450,48 @@ struct EventHandler::Impl
     handler->SendEvent( StyleChange::DEFAULT_FONT_SIZE_CHANGE );
   }
 
+  void ConvertTouchPosition( Integration::Point& point )
+  {
+    Vector2 position = point.GetScreenPosition();
+    Vector2 convertedPosition;
+
+    switch( mRotationAngle )
+    {
+      case 90:
+      {
+        convertedPosition.x = mWindowWidth - position.y;
+        convertedPosition.y = position.x;
+        break;
+      }
+      case 180:
+      {
+        convertedPosition.x = mWindowWidth - position.x;
+        convertedPosition.y = mWindowHeight - position.y;
+        break;
+      }
+      case 270:
+      {
+        convertedPosition.x = position.y;
+        convertedPosition.y = mWindowHeight - position.x;
+        break;
+      }
+      default:
+      {
+        convertedPosition = position;
+        break;
+      }
+    }
+
+    point.SetScreenPosition( convertedPosition );
+  }
+
   // Data
   EventHandler* mHandler;
   std::vector<Ecore_Event_Handler*> mEcoreEventHandler;
   Ecore_Wl_Window* mWindow;
+  int mRotationAngle;
+  int mWindowWidth;
+  int mWindowHeight;
 #ifdef DALI_ELDBUS_AVAILABLE
   Eldbus_Connection* mSystemConnection;
 #endif // DALI_ELDBUS_AVAILABLE
@@ -1268,12 +1539,14 @@ void EventHandler::SendEvent(Integration::Point& point, unsigned long timeStamp)
     timeStamp = GetCurrentMilliSeconds();
   }
 
+  mImpl->ConvertTouchPosition( point );
+
   Integration::TouchEvent touchEvent;
   Integration::HoverEvent hoverEvent;
   Integration::TouchEventCombiner::EventDispatchType type = mCombiner.GetNextTouchEvent(point, timeStamp, touchEvent, hoverEvent);
   if(type != Integration::TouchEventCombiner::DispatchNone )
   {
-    DALI_LOG_INFO(gTouchEventLogFilter, Debug::General, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.GetDeviceId(), point.GetState(), point.GetLocalPosition().x, point.GetLocalPosition().y);
+    DALI_LOG_INFO(gTouchEventLogFilter, Debug::General, "%d: Device %d: Button state %d (%.2f, %.2f)\n", timeStamp, point.GetDeviceId(), point.GetState(), point.GetScreenPosition().x, point.GetScreenPosition().y);
 
     // First the touch and/or hover event & related gesture events are queued
     if(type == Integration::TouchEventCombiner::DispatchTouch || type == Integration::TouchEventCombiner::DispatchBoth)
@@ -1331,6 +1604,10 @@ void EventHandler::SendRotationPrepareEvent( const RotationEvent& event )
 {
   if( mRotationObserver != NULL )
   {
+    mImpl->mRotationAngle = event.angle;
+    mImpl->mWindowWidth = event.width;
+    mImpl->mWindowHeight = event.height;
+
     mRotationObserver->OnRotationPrepare( event );
     mRotationObserver->OnRotationRequest();
   }
@@ -1409,3 +1686,5 @@ void EventHandler::SetRotationObserver( RotationObserver* observer )
 } // namespace Internal
 
 } // namespace Dali
+
+#pragma GCC diagnostic pop