Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ash / wm / ash_native_cursor_manager.cc
index d315792..0100105 100644 (file)
@@ -4,8 +4,8 @@
 
 #include "ash/wm/ash_native_cursor_manager.h"
 
+#include "ash/display/cursor_window_controller.h"
 #include "ash/display/display_controller.h"
-#include "ash/display/mirror_window_controller.h"
 #include "ash/shell.h"
 #include "ash/wm/image_cursors.h"
 #include "base/logging.h"
@@ -21,10 +21,10 @@ void SetCursorOnAllRootWindows(gfx::NativeCursor cursor) {
       Shell::GetInstance()->GetAllRootWindows();
   for (aura::Window::Windows::iterator iter = root_windows.begin();
        iter != root_windows.end(); ++iter)
-    (*iter)->GetDispatcher()->SetCursor(cursor);
+    (*iter)->GetDispatcher()->host()->SetCursor(cursor);
 #if defined(OS_CHROMEOS)
   Shell::GetInstance()->display_controller()->
-      mirror_window_controller()->SetMirroredCursor(cursor);
+      cursor_window_controller()->SetCursor(cursor);
 #endif
 }
 
@@ -33,10 +33,10 @@ void NotifyCursorVisibilityChange(bool visible) {
       Shell::GetInstance()->GetAllRootWindows();
   for (aura::Window::Windows::iterator iter = root_windows.begin();
        iter != root_windows.end(); ++iter)
-    (*iter)->GetDispatcher()->OnCursorVisibilityChanged(visible);
+    (*iter)->GetDispatcher()->host()->OnCursorVisibilityChanged(visible);
 #if defined(OS_CHROMEOS)
-  Shell::GetInstance()->display_controller()->mirror_window_controller()->
-      SetMirroredCursorVisibility(visible);
+  Shell::GetInstance()->display_controller()->cursor_window_controller()->
+      SetVisibility(visible);
 #endif
 }
 
@@ -52,24 +52,48 @@ void NotifyMouseEventsEnableStateChange(bool enabled) {
 }  // namespace
 
 AshNativeCursorManager::AshNativeCursorManager()
-    : image_cursors_(new ImageCursors) {
+    : native_cursor_enabled_(true),
+      image_cursors_(new ImageCursors) {
 }
 
 AshNativeCursorManager::~AshNativeCursorManager() {
 }
 
+
+void AshNativeCursorManager::SetNativeCursorEnabled(bool enabled) {
+  native_cursor_enabled_ = enabled;
+
+  views::corewm::CursorManager* cursor_manager =
+      Shell::GetInstance()->cursor_manager();
+  SetCursor(cursor_manager->GetCursor(), cursor_manager);
+}
+
 void AshNativeCursorManager::SetDisplay(
     const gfx::Display& display,
     views::corewm::NativeCursorManagerDelegate* delegate) {
   if (image_cursors_->SetDisplay(display))
     SetCursor(delegate->GetCursor(), delegate);
+#if defined(OS_CHROMEOS)
+  Shell::GetInstance()->display_controller()->cursor_window_controller()->
+      SetDisplay(display);
+#endif
 }
 
 void AshNativeCursorManager::SetCursor(
     gfx::NativeCursor cursor,
     views::corewm::NativeCursorManagerDelegate* delegate) {
   gfx::NativeCursor new_cursor = cursor;
-  image_cursors_->SetPlatformCursor(&new_cursor);
+  if (native_cursor_enabled_) {
+    image_cursors_->SetPlatformCursor(&new_cursor);
+  } else {
+    gfx::NativeCursor invisible_cursor(ui::kCursorNone);
+    image_cursors_->SetPlatformCursor(&invisible_cursor);
+    if (new_cursor == ui::kCursorCustom) {
+      new_cursor = invisible_cursor;
+    } else {
+      new_cursor.SetPlatformCursor(invisible_cursor.platform());
+    }
+  }
   new_cursor.set_device_scale_factor(
       image_cursors_->GetDisplay().device_scale_factor());
 
@@ -88,6 +112,11 @@ void AshNativeCursorManager::SetCursorSet(
   // Sets the cursor to reflect the scale change immediately.
   if (delegate->IsCursorVisible())
     SetCursor(delegate->GetCursor(), delegate);
+
+#if defined(OS_CHROMEOS)
+  Shell::GetInstance()->display_controller()->cursor_window_controller()->
+      SetCursorSet(cursor_set);
+#endif
 }
 
 void AshNativeCursorManager::SetScale(