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 "ui/aura/mus/window_tree_client.h" | 5 #include "ui/aura/mus/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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 : ChangeType::NEW_WINDOW)); | 564 : ChangeType::NEW_WINDOW)); |
565 if (create_top_level) { | 565 if (create_top_level) { |
566 tree_->NewTopLevelWindow(change_id, window->server_id(), | 566 tree_->NewTopLevelWindow(change_id, window->server_id(), |
567 std::move(transport_properties)); | 567 std::move(transport_properties)); |
568 } else { | 568 } else { |
569 tree_->NewWindow(change_id, window->server_id(), | 569 tree_->NewWindow(change_id, window->server_id(), |
570 std::move(transport_properties)); | 570 std::move(transport_properties)); |
571 } | 571 } |
572 } | 572 } |
573 | 573 |
574 void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window) { | 574 void WindowTreeClient::OnWindowMusDestroyed(WindowMus* window, Origin origin) { |
575 if (focus_synchronizer_->focused_window() == window) | 575 if (focus_synchronizer_->focused_window() == window) |
576 focus_synchronizer_->OnFocusedWindowDestroyed(); | 576 focus_synchronizer_->OnFocusedWindowDestroyed(); |
577 | 577 |
578 // TODO: decide how to deal with windows not owned by this client. | 578 // TODO: decide how to deal with windows not owned by this client. |
579 if (WasCreatedByThisClient(window) || IsRoot(window)) { | 579 if (origin == Origin::CLIENT && |
| 580 (WasCreatedByThisClient(window) || IsRoot(window))) { |
580 const uint32_t change_id = | 581 const uint32_t change_id = |
581 ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>( | 582 ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>( |
582 window, ChangeType::DELETE_WINDOW)); | 583 window, ChangeType::DELETE_WINDOW)); |
583 tree_->DeleteWindow(change_id, window->server_id()); | 584 tree_->DeleteWindow(change_id, window->server_id()); |
584 } | 585 } |
585 | 586 |
586 windows_.erase(window->server_id()); | 587 windows_.erase(window->server_id()); |
587 | 588 |
588 for (auto& entry : embedded_windows_) { | 589 for (auto& entry : embedded_windows_) { |
589 auto it = entry.second.find(window->GetWindow()); | 590 auto it = entry.second.find(window->GetWindow()); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 WindowMus* window = GetWindowByServerId(window_id); | 1002 WindowMus* window = GetWindowByServerId(window_id); |
1002 WindowMus* relative_window = GetWindowByServerId(relative_window_id); | 1003 WindowMus* relative_window = GetWindowByServerId(relative_window_id); |
1003 WindowMus* parent = WindowMus::Get(window->GetWindow()->parent()); | 1004 WindowMus* parent = WindowMus::Get(window->GetWindow()->parent()); |
1004 if (window && relative_window && parent && | 1005 if (window && relative_window && parent && |
1005 parent == WindowMus::Get(relative_window->GetWindow()->parent())) { | 1006 parent == WindowMus::Get(relative_window->GetWindow()->parent())) { |
1006 parent->ReorderFromServer(window, relative_window, direction); | 1007 parent->ReorderFromServer(window, relative_window, direction); |
1007 } | 1008 } |
1008 } | 1009 } |
1009 | 1010 |
1010 void WindowTreeClient::OnWindowDeleted(Id window_id) { | 1011 void WindowTreeClient::OnWindowDeleted(Id window_id) { |
1011 // TODO(sky): decide how best to deal with this. It seems we should let the | 1012 WindowMus* window = GetWindowByServerId(window_id); |
1012 // delegate do the actualy deletion. | 1013 if (window) |
1013 delete GetWindowByServerId(window_id)->GetWindow(); | 1014 window->DestroyFromServer(); |
1014 } | 1015 } |
1015 | 1016 |
1016 void WindowTreeClient::OnWindowVisibilityChanged(Id window_id, bool visible) { | 1017 void WindowTreeClient::OnWindowVisibilityChanged(Id window_id, bool visible) { |
1017 WindowMus* window = GetWindowByServerId(window_id); | 1018 WindowMus* window = GetWindowByServerId(window_id); |
1018 if (!window) | 1019 if (!window) |
1019 return; | 1020 return; |
1020 | 1021 |
1021 InFlightVisibleChange new_change(this, window, visible); | 1022 InFlightVisibleChange new_change(this, window, visible); |
1022 if (ApplyServerChangeToExistingInFlightChange(new_change)) | 1023 if (ApplyServerChangeToExistingInFlightChange(new_change)) |
1023 return; | 1024 return; |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 } | 1275 } |
1275 | 1276 |
1276 void WindowTreeClient::WmNewDisplayAdded(const display::Display& display, | 1277 void WindowTreeClient::WmNewDisplayAdded(const display::Display& display, |
1277 ui::mojom::WindowDataPtr root_data, | 1278 ui::mojom::WindowDataPtr root_data, |
1278 bool parent_drawn) { | 1279 bool parent_drawn) { |
1279 WmNewDisplayAddedImpl(display, std::move(root_data), parent_drawn); | 1280 WmNewDisplayAddedImpl(display, std::move(root_data), parent_drawn); |
1280 } | 1281 } |
1281 | 1282 |
1282 void WindowTreeClient::WmDisplayRemoved(int64_t display_id) { | 1283 void WindowTreeClient::WmDisplayRemoved(int64_t display_id) { |
1283 DCHECK(window_manager_delegate_); | 1284 DCHECK(window_manager_delegate_); |
1284 // TODO: route to WindowTreeHost. | 1285 for (WindowMus* root : roots_) { |
1285 /* | 1286 DCHECK(root->GetWindow()->GetHost()); |
1286 for (Window* root : roots_) { | 1287 WindowTreeHostMus* window_tree_host = |
1287 if (root->display_id() == display_id) { | 1288 static_cast<WindowTreeHostMus*>(root->GetWindow()->GetHost()); |
1288 window_manager_delegate_->OnWmDisplayRemoved(root); | 1289 if (window_tree_host->display_id() == display_id) { |
| 1290 window_manager_delegate_->OnWmDisplayRemoved(window_tree_host); |
1289 return; | 1291 return; |
1290 } | 1292 } |
1291 } | 1293 } |
1292 */ | |
1293 } | 1294 } |
1294 | 1295 |
1295 void WindowTreeClient::WmDisplayModified(const display::Display& display) { | 1296 void WindowTreeClient::WmDisplayModified(const display::Display& display) { |
1296 DCHECK(window_manager_delegate_); | 1297 DCHECK(window_manager_delegate_); |
1297 // TODO(sky): this should likely route to WindowTreeHost. | 1298 // TODO(sky): this should likely route to WindowTreeHost. |
1298 window_manager_delegate_->OnWmDisplayModified(display); | 1299 window_manager_delegate_->OnWmDisplayModified(display); |
1299 } | 1300 } |
1300 | 1301 |
1301 void WindowTreeClient::WmSetBounds(uint32_t change_id, | 1302 void WindowTreeClient::WmSetBounds(uint32_t change_id, |
1302 Id window_id, | 1303 Id window_id, |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1531 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1532 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
1532 this, capture_synchronizer_.get(), window)); | 1533 this, capture_synchronizer_.get(), window)); |
1533 } | 1534 } |
1534 | 1535 |
1535 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1536 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
1536 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1537 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
1537 this, focus_synchronizer_.get(), window)); | 1538 this, focus_synchronizer_.get(), window)); |
1538 } | 1539 } |
1539 | 1540 |
1540 } // namespace aura | 1541 } // namespace aura |
OLD | NEW |