OLD | NEW |
---|---|
(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::SetLockWindowStateWithVisibleShelf(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 const wm::WMEvent event(wm::WM_EVENT_WORKAREA_BOUNDS_CHANGED); | |
54 AdjustWindowsForWorkAreaChange(&event); | |
oshima
2017/05/25 19:49:59
Why this is necessary?
tbarzic
2017/05/25 20:32:20
To adjust window bounds when the work area bounds
oshima
2017/05/25 23:46:20
I assume you meant when GetDisplayWorkAreaBoundsIn
tbarzic
2017/05/26 00:49:32
Done.
| |
55 } | |
56 | |
57 void LockActionHandlerLayoutManager::OnLockScreenNoteStateChanged( | |
58 mojom::TrayActionState state) { | |
59 // Make sure the container is properly stacked relative to lock screen | |
60 // container - lock action handler should be above lock screen only when a | |
61 // lock screen action is active. | |
62 if (state == mojom::TrayActionState::kActive) { | |
63 window()->parent()->StackChildAbove( | |
64 window(), | |
65 root_window()->GetChildById(kShellWindowId_LockScreenContainer)); | |
66 } else { | |
67 window()->parent()->StackChildBelow( | |
68 window(), | |
69 root_window()->GetChildById(kShellWindowId_LockScreenContainer)); | |
70 } | |
71 | |
72 // Update children state: | |
73 // * a child can be visible only in background and active states | |
74 // * children should not be active in background state | |
75 // * on transition to active state: | |
76 // * show hidden windows, so children that were added when action was not | |
77 // in active state are shown | |
78 // * activate a container child to ensure the container gets focus when | |
79 // moving from background state. | |
80 for (aura::Window* child : window()->children()) { | |
81 if (state == mojom::TrayActionState::kActive) { | |
82 child->Show(); | |
83 } else if (state != mojom::TrayActionState::kBackground) { | |
84 child->Hide(); | |
85 } else if (wm::IsActiveWindow(child)) { | |
86 wm::DeactivateWindow(child); | |
87 } | |
88 } | |
89 | |
90 if (!window()->children().empty() && | |
91 state == mojom::TrayActionState::kActive) { | |
92 wm::ActivateWindow(window()->children().back()); | |
93 } | |
94 } | |
95 | |
96 } // namespace ash | |
OLD | NEW |