OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/mus/ws/window_tree_host_impl.h" | 5 #include "components/mus/ws/window_tree_host_impl.h" |
6 | 6 |
7 #include "base/debug/debugger.h" | 7 #include "base/debug/debugger.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "components/mus/common/types.h" | 9 #include "components/mus/common/types.h" |
10 #include "components/mus/public/interfaces/input_event_constants.mojom.h" | 10 #include "components/mus/public/interfaces/input_event_constants.mojom.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 return true; | 44 return true; |
45 } | 45 } |
46 | 46 |
47 mojom::EventPtr CoalesceEvents(mojom::EventPtr first, mojom::EventPtr second) { | 47 mojom::EventPtr CoalesceEvents(mojom::EventPtr first, mojom::EventPtr second) { |
48 DCHECK_EQ(first->action, mojom::EventType::POINTER_MOVE) | 48 DCHECK_EQ(first->action, mojom::EventType::POINTER_MOVE) |
49 << " Non-move events cannot be merged yet."; | 49 << " Non-move events cannot be merged yet."; |
50 // For mouse moves, the new event just replaces the old event. | 50 // For mouse moves, the new event just replaces the old event. |
51 return second; | 51 return second; |
52 } | 52 } |
53 | 53 |
| 54 uint32_t next_id = 1; |
| 55 |
54 } // namespace | 56 } // namespace |
55 | 57 |
56 class WindowTreeHostImpl::ProcessedEventTarget { | 58 class WindowTreeHostImpl::ProcessedEventTarget { |
57 public: | 59 public: |
58 ProcessedEventTarget(ServerWindow* window, bool in_nonclient_area) | 60 ProcessedEventTarget(ServerWindow* window, bool in_nonclient_area) |
59 : in_nonclient_area_(in_nonclient_area) { | 61 : in_nonclient_area_(in_nonclient_area) { |
60 tracker_.Add(window); | 62 tracker_.Add(window); |
61 } | 63 } |
62 | 64 |
63 ~ProcessedEventTarget() {} | 65 ~ProcessedEventTarget() {} |
(...skipping 27 matching lines...) Expand all Loading... |
91 const scoped_refptr<SurfacesState>& surfaces_state, | 93 const scoped_refptr<SurfacesState>& surfaces_state, |
92 mojom::WindowManagerPtr window_manager) | 94 mojom::WindowManagerPtr window_manager) |
93 : delegate_(nullptr), | 95 : delegate_(nullptr), |
94 connection_manager_(connection_manager), | 96 connection_manager_(connection_manager), |
95 client_(std::move(client)), | 97 client_(std::move(client)), |
96 event_dispatcher_(this), | 98 event_dispatcher_(this), |
97 display_manager_( | 99 display_manager_( |
98 DisplayManager::Create(app_impl, gpu_state, surfaces_state)), | 100 DisplayManager::Create(app_impl, gpu_state, surfaces_state)), |
99 window_manager_(std::move(window_manager)), | 101 window_manager_(std::move(window_manager)), |
100 tree_awaiting_input_ack_(nullptr), | 102 tree_awaiting_input_ack_(nullptr), |
101 last_cursor_(0) { | 103 last_cursor_(0), |
| 104 id_(next_id) { |
102 display_manager_->Init(this); | 105 display_manager_->Init(this); |
103 if (client_) { | 106 if (client_) { |
104 client_.set_connection_error_handler(base::Bind( | 107 client_.set_connection_error_handler(base::Bind( |
105 &WindowTreeHostImpl::OnClientClosed, base::Unretained(this))); | 108 &WindowTreeHostImpl::OnClientClosed, base::Unretained(this))); |
106 } | 109 } |
107 } | 110 } |
108 | 111 |
109 WindowTreeHostImpl::~WindowTreeHostImpl() { | 112 WindowTreeHostImpl::~WindowTreeHostImpl() { |
110 DestroyFocusController(); | 113 DestroyFocusController(); |
111 for (ServerWindow* window : windows_needing_frame_destruction_) | 114 for (ServerWindow* window : windows_needing_frame_destruction_) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 if (windows_needing_frame_destruction_.count(window)) | 151 if (windows_needing_frame_destruction_.count(window)) |
149 return; | 152 return; |
150 windows_needing_frame_destruction_.insert(window); | 153 windows_needing_frame_destruction_.insert(window); |
151 window->AddObserver(this); | 154 window->AddObserver(this); |
152 } | 155 } |
153 | 156 |
154 const mojom::ViewportMetrics& WindowTreeHostImpl::GetViewportMetrics() const { | 157 const mojom::ViewportMetrics& WindowTreeHostImpl::GetViewportMetrics() const { |
155 return display_manager_->GetViewportMetrics(); | 158 return display_manager_->GetViewportMetrics(); |
156 } | 159 } |
157 | 160 |
| 161 mojom::Rotation WindowTreeHostImpl::GetRotation() const { |
| 162 return display_manager_->GetRotation(); |
| 163 } |
| 164 |
158 void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) { | 165 void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) { |
159 ServerWindow* old_focused_window = focus_controller_->GetFocusedWindow(); | 166 ServerWindow* old_focused_window = focus_controller_->GetFocusedWindow(); |
160 if (old_focused_window == new_focused_window) | 167 if (old_focused_window == new_focused_window) |
161 return; | 168 return; |
162 DCHECK(root_window()->Contains(new_focused_window)); | 169 DCHECK(root_window()->Contains(new_focused_window)); |
163 focus_controller_->SetFocusedWindow(new_focused_window); | 170 focus_controller_->SetFocusedWindow(new_focused_window); |
164 } | 171 } |
165 | 172 |
166 ServerWindow* WindowTreeHostImpl::GetFocusedWindow() { | 173 ServerWindow* WindowTreeHostImpl::GetFocusedWindow() { |
167 return focus_controller_->GetFocusedWindow(); | 174 return focus_controller_->GetFocusedWindow(); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 DispatchInputEventToWindowImpl(target, in_nonclient_area, std::move(event)); | 536 DispatchInputEventToWindowImpl(target, in_nonclient_area, std::move(event)); |
530 } | 537 } |
531 | 538 |
532 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) { | 539 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) { |
533 windows_needing_frame_destruction_.erase(window); | 540 windows_needing_frame_destruction_.erase(window); |
534 window->RemoveObserver(this); | 541 window->RemoveObserver(this); |
535 } | 542 } |
536 | 543 |
537 } // namespace ws | 544 } // namespace ws |
538 } // namespace mus | 545 } // namespace mus |
OLD | NEW |