Infobar material design refresh: layout
[chromium-blink-merge.git] / chrome / browser / ui / views / tabs / window_finder_x11.cc
blobdb7a4cc2527594ac7c3a0dbe90b236fde942d06d
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"
11 namespace {
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
24 #if defined(USE_ASH)
25 gfx::NativeWindow GetLocalProcessWindowAtPointAsh(
26 const gfx::Point& screen_point,
27 const std::set<gfx::NativeWindow>& ignore);
28 #endif
30 gfx::NativeWindow GetLocalProcessWindowAtPoint(
31 chrome::HostDesktopType host_desktop_type,
32 const gfx::Point& screen_point,
33 const std::set<gfx::NativeWindow>& ignore) {
34 #if defined(USE_ASH)
35 if (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH)
36 return GetLocalProcessWindowAtPointAsh(screen_point, ignore);
37 #endif
39 // The X11 server is the canonical state of what the window stacking order
40 // is.
41 views::X11TopmostWindowFinder finder;
42 return finder.FindLocalProcessWindowAt(DIPToPixelPoint(screen_point), ignore);