1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/tabs/window_finder.h"
7 #include "ui/gfx/geometry/point_conversions.h"
8 #include "ui/gfx/screen.h"
9 #include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h"
13 float GetDeviceScaleFactor() {
14 gfx::Display display
= gfx::Screen::GetNativeScreen()->GetPrimaryDisplay();
15 return display
.device_scale_factor();
18 gfx::Point
DIPToPixelPoint(const gfx::Point
& dip_point
) {
19 return ToFlooredPoint(gfx::ScalePoint(dip_point
, GetDeviceScaleFactor()));
22 } // anonymous namespace
25 gfx::NativeWindow
GetLocalProcessWindowAtPointAsh(
26 const gfx::Point
& screen_point
,
27 const std::set
<gfx::NativeWindow
>& ignore
);
30 gfx::NativeWindow
GetLocalProcessWindowAtPoint(
31 chrome::HostDesktopType host_desktop_type
,
32 const gfx::Point
& screen_point
,
33 const std::set
<gfx::NativeWindow
>& ignore
) {
35 if (host_desktop_type
== chrome::HOST_DESKTOP_TYPE_ASH
)
36 return GetLocalProcessWindowAtPointAsh(screen_point
, ignore
);
39 // The X11 server is the canonical state of what the window stacking order
41 views::X11TopmostWindowFinder finder
;
42 return finder
.FindLocalProcessWindowAt(DIPToPixelPoint(screen_point
), ignore
);