| Index: ui/gfx/win/display_manager.h
|
| diff --git a/ui/gfx/win/display_manager.h b/ui/gfx/win/display_manager.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c6480456e539d24d8e2a4cc37b95d818c63710f4
|
| --- /dev/null
|
| +++ b/ui/gfx/win/display_manager.h
|
| @@ -0,0 +1,85 @@
|
| +// Copyright 2016 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.
|
| +
|
| +#ifndef UI_GFX_WIN_DISPLAY_MANAGER_H_
|
| +#define UI_GFX_WIN_DISPLAY_MANAGER_H_
|
| +
|
| +#include <windows.h>
|
| +#include <memory>
|
| +#include <vector>
|
| +
|
| +#include "base/macros.h"
|
| +#include "base/memory/singleton.h"
|
| +#include "base/observer_list.h"
|
| +#include "ui/gfx/display.h"
|
| +#include "ui/gfx/gfx_export.h"
|
| +
|
| +namespace gfx {
|
| +
|
| +class Point;
|
| +class Rect;
|
| +class ScreenWin;
|
| +class SingletonHwndObserver;
|
| +
|
| +namespace win {
|
| +
|
| +class DisplayManagerObserver;
|
| +class DisplayInfo;
|
| +class ScreenWinDisplay;
|
| +
|
| +// Holds all of the ScreenWinDisplays corresponding to a Windows HMONITOR.
|
| +class GFX_EXPORT DisplayManager {
|
| + public:
|
| + static DisplayManager* GetInstance();
|
| +
|
| + void AddObserver(DisplayManagerObserver* observer);
|
| + void RemoveObserver(DisplayManagerObserver* observer);
|
| +
|
| + const std::vector<ScreenWinDisplay>& GetScreenWinDisplays();
|
| + ScreenWinDisplay GetScreenWinDisplay(const MONITORINFOEX& monitor_info) const;
|
| + ScreenWinDisplay GetScreenWinDisplayNearestHWND(HWND hwnd) const;
|
| + ScreenWinDisplay GetScreenWinDisplayNearestScreenRect(
|
| + const Rect& screen_rect) const;
|
| + ScreenWinDisplay GetScreenWinDisplayNearestScreenPoint(
|
| + const Point& screen_point) const;
|
| + ScreenWinDisplay GetScreenWinDisplayNearestDIPRect(const Rect& dip_rect)
|
| + const;
|
| + ScreenWinDisplay GetScreenWinDisplayNearestDIPPoint(const Point& dip_point)
|
| + const;
|
| + ScreenWinDisplay GetPrimaryScreenWinDisplay() const;
|
| + float GetScaleFactorForHWND(HWND hwnd) const;
|
| + float GetScaleFactorForScreenPoint(const Point& screen_point) const;
|
| +
|
| + // For Unit Tests.
|
| + virtual MONITORINFOEX MonitorInfoFromScreenPoint(
|
| + const gfx::Point& screen_point) const;
|
| + virtual MONITORINFOEX MonitorInfoFromScreenRect(const gfx::Rect& screen_rect)
|
| + const;
|
| + virtual MONITORINFOEX MonitorInfoFromWindow(HWND hwnd) const;
|
| + virtual HWND GetRootWindow(HWND hwnd) const;
|
| +
|
| + protected:
|
| + friend std::default_delete<DisplayManager>;
|
| +
|
| + static void SetInstanceForTesting(scoped_ptr<DisplayManager> display_manager);
|
| +
|
| + DisplayManager();
|
| + virtual ~DisplayManager();
|
| +
|
| + void UpdateFromDisplayInfos(const std::vector<DisplayInfo>& display_infos);
|
| +
|
| + private:
|
| + void WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
|
| +
|
| + scoped_ptr<gfx::SingletonHwndObserver> singleton_hwnd_observer_;
|
| + base::ObserverList<DisplayManagerObserver, true> observer_list_;
|
| + std::vector<ScreenWinDisplay> screen_win_displays_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(DisplayManager);
|
| +};
|
| +
|
| +} // namespace win
|
| +} // namespace gfx
|
| +
|
| +#endif // UI_GFX_WIN_DISPLAY_MANAGER_H_
|
|
|