blob: 73f1b1a54387283c54298bb379c5143e60476bf4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/accelerators/accelerator_commands.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/wm/window_cycle_controller.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
namespace ash {
namespace accelerators {
bool ToggleMinimized() {
aura::Window* window = wm::GetActiveWindow();
// Attempt to restore the window that would be cycled through next from
// the launcher when there is no active window.
if (!window) {
ash::Shell::GetInstance()->window_cycle_controller()->
HandleCycleWindow(WindowCycleController::FORWARD, false);
return true;
}
wm::WindowState* window_state = wm::GetWindowState(window);
if (!window_state->CanMinimize())
return false;
ash::Shell::GetInstance()->delegate()->RecordUserMetricsAction(
ash::UMA_MINIMIZE_PER_KEY);
window_state->Minimize();
return true;
}
void ToggleMaximized() {
wm::WindowState* window_state = wm::GetActiveWindowState();
if (!window_state)
return;
// Get out of fullscreen when in fullscreen mode.
if (window_state->IsFullscreen())
Shell::GetInstance()->delegate()->ToggleFullscreen();
else
window_state->ToggleMaximized();
}
} // namespace accelerators
} // namespace ash
|