Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Side by Side Diff: remoting/client/ui/desktop_viewport.cc

Issue 2909703002: [CRD iOS] Preserve viewport state when toggling the soft keyboard (Closed)
Patch Set: Merge ToT Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/client/ui/desktop_viewport.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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, otherwise keep
39 // the offset and scale and just change the constraint. This is to cover these
40 // use cases:
41 // * Rotation => Reset
42 // * Keyboard => No reset
43 // * Settings menu => No reset
44 //
45 // TODO(yuweih): This is probably too much inferring. Let the caller to decide
46 // when to call ResizeToFit() if things don't work right.
47 bool need_to_reset =
48 surface_width != surface_size_.x && surface_height != surface_size_.y;
49
38 surface_size_.x = surface_width; 50 surface_size_.x = surface_width;
39 surface_size_.y = surface_height; 51 surface_size_.y = surface_height;
40 ResizeToFit(); 52
53 if (need_to_reset) {
54 ResizeToFit();
55 return;
56 }
57
58 UpdateViewport();
41 } 59 }
42 60
43 void DesktopViewport::MoveDesktop(float dx, float dy) { 61 void DesktopViewport::MoveDesktop(float dx, float dy) {
44 desktop_to_surface_transform_.PostTranslate({dx, dy}); 62 desktop_to_surface_transform_.PostTranslate({dx, dy});
45 UpdateViewport(); 63 UpdateViewport();
46 } 64 }
47 65
48 void DesktopViewport::ScaleDesktop(float px, float py, float scale) { 66 void DesktopViewport::ScaleDesktop(float px, float py, float scale) {
49 desktop_to_surface_transform_.PostScale({px, py}, scale); 67 desktop_to_surface_transform_.PostScale({px, py}, scale);
50 UpdateViewport(); 68 UpdateViewport();
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 280
263 if (new_point.y < bounds.top) { 281 if (new_point.y < bounds.top) {
264 new_point.y = bounds.top; 282 new_point.y = bounds.top;
265 } else if (new_point.y > bounds.bottom) { 283 } else if (new_point.y > bounds.bottom) {
266 new_point.y = bounds.bottom; 284 new_point.y = bounds.bottom;
267 } 285 }
268 return new_point; 286 return new_point;
269 } 287 }
270 288
271 } // namespace remoting 289 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/ui/desktop_viewport.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698