Chromium Code Reviews| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 DCHECK(window_manager_delegate_); | 204 DCHECK(window_manager_delegate_); |
| 205 | 205 |
| 206 ui::mojom::WindowManagerWindowTreeFactoryPtr factory; | 206 ui::mojom::WindowManagerWindowTreeFactoryPtr factory; |
| 207 connector->ConnectToInterface(ui::mojom::kServiceName, &factory); | 207 connector->ConnectToInterface(ui::mojom::kServiceName, &factory); |
| 208 ui::mojom::WindowTreePtr window_tree; | 208 ui::mojom::WindowTreePtr window_tree; |
| 209 factory->CreateWindowTree(GetProxy(&window_tree), | 209 factory->CreateWindowTree(GetProxy(&window_tree), |
| 210 binding_.CreateInterfacePtrAndBind()); | 210 binding_.CreateInterfacePtrAndBind()); |
| 211 SetWindowTree(std::move(window_tree)); | 211 SetWindowTree(std::move(window_tree)); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void WindowTreeClient::SetClientArea( | |
| 215 Window* window, | |
| 216 const gfx::Insets& client_area, | |
| 217 const std::vector<gfx::Rect>& additional_client_areas) { | |
| 218 DCHECK(tree_); | |
| 219 float device_scale_factor = ScaleFactorForDisplay(window); | |
| 220 std::vector<gfx::Rect> additional_client_areas_in_pixel; | |
| 221 for (const gfx::Rect& area : additional_client_areas) { | |
| 222 additional_client_areas_in_pixel.push_back( | |
| 223 gfx::ConvertRectToPixel(device_scale_factor, area)); | |
| 224 } | |
| 225 tree_->SetClientArea( | |
| 226 WindowMus::Get(window)->server_id(), | |
| 227 gfx::ConvertInsetsToPixel(device_scale_factor, client_area), | |
| 228 additional_client_areas_in_pixel); | |
| 229 } | |
| 230 | |
| 231 void WindowTreeClient::SetHitTestMask(Window* window, const gfx::Rect& mask) { | |
| 232 DCHECK(tree_); | |
| 233 tree_->SetHitTestMask( | |
| 234 WindowMus::Get(window)->server_id(), | |
| 235 gfx::ConvertRectToPixel(ScaleFactorForDisplay(window), mask)); | |
| 236 } | |
| 237 | |
| 238 void WindowTreeClient::ClearHitTestMask(Window* window) { | |
| 239 DCHECK(tree_); | |
| 240 tree_->SetHitTestMask(WindowMus::Get(window)->server_id(), base::nullopt); | |
| 241 } | |
| 242 | |
| 243 void WindowTreeClient::SetCanFocus(Window* window, bool can_focus) { | 214 void WindowTreeClient::SetCanFocus(Window* window, bool can_focus) { |
| 244 DCHECK(tree_); | 215 DCHECK(tree_); |
| 245 DCHECK(window); | 216 DCHECK(window); |
| 246 tree_->SetCanFocus(WindowMus::Get(window)->server_id(), can_focus); | 217 tree_->SetCanFocus(WindowMus::Get(window)->server_id(), can_focus); |
| 247 } | 218 } |
| 248 | 219 |
| 249 void WindowTreeClient::SetPredefinedCursor(WindowMus* window, | 220 void WindowTreeClient::SetPredefinedCursor(WindowMus* window, |
| 250 ui::mojom::Cursor old_cursor, | 221 ui::mojom::Cursor old_cursor, |
| 251 ui::mojom::Cursor new_cursor) { | 222 ui::mojom::Cursor new_cursor) { |
| 252 DCHECK(tree_); | 223 DCHECK(tree_); |
| (...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1479 } | 1450 } |
| 1480 } | 1451 } |
| 1481 | 1452 |
| 1482 void WindowTreeClient::OnWindowTreeHostBoundsWillChange( | 1453 void WindowTreeClient::OnWindowTreeHostBoundsWillChange( |
| 1483 WindowTreeHostMus* window_tree_host, | 1454 WindowTreeHostMus* window_tree_host, |
| 1484 const gfx::Rect& bounds) { | 1455 const gfx::Rect& bounds) { |
| 1485 ScheduleInFlightBoundsChange(WindowMus::Get(window_tree_host->window()), | 1456 ScheduleInFlightBoundsChange(WindowMus::Get(window_tree_host->window()), |
| 1486 window_tree_host->GetBounds(), bounds); | 1457 window_tree_host->GetBounds(), bounds); |
| 1487 } | 1458 } |
| 1488 | 1459 |
| 1460 void WindowTreeClient::OnWindowTreeHostClientAreaWillChange( | |
| 1461 WindowTreeHostMus* window_tree_host, | |
| 1462 const gfx::Insets& client_area) { | |
| 1463 DCHECK(tree_); | |
| 1464 Window* window = window_tree_host->window(); | |
| 1465 float device_scale_factor = ScaleFactorForDisplay(window); | |
| 1466 std::vector<gfx::Rect> additional_client_areas_in_pixel; | |
| 1467 // TODO(erg): Currently, nobody uses |additional_client_area_in_pixels|. | |
|
sky
2016/11/22 04:19:09
It's used in two places. See NonClientFrameControl
Elliot Glaysher
2016/11/22 18:57:12
Done.
| |
| 1468 tree_->SetClientArea( | |
| 1469 WindowMus::Get(window)->server_id(), | |
| 1470 gfx::ConvertInsetsToPixel(device_scale_factor, client_area), | |
| 1471 additional_client_areas_in_pixel); | |
| 1472 } | |
| 1473 | |
| 1474 void WindowTreeClient::OnWindowTreeHostHitTestMaskWillChange( | |
| 1475 WindowTreeHostMus* window_tree_host, | |
| 1476 const base::Optional<gfx::Rect>& mask_rect) { | |
| 1477 Window* window = window_tree_host->window(); | |
| 1478 | |
| 1479 base::Optional<gfx::Rect> out_rect = base::nullopt; | |
| 1480 if (mask_rect) { | |
| 1481 out_rect = gfx::ConvertRectToPixel(ScaleFactorForDisplay(window), | |
| 1482 mask_rect.value()); | |
| 1483 } | |
| 1484 | |
| 1485 tree_->SetHitTestMask(WindowMus::Get(window_tree_host->window())->server_id(), | |
| 1486 out_rect); | |
| 1487 } | |
| 1488 | |
| 1489 std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortForTopLevel() { | 1489 std::unique_ptr<WindowPortMus> WindowTreeClient::CreateWindowPortForTopLevel() { |
| 1490 std::unique_ptr<WindowPortMus> window_port = | 1490 std::unique_ptr<WindowPortMus> window_port = |
| 1491 base::MakeUnique<WindowPortMus>(this, WindowMusType::TOP_LEVEL); | 1491 base::MakeUnique<WindowPortMus>(this, WindowMusType::TOP_LEVEL); |
| 1492 roots_.insert(window_port.get()); | 1492 roots_.insert(window_port.get()); |
| 1493 return window_port; | 1493 return window_port; |
| 1494 } | 1494 } |
| 1495 | 1495 |
| 1496 void WindowTreeClient::OnWindowTreeHostCreated( | 1496 void WindowTreeClient::OnWindowTreeHostCreated( |
| 1497 WindowTreeHostMus* window_tree_host) { | 1497 WindowTreeHostMus* window_tree_host) { |
| 1498 // All WindowTreeHosts are destroyed before this, so we don't need to unset | 1498 // All WindowTreeHosts are destroyed before this, so we don't need to unset |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1541 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1541 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
| 1542 this, capture_synchronizer_.get(), window)); | 1542 this, capture_synchronizer_.get(), window)); |
| 1543 } | 1543 } |
| 1544 | 1544 |
| 1545 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1545 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
| 1546 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1546 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
| 1547 this, focus_synchronizer_.get(), window)); | 1547 this, focus_synchronizer_.get(), window)); |
| 1548 } | 1548 } |
| 1549 | 1549 |
| 1550 } // namespace aura | 1550 } // namespace aura |
| OLD | NEW |