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 | |
56 } // namespace | 54 } // namespace |
57 | 55 |
58 class WindowTreeHostImpl::ProcessedEventTarget { | 56 class WindowTreeHostImpl::ProcessedEventTarget { |
59 public: | 57 public: |
60 ProcessedEventTarget(ServerWindow* window, bool in_nonclient_area) | 58 ProcessedEventTarget(ServerWindow* window, bool in_nonclient_area) |
61 : in_nonclient_area_(in_nonclient_area) { | 59 : in_nonclient_area_(in_nonclient_area) { |
62 tracker_.Add(window); | 60 tracker_.Add(window); |
63 } | 61 } |
64 | 62 |
65 ~ProcessedEventTarget() {} | 63 ~ProcessedEventTarget() {} |
(...skipping 27 matching lines...) Expand all Loading... |
93 const scoped_refptr<SurfacesState>& surfaces_state, | 91 const scoped_refptr<SurfacesState>& surfaces_state, |
94 mojom::WindowManagerPtr window_manager) | 92 mojom::WindowManagerPtr window_manager) |
95 : delegate_(nullptr), | 93 : delegate_(nullptr), |
96 connection_manager_(connection_manager), | 94 connection_manager_(connection_manager), |
97 client_(std::move(client)), | 95 client_(std::move(client)), |
98 event_dispatcher_(this), | 96 event_dispatcher_(this), |
99 display_manager_( | 97 display_manager_( |
100 DisplayManager::Create(app_impl, gpu_state, surfaces_state)), | 98 DisplayManager::Create(app_impl, gpu_state, surfaces_state)), |
101 window_manager_(std::move(window_manager)), | 99 window_manager_(std::move(window_manager)), |
102 tree_awaiting_input_ack_(nullptr), | 100 tree_awaiting_input_ack_(nullptr), |
103 last_cursor_(0), | 101 last_cursor_(0) { |
104 id_(next_id) { | |
105 display_manager_->Init(this); | 102 display_manager_->Init(this); |
106 if (client_) { | 103 if (client_) { |
107 client_.set_connection_error_handler(base::Bind( | 104 client_.set_connection_error_handler(base::Bind( |
108 &WindowTreeHostImpl::OnClientClosed, base::Unretained(this))); | 105 &WindowTreeHostImpl::OnClientClosed, base::Unretained(this))); |
109 } | 106 } |
110 } | 107 } |
111 | 108 |
112 WindowTreeHostImpl::~WindowTreeHostImpl() { | 109 WindowTreeHostImpl::~WindowTreeHostImpl() { |
113 DestroyFocusController(); | 110 DestroyFocusController(); |
114 for (ServerWindow* window : windows_needing_frame_destruction_) | 111 for (ServerWindow* window : windows_needing_frame_destruction_) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 if (windows_needing_frame_destruction_.count(window)) | 148 if (windows_needing_frame_destruction_.count(window)) |
152 return; | 149 return; |
153 windows_needing_frame_destruction_.insert(window); | 150 windows_needing_frame_destruction_.insert(window); |
154 window->AddObserver(this); | 151 window->AddObserver(this); |
155 } | 152 } |
156 | 153 |
157 const mojom::ViewportMetrics& WindowTreeHostImpl::GetViewportMetrics() const { | 154 const mojom::ViewportMetrics& WindowTreeHostImpl::GetViewportMetrics() const { |
158 return display_manager_->GetViewportMetrics(); | 155 return display_manager_->GetViewportMetrics(); |
159 } | 156 } |
160 | 157 |
161 mojom::Rotation WindowTreeHostImpl::GetRotation() const { | |
162 return display_manager_->GetRotation(); | |
163 } | |
164 | |
165 void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) { | 158 void WindowTreeHostImpl::SetFocusedWindow(ServerWindow* new_focused_window) { |
166 ServerWindow* old_focused_window = focus_controller_->GetFocusedWindow(); | 159 ServerWindow* old_focused_window = focus_controller_->GetFocusedWindow(); |
167 if (old_focused_window == new_focused_window) | 160 if (old_focused_window == new_focused_window) |
168 return; | 161 return; |
169 DCHECK(root_window()->Contains(new_focused_window)); | 162 DCHECK(root_window()->Contains(new_focused_window)); |
170 focus_controller_->SetFocusedWindow(new_focused_window); | 163 focus_controller_->SetFocusedWindow(new_focused_window); |
171 } | 164 } |
172 | 165 |
173 ServerWindow* WindowTreeHostImpl::GetFocusedWindow() { | 166 ServerWindow* WindowTreeHostImpl::GetFocusedWindow() { |
174 return focus_controller_->GetFocusedWindow(); | 167 return focus_controller_->GetFocusedWindow(); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 DispatchInputEventToWindowImpl(target, in_nonclient_area, std::move(event)); | 529 DispatchInputEventToWindowImpl(target, in_nonclient_area, std::move(event)); |
537 } | 530 } |
538 | 531 |
539 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) { | 532 void WindowTreeHostImpl::OnWindowDestroyed(ServerWindow* window) { |
540 windows_needing_frame_destruction_.erase(window); | 533 windows_needing_frame_destruction_.erase(window); |
541 window->RemoveObserver(this); | 534 window->RemoveObserver(this); |
542 } | 535 } |
543 | 536 |
544 } // namespace ws | 537 } // namespace ws |
545 } // namespace mus | 538 } // namespace mus |
OLD | NEW |