| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 ui::mojom::WindowTreePtr window_tree; | 225 ui::mojom::WindowTreePtr window_tree; |
| 226 factory->CreateWindowTree(GetProxy(&window_tree), | 226 factory->CreateWindowTree(GetProxy(&window_tree), |
| 227 binding_.CreateInterfacePtrAndBind()); | 227 binding_.CreateInterfacePtrAndBind()); |
| 228 SetWindowTree(std::move(window_tree)); | 228 SetWindowTree(std::move(window_tree)); |
| 229 } | 229 } |
| 230 | 230 |
| 231 client::CaptureClient* WindowTreeClient::GetCaptureClient() { | 231 client::CaptureClient* WindowTreeClient::GetCaptureClient() { |
| 232 return delegate_->GetCaptureClient(); | 232 return delegate_->GetCaptureClient(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void WindowTreeClient::SetClientArea( | |
| 236 Window* window, | |
| 237 const gfx::Insets& client_area, | |
| 238 const std::vector<gfx::Rect>& additional_client_areas) { | |
| 239 DCHECK(tree_); | |
| 240 float device_scale_factor = ScaleFactorForDisplay(window); | |
| 241 std::vector<gfx::Rect> additional_client_areas_in_pixel; | |
| 242 for (const gfx::Rect& area : additional_client_areas) { | |
| 243 additional_client_areas_in_pixel.push_back( | |
| 244 gfx::ConvertRectToPixel(device_scale_factor, area)); | |
| 245 } | |
| 246 tree_->SetClientArea( | |
| 247 WindowMus::Get(window)->server_id(), | |
| 248 gfx::ConvertInsetsToPixel(device_scale_factor, client_area), | |
| 249 additional_client_areas_in_pixel); | |
| 250 } | |
| 251 | |
| 252 void WindowTreeClient::SetHitTestMask(Window* window, const gfx::Rect& mask) { | |
| 253 DCHECK(tree_); | |
| 254 tree_->SetHitTestMask( | |
| 255 WindowMus::Get(window)->server_id(), | |
| 256 gfx::ConvertRectToPixel(ScaleFactorForDisplay(window), mask)); | |
| 257 } | |
| 258 | |
| 259 void WindowTreeClient::ClearHitTestMask(Window* window) { | |
| 260 DCHECK(tree_); | |
| 261 tree_->SetHitTestMask(WindowMus::Get(window)->server_id(), base::nullopt); | |
| 262 } | |
| 263 | |
| 264 void WindowTreeClient::SetCanFocus(Window* window, bool can_focus) { | 235 void WindowTreeClient::SetCanFocus(Window* window, bool can_focus) { |
| 265 DCHECK(tree_); | 236 DCHECK(tree_); |
| 266 DCHECK(window); | 237 DCHECK(window); |
| 267 tree_->SetCanFocus(WindowMus::Get(window)->server_id(), can_focus); | 238 tree_->SetCanFocus(WindowMus::Get(window)->server_id(), can_focus); |
| 268 } | 239 } |
| 269 | 240 |
| 270 void WindowTreeClient::SetPredefinedCursor(WindowMus* window, | 241 void WindowTreeClient::SetPredefinedCursor(WindowMus* window, |
| 271 ui::mojom::Cursor old_cursor, | 242 ui::mojom::Cursor old_cursor, |
| 272 ui::mojom::Cursor new_cursor) { | 243 ui::mojom::Cursor new_cursor) { |
| 273 DCHECK(tree_); | 244 DCHECK(tree_); |
| (...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1503 } | 1474 } |
| 1504 } | 1475 } |
| 1505 | 1476 |
| 1506 void WindowTreeClient::OnWindowTreeHostBoundsWillChange( | 1477 void WindowTreeClient::OnWindowTreeHostBoundsWillChange( |
| 1507 WindowTreeHostMus* window_tree_host, | 1478 WindowTreeHostMus* window_tree_host, |
| 1508 const gfx::Rect& bounds) { | 1479 const gfx::Rect& bounds) { |
| 1509 ScheduleInFlightBoundsChange(WindowMus::Get(window_tree_host->window()), | 1480 ScheduleInFlightBoundsChange(WindowMus::Get(window_tree_host->window()), |
| 1510 window_tree_host->GetBounds(), bounds); | 1481 window_tree_host->GetBounds(), bounds); |
| 1511 } | 1482 } |
| 1512 | 1483 |
| 1484 void WindowTreeClient::OnWindowTreeHostClientAreaWillChange( |
| 1485 WindowTreeHostMus* window_tree_host, |
| 1486 const gfx::Insets& client_area, |
| 1487 const std::vector<gfx::Rect>& additional_client_areas) { |
| 1488 DCHECK(tree_); |
| 1489 Window* window = window_tree_host->window(); |
| 1490 float device_scale_factor = ScaleFactorForDisplay(window); |
| 1491 std::vector<gfx::Rect> additional_client_areas_in_pixel; |
| 1492 for (const gfx::Rect& area : additional_client_areas) { |
| 1493 additional_client_areas_in_pixel.push_back( |
| 1494 gfx::ConvertRectToPixel(device_scale_factor, area)); |
| 1495 } |
| 1496 tree_->SetClientArea( |
| 1497 WindowMus::Get(window)->server_id(), |
| 1498 gfx::ConvertInsetsToPixel(device_scale_factor, client_area), |
| 1499 additional_client_areas_in_pixel); |
| 1500 } |
| 1501 |
| 1502 void WindowTreeClient::OnWindowTreeHostHitTestMaskWillChange( |
| 1503 WindowTreeHostMus* window_tree_host, |
| 1504 const base::Optional<gfx::Rect>& mask_rect) { |
| 1505 Window* window = window_tree_host->window(); |
| 1506 |
| 1507 base::Optional<gfx::Rect> out_rect = base::nullopt; |
| 1508 if (mask_rect) { |
| 1509 out_rect = gfx::ConvertRectToPixel(ScaleFactorForDisplay(window), |
| 1510 mask_rect.value()); |
| 1511 } |
| 1512 |
| 1513 tree_->SetHitTestMask(WindowMus::Get(window_tree_host->window())->server_id(), |
| 1514 out_rect); |
| 1515 } |
| 1516 |
| 1513 std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortForTopLevel() { | 1517 std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortForTopLevel() { |
| 1514 std::unique_ptr<WindowPortMus> window_port = | 1518 std::unique_ptr<WindowPortMus> window_port = |
| 1515 base::MakeUnique<WindowPortMus>(this, WindowMusType::TOP_LEVEL); | 1519 base::MakeUnique<WindowPortMus>(this, WindowMusType::TOP_LEVEL); |
| 1516 roots_.insert(window_port.get()); | 1520 roots_.insert(window_port.get()); |
| 1517 return window_port; | 1521 return window_port; |
| 1518 } | 1522 } |
| 1519 | 1523 |
| 1520 void WindowTreeClient::OnWindowTreeHostCreated( | 1524 void WindowTreeClient::OnWindowTreeHostCreated( |
| 1521 WindowTreeHostMus* window_tree_host) { | 1525 WindowTreeHostMus* window_tree_host) { |
| 1522 // All WindowTreeHosts are destroyed before this, so we don't need to unset | 1526 // All WindowTreeHosts are destroyed before this, so we don't need to unset |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1583 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1587 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
| 1584 this, capture_synchronizer_.get(), window)); | 1588 this, capture_synchronizer_.get(), window)); |
| 1585 } | 1589 } |
| 1586 | 1590 |
| 1587 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1591 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
| 1588 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1592 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
| 1589 this, focus_synchronizer_.get(), window)); | 1593 this, focus_synchronizer_.get(), window)); |
| 1590 } | 1594 } |
| 1591 | 1595 |
| 1592 } // namespace aura | 1596 } // namespace aura |
| OLD | NEW |