[Tizen] Fix to get the logical key to ecore key variable
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / ubuntu-x11 / window-base-ecore-x.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 5f92464..edc82c8
@@ -29,6 +29,7 @@
 
 // EXTERNAL_HEADERS
 #include <dali/public-api/object/any.h>
+#include <dali/public-api/events/mouse-button.h>
 #include <dali/integration-api/debug.h>
 #include <Ecore_Input.h>
 
@@ -249,6 +250,7 @@ WindowBaseEcoreX::WindowBaseEcoreX( Dali::PositionSize positionSize, Any surface
 : mEcoreEventHandler(),
   mEcoreWindow( 0 ),
   mOwnSurface( false ),
+  mIsTransparent( false ), // Should only be set to true once we actually create a transparent window regardless of what isTransparent is.
   mRotationAppSet( false )
 {
   Initialize( positionSize, surface, isTransparent );
@@ -438,14 +440,6 @@ void WindowBaseEcoreX::OnMouseButtonDown( void* data, int type, void* event )
   {
     PointState::Type state ( PointState::DOWN );
 
-    // Check if the buttons field is set and ensure it's the primary touch button.
-    // If this event was triggered by buttons other than the primary button (used for touch), then
-    // just send an interrupted event to Core.
-    if( touchEvent->buttons && ( touchEvent->buttons != PRIMARY_TOUCH_BUTTON_ID ) )
-    {
-      state = PointState::INTERRUPTED;
-    }
-
     Integration::Point point;
     point.SetDeviceId( touchEvent->multi.device );
     point.SetState( state );
@@ -453,6 +447,10 @@ void WindowBaseEcoreX::OnMouseButtonDown( void* data, int type, void* event )
     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 ) );
+    if( touchEvent->buttons)
+    {
+      point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
+    }
 
     mTouchEventSignal.Emit( point, touchEvent->timestamp );
   }
@@ -471,6 +469,10 @@ void WindowBaseEcoreX::OnMouseButtonUp( void* data, int type, void* event )
     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 ) );
+    if( touchEvent->buttons)
+    {
+      point.SetMouseButton( static_cast< MouseButton::Type >( touchEvent->buttons) );
+    }
 
     mTouchEventSignal.Emit( point, touchEvent->timestamp );
   }
@@ -517,6 +519,7 @@ void WindowBaseEcoreX::OnKeyDown( void* data, int type, void* event )
     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseEcoreX::OnKeyDown\n" );
 
     std::string keyName( keyEvent->keyname );
+    std::string key( "" );
     std::string keyString( "" );
     std::string compose( "" );
 
@@ -526,6 +529,12 @@ void WindowBaseEcoreX::OnKeyDown( void* data, int type, void* event )
       compose = keyEvent->compose;
     }
 
+    // Ensure key symbol is not NULL as keys like SHIFT have a null string.
+    if( keyEvent->key )
+    {
+      key = keyEvent->key;
+    }
+
     int keyCode = ecore_x_keysym_keycode_get( keyEvent->keyname );
     int modifier( keyEvent->modifiers );
     unsigned long time = keyEvent->timestamp;
@@ -536,7 +545,7 @@ void WindowBaseEcoreX::OnKeyDown( void* data, int type, void* event )
       keyString = keyEvent->string;
     }
 
-    Integration::KeyEvent keyEvent( keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, compose, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS );
+    Integration::KeyEvent keyEvent( keyName, key, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, compose, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS );
 
     mKeyEventSignal.Emit( keyEvent );
   }
@@ -551,6 +560,7 @@ void WindowBaseEcoreX::OnKeyUp( void* data, int type, void* event )
     DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, " WindowBaseEcoreX::OnKeyUp\n" );
 
     std::string keyName( keyEvent->keyname );
+    std::string key( "" );
     std::string keyString( "" );
     std::string compose( "" );
 
@@ -559,6 +569,12 @@ void WindowBaseEcoreX::OnKeyUp( void* data, int type, void* event )
     {
       compose = keyEvent->compose;
     }
+    // Ensure key symbol is not NULL as keys like SHIFT have a null string.
+    if( keyEvent->key )
+    {
+      key = keyEvent->key;
+    }
+
     int keyCode = ecore_x_keysym_keycode_get( keyEvent->keyname );
     int modifier( keyEvent->modifiers );
     unsigned long time( keyEvent->timestamp );
@@ -569,7 +585,7 @@ void WindowBaseEcoreX::OnKeyUp( void* data, int type, void* event )
       keyString = keyEvent->string;
     }
 
-    Integration::KeyEvent keyEvent( keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, compose, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS );
+    Integration::KeyEvent keyEvent( keyName, key, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, compose, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS );
 
     mKeyEventSignal.Emit( keyEvent );
   }
@@ -920,6 +936,7 @@ void WindowBaseEcoreX::CreateWindow( PositionSize positionSize, bool isTranspare
  {
    // create 32 bit window
    mEcoreWindow = ecore_x_window_argb_new( 0, positionSize.x, positionSize.y, positionSize.width, positionSize.height );
+   mIsTransparent = true;
  }
  else
  {