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 "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 24 matching lines...) Expand all Loading... | |
| 35 | 35 |
| 36 namespace ui { | 36 namespace ui { |
| 37 | 37 |
| 38 Id MakeTransportId(ClientSpecificId client_id, ClientSpecificId local_id) { | 38 Id MakeTransportId(ClientSpecificId client_id, ClientSpecificId local_id) { |
| 39 return (client_id << 16) | local_id; | 39 return (client_id << 16) | local_id; |
| 40 } | 40 } |
| 41 | 41 |
| 42 // Helper function to get the device_scale_factor() of the display::Display | 42 // Helper function to get the device_scale_factor() of the display::Display |
| 43 // with |display_id|. | 43 // with |display_id|. |
| 44 float ScaleFactorForDisplay(int64_t display_id) { | 44 float ScaleFactorForDisplay(int64_t display_id) { |
| 45 // TODO(jonross): Remove this once aura-mus is complete. Currently the screen | |
| 46 // is not being set properly for mus-in-renderer. (http://crbug.com/659155) | |
| 47 if (!display::Screen::GetScreen()) | |
| 48 return 1.f; | |
| 49 | |
| 50 // TODO(riajiang): Change to use display::GetDisplayWithDisplayId() after | 45 // TODO(riajiang): Change to use display::GetDisplayWithDisplayId() after |
| 51 // https://codereview.chromium.org/2361283002/ is landed. | 46 // https://codereview.chromium.org/2361283002/ is landed. |
| 52 std::vector<display::Display> displays = | 47 std::vector<display::Display> displays = |
| 53 display::Screen::GetScreen()->GetAllDisplays(); | 48 display::Screen::GetScreen()->GetAllDisplays(); |
| 54 auto iter = std::find_if(displays.begin(), displays.end(), | 49 auto iter = std::find_if(displays.begin(), displays.end(), |
| 55 [display_id](const display::Display& display) { | 50 [display_id](const display::Display& display) { |
| 56 return display.id() == display_id; | 51 return display.id() == display_id; |
| 57 }); | 52 }); |
| 58 if (iter != displays.end()) | 53 if (iter != displays.end()) |
| 59 return iter->device_scale_factor(); | 54 return iter->device_scale_factor(); |
| (...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1314 | 1309 |
| 1315 void WindowTreeClient::WmSetBounds(uint32_t change_id, | 1310 void WindowTreeClient::WmSetBounds(uint32_t change_id, |
| 1316 Id window_id, | 1311 Id window_id, |
| 1317 const gfx::Rect& transit_bounds) { | 1312 const gfx::Rect& transit_bounds) { |
| 1318 Window* window = GetWindowByServerId(window_id); | 1313 Window* window = GetWindowByServerId(window_id); |
| 1319 bool result = false; | 1314 bool result = false; |
| 1320 if (window) { | 1315 if (window) { |
| 1321 DCHECK(window_manager_delegate_); | 1316 DCHECK(window_manager_delegate_); |
| 1322 gfx::Rect transit_bounds_in_dip = gfx::ConvertRectToDIP( | 1317 gfx::Rect transit_bounds_in_dip = gfx::ConvertRectToDIP( |
| 1323 ScaleFactorForDisplay(window->display_id()), transit_bounds); | 1318 ScaleFactorForDisplay(window->display_id()), transit_bounds); |
| 1324 gfx::Rect bounds = transit_bounds_in_dip; | 1319 window_manager_delegate_->OnWmSetBounds(window, &transit_bounds_in_dip); |
|
Fady Samuel
2016/12/02 23:18:25
Add window->SetBounds(transit_bounds_in_dip)?
thanhph
2016/12/05 17:54:00
Done.
| |
| 1325 result = window_manager_delegate_->OnWmSetBounds(window, &bounds); | 1320 result = true; |
| 1326 if (result) { | |
| 1327 // If the resulting bounds differ return false. Returning false ensures | |
| 1328 // the client applies the bounds we set below. | |
| 1329 result = bounds == transit_bounds_in_dip; | |
| 1330 window->SetBounds(bounds); | |
| 1331 } | |
| 1332 } | 1321 } |
| 1333 if (window_manager_internal_client_) | 1322 if (window_manager_internal_client_) |
| 1334 window_manager_internal_client_->WmResponse(change_id, result); | 1323 window_manager_internal_client_->WmResponse(change_id, result); |
| 1335 } | 1324 } |
| 1336 | 1325 |
| 1337 void WindowTreeClient::WmSetProperty( | 1326 void WindowTreeClient::WmSetProperty( |
| 1338 uint32_t change_id, | 1327 uint32_t change_id, |
| 1339 Id window_id, | 1328 Id window_id, |
| 1340 const std::string& name, | 1329 const std::string& name, |
| 1341 const base::Optional<std::vector<uint8_t>>& transit_data) { | 1330 const base::Optional<std::vector<uint8_t>>& transit_data) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1478 // TODO(riajiang): Figure out if |offset| needs to be converted. | 1467 // TODO(riajiang): Figure out if |offset| needs to be converted. |
| 1479 // (http://crbugs.com/646932) | 1468 // (http://crbugs.com/646932) |
| 1480 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( | 1469 window_manager_internal_client_->SetUnderlaySurfaceOffsetAndExtendedHitArea( |
| 1481 server_id(window), offset.x(), offset.y(), | 1470 server_id(window), offset.x(), offset.y(), |
| 1482 gfx::ConvertInsetsToDIP(ScaleFactorForDisplay(window->display_id()), | 1471 gfx::ConvertInsetsToDIP(ScaleFactorForDisplay(window->display_id()), |
| 1483 hit_area)); | 1472 hit_area)); |
| 1484 } | 1473 } |
| 1485 } | 1474 } |
| 1486 | 1475 |
| 1487 } // namespace ui | 1476 } // namespace ui |
| OLD | NEW |