Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "remoting/client/ui/desktop_viewport.h" | 5 #include "remoting/client/ui/desktop_viewport.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 desktop_size_.x = desktop_width; | 28 desktop_size_.x = desktop_width; |
| 29 desktop_size_.y = desktop_height; | 29 desktop_size_.y = desktop_height; |
| 30 ResizeToFit(); | 30 ResizeToFit(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void DesktopViewport::SetSurfaceSize(int surface_width, int surface_height) { | 33 void DesktopViewport::SetSurfaceSize(int surface_width, int surface_height) { |
| 34 if (surface_width == surface_size_.x && surface_height == surface_size_.y) { | 34 if (surface_width == surface_size_.x && surface_height == surface_size_.y) { |
| 35 return; | 35 return; |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Only reset the viewport if both dimensions have changed. This is to | |
| 39 // preserve the viewport state in case the surface is just scrolled up. | |
|
nicholss
2017/05/26 20:12:49
The keyboard showing changes the size of the viewp
Yuwei
2017/05/30 19:27:08
Done.
| |
| 40 // E.g. when showing the soft keyboard. | |
| 41 bool need_to_reset = | |
| 42 surface_width != surface_size_.x && surface_height != surface_size_.y; | |
| 43 | |
| 38 surface_size_.x = surface_width; | 44 surface_size_.x = surface_width; |
| 39 surface_size_.y = surface_height; | 45 surface_size_.y = surface_height; |
| 40 ResizeToFit(); | 46 |
| 47 if (need_to_reset) { | |
| 48 ResizeToFit(); | |
| 49 return; | |
| 50 } | |
| 51 | |
| 52 UpdateViewport(); | |
| 41 } | 53 } |
| 42 | 54 |
| 43 void DesktopViewport::MoveDesktop(float dx, float dy) { | 55 void DesktopViewport::MoveDesktop(float dx, float dy) { |
| 44 desktop_to_surface_transform_.PostTranslate({dx, dy}); | 56 desktop_to_surface_transform_.PostTranslate({dx, dy}); |
| 45 UpdateViewport(); | 57 UpdateViewport(); |
| 46 } | 58 } |
| 47 | 59 |
| 48 void DesktopViewport::ScaleDesktop(float px, float py, float scale) { | 60 void DesktopViewport::ScaleDesktop(float px, float py, float scale) { |
| 49 desktop_to_surface_transform_.PostScale({px, py}, scale); | 61 desktop_to_surface_transform_.PostScale({px, py}, scale); |
| 50 UpdateViewport(); | 62 UpdateViewport(); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 | 274 |
| 263 if (new_point.y < bounds.top) { | 275 if (new_point.y < bounds.top) { |
| 264 new_point.y = bounds.top; | 276 new_point.y = bounds.top; |
| 265 } else if (new_point.y > bounds.bottom) { | 277 } else if (new_point.y > bounds.bottom) { |
| 266 new_point.y = bounds.bottom; | 278 new_point.y = bounds.bottom; |
| 267 } | 279 } |
| 268 return new_point; | 280 return new_point; |
| 269 } | 281 } |
| 270 | 282 |
| 271 } // namespace remoting | 283 } // namespace remoting |
| OLD | NEW |