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

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

Issue 2747543002: ash: Start/stop observing KeyboardController via ShellObserver (Closed)
Patch Set: pass root_window to OnVirtualKeyboardStateChanged() Created 3 years, 9 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
« no previous file with comments | « ash/common/wm/workspace/workspace_layout_manager.h ('k') | ash/root_window_controller.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/common/wm/workspace/workspace_layout_manager.h" 5 #include "ash/common/wm/workspace/workspace_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/common/session/session_state_delegate.h" 9 #include "ash/common/session/session_state_delegate.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
(...skipping 22 matching lines...) Expand all
33 #include "ui/wm/public/activation_client.h" 33 #include "ui/wm/public/activation_client.h"
34 34
35 namespace ash { 35 namespace ash {
36 36
37 WorkspaceLayoutManager::WorkspaceLayoutManager(WmWindow* window) 37 WorkspaceLayoutManager::WorkspaceLayoutManager(WmWindow* window)
38 : window_(window), 38 : window_(window),
39 root_window_(window->GetRootWindow()), 39 root_window_(window->GetRootWindow()),
40 root_window_controller_(root_window_->GetRootWindowController()), 40 root_window_controller_(root_window_->GetRootWindowController()),
41 shell_(window_->GetShell()), 41 shell_(window_->GetShell()),
42 work_area_in_parent_(wm::GetDisplayWorkAreaBoundsInParent(window_)), 42 work_area_in_parent_(wm::GetDisplayWorkAreaBoundsInParent(window_)),
43 is_fullscreen_(wm::GetWindowForFullscreenMode(window) != nullptr) { 43 is_fullscreen_(wm::GetWindowForFullscreenMode(window) != nullptr),
44 keyboard_observer_(this) {
44 Shell::GetInstance()->AddShellObserver(this); 45 Shell::GetInstance()->AddShellObserver(this);
45 Shell::GetInstance()->activation_client()->AddObserver(this); 46 Shell::GetInstance()->activation_client()->AddObserver(this);
46 root_window_->aura_window()->AddObserver(this); 47 root_window_->aura_window()->AddObserver(this);
47 display::Screen::GetScreen()->AddObserver(this); 48 display::Screen::GetScreen()->AddObserver(this);
48 DCHECK(window->aura_window()->GetProperty(kSnapChildrenToPixelBoundary)); 49 DCHECK(window->aura_window()->GetProperty(kSnapChildrenToPixelBoundary));
49 } 50 }
50 51
51 WorkspaceLayoutManager::~WorkspaceLayoutManager() { 52 WorkspaceLayoutManager::~WorkspaceLayoutManager() {
52 if (root_window_) 53 if (root_window_)
53 root_window_->aura_window()->RemoveObserver(this); 54 root_window_->aura_window()->RemoveObserver(this);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 172 }
172 } else if (window_state->HasRestoreBounds()) { 173 } else if (window_state->HasRestoreBounds()) {
173 // Keyboard hidden, restore original bounds if they exist. If the user has 174 // Keyboard hidden, restore original bounds if they exist. If the user has
174 // resized or dragged the window in the meantime, WorkspaceWindowResizer 175 // resized or dragged the window in the meantime, WorkspaceWindowResizer
175 // will have cleared the restore bounds and this code will not accidentally 176 // will have cleared the restore bounds and this code will not accidentally
176 // override user intent. 177 // override user intent.
177 window_state->SetAndClearRestoreBounds(); 178 window_state->SetAndClearRestoreBounds();
178 } 179 }
179 } 180 }
180 181
181 void WorkspaceLayoutManager::OnKeyboardClosed() {} 182 void WorkspaceLayoutManager::OnKeyboardClosed() {
183 keyboard_observer_.RemoveAll();
184 }
182 185
183 ////////////////////////////////////////////////////////////////////////////// 186 //////////////////////////////////////////////////////////////////////////////
184 // WorkspaceLayoutManager, aura::WindowObserver implementation: 187 // WorkspaceLayoutManager, aura::WindowObserver implementation:
185 188
186 void WorkspaceLayoutManager::OnWindowHierarchyChanged( 189 void WorkspaceLayoutManager::OnWindowHierarchyChanged(
187 const HierarchyChangeParams& params) { 190 const HierarchyChangeParams& params) {
188 if (!wm::GetWindowState(params.target)->IsActive()) 191 if (!wm::GetWindowState(params.target)->IsActive())
189 return; 192 return;
190 // If the window is already tracked by the workspace this update would be 193 // If the window is already tracked by the workspace this update would be
191 // redundant as the fullscreen and shelf state would have been handled in 194 // redundant as the fullscreen and shelf state would have been handled in
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 // On exiting from pinned mode, if the workspace is still in fullscreen 323 // On exiting from pinned mode, if the workspace is still in fullscreen
321 // mode, then this event does not trigger the restoring yet. On exiting 324 // mode, then this event does not trigger the restoring yet. On exiting
322 // from fullscreen, the temporarily disabled always-on-top property will be 325 // from fullscreen, the temporarily disabled always-on-top property will be
323 // restored. 326 // restored.
324 return; 327 return;
325 } 328 }
326 329
327 UpdateAlwaysOnTop(WmShell::Get()->IsPinned() ? pinned_window : nullptr); 330 UpdateAlwaysOnTop(WmShell::Get()->IsPinned() ? pinned_window : nullptr);
328 } 331 }
329 332
333 void WorkspaceLayoutManager::OnVirtualKeyboardStateChanged(
334 bool activated,
335 WmWindow* root_window) {
336 if (root_window != root_window_)
sky 2017/03/14 03:23:50 As this code exists in a handful of places, WDYT o
xiyuan 2017/03/14 21:25:55 Good idea. Done.
337 return;
338
339 keyboard::KeyboardController* const keyboard_controller =
340 keyboard::KeyboardController::GetInstance();
341 if (activated && !keyboard_observer_.IsObserving(keyboard_controller)) {
342 keyboard_observer_.Add(keyboard_controller);
343 } else if (!activated &&
344 keyboard_observer_.IsObserving(keyboard_controller)) {
345 keyboard_observer_.Remove(keyboard_controller);
346 }
347 }
348
330 ////////////////////////////////////////////////////////////////////////////// 349 //////////////////////////////////////////////////////////////////////////////
331 // WorkspaceLayoutManager, private: 350 // WorkspaceLayoutManager, private:
332 351
333 void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange( 352 void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange(
334 const wm::WMEvent* event) { 353 const wm::WMEvent* event) {
335 DCHECK(event->type() == wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED || 354 DCHECK(event->type() == wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED ||
336 event->type() == wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); 355 event->type() == wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED);
337 356
338 work_area_in_parent_ = wm::GetDisplayWorkAreaBoundsInParent(window_); 357 work_area_in_parent_ = wm::GetDisplayWorkAreaBoundsInParent(window_);
339 358
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 for (auto* window : windows) { 402 for (auto* window : windows) {
384 wm::WindowState* window_state = window->GetWindowState(); 403 wm::WindowState* window_state = window->GetWindowState();
385 if (window_on_top) 404 if (window_on_top)
386 window_state->DisableAlwaysOnTop(window_on_top); 405 window_state->DisableAlwaysOnTop(window_on_top);
387 else 406 else
388 window_state->RestoreAlwaysOnTop(); 407 window_state->RestoreAlwaysOnTop();
389 } 408 }
390 } 409 }
391 410
392 } // namespace ash 411 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/workspace/workspace_layout_manager.h ('k') | ash/root_window_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698