Merge "Add native render surface for wayland" into devel/master
[platform/core/uifw/dali-adaptor.git] / adaptors / wayland / wayland-manager.cpp
index 3134477..a03807e 100644 (file)
@@ -77,33 +77,39 @@ void RegistryGlobalCallback( void *data,
 
   WaylandManager* client = static_cast<   WaylandManager* >( data );
 
-  if (strcmp( interface, wl_compositor_interface.name) == 0)
+  if( strcmp( interface, wl_compositor_interface.name ) == 0 )
   {
-    client->mCompositor = static_cast<Dali::WlCompositor*>(wl_registry_bind( wlRegistry, name , &wl_compositor_interface, version ));
+    client->mCompositor = static_cast< Dali::WlCompositor* >( wl_registry_bind( wlRegistry, name, &wl_compositor_interface, version ) );
   }
-  else if( strcmp( interface, wl_seat_interface.name) == 0  )
+  else if( strcmp( interface, wl_seat_interface.name ) == 0 )
   {
     // register for seat callbacks and add a new seat to the input manager
-    Dali::WlSeat* seatInterface = static_cast<Dali::WlSeat*>( wl_registry_bind( wlRegistry, name,  &wl_seat_interface, version ));
+    Dali::WlSeat* seatInterface = static_cast< Dali::WlSeat* >( wl_registry_bind( wlRegistry, name, &wl_seat_interface, version ) );
 
     client->mInputManager.AddSeatListener( seatInterface );
   }
-  else if ( strcmp( interface, wl_output_interface.name ) == 0)
+  else if( strcmp( interface, wl_output_interface.name ) == 0 )
   {
     // get the interface and add the listener
-    Dali::WlOutput* output =  static_cast< Dali::WlOutput* >(wl_registry_bind(wlRegistry, name, &wl_output_interface, version));
+    Dali::WlOutput* output = static_cast< Dali::WlOutput* >( wl_registry_bind( wlRegistry, name, &wl_output_interface, version ) );
     client->mCompositorOutput.AddListener( output );
   }
-  else if (strcmp(interface, wl_shell_interface.name) == 0)
+  else if( strcmp( interface, wl_shell_interface.name ) == 0 )
   {
-    client->mShell = static_cast<Dali::WlShell*>(wl_registry_bind( wlRegistry, name , &wl_shell_interface, version));
+    client->mShell = static_cast< Dali::WlShell* >( wl_registry_bind( wlRegistry, name, &wl_shell_interface, version ) );
   }
-  else if ( strcmp( interface, xdg_shell_interface.name ) == 0)
+  else if( strcmp( interface, xdg_shell_interface.name ) == 0 )
   {
-    client->mXdgShell  =  static_cast< struct xdg_shell* >(wl_registry_bind(wlRegistry, name, &xdg_shell_interface, version));
+    client->mXdgShell = static_cast< struct xdg_shell* >( wl_registry_bind( wlRegistry, name, &xdg_shell_interface, version ) );
     // without this line Tizen 3 reports...
     // xdg_shell@7: error 0: Must call use_unstable_version first
-    xdg_shell_use_unstable_version(client->mXdgShell, 5);
+    xdg_shell_use_unstable_version( client->mXdgShell, 5 );
+  }
+  else if( strcmp( interface, wl_text_input_manager_interface.name ) == 0 )
+  {
+    Dali::WlTextInputManager* inputManager = static_cast< Dali::WlTextInputManager* >( wl_registry_bind( wlRegistry, name, &wl_text_input_manager_interface, version ) );
+
+    client->mInputManager.AddTextInputManager( inputManager );
   }
 
 
@@ -174,6 +180,8 @@ void WaylandManager::Initialise()
   // Monitor the display file descriptor used to communicate with Wayland server
   InstallFileDescriptorMonitor();
 
+  mInputManager.AssignDisplay( mDisplay );
+
   // Get the interfaces to compositor / shell etc
   GetWaylandInterfaces();
 
@@ -204,7 +212,7 @@ void WaylandManager::ReadAndDispatchEvents()
   }
   else
   {
-    DALI_LOG_ERROR("wl_display_read_events error");
+    DALI_LOG_ERROR("wl_display_read_events error\n");
   }
 
 }
@@ -264,6 +272,9 @@ void WaylandManager::CreateSurface( Dali::Wayland::Window& window )
 
   mSurface = wl_compositor_create_surface( mCompositor );
 
+  // the Input panel (Virtual keyboard ) needs to know which surface it should display on.
+  mInputManager.AssignSurface( mSurface );
+
   DALI_ASSERT_ALWAYS( mSurface && "wl_compositor_create_surface failed" );
 
   // keep track of the surface id
@@ -282,7 +293,8 @@ void WaylandManager::CreateSurface( Dali::Wayland::Window& window )
 
     if( window.mTitle.length() )
     {
-      xdg_surface_set_title(  mXdgSurface, window.mTitle.c_str() );
+      xdg_surface_set_title( mXdgSurface, window.mTitle.c_str() );
+      xdg_surface_set_app_id(mXdgSurface, window.mTitle.c_str() );
     }
     xdg_shell_add_listener( mXdgShell, &XdgShellListener, 0);
   }