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

Side by Side Diff: ash/wm/lock_action_handler_layout_manager.cc

Issue 2876993002: Introduce window container to be used by lock screen app windows (Closed)
Patch Set: . Created 3 years, 7 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/wm/lock_action_handler_layout_manager.h"
6
7 #include <vector>
8
9 #include "ash/public/cpp/shell_window_ids.h"
10 #include "ash/public/interfaces/tray_action.mojom.h"
11 #include "ash/shelf/shelf.h"
12 #include "ash/shell.h"
13 #include "ash/tray_action/tray_action.h"
14 #include "ash/wm/lock_window_state.h"
15 #include "ash/wm/window_state.h"
16 #include "ash/wm/window_util.h"
17 #include "ash/wm/wm_event.h"
18 #include "ash/wm_window.h"
19
20 namespace ash {
21
22 LockActionHandlerLayoutManager::LockActionHandlerLayoutManager(
23 aura::Window* window,
24 Shelf* shelf)
25 : LockLayoutManager(window),
26 shelf_observer_(this),
27 tray_action_observer_(this) {
28 TrayAction* tray_action = Shell::Get()->tray_action();
29 tray_action_observer_.Add(tray_action);
30 shelf_observer_.Add(shelf);
31 }
32
33 LockActionHandlerLayoutManager::~LockActionHandlerLayoutManager() = default;
34
35 void LockActionHandlerLayoutManager::OnWindowAddedToLayout(
36 aura::Window* child) {
37 wm::WindowState* window_state =
38 LockWindowState::SetLockWindowStateWithShelfExcluded(child);
39 wm::WMEvent event(wm::WM_EVENT_ADDED_TO_WORKSPACE);
40 window_state->OnWMEvent(&event);
41 }
42
43 void LockActionHandlerLayoutManager::OnChildWindowVisibilityChanged(
44 aura::Window* child,
45 bool visible) {
46 // Windows should be shown only in active state.
47 if (visible && !Shell::Get()->tray_action()->IsLockScreenNoteActive())
48 child->Hide();
49 }
50
51 void LockActionHandlerLayoutManager::WillChangeVisibilityState(
52 ShelfVisibilityState visibility) {
53 // Unlike LockLayoutManager, LockActionHandlerLayoutManager windows' bounds
54 // depend on the user work area bounds defined by shelf layout (see
55 // ScreenUtil::GetDisplayWorkAreaBoundsInParentForLockScreen) - when shelf
56 // bounds change, the windows in this layout manager should be updated, too.
57 const wm::WMEvent event(wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED);
58 AdjustWindowsForWorkAreaChange(&event);
59 }
60
61 void LockActionHandlerLayoutManager::OnLockScreenNoteStateChanged(
62 mojom::TrayActionState state) {
63 // Make sure the container is properly stacked relative to lock screen
64 // container - lock action handler should be above lock screen only when a
65 // lock screen action is active.
66 if (state == mojom::TrayActionState::kActive) {
67 window()->parent()->StackChildAbove(
68 window(),
69 root_window()->GetChildById(kShellWindowId_LockScreenContainer));
70 } else {
71 window()->parent()->StackChildBelow(
72 window(),
73 root_window()->GetChildById(kShellWindowId_LockScreenContainer));
74 }
75
76 // Update children state:
77 // * a child can be visible only in background and active states
78 // * children should not be active in background state
79 // * on transition to active state:
80 // * show hidden windows, so children that were added when action was not
81 // in active state are shown
82 // * activate a container child to ensure the container gets focus when
83 // moving from background state.
84 for (aura::Window* child : window()->children()) {
85 if (state == mojom::TrayActionState::kActive) {
86 child->Show();
87 } else if (state != mojom::TrayActionState::kBackground) {
88 child->Hide();
89 } else if (wm::IsActiveWindow(child)) {
90 wm::DeactivateWindow(child);
91 }
92 }
93
94 if (!window()->children().empty() &&
95 state == mojom::TrayActionState::kActive) {
96 wm::ActivateWindow(window()->children().back());
97 }
98 }
99
100 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/lock_action_handler_layout_manager.h ('k') | ash/wm/lock_action_handler_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698