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

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.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())
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 gfx::Rect window_bounds = ScreenUtil::ConvertRectToScreen(
155 window_,
156 window->GetTargetBounds());
157 gfx::Rect intersect = gfx::IntersectRects(window_bounds, new_bounds);
158 int shift = std::min(intersect.height(),
159 window->bounds().y() - work_area_in_parent_.y());
160 if (shift > 0) {
161 gfx::Point origin(window->bounds().x(), window->bounds().y() - shift);
162 SetChildBounds(window, gfx::Rect(origin, window->bounds().size()));
163 }
164 } else if (toplevel_window_state->HasRestoreBounds()) {
165 // Keyboard hidden, restore original bounds if they exist.
166 toplevel_window_state->SetAndClearRestoreBounds();
155 } 167 }
156 } 168 }
157 169
158 ////////////////////////////////////////////////////////////////////////////// 170 //////////////////////////////////////////////////////////////////////////////
159 // WorkspaceLayoutManager, ash::ShellObserver implementation: 171 // WorkspaceLayoutManager, ash::ShellObserver implementation:
160 172
161 void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() { 173 void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() {
162 const gfx::Rect work_area(ScreenUtil::ConvertRectFromScreen( 174 const gfx::Rect work_area(ScreenUtil::ConvertRectFromScreen(
163 window_, 175 window_,
164 Shell::GetScreen()->GetDisplayNearestWindow(window_).work_area())); 176 Shell::GetScreen()->GetDisplayNearestWindow(window_).work_area()));
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 bool is_fullscreen = GetRootWindowController( 319 bool is_fullscreen = GetRootWindowController(
308 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL; 320 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL;
309 if (is_fullscreen != is_fullscreen_) { 321 if (is_fullscreen != is_fullscreen_) {
310 ash::Shell::GetInstance()->NotifyFullscreenStateChange( 322 ash::Shell::GetInstance()->NotifyFullscreenStateChange(
311 is_fullscreen, window_->GetRootWindow()); 323 is_fullscreen, window_->GetRootWindow());
312 is_fullscreen_ = is_fullscreen; 324 is_fullscreen_ = is_fullscreen;
313 } 325 }
314 } 326 }
315 327
316 } // namespace ash 328 } // 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