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

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 TextInputClient::OnClientFocusLost() 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/aura/client/aura_constants.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/aura/window.h"
10 #include "ui/base/ui_base_switches.h"
11 #include "ui/gfx/geometry/rect.h"
12 #include "ui/wm/core/coordinate_conversion.h"
13
14 namespace wm {
15
16 bool MoveWindowToEnsureCaretNotInRect(aura::Window* window,
17 const gfx::Rect& rect_in_screen) {
18 gfx::Rect original_window_bounds = window->GetBoundsInScreen();
19 // Calculate vertial window shift
20 gfx::Rect rect_in_root_window = rect_in_screen;
21 ::wm::ConvertRectFromScreen(window->GetRootWindow(), &rect_in_root_window);
22 const int top_y = std::max(
23 rect_in_root_window.y() - window->GetBoundsInRootWindow().height(), 0);
oshima 2017/04/11 04:48:50 you can use just bounds. Or store to local variabl
yhanada 2017/04/11 15:26:53 Done.
24
25 // No need to move up the window
26 if (top_y == window->GetBoundsInRootWindow().y())
27 return false;
28
29 // Set restore bounds and move the window.
30 window->SetProperty(aura::client::kVirtualKeyboardRestoreBoundsKey,
31 new gfx::Rect(original_window_bounds));
32
33 gfx::Point new_origin(window->GetBoundsInRootWindow().x(), top_y);
oshima 2017/04/11 04:48:50 copy the bounds in root, and set_y
yhanada 2017/04/11 15:26:53 Done.
34 gfx::Rect new_window_bounds_in_root_window_space =
35 gfx::Rect(new_origin, original_window_bounds.size());
36 window->SetBounds(new_window_bounds_in_root_window_space);
37 return true;
38 }
39
40 void RestoreWindowBoundsOnClientFocusLost(aura::Window* window) {
41 #if defined(OS_CHROMEOS)
42 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
43 ::switches::kUseNewVirtualKeyboardBehavior))
44 return;
45
46 // Get restore bounds of the window
47 gfx::Rect* vk_restore_bounds =
48 window->GetProperty(aura::client::kVirtualKeyboardRestoreBoundsKey);
49
50 if (vk_restore_bounds) {
51 // Restore the window bounds
52 // TODO(yhanada): Don't move the window if a user has moved it while the
53 // keyboard is shown.
54 if (window->GetBoundsInScreen() != *vk_restore_bounds) {
55 gfx::Rect original_bounds = *vk_restore_bounds;
56 ::wm::ConvertRectFromScreen(window->GetRootWindow(), &original_bounds);
57 window->SetBounds(original_bounds);
58 }
59 window->ClearProperty(aura::client::kVirtualKeyboardRestoreBoundsKey);
60 }
61 #endif // defined(OS_CHROMEOS)
62 }
63
64 } // namespace wm
OLDNEW
« ui/aura/client/aura_constants.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