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

Side by Side Diff: ui/wm/core/ime_util.cc

Issue 2553603002: New accessibility virtual keyboard behavior in non-sticky mode. (Closed)
Patch Set: Remove unused variable Created 3 years, 8 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
« ui/wm/core/ime_util.h ('K') | « ui/wm/core/ime_util.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/wm/core/ime_util.h"
6
7 #include "base/command_line.h"
8 #include "ui/aura/client/aura_constants.h"
9 #include "ui/base/ui_base_switches.h"
10 #include "ui/gfx/geometry/rect.h"
11 #include "ui/wm/core/coordinate_conversion.h"
12
13 namespace wm {
14
15 DEFINE_OWNED_UI_CLASS_PROPERTY_KEY(gfx::Rect,
16 kVirtualKeyboardRestoreBoundsKey,
17 nullptr);
18
19 bool MoveWindowToEnsureCaretNotInRect(aura::Window* window,
20 const gfx::Rect& rect_in_screen) {
21 gfx::Rect original_window_bounds = window->GetBoundsInScreen();
22 // Calculate vertial window shift
23 gfx::Rect rect_in_root_window = rect_in_screen;
24 ::wm::ConvertRectFromScreen(window->GetRootWindow(), &rect_in_root_window);
25 gfx::Rect bounds_in_root_window = window->GetBoundsInRootWindow();
26 const int top_y =
27 std::max(rect_in_root_window.y() - bounds_in_root_window.height(), 0);
28
29 // No need to move up the window
30 if (top_y >= bounds_in_root_window.y())
31 return false;
32
33 // Set restore bounds and move the window.
34 window->SetProperty(kVirtualKeyboardRestoreBoundsKey,
35 new gfx::Rect(original_window_bounds));
36
37 gfx::Rect new_bounds_in_root_window = bounds_in_root_window;
38 new_bounds_in_root_window.set_y(top_y);
39 window->SetBounds(new_bounds_in_root_window);
40 return true;
41 }
42
43 void RestoreWindowBoundsOnClientFocusLost(aura::Window* window) {
44 #if defined(OS_CHROMEOS)
45 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
46 ::switches::kUseNewVirtualKeyboardBehavior))
47 return;
48
49 // Get restore bounds of the window
50 gfx::Rect* vk_restore_bounds =
51 window->GetProperty(kVirtualKeyboardRestoreBoundsKey);
52
53 if (vk_restore_bounds) {
54 // Restore the window bounds
55 // TODO(yhanada): Don't move the window if a user has moved it while the
56 // keyboard is shown.
57 if (window->GetBoundsInScreen() != *vk_restore_bounds) {
58 gfx::Rect original_bounds = *vk_restore_bounds;
59 ::wm::ConvertRectFromScreen(window->GetRootWindow(), &original_bounds);
60 window->SetBounds(original_bounds);
61 }
62 window->ClearProperty(wm::kVirtualKeyboardRestoreBoundsKey);
63 }
64 #endif // defined(OS_CHROMEOS)
65 }
66
67 } // namespace wm
OLDNEW
« ui/wm/core/ime_util.h ('K') | « ui/wm/core/ime_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698