Revert "[Tizen] Added 'make clean' on each profile build."
[platform/core/uifw/dali-adaptor.git] / adaptors / wayland / input-manager.cpp
index 8cf7b4a..c276a41 100644 (file)
 // CLASS HEADER
 #include "input-manager.h"
 
+// EXTERNAL INCLUDES
+#include <dali/integration-api/events/key-event-integ.h>
+
 // INTERNAL INCLUDES
 #include <input/input-listeners.h>
+#include <input/text/text-input-listeners.h>
+#include <virtual-keyboard.h>
 
 namespace Dali
 {
@@ -39,7 +44,8 @@ const unsigned int TOUCH_DEVICE_ID = 3;
 } // unnamed namespace
 
 InputManager::InputManager()
-:mWindowEventInterface( NULL )
+:mDisplay( NULL ),
+ mWindowEventInterface( NULL )
 {
 
 }
@@ -55,18 +61,53 @@ InputManager::~InputManager()
 void InputManager::AssignWindowEventInterface( WindowEventInterface* eventInterface)
 {
   mWindowEventInterface = eventInterface;
+  mTextInputManger.AssignWindowEventInterface( mWindowEventInterface );
+}
+
+void InputManager::AssignDisplay( WlDisplay* display )
+{
+  mDisplay = display;
+  mTextInputManger.AssignDisplay( mDisplay );
 }
 
+void InputManager::AssignSurface( WlSurface* surface)
+{
+  for( Dali::Vector< Seat* >::Iterator iter = mSeats.Begin(); iter != mSeats.End() ; ++iter )
+  {
+    Seat* seat = (*iter);
+    seat->SetSurfaceInterface( surface );
+  }
+}
+
+
 void InputManager::AddSeatListener( Dali::WlSeat* seatInterface )
 {
   Seat* seat = new Seat( this, seatInterface );
 
   AddSeat( seat );
+  mTextInputManger.AddSeat( seat );
 
   // listen to seat events
   wl_seat_add_listener( seatInterface, Wayland::GetSeatListener(), this );
 
 }
+
+void InputManager::AddTextInputManager( Dali::WlTextInputManager* textInputManager )
+{
+
+  for( Dali::Vector< Seat* >::Iterator iter = mSeats.Begin(); iter != mSeats.End() ; ++iter )
+  {
+    Seat* seat = (*iter);
+
+    // Create a text input object for each seat
+    WlTextInput* textInput = wl_text_input_manager_create_text_input( textInputManager );
+    seat->SetTextInputInterface( textInput );
+
+    wl_text_input_add_listener( textInput, Wayland::GetTextInputListener(), &mTextInputManger );
+  }
+
+}
+
 void InputManager::PointerEnter( Seat* seat, unsigned int serial, WlSurface* surface, float x, float y )
 {
   if( mWindowEventInterface )
@@ -88,7 +129,10 @@ void InputManager::PointerMotion( Seat* seat, unsigned int timestamp, float x, f
 {
   if( mWindowEventInterface )
   {
-    TouchPoint point ( POINTER_DEVICE_ID, TouchPoint::Motion, x , y);
+    Integration::Point point;
+    point.SetDeviceId( POINTER_DEVICE_ID );
+    point.SetState( PointState::MOTION );
+    point.SetScreenPosition( Vector2( x , y ) );
     mWindowEventInterface->TouchEvent( point, timestamp );
   }
 }
@@ -100,11 +144,19 @@ void InputManager::PointerButton( Seat* seat, unsigned int serial, unsigned int
   {
     const Dali::Vector2& pointer( seat->GetLastPointerPosition() );
 
-    TouchPoint point ( POINTER_DEVICE_ID, TouchPoint::Up,  pointer.x,  pointer.y );
-    if( state == 1)
+    Integration::Point point;
+    point.SetDeviceId( POINTER_DEVICE_ID );
+    point.SetScreenPosition( pointer );
+
+    if( state == 1 )
     {
-      point.state = TouchPoint::Down;
+      point.SetState( PointState::DOWN );
     }
+    else
+    {
+      point.SetState( PointState::UP );
+    }
+
     mWindowEventInterface->TouchEvent( point, timestamp );
   }
 }
@@ -142,7 +194,7 @@ void InputManager::KeyFocusLeave( Seat* seat, unsigned int serial, WlSurface* su
 
 void InputManager::KeyEvent( Seat* seat, unsigned int serial, unsigned int timestamp, unsigned int keycode, unsigned int state )
 {
-  Dali::KeyEvent keyEvent = seat->GetDALiKeyEvent( serial, timestamp, keycode, state );
+  Integration::KeyEvent keyEvent( seat->GetDALiKeyEvent( serial, timestamp, keycode, state ) );
 
   mWindowEventInterface->KeyEvent( keyEvent);
 
@@ -174,7 +226,10 @@ void InputManager::TouchDown( Seat* seat, unsigned int serial, unsigned int time
   {
     const Dali::Vector2& pointer( seat->GetLastPointerPosition() );
 
-    TouchPoint point ( touchId, TouchPoint::Down,  pointer.x,  pointer.y );
+    Integration::Point point;
+    point.SetDeviceId( touchId );
+    point.SetState( PointState::DOWN );
+    point.SetScreenPosition( pointer );
     mWindowEventInterface->TouchEvent( point, timestamp );
   }
 }
@@ -186,7 +241,10 @@ void InputManager::TouchUp( Seat* seat, unsigned int serial, unsigned int timest
   {
     const Dali::Vector2& pointer( seat->GetLastPointerPosition() );
 
-    TouchPoint point ( touchId, TouchPoint::Up,  pointer.x,  pointer.y );
+    Integration::Point point;
+    point.SetDeviceId( touchId );
+    point.SetState( PointState::UP );
+    point.SetScreenPosition( pointer );
     mWindowEventInterface->TouchEvent( point, timestamp );
   }
 }
@@ -197,7 +255,10 @@ void InputManager::TouchMotion( Seat* seat, unsigned int timestamp, int touchId,
   {
     const Dali::Vector2& pointer( seat->GetLastPointerPosition() );
 
-    TouchPoint point ( touchId, TouchPoint::Motion,  pointer.x,  pointer.y );
+    Integration::Point point;
+    point.SetDeviceId( touchId );
+    point.SetState( PointState::MOTION );
+    point.SetScreenPosition( pointer );
     mWindowEventInterface->TouchEvent( point, timestamp );
   }
 }
@@ -215,7 +276,9 @@ void InputManager::TouchCancel( Seat* seat )
 
     // it looks like DALi just checks the first touch point for interruption
     // so touchId can be zero
-    TouchPoint point ( 0, TouchPoint::Interrupted,  pointer.x,  pointer.y );
+    Integration::Point point;
+    point.SetState( PointState::INTERRUPTED );
+    point.SetScreenPosition( pointer );
     mWindowEventInterface->TouchEvent( point, 0 );
   }
 }