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

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

Issue 2747543002: ash: Start/stop observing KeyboardController via ShellObserver (Closed)
Patch Set: update LockLayoutManager to use similar logic 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/keyboard/keyboard_observer_register.h"
9 #include "ash/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_state_delegate.h"
10 #include "ash/common/shelf/wm_shelf.h" 11 #include "ash/common/shelf/wm_shelf.h"
11 #include "ash/common/wm/always_on_top_controller.h" 12 #include "ash/common/wm/always_on_top_controller.h"
12 #include "ash/common/wm/fullscreen_window_finder.h" 13 #include "ash/common/wm/fullscreen_window_finder.h"
13 #include "ash/common/wm/window_positioner.h" 14 #include "ash/common/wm/window_positioner.h"
14 #include "ash/common/wm/window_state.h" 15 #include "ash/common/wm/window_state.h"
15 #include "ash/common/wm/wm_event.h" 16 #include "ash/common/wm/wm_event.h"
16 #include "ash/common/wm/wm_screen_util.h" 17 #include "ash/common/wm/wm_screen_util.h"
17 #include "ash/common/wm/workspace/workspace_layout_manager_backdrop_delegate.h" 18 #include "ash/common/wm/workspace/workspace_layout_manager_backdrop_delegate.h"
18 #include "ash/common/wm_shell.h" 19 #include "ash/common/wm_shell.h"
(...skipping 14 matching lines...) Expand all
33 #include "ui/wm/public/activation_client.h" 34 #include "ui/wm/public/activation_client.h"
34 35
35 namespace ash { 36 namespace ash {
36 37
37 WorkspaceLayoutManager::WorkspaceLayoutManager(WmWindow* window) 38 WorkspaceLayoutManager::WorkspaceLayoutManager(WmWindow* window)
38 : window_(window), 39 : window_(window),
39 root_window_(window->GetRootWindow()), 40 root_window_(window->GetRootWindow()),
40 root_window_controller_(root_window_->GetRootWindowController()), 41 root_window_controller_(root_window_->GetRootWindowController()),
41 shell_(window_->GetShell()), 42 shell_(window_->GetShell()),
42 work_area_in_parent_(wm::GetDisplayWorkAreaBoundsInParent(window_)), 43 work_area_in_parent_(wm::GetDisplayWorkAreaBoundsInParent(window_)),
43 is_fullscreen_(wm::GetWindowForFullscreenMode(window) != nullptr) { 44 is_fullscreen_(wm::GetWindowForFullscreenMode(window) != nullptr),
45 keyboard_observer_(this) {
44 Shell::GetInstance()->AddShellObserver(this); 46 Shell::GetInstance()->AddShellObserver(this);
45 Shell::GetInstance()->activation_client()->AddObserver(this); 47 Shell::GetInstance()->activation_client()->AddObserver(this);
46 root_window_->aura_window()->AddObserver(this); 48 root_window_->aura_window()->AddObserver(this);
47 display::Screen::GetScreen()->AddObserver(this); 49 display::Screen::GetScreen()->AddObserver(this);
48 DCHECK(window->aura_window()->GetProperty(kSnapChildrenToPixelBoundary)); 50 DCHECK(window->aura_window()->GetProperty(kSnapChildrenToPixelBoundary));
49 } 51 }
50 52
51 WorkspaceLayoutManager::~WorkspaceLayoutManager() { 53 WorkspaceLayoutManager::~WorkspaceLayoutManager() {
52 if (root_window_) 54 if (root_window_)
53 root_window_->aura_window()->RemoveObserver(this); 55 root_window_->aura_window()->RemoveObserver(this);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 173 }
172 } else if (window_state->HasRestoreBounds()) { 174 } else if (window_state->HasRestoreBounds()) {
173 // Keyboard hidden, restore original bounds if they exist. If the user has 175 // Keyboard hidden, restore original bounds if they exist. If the user has
174 // resized or dragged the window in the meantime, WorkspaceWindowResizer 176 // resized or dragged the window in the meantime, WorkspaceWindowResizer
175 // will have cleared the restore bounds and this code will not accidentally 177 // will have cleared the restore bounds and this code will not accidentally
176 // override user intent. 178 // override user intent.
177 window_state->SetAndClearRestoreBounds(); 179 window_state->SetAndClearRestoreBounds();
178 } 180 }
179 } 181 }
180 182
181 void WorkspaceLayoutManager::OnKeyboardClosed() {} 183 void WorkspaceLayoutManager::OnKeyboardClosed() {
184 keyboard_observer_.RemoveAll();
185 }
182 186
183 ////////////////////////////////////////////////////////////////////////////// 187 //////////////////////////////////////////////////////////////////////////////
184 // WorkspaceLayoutManager, aura::WindowObserver implementation: 188 // WorkspaceLayoutManager, aura::WindowObserver implementation:
185 189
186 void WorkspaceLayoutManager::OnWindowHierarchyChanged( 190 void WorkspaceLayoutManager::OnWindowHierarchyChanged(
187 const HierarchyChangeParams& params) { 191 const HierarchyChangeParams& params) {
188 if (!wm::GetWindowState(params.target)->IsActive()) 192 if (!wm::GetWindowState(params.target)->IsActive())
189 return; 193 return;
190 // If the window is already tracked by the workspace this update would be 194 // 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 195 // 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 324 // 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 325 // mode, then this event does not trigger the restoring yet. On exiting
322 // from fullscreen, the temporarily disabled always-on-top property will be 326 // from fullscreen, the temporarily disabled always-on-top property will be
323 // restored. 327 // restored.
324 return; 328 return;
325 } 329 }
326 330
327 UpdateAlwaysOnTop(WmShell::Get()->IsPinned() ? pinned_window : nullptr); 331 UpdateAlwaysOnTop(WmShell::Get()->IsPinned() ? pinned_window : nullptr);
328 } 332 }
329 333
334 void WorkspaceLayoutManager::OnVirtualKeyboardStateChanged(
335 bool activated,
336 WmWindow* root_window) {
337 UpdateKeyboardObserverFromStateChanged(activated, root_window, root_window_,
338 &keyboard_observer_);
339 }
340
330 ////////////////////////////////////////////////////////////////////////////// 341 //////////////////////////////////////////////////////////////////////////////
331 // WorkspaceLayoutManager, private: 342 // WorkspaceLayoutManager, private:
332 343
333 void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange( 344 void WorkspaceLayoutManager::AdjustAllWindowsBoundsForWorkAreaChange(
334 const wm::WMEvent* event) { 345 const wm::WMEvent* event) {
335 DCHECK(event->type() == wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED || 346 DCHECK(event->type() == wm::WM_EVENT_DISPLAY_BOUNDS_CHANGED ||
336 event->type() == wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); 347 event->type() == wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED);
337 348
338 work_area_in_parent_ = wm::GetDisplayWorkAreaBoundsInParent(window_); 349 work_area_in_parent_ = wm::GetDisplayWorkAreaBoundsInParent(window_);
339 350
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 for (auto* window : windows) { 394 for (auto* window : windows) {
384 wm::WindowState* window_state = window->GetWindowState(); 395 wm::WindowState* window_state = window->GetWindowState();
385 if (window_on_top) 396 if (window_on_top)
386 window_state->DisableAlwaysOnTop(window_on_top); 397 window_state->DisableAlwaysOnTop(window_on_top);
387 else 398 else
388 window_state->RestoreAlwaysOnTop(); 399 window_state->RestoreAlwaysOnTop();
389 } 400 }
390 } 401 }
391 402
392 } // namespace ash 403 } // 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