Skip to content

Commit

Permalink
Ozone and X11: Use TopMostWindowFinder through display::Screen
Browse files Browse the repository at this point in the history
display::Screen has already had one interface for that. We
do the same for finding local window with ignored windows
as well.

Bug: 1069469
Change-Id: I59b4d3cb89a3bf4cf25beae82bc07cc468f4b50b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2157004
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Cr-Commit-Position: refs/heads/master@{#765115}
  • Loading branch information
msisov authored and Commit Bot committed May 4, 2020
1 parent 1c64303 commit eb235c1
Show file tree
Hide file tree
Showing 45 changed files with 616 additions and 423 deletions.
14 changes: 13 additions & 1 deletion ash/display/screen_ash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "ash/display/window_tree_host_manager.h"
#include "ash/public/cpp/ash_switches.h"
#include "ash/public/cpp/window_finder.h"
#include "ash/root_window_controller.h"
#include "ash/root_window_settings.h"
#include "ash/shelf/shelf_widget.h"
Expand Down Expand Up @@ -47,7 +48,12 @@ class ScreenForShutdown : public display::Screen {
gfx::Point GetCursorScreenPoint() override { return gfx::Point(); }
bool IsWindowUnderCursor(gfx::NativeWindow window) override { return false; }
gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override {
return NULL;
return nullptr;
}
gfx::NativeWindow GetLocalProcessWindowAtPoint(
const gfx::Point& point,
const std::set<gfx::NativeWindow>& ignore) override {
return nullptr;
}
int GetNumDisplays() const override { return display_list_.size(); }
const std::vector<display::Display>& GetAllDisplays() const override {
Expand Down Expand Up @@ -110,6 +116,12 @@ gfx::NativeWindow ScreenAsh::GetWindowAtScreenPoint(const gfx::Point& point) {
return root_window->GetEventHandlerForPoint(local_point);
}

gfx::NativeWindow ScreenAsh::GetLocalProcessWindowAtPoint(
const gfx::Point& point,
const std::set<gfx::NativeWindow>& ignore) {
return ash::GetTopmostWindowAtPoint(point, ignore);
}

int ScreenAsh::GetNumDisplays() const {
return GetDisplayManager()->GetNumDisplays();
}
Expand Down
3 changes: 3 additions & 0 deletions ash/display/screen_ash.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class ASH_EXPORT ScreenAsh : public display::Screen {
gfx::Point GetCursorScreenPoint() override;
bool IsWindowUnderCursor(gfx::NativeWindow window) override;
gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override;
gfx::NativeWindow GetLocalProcessWindowAtPoint(
const gfx::Point& point,
const std::set<gfx::NativeWindow>& ignore) override;
int GetNumDisplays() const override;
const std::vector<display::Display>& GetAllDisplays() const override;
display::Display GetDisplayNearestWindow(
Expand Down
15 changes: 1 addition & 14 deletions chrome/browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2546,7 +2546,6 @@ jumbo_static_library("ui") {
"views/frame/native_browser_frame_factory_mac.mm",
"views/tab_contents/chrome_web_contents_view_delegate_views_mac.h",
"views/tab_contents/chrome_web_contents_view_delegate_views_mac.mm",
"views/tabs/window_finder_mac.mm",
"web_contents_sizer.mm",
"webui/help/version_updater_mac.h",
"webui/help/version_updater_mac.mm",
Expand Down Expand Up @@ -2618,7 +2617,6 @@ jumbo_static_library("ui") {
"views/status_icons/status_tray_state_changer_win.h",
"views/status_icons/status_tray_win.cc",
"views/status_icons/status_tray_win.h",
"views/tabs/window_finder_win.cc",
"views/try_chrome_dialog_win/arrow_border.cc",
"views/try_chrome_dialog_win/arrow_border.h",
"views/try_chrome_dialog_win/button_layout.cc",
Expand Down Expand Up @@ -2780,18 +2778,6 @@ jumbo_static_library("ui") {
if (use_aura) {
deps += [ "//third_party/fontconfig" ]
}

# WindowFinder implementation selection is a bit tricky, so do all here
# to get it right and prevent ODR violations.
if (is_chromeos) {
sources += [ "views/tabs/window_finder_chromeos.cc" ]
} else if (use_x11) {
sources += [ "views/tabs/window_finder_x11.cc" ]
deps += [ "//ui/platform_window/x11" ]
} else {
assert(use_ozone)
sources += [ "views/tabs/window_finder_ozone.cc" ]
}
}

if (is_chromeos) {
Expand Down Expand Up @@ -3455,6 +3441,7 @@ jumbo_static_library("ui") {
"views/tabs/tab_style_views.h",
"views/tabs/tab_width_constraints.cc",
"views/tabs/tab_width_constraints.h",
"views/tabs/window_finder.cc",
"views/tabs/window_finder.h",
"views/task_manager_view.cc",
"views/task_manager_view.h",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

#include "chrome/browser/ui/views/tabs/window_finder.h"

#include "ash/public/cpp/window_finder.h"
#include "ui/display/screen.h"

gfx::NativeWindow WindowFinder::GetLocalProcessWindowAtPoint(
const gfx::Point& screen_point,
const std::set<gfx::NativeWindow>& ignore) {
return ash::GetTopmostWindowAtPoint(screen_point, ignore);
return display::Screen::GetScreen()->GetLocalProcessWindowAtPoint(
screen_point, ignore);
}
12 changes: 7 additions & 5 deletions chrome/browser/ui/views/tabs/window_finder.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ namespace gfx {
class Point;
}

// Class used by the tabstrip to find chrome windows that we can attach tabs to.
// Class used by the tabstrip to find chrome windows (through display::Screen)
// that we can attach tabs to. We don't call
// display::Screen::GetLocalProcessWindowAtPoint, but use this class just for
// the sake of simplicity in unittests. That is, some of them want to set own
// implementation of WindowFinder and emulate mouse movements. However, if they
// set another screen, assertion that screen has been changed may be hit.
class WindowFinder {
public:
WindowFinder() = default;
virtual ~WindowFinder() = default;

// Finds the topmost visible chrome window at |screen_point|. This should
// return nullptr if |screen_point| is in another program's window which
// occludes the topmost chrome window. Ignores the windows in |ignore|, which
// contain windows such as the tab being dragged right now.
// See comment at display::Screen::GetLocalProcessWindowAtPoint().
virtual gfx::NativeWindow GetLocalProcessWindowAtPoint(
const gfx::Point& screen_point,
const std::set<gfx::NativeWindow>& ignore);
Expand Down
35 changes: 0 additions & 35 deletions chrome/browser/ui/views/tabs/window_finder_mac.mm

This file was deleted.

22 changes: 0 additions & 22 deletions chrome/browser/ui/views/tabs/window_finder_ozone.cc

This file was deleted.

Loading

0 comments on commit eb235c1

Please sign in to comment.