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

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: 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.height() > 0) {
flackr 2014/08/14 18:20:55 nit: Use !new_bounds.IsEmpty() Can't this get call
Peter Wen 2014/08/14 19:13:31 Done. Added HasRestoreBounds guard. @kevers - Is
149 gfx::Rect intersect = gfx::IntersectRects(window_bounds, new_bounds); 149 // Store existing bounds to be restored before resizing for keyboard.
150 int shift = std::min(intersect.height(), 150 toplevel_window_state->SaveCurrentBoundsForRestore();
151 window->bounds().y() - work_area_in_parent_.y()); 151
152 if (shift > 0) { 152 gfx::Rect window_bounds = ScreenUtil::ConvertRectToScreen(
153 gfx::Point origin(window->bounds().x(), window->bounds().y() - shift); 153 window_,
154 SetChildBounds(window, gfx::Rect(origin, window->bounds().size())); 154 window->GetTargetBounds());
155 gfx::Rect intersect = gfx::IntersectRects(window_bounds, new_bounds);
156 int shift = std::min(intersect.height(),
157 window->bounds().y() - work_area_in_parent_.y());
158 if (shift > 0) {
159 gfx::Point origin(window->bounds().x(), window->bounds().y() - shift);
160 SetChildBounds(window, gfx::Rect(origin, window->bounds().size()));
161 }
162 } else if (toplevel_window_state->HasRestoreBounds()) {
163 // Keyboard hidden, restore original bounds if they exist.
164 toplevel_window_state->SetAndClearRestoreBounds();
155 } 165 }
156 } 166 }
157 167
158 ////////////////////////////////////////////////////////////////////////////// 168 //////////////////////////////////////////////////////////////////////////////
159 // WorkspaceLayoutManager, ash::ShellObserver implementation: 169 // WorkspaceLayoutManager, ash::ShellObserver implementation:
160 170
161 void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() { 171 void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() {
162 const gfx::Rect work_area(ScreenUtil::ConvertRectFromScreen( 172 const gfx::Rect work_area(ScreenUtil::ConvertRectFromScreen(
163 window_, 173 window_,
164 Shell::GetScreen()->GetDisplayNearestWindow(window_).work_area())); 174 Shell::GetScreen()->GetDisplayNearestWindow(window_).work_area()));
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 bool is_fullscreen = GetRootWindowController( 317 bool is_fullscreen = GetRootWindowController(
308 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL; 318 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL;
309 if (is_fullscreen != is_fullscreen_) { 319 if (is_fullscreen != is_fullscreen_) {
310 ash::Shell::GetInstance()->NotifyFullscreenStateChange( 320 ash::Shell::GetInstance()->NotifyFullscreenStateChange(
311 is_fullscreen, window_->GetRootWindow()); 321 is_fullscreen, window_->GetRootWindow());
312 is_fullscreen_ = is_fullscreen; 322 is_fullscreen_ = is_fullscreen;
313 } 323 }
314 } 324 }
315 325
316 } // namespace ash 326 } // 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