Skip to content

Commit

Permalink
Remove 'real_topmost' parameter from ash::GetTopmostWindowAtPoint
Browse files Browse the repository at this point in the history
This parameter was introduced for ws. Since it's not there anymore,
we can remove this parameter.

Bug: none
Test: trybot
Change-Id: I241abc2c872892a395224bf09212db7512262970
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1646863
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Jun Mukai <mukai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#669380}
  • Loading branch information
jmuk authored and Commit Bot committed Jun 14, 2019
1 parent 8c7ab9f commit f22a33a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 49 deletions.
12 changes: 5 additions & 7 deletions ash/public/cpp/window_finder.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ class Point;
namespace ash {

// Finds the topmost window at |screen_point| with ignoring |ignore|. If
// |real_topmost| is not nullptr, it will be updated to the topmost visible
// window regardless of |ignore|. If overview is active when this function is
// called, the overview window that contains |screen_point| will be returned.
// Note this overview window might not be visibile (e.g., it represents an aura
// window whose window state is MINIMIZED).
// overview is active when this function is called, the overview window that
// contains |screen_point| will be returned. Note this overview window might not
// be visibile (e.g., it represents an aura window whose window state is
// MINIMIZED).
ASH_EXPORT aura::Window* GetTopmostWindowAtPoint(
const gfx::Point& screen_point,
const std::set<aura::Window*>& ignore,
aura::Window** real_topmost);
const std::set<aura::Window*>& ignore);

} // namespace ash

Expand Down
26 changes: 9 additions & 17 deletions ash/wm/window_finder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ aura::Window* GetTopmostWindowAtPointWithinWindow(
const gfx::Point& screen_point,
aura::Window* window,
aura::WindowTargeter* targeter,
const std::set<aura::Window*> ignore,
aura::Window** real_topmost) {
const std::set<aura::Window*> ignore) {
if (!window->IsVisible())
return nullptr;

Expand All @@ -62,11 +61,8 @@ aura::Window* GetTopmostWindowAtPointWithinWindow(
return nullptr;

if (IsTopLevelWindow(window)) {
if (IsWindowTargeted(window, screen_point, targeter)) {
if (real_topmost && !(*real_topmost))
*real_topmost = window;
if (IsWindowTargeted(window, screen_point, targeter))
return (ignore.find(window) == ignore.end()) ? window : nullptr;
}
return nullptr;
}

Expand All @@ -76,7 +72,7 @@ aura::Window* GetTopmostWindowAtPointWithinWindow(
aura::WindowTargeter* child_targeter =
(*i)->targeter() ? (*i)->targeter() : targeter;
aura::Window* result = GetTopmostWindowAtPointWithinWindow(
screen_point, *i, child_targeter, ignore, real_topmost);
screen_point, *i, child_targeter, ignore);
if (result)
return result;
}
Expand Down Expand Up @@ -115,18 +111,14 @@ aura::Window* GetToplevelWindowInOverviewAtPoint(
namespace ash {

aura::Window* GetTopmostWindowAtPoint(const gfx::Point& screen_point,
const std::set<aura::Window*>& ignore,
aura::Window** real_topmost) {
if (real_topmost)
*real_topmost = nullptr;
aura::Window* root = wm::GetRootWindowAt(screen_point);
// GetTopmostWindowAtPointWithinWindow() always needs to be called to update
// |real_topmost| correctly.
aura::Window* topmost_window = GetTopmostWindowAtPointWithinWindow(
screen_point, root, root->targeter(), ignore, real_topmost);
const std::set<aura::Window*>& ignore) {
aura::Window* overview_window =
GetToplevelWindowInOverviewAtPoint(screen_point, ignore);
return overview_window ? overview_window : topmost_window;
if (overview_window)
return overview_window;
aura::Window* root = wm::GetRootWindowAt(screen_point);
return GetTopmostWindowAtPointWithinWindow(screen_point, root,
root->targeter(), ignore);
}

} // namespace ash
37 changes: 13 additions & 24 deletions ash/wm/window_finder_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ TEST_F(WindowFinderTest, RealTopmostCanBeNullptr) {
CreateTestWindow(gfx::Rect(0, 0, 100, 100));
std::set<aura::Window*> ignore;

EXPECT_EQ(window1.get(),
GetTopmostWindowAtPoint(gfx::Point(10, 10), ignore, nullptr));
EXPECT_EQ(window1.get(), GetTopmostWindowAtPoint(gfx::Point(10, 10), ignore));
}

TEST_F(WindowFinderTest, MultipleDisplays) {
Expand All @@ -37,12 +36,10 @@ TEST_F(WindowFinderTest, MultipleDisplays) {
ASSERT_NE(window1->GetRootWindow(), window2->GetRootWindow());

std::set<aura::Window*> ignore;
EXPECT_EQ(window1.get(),
GetTopmostWindowAtPoint(gfx::Point(10, 10), ignore, nullptr));
EXPECT_EQ(window1.get(), GetTopmostWindowAtPoint(gfx::Point(10, 10), ignore));
EXPECT_EQ(window2.get(),
GetTopmostWindowAtPoint(gfx::Point(210, 10), ignore, nullptr));
EXPECT_EQ(nullptr,
GetTopmostWindowAtPoint(gfx::Point(10, 210), ignore, nullptr));
GetTopmostWindowAtPoint(gfx::Point(210, 10), ignore));
EXPECT_EQ(nullptr, GetTopmostWindowAtPoint(gfx::Point(10, 210), ignore));
}

TEST_F(WindowFinderTest, WindowTargeterWithHitTestRects) {
Expand All @@ -53,21 +50,14 @@ TEST_F(WindowFinderTest, WindowTargeterWithHitTestRects) {

std::set<aura::Window*> ignore;

aura::Window* real_topmost = nullptr;
EXPECT_EQ(window2.get(),
GetTopmostWindowAtPoint(gfx::Point(10, 10), ignore, &real_topmost));
EXPECT_EQ(window2.get(), real_topmost);
EXPECT_EQ(window2.get(), GetTopmostWindowAtPoint(gfx::Point(10, 10), ignore));

auto targeter = std::make_unique<aura::WindowTargeter>();
targeter->SetInsets(gfx::Insets(0, 50, 0, 0));
window2->SetEventTargeter(std::move(targeter));

EXPECT_EQ(window1.get(),
GetTopmostWindowAtPoint(gfx::Point(10, 10), ignore, &real_topmost));
EXPECT_EQ(window1.get(), real_topmost);
EXPECT_EQ(window2.get(),
GetTopmostWindowAtPoint(gfx::Point(60, 10), ignore, &real_topmost));
EXPECT_EQ(window2.get(), real_topmost);
EXPECT_EQ(window1.get(), GetTopmostWindowAtPoint(gfx::Point(10, 10), ignore));
EXPECT_EQ(window2.get(), GetTopmostWindowAtPoint(gfx::Point(60, 10), ignore));
}

// Tests that when overview is active, GetTopmostWindowAtPoint() will return
Expand All @@ -94,15 +84,14 @@ TEST_F(WindowFinderTest, TopmostWindowWithOverviewActive) {
grid->GetOverviewItemContaining(window2.get())->target_bounds());

std::set<aura::Window*> ignore;
aura::Window* real_topmost = nullptr;
EXPECT_EQ(window1.get(), GetTopmostWindowAtPoint(bounds1.CenterPoint(),
ignore, &real_topmost));
EXPECT_EQ(window2.get(), GetTopmostWindowAtPoint(bounds2.CenterPoint(),
ignore, &real_topmost));
EXPECT_EQ(window1.get(),
GetTopmostWindowAtPoint(bounds1.CenterPoint(), ignore));
EXPECT_EQ(window2.get(),
GetTopmostWindowAtPoint(bounds2.CenterPoint(), ignore));

wm::GetWindowState(window1.get())->Minimize();
EXPECT_EQ(window1.get(), GetTopmostWindowAtPoint(bounds1.CenterPoint(),
ignore, &real_topmost));
EXPECT_EQ(window1.get(),
GetTopmostWindowAtPoint(bounds1.CenterPoint(), ignore));
}

} // namespace ash
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/tabs/window_finder_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
gfx::NativeWindow WindowFinder::GetLocalProcessWindowAtPoint(
const gfx::Point& screen_point,
const std::set<gfx::NativeWindow>& ignore) {
return ash::GetTopmostWindowAtPoint(screen_point, ignore, nullptr);
return ash::GetTopmostWindowAtPoint(screen_point, ignore);
}

0 comments on commit f22a33a

Please sign in to comment.