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

Side by Side Diff: ui/views/mus/screen_mus.cc

Issue 2626453002: Standardize Screen::GetCursorScreenPoint() on Env::last_mouse_location (Closed)
Patch Set: explicit Created 3 years, 11 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 // This has to be before any other includes, else default is picked up. 5 // This has to be before any other includes, else default is picked up.
6 // See base/logging for details on this. 6 // See base/logging for details on this.
7 #define NOTIMPLEMENTED_POLICY 5 7 #define NOTIMPLEMENTED_POLICY 5
8 8
9 #include "ui/views/mus/screen_mus.h" 9 #include "ui/views/mus/screen_mus.h"
10 10
11 #include "services/service_manager/public/cpp/connection.h" 11 #include "services/service_manager/public/cpp/connection.h"
12 #include "services/service_manager/public/cpp/connector.h" 12 #include "services/service_manager/public/cpp/connector.h"
13 #include "services/ui/public/interfaces/constants.mojom.h" 13 #include "services/ui/public/interfaces/constants.mojom.h"
14 #include "ui/aura/env.h"
14 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
15 #include "ui/views/mus/screen_mus_delegate.h" 16 #include "ui/views/mus/screen_mus_delegate.h"
16 #include "ui/views/mus/window_manager_frame_values.h" 17 #include "ui/views/mus/window_manager_frame_values.h"
17 18
18 namespace mojo { 19 namespace mojo {
19 20
20 template <> 21 template <>
21 struct TypeConverter<views::WindowManagerFrameValues, 22 struct TypeConverter<views::WindowManagerFrameValues,
22 ui::mojom::FrameDecorationValuesPtr> { 23 ui::mojom::FrameDecorationValuesPtr> {
23 static views::WindowManagerFrameValues Convert( 24 static views::WindowManagerFrameValues Convert(
24 const ui::mojom::FrameDecorationValuesPtr& input) { 25 const ui::mojom::FrameDecorationValuesPtr& input) {
25 views::WindowManagerFrameValues result; 26 views::WindowManagerFrameValues result;
26 result.normal_insets = input->normal_client_area_insets; 27 result.normal_insets = input->normal_client_area_insets;
27 result.maximized_insets = input->maximized_client_area_insets; 28 result.maximized_insets = input->maximized_client_area_insets;
28 result.max_title_bar_button_width = input->max_title_bar_button_width; 29 result.max_title_bar_button_width = input->max_title_bar_button_width;
29 return result; 30 return result;
30 } 31 }
31 }; 32 };
32 33
33 } // namespace mojo 34 } // namespace mojo
34 35
35 namespace views { 36 namespace views {
36 37
37 using Type = display::DisplayList::Type; 38 using Type = display::DisplayList::Type;
38 39
39 ScreenMus::ScreenMus(ScreenMusDelegate* delegate) 40 ScreenMus::ScreenMus(ScreenMusDelegate* delegate)
40 : delegate_(delegate), display_manager_observer_binding_(this) { 41 : delegate_(delegate), display_manager_observer_binding_(this) {
42 DCHECK(delegate);
41 display::Screen::SetScreenInstance(this); 43 display::Screen::SetScreenInstance(this);
42 } 44 }
43 45
44 ScreenMus::~ScreenMus() { 46 ScreenMus::~ScreenMus() {
45 DCHECK_EQ(this, display::Screen::GetScreen()); 47 DCHECK_EQ(this, display::Screen::GetScreen());
46 display::Screen::SetScreenInstance(nullptr); 48 display::Screen::SetScreenInstance(nullptr);
47 } 49 }
48 50
49 void ScreenMus::Init(service_manager::Connector* connector) { 51 void ScreenMus::Init(service_manager::Connector* connector) {
50 connector->BindInterface(ui::mojom::kServiceName, &display_manager_); 52 connector->BindInterface(ui::mojom::kServiceName, &display_manager_);
(...skipping 13 matching lines...) Expand all
64 if (display_list().displays().empty()) { 66 if (display_list().displays().empty()) {
65 DCHECK(display_manager_.encountered_error() || !success); 67 DCHECK(display_manager_.encountered_error() || !success);
66 // In this case we install a default display and assume the process is 68 // In this case we install a default display and assume the process is
67 // going to exit shortly so that the real value doesn't matter. 69 // going to exit shortly so that the real value doesn't matter.
68 display_list().AddDisplay( 70 display_list().AddDisplay(
69 display::Display(0xFFFFFFFF, gfx::Rect(0, 0, 801, 802)), Type::PRIMARY); 71 display::Display(0xFFFFFFFF, gfx::Rect(0, 0, 801, 802)), Type::PRIMARY);
70 } 72 }
71 } 73 }
72 74
73 gfx::Point ScreenMus::GetCursorScreenPoint() { 75 gfx::Point ScreenMus::GetCursorScreenPoint() {
74 if (!delegate_) { 76 return aura::Env::GetInstance()->last_mouse_location();
75 // TODO(erg): If we need the cursor point in the window manager, we'll need
76 // to make |delegate_| required. It only recently changed to be optional.
77 NOTIMPLEMENTED();
78 return gfx::Point();
79 }
80
81 return delegate_->GetCursorScreenPoint();
82 } 77 }
83 78
84 bool ScreenMus::IsWindowUnderCursor(gfx::NativeWindow window) { 79 bool ScreenMus::IsWindowUnderCursor(gfx::NativeWindow window) {
85 return window && window->IsVisible() && 80 return window && window->IsVisible() &&
86 window->GetBoundsInScreen().Contains(GetCursorScreenPoint()); 81 window->GetBoundsInScreen().Contains(GetCursorScreenPoint());
87 } 82 }
88 83
89 aura::Window* ScreenMus::GetWindowAtScreenPoint(const gfx::Point& point) { 84 aura::Window* ScreenMus::GetWindowAtScreenPoint(const gfx::Point& point) {
90 return delegate_->GetWindowAtScreenPoint(point); 85 return delegate_->GetWindowAtScreenPoint(point);
91 } 86 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 for (size_t i = 0; i < ws_displays.size(); ++i) { 119 for (size_t i = 0; i < ws_displays.size(); ++i) {
125 const display::Display& display = ws_displays[i]->display; 120 const display::Display& display = ws_displays[i]->display;
126 const bool is_primary = 121 const bool is_primary =
127 display.id() == display_list().GetPrimaryDisplayIterator()->id(); 122 display.id() == display_list().GetPrimaryDisplayIterator()->id();
128 ProcessDisplayChanged(display, is_primary); 123 ProcessDisplayChanged(display, is_primary);
129 if (is_primary) { 124 if (is_primary) {
130 WindowManagerFrameValues frame_values = 125 WindowManagerFrameValues frame_values =
131 ws_displays[i] 126 ws_displays[i]
132 ->frame_decoration_values.To<WindowManagerFrameValues>(); 127 ->frame_decoration_values.To<WindowManagerFrameValues>();
133 WindowManagerFrameValues::SetInstance(frame_values); 128 WindowManagerFrameValues::SetInstance(frame_values);
134 if (delegate_) 129 delegate_->OnWindowManagerFrameValuesChanged();
135 delegate_->OnWindowManagerFrameValuesChanged();
136 } 130 }
137 } 131 }
138 } 132 }
139 133
140 void ScreenMus::OnDisplayRemoved(int64_t display_id) { 134 void ScreenMus::OnDisplayRemoved(int64_t display_id) {
141 display_list().RemoveDisplay(display_id); 135 display_list().RemoveDisplay(display_id);
142 } 136 }
143 137
144 void ScreenMus::OnPrimaryDisplayChanged(int64_t primary_display_id) { 138 void ScreenMus::OnPrimaryDisplayChanged(int64_t primary_display_id) {
145 // TODO(kylechar): DisplayList would need to change to handle having no 139 // TODO(kylechar): DisplayList would need to change to handle having no
146 // primary display. 140 // primary display.
147 if (primary_display_id == display::kInvalidDisplayId) 141 if (primary_display_id == display::kInvalidDisplayId)
148 return; 142 return;
149 143
150 ProcessDisplayChanged(*display_list().FindDisplayById(primary_display_id), 144 ProcessDisplayChanged(*display_list().FindDisplayById(primary_display_id),
151 true); 145 true);
152 } 146 }
153 147
154 } // namespace views 148 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698