Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: ash/mus/screen_mus.cc

Issue 2726603003: mus+ash: Copy parts of ScreenAsh to ScreenMus. (Closed)
Patch Set: Add unit tests. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/mus/screen_mus.h" 5 #include "ash/mus/screen_mus.h"
6 6
7 #include "ash/common/wm/root_window_finder.h"
8 #include "ash/common/wm_window.h"
7 #include "services/ui/public/interfaces/display/display_controller.mojom.h" 9 #include "services/ui/public/interfaces/display/display_controller.mojom.h"
10 #include "ui/aura/client/screen_position_client.h"
8 #include "ui/aura/env.h" 11 #include "ui/aura/env.h"
9 #include "ui/aura/mus/window_tree_host_mus.h" 12 #include "ui/aura/mus/window_tree_host_mus.h"
10 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
11 14
12 namespace ash { 15 namespace ash {
13 16
14 ScreenMus::ScreenMus(display::mojom::DisplayController* display_controller) 17 ScreenMus::ScreenMus(display::mojom::DisplayController* display_controller)
15 : display_controller_(display_controller) {} 18 : display_controller_(display_controller) {}
16 19
17 ScreenMus::~ScreenMus() = default; 20 ScreenMus::~ScreenMus() = default;
(...skipping 24 matching lines...) Expand all
42 return GetPrimaryDisplay(); 45 return GetPrimaryDisplay();
43 auto iter = display_list().FindDisplayById( 46 auto iter = display_list().FindDisplayById(
44 static_cast<const aura::WindowTreeHostMus*>(host)->display_id()); 47 static_cast<const aura::WindowTreeHostMus*>(host)->display_id());
45 return iter == display_list().displays().end() ? GetPrimaryDisplay() : *iter; 48 return iter == display_list().displays().end() ? GetPrimaryDisplay() : *iter;
46 } 49 }
47 50
48 gfx::Point ScreenMus::GetCursorScreenPoint() { 51 gfx::Point ScreenMus::GetCursorScreenPoint() {
49 return aura::Env::GetInstance()->last_mouse_location(); 52 return aura::Env::GetInstance()->last_mouse_location();
50 } 53 }
51 54
55 bool ScreenMus::IsWindowUnderCursor(gfx::NativeWindow window) {
56 return GetWindowAtScreenPoint(GetCursorScreenPoint()) == window;
57 }
58
59 gfx::NativeWindow ScreenMus::GetWindowAtScreenPoint(const gfx::Point& point) {
60 aura::Window* root_window =
61 WmWindow::GetAuraWindow(wm::GetRootWindowAt(point));
62 aura::client::ScreenPositionClient* position_client =
63 aura::client::GetScreenPositionClient(root_window);
64
65 gfx::Point local_point = point;
66 if (position_client)
67 position_client->ConvertPointFromScreen(root_window, &local_point);
68
69 return root_window->GetTopWindowContainingPoint(local_point);
70 }
71
52 } // namespace ash 72 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698