Index: chrome/browser/ui/views/tabs/tab_drag_controller.cc |
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
index e604c7c47692ca25ace806a1355c3f0626e444db..3e3f803c2f3dd8f8d3d57047dd55feffb3c48c42 100644 |
--- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc |
@@ -47,6 +47,9 @@ |
#endif |
#if defined(USE_AURA) |
+#if defined(OS_ANDROID) |
+#include "ui/aura/client/screen_position_client.h" |
+#endif |
#include "ui/aura/env.h" |
#include "ui/aura/window.h" |
#include "ui/wm/core/window_modality_controller.h" |
@@ -115,6 +118,43 @@ gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) { |
} |
#endif |
+// TODO(mfomitchev): figure out how to not have code duplication with |
+// Ahs's window_finder impl |
+#if defined(OS_ANDROID) && defined(USE_AURA) |
+gfx::NativeWindow GetLocalProcessWindowAtPointImpl( |
+ const gfx::Point& screen_point, |
+ const std::set<gfx::NativeWindow>& ignore, |
+ gfx::NativeWindow window) { |
+ if (ignore.find(window) != ignore.end()) |
+ return nullptr; |
+ |
+ if (!window->IsVisible()) |
+ return nullptr; |
+ |
+ if (window->layer()->type() == ui::LAYER_TEXTURED) { |
+ // Returns the window that has visible layer and can hit the |
+ // |screen_point|, because we want to detach the tab as soon as |
+ // the dragging mouse moved over to the window that can hide the |
+ // moving tab. |
+ aura::client::ScreenPositionClient* client = |
+ aura::client::GetScreenPositionClient(window->GetRootWindow()); |
+ gfx::Point local_point = screen_point; |
+ client->ConvertPointFromScreen(window, &local_point); |
+ return window->GetEventHandlerForPoint(local_point) ? window : nullptr; |
+ } |
+ |
+ for (aura::Window::Windows::const_reverse_iterator i = |
+ window->children().rbegin(); i != window->children().rend(); ++i) { |
+ gfx::NativeWindow result = |
+ GetLocalProcessWindowAtPointImpl(screen_point, ignore, *i); |
+ if (result) |
+ return result; |
+ } |
+ return nullptr; |
+} |
+#endif // defined(OS_ANDROID) && defined(USE_AURA) |
+ |
+ |
// Returns true if |bounds| contains the y-coordinate |y|. The y-coordinate |
// of |bounds| is adjusted by |vertical_adjustment|. |
bool DoesRectContainVerticalPointExpanded( |
@@ -1804,6 +1844,13 @@ gfx::NativeWindow TabDragController::GetLocalProcessWindow( |
if (dragged_window) |
exclude.insert(dragged_window); |
} |
+#if defined(OS_ANDROID) |
+ gfx::NativeWindow dragged_window = |
+ attached_tabstrip_->GetWidget()->GetNativeWindow(); |
+ return GetLocalProcessWindowAtPointImpl(screen_point, |
+ exclude, |
+ dragged_window->GetRootWindow()); |
+#else |
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
// Exclude windows which are pending deletion via Browser::TabStripEmpty(). |
// These windows can be returned in the Linux Aura port because the browser |
@@ -1821,5 +1868,5 @@ gfx::NativeWindow TabDragController::GetLocalProcessWindow( |
return GetLocalProcessWindowAtPoint(host_desktop_type_, |
screen_point, |
exclude); |
- |
+#endif // defined(OS_ANDROID) |
} |