OLD | NEW |
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 wm::SetBoundsEvent event(wm::WM_EVENT_SET_BOUNDS, requested_bounds); | 127 wm::SetBoundsEvent event(wm::WM_EVENT_SET_BOUNDS, requested_bounds); |
128 window_state->OnWMEvent(&event); | 128 window_state->OnWMEvent(&event); |
129 UpdateShelfVisibility(); | 129 UpdateShelfVisibility(); |
130 } | 130 } |
131 | 131 |
132 ////////////////////////////////////////////////////////////////////////////// | 132 ////////////////////////////////////////////////////////////////////////////// |
133 // WorkspaceLayoutManager, keyboard::KeyboardControllerObserver implementation: | 133 // WorkspaceLayoutManager, keyboard::KeyboardControllerObserver implementation: |
134 | 134 |
135 void WorkspaceLayoutManager::OnKeyboardBoundsChanging( | 135 void WorkspaceLayoutManager::OnKeyboardBoundsChanging( |
136 const gfx::Rect& new_bounds) { | 136 const gfx::Rect& new_bounds) { |
137 aura::Window* root_window = window_->GetRootWindow(); | |
138 ui::InputMethod* input_method = | 137 ui::InputMethod* input_method = |
139 root_window->GetProperty(aura::client::kRootWindowInputMethodKey); | 138 root_window_->GetProperty(aura::client::kRootWindowInputMethodKey); |
140 ui::TextInputClient* text_input_client = input_method->GetTextInputClient(); | 139 ui::TextInputClient* text_input_client = input_method->GetTextInputClient(); |
141 if (!text_input_client) | 140 if (!text_input_client) |
142 return; | 141 return; |
143 aura::Window *window = text_input_client->GetAttachedWindow(); | 142 aura::Window *window = |
| 143 text_input_client->GetAttachedWindow()->GetToplevelWindow(); |
144 if (!window || !window_->Contains(window)) | 144 if (!window || !window_->Contains(window)) |
145 return; | 145 return; |
146 aura::Window *toplevel_window = window->GetToplevelWindow(); | 146 wm::WindowState* window_state = wm::GetWindowState(window); |
147 wm::WindowState* toplevel_window_state = wm::GetWindowState(toplevel_window); | |
148 if (!new_bounds.IsEmpty()) { | 147 if (!new_bounds.IsEmpty()) { |
149 // Store existing bounds to be restored before resizing for keyboard if it | 148 // Store existing bounds to be restored before resizing for keyboard if it |
150 // is not already stored. | 149 // is not already stored. |
151 if (!toplevel_window_state->HasRestoreBounds()) | 150 if (!window_state->HasRestoreBounds()) |
152 toplevel_window_state->SaveCurrentBoundsForRestore(); | 151 window_state->SaveCurrentBoundsForRestore(); |
153 | 152 |
154 gfx::Rect window_bounds = ScreenUtil::ConvertRectToScreen( | 153 gfx::Rect window_bounds = ScreenUtil::ConvertRectToScreen( |
155 window_, | 154 window_, |
156 window->GetTargetBounds()); | 155 window->GetTargetBounds()); |
157 gfx::Rect intersect = gfx::IntersectRects(window_bounds, new_bounds); | 156 gfx::Rect intersect = gfx::IntersectRects(window_bounds, new_bounds); |
158 int shift = std::min(intersect.height(), | 157 int shift = std::min(intersect.height(), |
159 window->bounds().y() - work_area_in_parent_.y()); | 158 window->bounds().y() - work_area_in_parent_.y()); |
160 if (shift > 0) { | 159 if (shift > 0) { |
161 gfx::Point origin(window->bounds().x(), window->bounds().y() - shift); | 160 gfx::Point origin(window->bounds().x(), window->bounds().y() - shift); |
162 SetChildBounds(window, gfx::Rect(origin, window->bounds().size())); | 161 SetChildBounds(window, gfx::Rect(origin, window->bounds().size())); |
163 } | 162 } |
164 } else if (toplevel_window_state->HasRestoreBounds()) { | 163 } else if (window_state->HasRestoreBounds()) { |
165 // Keyboard hidden, restore original bounds if they exist. | 164 // Keyboard hidden, restore original bounds if they exist. |
166 toplevel_window_state->SetAndClearRestoreBounds(); | 165 window_state->SetAndClearRestoreBounds(); |
167 } | 166 } |
168 } | 167 } |
169 | 168 |
170 ////////////////////////////////////////////////////////////////////////////// | 169 ////////////////////////////////////////////////////////////////////////////// |
171 // WorkspaceLayoutManager, ash::ShellObserver implementation: | 170 // WorkspaceLayoutManager, ash::ShellObserver implementation: |
172 | 171 |
173 void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() { | 172 void WorkspaceLayoutManager::OnDisplayWorkAreaInsetsChanged() { |
174 const gfx::Rect work_area(ScreenUtil::ConvertRectFromScreen( | 173 const gfx::Rect work_area(ScreenUtil::ConvertRectFromScreen( |
175 window_, | 174 window_, |
176 Shell::GetScreen()->GetDisplayNearestWindow(window_).work_area())); | 175 Shell::GetScreen()->GetDisplayNearestWindow(window_).work_area())); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 bool is_fullscreen = GetRootWindowController( | 318 bool is_fullscreen = GetRootWindowController( |
320 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL; | 319 window_->GetRootWindow())->GetWindowForFullscreenMode() != NULL; |
321 if (is_fullscreen != is_fullscreen_) { | 320 if (is_fullscreen != is_fullscreen_) { |
322 ash::Shell::GetInstance()->NotifyFullscreenStateChange( | 321 ash::Shell::GetInstance()->NotifyFullscreenStateChange( |
323 is_fullscreen, window_->GetRootWindow()); | 322 is_fullscreen, window_->GetRootWindow()); |
324 is_fullscreen_ = is_fullscreen; | 323 is_fullscreen_ = is_fullscreen; |
325 } | 324 } |
326 } | 325 } |
327 | 326 |
328 } // namespace ash | 327 } // namespace ash |
OLD | NEW |