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

ash / wm / overlay_layout_manager.cc [blame]

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/wm/overlay_layout_manager.h"

#include "ash/wm/window_state.h"
#include "ash/wm/wm_event.h"
#include "base/check.h"
#include "ui/aura/window.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"

using display::Screen;

namespace ash {

OverlayLayoutManager::OverlayLayoutManager(aura::Window* overlay_container)
    : overlay_container_(overlay_container) {
  DCHECK(overlay_container_);
}

OverlayLayoutManager::~OverlayLayoutManager() = default;

void OverlayLayoutManager::OnDisplayMetricsChanged(
    const display::Display& display,
    uint32_t changed_metrics) {
  if (display.id() !=
      Screen::GetScreen()->GetDisplayNearestWindow(overlay_container_).id()) {
    // The update wasn't for this container's display.
    return;
  }

  for (aura::Window* child : overlay_container_->children()) {
    WindowState* window_state = WindowState::Get(child);
    if (window_state->IsFullscreen()) {
      const DisplayMetricsChangedWMEvent event(
          display::DisplayObserver::DISPLAY_METRIC_WORK_AREA);
      window_state->OnWMEvent(&event);
    }
  }
}

}  // namespace ash