| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/public/cpp/window_tree_client.h" | 5 #include "components/mus/public/cpp/window_tree_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "components/mus/public/cpp/window_tree_client_observer.h" | 23 #include "components/mus/public/cpp/window_tree_client_observer.h" |
| 24 #include "components/mus/public/interfaces/window_manager_window_tree_factory.mo
jom.h" | 24 #include "components/mus/public/interfaces/window_manager_window_tree_factory.mo
jom.h" |
| 25 #include "services/shell/public/cpp/connector.h" | 25 #include "services/shell/public/cpp/connector.h" |
| 26 #include "ui/display/mojo/display_type_converters.h" | 26 #include "ui/display/mojo/display_type_converters.h" |
| 27 #include "ui/events/event.h" | 27 #include "ui/events/event.h" |
| 28 #include "ui/gfx/geometry/insets.h" | 28 #include "ui/gfx/geometry/insets.h" |
| 29 #include "ui/gfx/geometry/size.h" | 29 #include "ui/gfx/geometry/size.h" |
| 30 | 30 |
| 31 namespace mus { | 31 namespace mus { |
| 32 | 32 |
| 33 namespace { |
| 34 |
| 33 void DeleteWindowTreeClient(WindowTreeClient* client) { delete client; } | 35 void DeleteWindowTreeClient(WindowTreeClient* client) { delete client; } |
| 34 | 36 |
| 35 Id MakeTransportId(ClientSpecificId client_id, ClientSpecificId local_id) { | 37 Id MakeTransportId(ClientSpecificId client_id, ClientSpecificId local_id) { |
| 36 return (client_id << 16) | local_id; | 38 return (client_id << 16) | local_id; |
| 37 } | 39 } |
| 38 | 40 |
| 39 Id server_id(Window* window) { | 41 Id server_id(Window* window) { |
| 40 return WindowPrivate(window).server_id(); | 42 return WindowPrivate(window).server_id(); |
| 41 } | 43 } |
| 42 | 44 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 54 private_window.set_properties( | 56 private_window.set_properties( |
| 55 window_data->properties | 57 window_data->properties |
| 56 .To<std::map<std::string, std::vector<uint8_t>>>()); | 58 .To<std::map<std::string, std::vector<uint8_t>>>()); |
| 57 client->AddWindow(window); | 59 client->AddWindow(window); |
| 58 private_window.LocalSetBounds(gfx::Rect(), window_data->bounds); | 60 private_window.LocalSetBounds(gfx::Rect(), window_data->bounds); |
| 59 if (parent) | 61 if (parent) |
| 60 WindowPrivate(parent).LocalAddChild(window); | 62 WindowPrivate(parent).LocalAddChild(window); |
| 61 return window; | 63 return window; |
| 62 } | 64 } |
| 63 | 65 |
| 66 } // namespace |
| 67 |
| 64 Window* BuildWindowTree(WindowTreeClient* client, | 68 Window* BuildWindowTree(WindowTreeClient* client, |
| 65 const mojo::Array<mojom::WindowDataPtr>& windows, | 69 const mojo::Array<mojom::WindowDataPtr>& windows, |
| 66 Window* initial_parent) { | 70 Window* initial_parent) { |
| 67 std::vector<Window*> parents; | 71 std::vector<Window*> parents; |
| 68 Window* root = NULL; | 72 Window* root = NULL; |
| 69 Window* last_window = NULL; | 73 Window* last_window = NULL; |
| 70 if (initial_parent) | 74 if (initial_parent) |
| 71 parents.push_back(initial_parent); | 75 parents.push_back(initial_parent); |
| 72 for (size_t i = 0; i < windows.size(); ++i) { | 76 for (size_t i = 0; i < windows.size(); ++i) { |
| 73 if (last_window && windows[i]->parent_id == server_id(last_window)) { | 77 if (last_window && windows[i]->parent_id == server_id(last_window)) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 93 next_window_id_(1), | 97 next_window_id_(1), |
| 94 next_change_id_(1), | 98 next_change_id_(1), |
| 95 delegate_(delegate), | 99 delegate_(delegate), |
| 96 window_manager_delegate_(window_manager_delegate), | 100 window_manager_delegate_(window_manager_delegate), |
| 97 capture_window_(nullptr), | 101 capture_window_(nullptr), |
| 98 focused_window_(nullptr), | 102 focused_window_(nullptr), |
| 99 binding_(this), | 103 binding_(this), |
| 100 tree_(nullptr), | 104 tree_(nullptr), |
| 101 delete_on_no_roots_(!window_manager_delegate), | 105 delete_on_no_roots_(!window_manager_delegate), |
| 102 in_destructor_(false), | 106 in_destructor_(false), |
| 107 event_handler_binding_(this), |
| 103 weak_factory_(this) { | 108 weak_factory_(this) { |
| 104 // Allow for a null request in tests. | 109 // Allow for a null request in tests. |
| 105 if (request.is_pending()) | 110 if (request.is_pending()) |
| 106 binding_.Bind(std::move(request)); | 111 binding_.Bind(std::move(request)); |
| 107 if (window_manager_delegate) | 112 if (window_manager_delegate) |
| 108 window_manager_delegate->SetWindowManagerClient(this); | 113 window_manager_delegate->SetWindowManagerClient(this); |
| 109 } | 114 } |
| 110 | 115 |
| 111 WindowTreeClient::~WindowTreeClient() { | 116 WindowTreeClient::~WindowTreeClient() { |
| 112 in_destructor_ = true; | 117 in_destructor_ = true; |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 if (!window) | 1001 if (!window) |
| 997 return; | 1002 return; |
| 998 | 1003 |
| 999 InFlightPredefinedCursorChange new_change(window, cursor); | 1004 InFlightPredefinedCursorChange new_change(window, cursor); |
| 1000 if (ApplyServerChangeToExistingInFlightChange(new_change)) | 1005 if (ApplyServerChangeToExistingInFlightChange(new_change)) |
| 1001 return; | 1006 return; |
| 1002 | 1007 |
| 1003 WindowPrivate(window).LocalSetPredefinedCursor(cursor); | 1008 WindowPrivate(window).LocalSetPredefinedCursor(cursor); |
| 1004 } | 1009 } |
| 1005 | 1010 |
| 1011 void X() { |
| 1012 LOG(ERROR) << "FFFFFFFFFFFFFFFFUCK"; |
| 1013 } |
| 1014 |
| 1015 void WindowTreeClient::RequestInputEventHandler( |
| 1016 mojom::InputEventHandlerRequest request) { |
| 1017 LOG(ERROR) << "Yes"; |
| 1018 event_handler_binding_.Bind(std::move(request)); |
| 1019 event_handler_binding_.set_connection_error_handler(base::Bind(&X)); |
| 1020 } |
| 1021 |
| 1006 void WindowTreeClient::OnChangeCompleted(uint32_t change_id, bool success) { | 1022 void WindowTreeClient::OnChangeCompleted(uint32_t change_id, bool success) { |
| 1007 std::unique_ptr<InFlightChange> change(std::move(in_flight_map_[change_id])); | 1023 std::unique_ptr<InFlightChange> change(std::move(in_flight_map_[change_id])); |
| 1008 in_flight_map_.erase(change_id); | 1024 in_flight_map_.erase(change_id); |
| 1009 if (!change) | 1025 if (!change) |
| 1010 return; | 1026 return; |
| 1011 | 1027 |
| 1012 if (!success) | 1028 if (!success) |
| 1013 change->ChangeFailed(); | 1029 change->ChangeFailed(); |
| 1014 | 1030 |
| 1015 InFlightChange* next_change = GetOldestInFlightChangeMatching(*change); | 1031 InFlightChange* next_change = GetOldestInFlightChangeMatching(*change); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 void WindowTreeClient::SetUnderlaySurfaceOffsetAndExtendedHitArea( | 1187 void WindowTreeClient::SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| 1172 Window* window, | 1188 Window* window, |
| 1173 const gfx::Vector2d& offset, | 1189 const gfx::Vector2d& offset, |
| 1174 const gfx::Insets& hit_area) { | 1190 const gfx::Insets& hit_area) { |
| 1175 if (window_manager_internal_client_) { | 1191 if (window_manager_internal_client_) { |
| 1176 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( | 1192 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| 1177 server_id(window), offset.x(), offset.y(), hit_area); | 1193 server_id(window), offset.x(), offset.y(), hit_area); |
| 1178 } | 1194 } |
| 1179 } | 1195 } |
| 1180 | 1196 |
| 1197 void WindowTreeClient::OnInputEvent(uint32_t window_id, |
| 1198 std::unique_ptr<ui::Event> event, |
| 1199 const OnInputEventCallback& callback) { |
| 1200 Window* window = GetWindowByServerId(window_id); // May be null. |
| 1201 LOG(ERROR) << "X: " << event->name() << " " << window << " " << window_id |
| 1202 << " " << windows_.size(); |
| 1203 if (!window && !windows_.empty()) |
| 1204 window = windows_.begin()->second; |
| 1205 if (window && window->input_event_handler_) { |
| 1206 window->input_event_handler_->OnWindowInputEvent(window, *event, nullptr); |
| 1207 } |
| 1208 callback.Run(true); |
| 1209 } |
| 1210 |
| 1181 } // namespace mus | 1211 } // namespace mus |
| OLD | NEW |