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 "services/ui/public/cpp/window_tree_client.h" | 5 #include "services/ui/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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 | 349 |
350 void WindowTreeClient::AttachSurface( | 350 void WindowTreeClient::AttachSurface( |
351 Id window_id, | 351 Id window_id, |
352 mojom::SurfaceType type, | 352 mojom::SurfaceType type, |
353 mojo::InterfaceRequest<mojom::Surface> surface, | 353 mojo::InterfaceRequest<mojom::Surface> surface, |
354 mojom::SurfaceClientPtr client) { | 354 mojom::SurfaceClientPtr client) { |
355 DCHECK(tree_); | 355 DCHECK(tree_); |
356 tree_->AttachSurface(window_id, type, std::move(surface), std::move(client)); | 356 tree_->AttachSurface(window_id, type, std::move(surface), std::move(client)); |
357 } | 357 } |
358 | 358 |
| 359 void WindowTreeClient::SatisfySurfaceSequence( |
| 360 Id window_id, |
| 361 const cc::SurfaceSequence& sequence) { |
| 362 DCHECK(tree_); |
| 363 tree_->SatisfySurfaceSequence(window_id, sequence); |
| 364 } |
| 365 |
359 void WindowTreeClient::LocalSetCapture(Window* window) { | 366 void WindowTreeClient::LocalSetCapture(Window* window) { |
360 if (capture_window_ == window) | 367 if (capture_window_ == window) |
361 return; | 368 return; |
362 Window* lost_capture = capture_window_; | 369 Window* lost_capture = capture_window_; |
363 capture_window_ = window; | 370 capture_window_ = window; |
364 if (lost_capture) { | 371 if (lost_capture) { |
365 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(lost_capture).observers(), | 372 FOR_EACH_OBSERVER(WindowObserver, *WindowPrivate(lost_capture).observers(), |
366 OnWindowLostCapture(lost_capture)); | 373 OnWindowLostCapture(lost_capture)); |
367 } | 374 } |
368 FOR_EACH_OBSERVER(WindowTreeClientObserver, observers_, | 375 FOR_EACH_OBSERVER(WindowTreeClientObserver, observers_, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 this, !parents.empty() ? parents.back() : nullptr, windows[i]); | 489 this, !parents.empty() ? parents.back() : nullptr, windows[i]); |
483 if (!last_window) | 490 if (!last_window) |
484 root = window; | 491 root = window; |
485 last_window = window; | 492 last_window = window; |
486 } | 493 } |
487 return root; | 494 return root; |
488 } | 495 } |
489 | 496 |
490 Window* WindowTreeClient::NewWindowImpl( | 497 Window* WindowTreeClient::NewWindowImpl( |
491 NewWindowType type, | 498 NewWindowType type, |
492 const Window::SharedProperties* properties) { | 499 const Window::SharedProperties* properties, |
| 500 bool container) { |
493 DCHECK(tree_); | 501 DCHECK(tree_); |
494 Window* window = | 502 Window* window = new Window( |
495 new Window(this, MakeTransportId(client_id_, next_window_id_++)); | 503 this, MakeTransportId(client_id_, next_window_id_++), container); |
496 if (properties) | 504 if (properties) |
497 window->properties_ = *properties; | 505 window->properties_ = *properties; |
498 AddWindow(window); | 506 AddWindow(window); |
499 | 507 |
500 const uint32_t change_id = | 508 const uint32_t change_id = |
501 ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>( | 509 ScheduleInFlightChange(base::MakeUnique<CrashInFlightChange>( |
502 window, type == NewWindowType::CHILD | 510 window, type == NewWindowType::CHILD |
503 ? ChangeType::NEW_WINDOW | 511 ? ChangeType::NEW_WINDOW |
504 : ChangeType::NEW_TOP_LEVEL_WINDOW)); | 512 : ChangeType::NEW_TOP_LEVEL_WINDOW)); |
505 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties; | 513 mojo::Map<mojo::String, mojo::Array<uint8_t>> transport_properties; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 base::MakeUnique<InFlightDragChange>(window, ChangeType::MOVE_LOOP)); | 695 base::MakeUnique<InFlightDragChange>(window, ChangeType::MOVE_LOOP)); |
688 // Tell the window manager to take over moving us. | 696 // Tell the window manager to take over moving us. |
689 tree_->PerformWindowMove(current_move_loop_change_, window->server_id(), | 697 tree_->PerformWindowMove(current_move_loop_change_, window->server_id(), |
690 source, cursor_location); | 698 source, cursor_location); |
691 } | 699 } |
692 | 700 |
693 void WindowTreeClient::CancelWindowMove(Window* window) { | 701 void WindowTreeClient::CancelWindowMove(Window* window) { |
694 tree_->CancelWindowMove(window->server_id()); | 702 tree_->CancelWindowMove(window->server_id()); |
695 } | 703 } |
696 | 704 |
697 Window* WindowTreeClient::NewWindow( | 705 Window* WindowTreeClient::NewWindow(const Window::SharedProperties* properties, |
698 const Window::SharedProperties* properties) { | 706 bool container) { |
699 return NewWindowImpl(NewWindowType::CHILD, properties); | 707 return NewWindowImpl(NewWindowType::CHILD, properties, container); |
700 } | 708 } |
701 | 709 |
702 Window* WindowTreeClient::NewTopLevelWindow( | 710 Window* WindowTreeClient::NewTopLevelWindow( |
703 const Window::SharedProperties* properties) { | 711 const Window::SharedProperties* properties) { |
704 Window* window = NewWindowImpl(NewWindowType::TOP_LEVEL, properties); | 712 Window* window = NewWindowImpl(NewWindowType::TOP_LEVEL, properties); |
705 // Assume newly created top level windows are drawn by default, otherwise | 713 // Assume newly created top level windows are drawn by default, otherwise |
706 // requests to focus will fail. We will get the real value in | 714 // requests to focus will fail. We will get the real value in |
707 // OnTopLevelCreated(). | 715 // OnTopLevelCreated(). |
708 window->LocalSetParentDrawn(true); | 716 window->LocalSetParentDrawn(true); |
709 return window; | 717 return window; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 if (!window) | 887 if (!window) |
880 return; | 888 return; |
881 | 889 |
882 InFlightBoundsChange new_change(window, new_bounds); | 890 InFlightBoundsChange new_change(window, new_bounds); |
883 if (ApplyServerChangeToExistingInFlightChange(new_change)) | 891 if (ApplyServerChangeToExistingInFlightChange(new_change)) |
884 return; | 892 return; |
885 | 893 |
886 WindowPrivate(window).LocalSetBounds(old_bounds, new_bounds); | 894 WindowPrivate(window).LocalSetBounds(old_bounds, new_bounds); |
887 } | 895 } |
888 | 896 |
| 897 void WindowTreeClient::OnWindowSurfaceCreated( |
| 898 Id window_id, |
| 899 const gfx::Size& size, |
| 900 float device_scale_factor, |
| 901 const cc::SurfaceId& surface_id, |
| 902 const cc::SurfaceSequence& surface_sequence) { |
| 903 Window* window = GetWindowByServerId(window_id); |
| 904 if (!window) |
| 905 return; |
| 906 |
| 907 // TODO(fsamuel): Figure out lifetime management. |
| 908 WindowPrivate(window).LocalSetSurfaceId(size, device_scale_factor, surface_id, |
| 909 surface_sequence); |
| 910 } |
| 911 |
889 void WindowTreeClient::OnClientAreaChanged( | 912 void WindowTreeClient::OnClientAreaChanged( |
890 uint32_t window_id, | 913 uint32_t window_id, |
891 const gfx::Insets& new_client_area, | 914 const gfx::Insets& new_client_area, |
892 mojo::Array<gfx::Rect> new_additional_client_areas) { | 915 mojo::Array<gfx::Rect> new_additional_client_areas) { |
893 Window* window = GetWindowByServerId(window_id); | 916 Window* window = GetWindowByServerId(window_id); |
894 if (window) { | 917 if (window) { |
895 WindowPrivate(window).LocalSetClientArea( | 918 WindowPrivate(window).LocalSetClientArea( |
896 new_client_area, | 919 new_client_area, |
897 new_additional_client_areas.To<std::vector<gfx::Rect>>()); | 920 new_additional_client_areas.To<std::vector<gfx::Rect>>()); |
898 } | 921 } |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 Window* window, | 1430 Window* window, |
1408 const gfx::Vector2d& offset, | 1431 const gfx::Vector2d& offset, |
1409 const gfx::Insets& hit_area) { | 1432 const gfx::Insets& hit_area) { |
1410 if (window_manager_internal_client_) { | 1433 if (window_manager_internal_client_) { |
1411 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( | 1434 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
1412 server_id(window), offset.x(), offset.y(), hit_area); | 1435 server_id(window), offset.x(), offset.y(), hit_area); |
1413 } | 1436 } |
1414 } | 1437 } |
1415 | 1438 |
1416 } // namespace ui | 1439 } // namespace ui |
OLD | NEW |