Commit 709d7c0b authored by Jun Mukai's avatar Jun Mukai Committed by Commit Bot

consolidate window_finder_{ash,chromeos,mus}

Those files are said to be ChromeOS only, putting all of them
into _chromeos.cc files and removing others. _ozone, _win, and
_x11 are actually referring to _mus, but they won't be used since
the feature isn't enabled on those platforms.

Bug: 867078
Test: build passes
Change-Id: I76e7285fce7aac7c229a7cbe8668c5f654276178
Reviewed-on: https://chromium-review.googlesource.com/1149186
Commit-Queue: Jun Mukai <mukai@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577980}
parent 4c3ad9d6
......@@ -1954,7 +1954,6 @@ jumbo_split_static_library("ui") {
"views/select_file_dialog_extension.h",
"views/select_file_dialog_extension_factory.cc",
"views/select_file_dialog_extension_factory.h",
"views/tabs/window_finder_ash.cc",
"webui/chromeos/assistant_optin/assistant_optin_handler.cc",
"webui/chromeos/assistant_optin/assistant_optin_handler.h",
"webui/chromeos/assistant_optin/assistant_optin_screen_exit_code.h",
......@@ -3104,8 +3103,6 @@ jumbo_split_static_library("ui") {
"views/ime_driver/remote_text_input_client.h",
"views/ime_driver/simple_input_method.cc",
"views/ime_driver/simple_input_method.h",
"views/tabs/window_finder_mus.cc",
"views/tabs/window_finder_mus.h",
]
deps += [ "//ui/views/mus" ]
......
specific_include_rules = {
# mash-ok. Mash uses window_finder_mus.cc instead of window_finder_ash.cc.
"window_finder_ash\.cc": [
# mash-ok
"window_finder_chromeos\.cc": [
"+ash/wm/root_window_finder.h",
],
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/tabs/window_finder.h"
// The direct usage of //ash/ is fine here, as this code is only executed in
// classic ash. See window_finder_chromeos.cc.
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/wm/root_window_finder.h" // mash-ok
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/wm/core/window_util.h"
namespace {
gfx::NativeWindow GetLocalProcessWindowAtPointImpl(
const gfx::Point& screen_point,
const std::set<gfx::NativeWindow>& ignore,
gfx::NativeWindow window) {
if (ignore.find(window) != ignore.end())
return NULL;
if (!window->IsVisible())
return NULL;
if (window->id() == ash::kShellWindowId_PhantomWindow ||
window->id() == ash::kShellWindowId_OverlayContainer ||
window->id() == ash::kShellWindowId_MouseCursorContainer)
return NULL;
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 NULL;
}
} // namespace
gfx::NativeWindow GetLocalProcessWindowAtPointAsh(
const gfx::Point& screen_point,
const std::set<gfx::NativeWindow>& ignore) {
return GetLocalProcessWindowAtPointImpl(
screen_point, ignore, ash::wm::GetRootWindowAt(screen_point));
}
......@@ -3,23 +3,88 @@
// found in the LICENSE file.
#include "chrome/browser/ui/views/tabs/window_finder.h"
#include "chrome/browser/ui/views/tabs/window_finder_mus.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/wm/root_window_finder.h" // mash-ok
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/mus/window_tree_client.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_features.h"
#include "ui/views/mus/mus_client.h"
namespace {
gfx::NativeWindow GetLocalProcessWindowAtPointAsh(
const gfx::Point& screen_point,
const std::set<gfx::NativeWindow>& ignore);
const std::set<gfx::NativeWindow>& ignore,
gfx::NativeWindow window) {
if (ignore.find(window) != ignore.end())
return nullptr;
gfx::NativeWindow WindowFinder::GetLocalProcessWindowAtPoint(
if (!window->IsVisible())
return nullptr;
if (window->id() == ash::kShellWindowId_PhantomWindow ||
window->id() == ash::kShellWindowId_OverlayContainer ||
window->id() == ash::kShellWindowId_MouseCursorContainer)
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 =
GetLocalProcessWindowAtPointAsh(screen_point, ignore, *i);
if (result)
return result;
}
return nullptr;
}
gfx::NativeWindow GetLocalProcessWindowAtPointMus(
const gfx::Point& screen_point,
const std::set<gfx::NativeWindow>& ignore) {
if (!features::IsAshInBrowserProcess()) {
gfx::NativeWindow mus_result = nullptr;
if (GetLocalProcessWindowAtPointMus(screen_point, ignore, &mus_result))
return mus_result;
std::set<aura::Window*> root_windows =
views::MusClient::Get()->window_tree_client()->GetRoots();
// TODO(erg): Needs to deal with stacking order here.
// For every mus window, look at the associated aura window and see if we're
// in that.
for (aura::Window* root : root_windows) {
views::Widget* widget = views::Widget::GetWidgetForNativeView(root);
if (widget && widget->GetWindowBoundsInScreen().Contains(screen_point)) {
aura::Window* content_window = widget->GetNativeWindow();
// If we were instructed to ignore this window, ignore it.
if (base::ContainsKey(ignore, content_window))
continue;
return content_window;
}
}
return GetLocalProcessWindowAtPointAsh(screen_point, ignore);
return nullptr;
}
} // namespace
gfx::NativeWindow WindowFinder::GetLocalProcessWindowAtPoint(
const gfx::Point& screen_point,
const std::set<gfx::NativeWindow>& ignore) {
if (!features::IsAshInBrowserProcess())
return GetLocalProcessWindowAtPointMus(screen_point, ignore);
return GetLocalProcessWindowAtPointAsh(
screen_point, ignore, ash::wm::GetRootWindowAt(screen_point));
}
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/tabs/window_finder_mus.h"
#include "ui/aura/mus/window_tree_client.h"
#include "ui/aura/window.h"
#include "ui/views/mus/mus_client.h"
#if defined(USE_AURA)
#include "ui/aura/env.h"
#endif
namespace {
bool IsUsingMus() {
#if defined(USE_AURA)
return aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS;
#else
return false;
#endif
}
} // namespace
bool GetLocalProcessWindowAtPointMus(
const gfx::Point& screen_point,
const std::set<gfx::NativeWindow>& ignore,
gfx::NativeWindow* mus_result) {
*mus_result = nullptr;
if (!IsUsingMus())
return false;
std::set<aura::Window*> root_windows =
views::MusClient::Get()->window_tree_client()->GetRoots();
// TODO(erg): Needs to deal with stacking order here.
// For every mus window, look at the associated aura window and see if we're
// in that.
for (aura::Window* root : root_windows) {
views::Widget* widget = views::Widget::GetWidgetForNativeView(root);
if (widget && widget->GetWindowBoundsInScreen().Contains(screen_point)) {
aura::Window* content_window = widget->GetNativeWindow();
// If we were instructed to ignore this window, ignore it.
if (base::ContainsKey(ignore, content_window))
continue;
*mus_result = content_window;
return true;
}
}
return true;
}
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_TABS_WINDOW_FINDER_MUS_H_
#define CHROME_BROWSER_UI_VIEWS_TABS_WINDOW_FINDER_MUS_H_
#include "chrome/browser/ui/views/tabs/window_finder.h"
// Used to locate the aura::Window under the specified point when in mus.
// If running in mus true is returned and |mus_result| is set to the
// aura::Window associated with the ui::Window under the specified point.
// It's possible for true to be returned and mus_result to be set to null.
bool GetLocalProcessWindowAtPointMus(
const gfx::Point& screen_point,
const std::set<gfx::NativeWindow>& ignore,
gfx::NativeWindow* mus_result);
#endif // CHROME_BROWSER_UI_VIEWS_TABS_WINDOW_FINDER_MUS_H_
......@@ -3,15 +3,11 @@
// found in the LICENSE file.
#include "chrome/browser/ui/views/tabs/window_finder.h"
#include "chrome/browser/ui/views/tabs/window_finder_mus.h"
gfx::NativeWindow WindowFinder::GetLocalProcessWindowAtPoint(
const gfx::Point& screen_point,
const std::set<gfx::NativeWindow>& ignore) {
gfx::NativeWindow mus_result = nullptr;
if (GetLocalProcessWindowAtPointMus(screen_point, ignore, &mus_result))
return mus_result;
NOTREACHED() << "For Ozone builds, only mash launch is supported for now.";
NOTIMPLEMENTED()
<< "For Ozone builds, window finder is not supported for now.";
return nullptr;
}
......@@ -11,7 +11,6 @@
#include "base/macros.h"
#include "base/win/scoped_gdi_object.h"
#include "base/win/windows_version.h"
#include "chrome/browser/ui/views/tabs/window_finder_mus.h"
#include "ui/aura/window.h"
#include "ui/display/win/screen_win.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
......@@ -239,10 +238,6 @@ std::set<HWND> RemapIgnoreSet(const std::set<gfx::NativeView>& ignore) {
gfx::NativeWindow WindowFinder::GetLocalProcessWindowAtPoint(
const gfx::Point& screen_point,
const std::set<gfx::NativeWindow>& ignore) {
gfx::NativeWindow mus_result = nullptr;
if (GetLocalProcessWindowAtPointMus(screen_point, ignore, &mus_result))
return mus_result;
return LocalProcessWindowFinder::GetProcessWindowAtPoint(
screen_point, RemapIgnoreSet(ignore));
}
......@@ -4,7 +4,6 @@
#include "chrome/browser/ui/views/tabs/window_finder.h"
#include "chrome/browser/ui/views/tabs/window_finder_mus.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/gfx/geometry/point_conversions.h"
......@@ -27,10 +26,6 @@ gfx::Point DIPToPixelPoint(const gfx::Point& dip_point) {
gfx::NativeWindow WindowFinder::GetLocalProcessWindowAtPoint(
const gfx::Point& screen_point,
const std::set<gfx::NativeWindow>& ignore) {
gfx::NativeWindow mus_result = nullptr;
if (GetLocalProcessWindowAtPointMus(screen_point, ignore, &mus_result))
return mus_result;
// The X11 server is the canonical state of what the window stacking order is.
views::X11TopmostWindowFinder finder;
return finder.FindLocalProcessWindowAt(DIPToPixelPoint(screen_point), ignore);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment