summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/window_sizer_aura.cc
blob: e4e8d53ab9a0f711cd5cfffc463e14e1d62e200e (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) 2011 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 "chrome/browser/ui/window_sizer.h"

#include "ui/aura/desktop.h"
#include "ui/aura/window.h"
#include "ui/gfx/screen.h"

// TODO(oshima): Get This from WindowManager
const int WindowSizer::kWindowTilePixels = 10;

// An implementation of WindowSizer::MonitorInfoProvider that gets the actual
// monitor information from X via GDK.
class DefaultMonitorInfoProvider : public WindowSizer::MonitorInfoProvider {
 public:
  DefaultMonitorInfoProvider() { }

  virtual gfx::Rect GetPrimaryMonitorWorkArea() const {
    return gfx::Screen::GetMonitorWorkAreaNearestPoint(
        gfx::Point(0, 0));
  }

  virtual gfx::Rect GetPrimaryMonitorBounds() const {
    aura::Desktop* desktop = aura::Desktop::GetInstance();
    return gfx::Rect(desktop->GetHostSize());
  }

  virtual gfx::Rect GetMonitorWorkAreaMatching(
      const gfx::Rect& match_rect) const {
    return gfx::Screen::GetMonitorWorkAreaNearestPoint(
        match_rect.origin());
  }

  virtual gfx::Point GetBoundsOffsetMatching(
      const gfx::Rect& match_rect) const {
    return GetMonitorWorkAreaMatching(match_rect).origin();
  }

  void UpdateWorkAreas() {
    work_areas_.clear();
    work_areas_.push_back(GetPrimaryMonitorBounds());
  }

 private:

  DISALLOW_COPY_AND_ASSIGN(DefaultMonitorInfoProvider);
};

// static
WindowSizer::MonitorInfoProvider*
WindowSizer::CreateDefaultMonitorInfoProvider() {
  return new DefaultMonitorInfoProvider();
}

// static
gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size) {
  // TODO(oshima):This is used to control panel/popups, and this may
  // not be needed on aura environment as they must be controlled by
  // WM.
  NOTIMPLEMENTED();
  return gfx::Point();
}