| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 #ifndef UI_AURA_MONITOR_MANAGER_H_ | |
| 6 #define UI_AURA_MONITOR_MANAGER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/observer_list.h" | |
| 14 #include "ui/aura/aura_export.h" | |
| 15 | |
| 16 namespace gfx { | |
| 17 class Display; | |
| 18 class Point; | |
| 19 class Size; | |
| 20 } | |
| 21 | |
| 22 namespace aura { | |
| 23 class DisplayObserver; | |
| 24 class RootWindow; | |
| 25 class Window; | |
| 26 | |
| 27 // MonitorManager creates, deletes and updates Monitor objects when | |
| 28 // monitor configuration changes, and notifies DisplayObservers about | |
| 29 // the change. This is owned by Env and its lifetime is longer than | |
| 30 // any windows. | |
| 31 class AURA_EXPORT MonitorManager { | |
| 32 public: | |
| 33 static void set_use_fullscreen_host_window(bool use_fullscreen) { | |
| 34 use_fullscreen_host_window_ = use_fullscreen; | |
| 35 } | |
| 36 static bool use_fullscreen_host_window() { | |
| 37 return use_fullscreen_host_window_; | |
| 38 } | |
| 39 | |
| 40 // Creates a monitor from string spec. 100+200-1440x800 creates monitor | |
| 41 // whose size is 1440x800 at the location (100, 200) in screen's coordinates. | |
| 42 // The location can be omitted and be just "1440x800", which creates | |
| 43 // monitor at the origin of the screen. An empty string creates | |
| 44 // the monitor with default size. | |
| 45 // The device scale factor can be specified by "*", like "1280x780*2", | |
| 46 // or will use the value of |gfx::Display::GetForcedDeviceScaleFactor()| if | |
| 47 // --force-device-scale-factor is specified. | |
| 48 static gfx::Display CreateMonitorFromSpec(const std::string& spec); | |
| 49 | |
| 50 // A utility function to create a root window for primary monitor. | |
| 51 static RootWindow* CreateRootWindowForPrimaryMonitor(); | |
| 52 | |
| 53 MonitorManager(); | |
| 54 virtual ~MonitorManager(); | |
| 55 | |
| 56 // Adds/removes DisplayObservers. | |
| 57 void AddObserver(DisplayObserver* observer); | |
| 58 void RemoveObserver(DisplayObserver* observer); | |
| 59 | |
| 60 // Called when monitor configuration has changed. The new monitor | |
| 61 // configurations is passed as a vector of Monitor object, which | |
| 62 // contains each monitor's new infomration. | |
| 63 virtual void OnNativeMonitorsChanged( | |
| 64 const std::vector<gfx::Display>& display) = 0; | |
| 65 | |
| 66 // Create a root window for given |monitor|. | |
| 67 virtual RootWindow* CreateRootWindowForMonitor( | |
| 68 const gfx::Display& display) = 0; | |
| 69 | |
| 70 // Returns the display at |index|. The display at 0 is considered "primary". | |
| 71 virtual const gfx::Display& GetDisplayAt(size_t index) = 0; | |
| 72 | |
| 73 virtual size_t GetNumDisplays() const = 0; | |
| 74 | |
| 75 // Returns the display object nearest given |window|. | |
| 76 virtual const gfx::Display& GetDisplayNearestWindow( | |
| 77 const Window* window) const = 0; | |
| 78 | |
| 79 // Returns the monitor object nearest given |pint|. | |
| 80 virtual const gfx::Display& GetDisplayNearestPoint( | |
| 81 const gfx::Point& point) const = 0; | |
| 82 | |
| 83 protected: | |
| 84 // Calls observers' OnDisplayBoundsChanged methods. | |
| 85 void NotifyBoundsChanged(const gfx::Display& display); | |
| 86 void NotifyDisplayAdded(const gfx::Display& display); | |
| 87 void NotifyDisplayRemoved(const gfx::Display& display); | |
| 88 | |
| 89 private: | |
| 90 // If set before the RootWindow is created, the host window will cover the | |
| 91 // entire monitor. Note that this can still be overridden via the | |
| 92 // switches::kAuraHostWindowSize flag. | |
| 93 static bool use_fullscreen_host_window_; | |
| 94 | |
| 95 ObserverList<DisplayObserver> observers_; | |
| 96 DISALLOW_COPY_AND_ASSIGN(MonitorManager); | |
| 97 }; | |
| 98 | |
| 99 } // namespace aura | |
| 100 | |
| 101 #endif // UI_AURA_MONITOR_MANAGER_H_ | |
| OLD | NEW |