| 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/lib/window_tree_client_impl.h" | 5 #include "components/mus/public/cpp/lib/window_tree_client_impl.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 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 DCHECK(window_manager_delegate_); | 1025 DCHECK(window_manager_delegate_); |
| 1026 gfx::Rect bounds = transit_bounds.To<gfx::Rect>(); | 1026 gfx::Rect bounds = transit_bounds.To<gfx::Rect>(); |
| 1027 result = window_manager_delegate_->OnWmSetBounds(window, &bounds); | 1027 result = window_manager_delegate_->OnWmSetBounds(window, &bounds); |
| 1028 if (result) { | 1028 if (result) { |
| 1029 // If the resulting bounds differ return false. Returning false ensures | 1029 // If the resulting bounds differ return false. Returning false ensures |
| 1030 // the client applies the bounds we set below. | 1030 // the client applies the bounds we set below. |
| 1031 result = bounds == transit_bounds.To<gfx::Rect>(); | 1031 result = bounds == transit_bounds.To<gfx::Rect>(); |
| 1032 window->SetBounds(bounds); | 1032 window->SetBounds(bounds); |
| 1033 } | 1033 } |
| 1034 } | 1034 } |
| 1035 window_manager_internal_client_->WmResponse(change_id, result); | 1035 if (window_manager_internal_client_) |
| 1036 window_manager_internal_client_->WmResponse(change_id, result); |
| 1036 } | 1037 } |
| 1037 | 1038 |
| 1038 void WindowTreeClientImpl::WmSetProperty(uint32_t change_id, | 1039 void WindowTreeClientImpl::WmSetProperty(uint32_t change_id, |
| 1039 Id window_id, | 1040 Id window_id, |
| 1040 const mojo::String& name, | 1041 const mojo::String& name, |
| 1041 mojo::Array<uint8_t> transit_data) { | 1042 mojo::Array<uint8_t> transit_data) { |
| 1042 Window* window = GetWindowByServerId(window_id); | 1043 Window* window = GetWindowByServerId(window_id); |
| 1043 bool result = false; | 1044 bool result = false; |
| 1044 if (window) { | 1045 if (window) { |
| 1045 DCHECK(window_manager_delegate_); | 1046 DCHECK(window_manager_delegate_); |
| 1046 std::unique_ptr<std::vector<uint8_t>> data; | 1047 std::unique_ptr<std::vector<uint8_t>> data; |
| 1047 if (!transit_data.is_null()) { | 1048 if (!transit_data.is_null()) { |
| 1048 data.reset( | 1049 data.reset( |
| 1049 new std::vector<uint8_t>(transit_data.To<std::vector<uint8_t>>())); | 1050 new std::vector<uint8_t>(transit_data.To<std::vector<uint8_t>>())); |
| 1050 } | 1051 } |
| 1051 result = window_manager_delegate_->OnWmSetProperty(window, name, &data); | 1052 result = window_manager_delegate_->OnWmSetProperty(window, name, &data); |
| 1052 if (result) { | 1053 if (result) { |
| 1053 // If the resulting bounds differ return false. Returning false ensures | 1054 // If the resulting bounds differ return false. Returning false ensures |
| 1054 // the client applies the bounds we set below. | 1055 // the client applies the bounds we set below. |
| 1055 window->SetSharedPropertyInternal(name, data.get()); | 1056 window->SetSharedPropertyInternal(name, data.get()); |
| 1056 } | 1057 } |
| 1057 } | 1058 } |
| 1058 window_manager_internal_client_->WmResponse(change_id, result); | 1059 if (window_manager_internal_client_) |
| 1060 window_manager_internal_client_->WmResponse(change_id, result); |
| 1059 } | 1061 } |
| 1060 | 1062 |
| 1061 void WindowTreeClientImpl::WmCreateTopLevelWindow( | 1063 void WindowTreeClientImpl::WmCreateTopLevelWindow( |
| 1062 uint32_t change_id, | 1064 uint32_t change_id, |
| 1063 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) { | 1065 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties) { |
| 1064 std::map<std::string, std::vector<uint8_t>> properties = | 1066 std::map<std::string, std::vector<uint8_t>> properties = |
| 1065 transport_properties.To<std::map<std::string, std::vector<uint8_t>>>(); | 1067 transport_properties.To<std::map<std::string, std::vector<uint8_t>>>(); |
| 1066 Window* window = | 1068 Window* window = |
| 1067 window_manager_delegate_->OnWmCreateTopLevelWindow(&properties); | 1069 window_manager_delegate_->OnWmCreateTopLevelWindow(&properties); |
| 1068 window_manager_internal_client_->OnWmCreatedTopLevelWindow(change_id, | 1070 if (window_manager_internal_client_) { |
| 1069 server_id(window)); | 1071 window_manager_internal_client_->OnWmCreatedTopLevelWindow( |
| 1072 change_id, server_id(window)); |
| 1073 } |
| 1070 } | 1074 } |
| 1071 | 1075 |
| 1072 void WindowTreeClientImpl::OnAccelerator(uint32_t id, mojom::EventPtr event) { | 1076 void WindowTreeClientImpl::OnAccelerator(uint32_t id, mojom::EventPtr event) { |
| 1073 window_manager_delegate_->OnAccelerator( | 1077 window_manager_delegate_->OnAccelerator( |
| 1074 id, *event.To<std::unique_ptr<ui::Event>>().get()); | 1078 id, *event.To<std::unique_ptr<ui::Event>>().get()); |
| 1075 } | 1079 } |
| 1076 | 1080 |
| 1077 void WindowTreeClientImpl::SetFrameDecorationValues( | 1081 void WindowTreeClientImpl::SetFrameDecorationValues( |
| 1078 mojom::FrameDecorationValuesPtr values) { | 1082 mojom::FrameDecorationValuesPtr values) { |
| 1079 window_manager_internal_client_->WmSetFrameDecorationValues( | 1083 if (window_manager_internal_client_) { |
| 1080 std::move(values)); | 1084 window_manager_internal_client_->WmSetFrameDecorationValues( |
| 1085 std::move(values)); |
| 1086 } |
| 1081 } | 1087 } |
| 1082 | 1088 |
| 1083 void WindowTreeClientImpl::SetNonClientCursor(Window* window, | 1089 void WindowTreeClientImpl::SetNonClientCursor(Window* window, |
| 1084 mus::mojom::Cursor cursor_id) { | 1090 mus::mojom::Cursor cursor_id) { |
| 1085 window_manager_internal_client_->WmSetNonClientCursor(server_id(window), | 1091 window_manager_internal_client_->WmSetNonClientCursor(server_id(window), |
| 1086 cursor_id); | 1092 cursor_id); |
| 1087 } | 1093 } |
| 1088 | 1094 |
| 1089 void WindowTreeClientImpl::AddAccelerator( | 1095 void WindowTreeClientImpl::AddAccelerator( |
| 1090 uint32_t id, | 1096 uint32_t id, |
| 1091 mojom::EventMatcherPtr event_matcher, | 1097 mojom::EventMatcherPtr event_matcher, |
| 1092 const base::Callback<void(bool)>& callback) { | 1098 const base::Callback<void(bool)>& callback) { |
| 1093 window_manager_internal_client_->AddAccelerator(id, std::move(event_matcher), | 1099 if (window_manager_internal_client_) { |
| 1094 callback); | 1100 window_manager_internal_client_->AddAccelerator( |
| 1101 id, std::move(event_matcher), callback); |
| 1102 } |
| 1095 } | 1103 } |
| 1096 | 1104 |
| 1097 void WindowTreeClientImpl::RemoveAccelerator(uint32_t id) { | 1105 void WindowTreeClientImpl::RemoveAccelerator(uint32_t id) { |
| 1098 window_manager_internal_client_->RemoveAccelerator(id); | 1106 if (window_manager_internal_client_) { |
| 1107 window_manager_internal_client_->RemoveAccelerator(id); |
| 1108 } |
| 1099 } | 1109 } |
| 1100 | 1110 |
| 1101 void WindowTreeClientImpl::AddActivationParent(Window* window) { | 1111 void WindowTreeClientImpl::AddActivationParent(Window* window) { |
| 1102 window_manager_internal_client_->AddActivationParent(server_id(window)); | 1112 if (window_manager_internal_client_) |
| 1113 window_manager_internal_client_->AddActivationParent(server_id(window)); |
| 1103 } | 1114 } |
| 1104 | 1115 |
| 1105 void WindowTreeClientImpl::RemoveActivationParent(Window* window) { | 1116 void WindowTreeClientImpl::RemoveActivationParent(Window* window) { |
| 1106 window_manager_internal_client_->RemoveActivationParent(server_id(window)); | 1117 if (window_manager_internal_client_) |
| 1118 window_manager_internal_client_->RemoveActivationParent(server_id(window)); |
| 1107 } | 1119 } |
| 1108 | 1120 |
| 1109 void WindowTreeClientImpl::ActivateNextWindow() { | 1121 void WindowTreeClientImpl::ActivateNextWindow() { |
| 1110 window_manager_internal_client_->ActivateNextWindow(); | 1122 if (window_manager_internal_client_) |
| 1123 window_manager_internal_client_->ActivateNextWindow(); |
| 1111 } | 1124 } |
| 1112 | 1125 |
| 1113 void WindowTreeClientImpl::SetUnderlaySurfaceOffsetAndExtendedHitArea( | 1126 void WindowTreeClientImpl::SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| 1114 Window* window, | 1127 Window* window, |
| 1115 const gfx::Vector2d& offset, | 1128 const gfx::Vector2d& offset, |
| 1116 const gfx::Insets& hit_area) { | 1129 const gfx::Insets& hit_area) { |
| 1117 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( | 1130 if (window_manager_internal_client_) { |
| 1118 server_id(window), offset.x(), offset.y(), mojo::Insets::From(hit_area)); | 1131 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| 1132 server_id(window), offset.x(), offset.y(), |
| 1133 mojo::Insets::From(hit_area)); |
| 1134 } |
| 1119 } | 1135 } |
| 1120 | 1136 |
| 1121 } // namespace mus | 1137 } // namespace mus |
| OLD | NEW |