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

Side by Side Diff: ash/wm/workspace/workspace_layout_manager.cc

Issue 468923002: Restore window size after accessbility keyboard hides. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix per reviewer. Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/wm/workspace/workspace_layout_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/wm/workspace/workspace_layout_manager.h" 5 #include "ash/wm/workspace/workspace_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/display/display_controller.h" 9 #include "ash/display/display_controller.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 const gfx::Rect& new_bounds) { 136 const gfx::Rect& new_bounds) {
137 aura::Window* root_window = window_->GetRootWindow(); 137 aura::Window* root_window = window_->GetRootWindow();
138 ui::InputMethod* input_method = 138 ui::InputMethod* input_method =
139 root_window->GetProperty(aura::client::kRootWindowInputMethodKey); 139 root_window->GetProperty(aura::client::kRootWindowInputMethodKey);
140 ui::TextInputClient* text_input_client = input_method->GetTextInputClient(); 140 ui::TextInputClient* text_input_client = input_method->GetTextInputClient();
141 if (!text_input_client) 141 if (!text_input_client)
142 return; 142 return;
143 aura::Window *window = text_input_client->GetAttachedWindow(); 143 aura::Window *window = text_input_client->GetAttachedWindow();
144 if (!window || !window_->Contains(window)) 144 if (!window || !window_->Contains(window))
145 return; 145 return;
146 gfx::Rect window_bounds = ScreenUtil::ConvertRectToScreen( 146 aura::Window *toplevel_window = window->GetToplevelWindow();
147 window_, 147 wm::WindowState* toplevel_window_state = wm::GetWindowState(toplevel_window);
148 window->GetTargetBounds()); 148 if (!new_bounds.IsEmpty()) {
149 gfx::Rect intersect = gfx::IntersectRects(window_bounds, new_bounds); 149 // Store existing bounds to be restored before resizing for keyboard if it
150 int shift = std::min(intersect.height(), 150 // is not already stored.
151 window->bounds().y() - work_area_in_parent_.y()); 151 if (!toplevel_window_state->HasRestoreBounds()) {
flackr 2014/08/14 19:17:58 nit: no curlies { } for single line statement. No
Peter Wen 2014/08/15 13:44:48 Done. It seems that workspace_layout_manager's on
152 if (shift > 0) { 152 toplevel_window_state->SaveCurrentBoundsForRestore();
153 gfx::Point origin(window->bounds().x(), window->bounds().y() - shift); 153 }
154 SetChildBounds(window, gfx::Rect(origin, window->bounds().size())); 154
155 gfx::Rect window_bounds = ScreenUtil::ConvertRectToScreen(
156 window_,
157 window->GetTargetBounds());
158 gfx::Rect intersect = gfx::IntersectRects(window_bounds, new_bounds);
159 int shift = std::min(intersect.height(),
160 window->bounds().y() - work_area_in_parent_.y());
161 if (shift > 0) {
flackr 2014/08/14 19:17:58 Should we even set restore bounds if there is no c
Peter Wen 2014/08/15 13:44:48 Yes, as that way even if the focused input area do
flackr 2014/08/20 15:02:14 Alright, sounds fine. It should be fine either way
162 gfx::Point origin(window->bounds().x(), window->bounds().y() - shift);
163 SetChildBounds(window, gfx::Rect(origin, window->bounds().size()));
164 }
165 } else if (toplevel_window_state->HasRestoreBounds()) {
166 // Keyboard hidden, restore original bounds if they exist.
167 toplevel_window_state->SetAndClearRestoreBounds();
155 } 168 }
156 } 169 }
157 170
158 ////////////////////////////////////////////////////////////////////////////// 171 //////////////////////////////////////////////////////////////////////////////
159 // WorkspaceLayoutManager, ash::ShellObserver implementation: 172 // WorkspaceLayoutManager, ash::ShellObserver implementation:
160 173
161 void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() { 174 void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() {
162 const gfx::Rect work_area(ScreenUtil::ConvertRectFromScreen( 175 const gfx::Rect work_area(ScreenUtil::ConvertRectFromScreen(
163 window_, 176 window_,
164 Shell::GetScreen()->GetDisplayNearestWindow(window_).work_area())); 177 Shell::GetScreen()->GetDisplayNearestWindow(window_).work_area()));
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 bool is_fullscreen = GetRootWindowController( 320 bool is_fullscreen = GetRootWindowController(
308 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL; 321 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL;
309 if (is_fullscreen != is_fullscreen_) { 322 if (is_fullscreen != is_fullscreen_) {
310 ash::Shell::GetInstance()->NotifyFullscreenStateChange( 323 ash::Shell::GetInstance()->NotifyFullscreenStateChange(
311 is_fullscreen, window_->GetRootWindow()); 324 is_fullscreen, window_->GetRootWindow());
312 is_fullscreen_ = is_fullscreen; 325 is_fullscreen_ = is_fullscreen;
313 } 326 }
314 } 327 }
315 328
316 } // namespace ash 329 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/workspace/workspace_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698