summaryrefslogtreecommitdiffstats
path: root/ash/wm/window_state_util.cc
blob: e5d6f8e1cdd9cf4c3207e3cb1c805c9232712e53 (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
// Copyright 2014 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/wm/window_state_util.h"

#include "ash/wm/window_state.h"
#include "ash/wm/window_state_delegate.h"
#include "ui/aura/client/aura_constants.h"

namespace ash {
namespace wm {

void ToggleFullScreen(wm::WindowState* window_state,
                      WindowStateDelegate* delegate) {
  // Window which cannot be maximized should not be full screen'ed.
  // It can, however, be restored if it was full screen'ed.
  bool is_fullscreen = window_state->IsFullscreen();
  if (!is_fullscreen && !window_state->CanMaximize())
    return;

  if (delegate && delegate->ToggleFullscreen(window_state))
    return;

  if (is_fullscreen) {
    window_state->Restore();
  } else {
    // Set the property to activate full screen.
    window_state->window()->SetProperty(aura::client::kShowStateKey,
                                        ui::SHOW_STATE_FULLSCREEN);
  }
}

}  // namespace wm
}  // namespace ash