Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(800)

Unified Diff: ui/display/win/screen_win.cc

Issue 1825723002: Move ScreenWin to ui/display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added is_chromeos guard Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/display/win/screen_win.cc
diff --git a/ui/gfx/screen_win.cc b/ui/display/win/screen_win.cc
similarity index 75%
rename from ui/gfx/screen_win.cc
rename to ui/display/win/screen_win.cc
index 46bce435e742d3afa9d99a2ff3c87a331d3be19a..96d880f4d519b995c666d3f35e8a1e9589c0ac76 100644
--- a/ui/gfx/screen_win.cc
+++ b/ui/display/win/screen_win.cc
@@ -2,32 +2,35 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/gfx/screen_win.h"
+#include "ui/display/win/screen_win.h"
#include <windows.h>
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "ui/display/win/display_info.h"
+#include "ui/display/win/screen_win_display.h"
#include "ui/gfx/display.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
-#include "ui/gfx/win/display_info.h"
#include "ui/gfx/win/dpi.h"
-#include "ui/gfx/win/screen_win_display.h"
+
+namespace display {
+namespace win {
namespace {
-std::vector<gfx::win::ScreenWinDisplay> DisplayInfosToScreenWinDisplays(
- const std::vector<gfx::win::DisplayInfo>& display_infos) {
- std::vector<gfx::win::ScreenWinDisplay> screen_win_displays;
+std::vector<ScreenWinDisplay> DisplayInfosToScreenWinDisplays(
+ const std::vector<DisplayInfo>& display_infos) {
+ std::vector<ScreenWinDisplay> screen_win_displays;
for (const auto& display_info : display_infos)
- screen_win_displays.push_back(gfx::win::ScreenWinDisplay(display_info));
+ screen_win_displays.push_back(ScreenWinDisplay(display_info));
return screen_win_displays;
}
std::vector<gfx::Display> ScreenWinDisplaysToDisplays(
- const std::vector<gfx::win::ScreenWinDisplay>& screen_win_displays) {
+ const std::vector<ScreenWinDisplay>& screen_win_displays) {
std::vector<gfx::Display> displays;
for (const auto& screen_win_display : screen_win_displays)
displays.push_back(screen_win_display.display());
@@ -47,17 +50,16 @@ BOOL CALLBACK EnumMonitorCallback(HMONITOR monitor,
HDC hdc,
LPRECT rect,
LPARAM data) {
- std::vector<gfx::win::DisplayInfo>* display_infos =
- reinterpret_cast<std::vector<gfx::win::DisplayInfo>*>(data);
+ std::vector<DisplayInfo>* display_infos =
+ reinterpret_cast<std::vector<DisplayInfo>*>(data);
DCHECK(display_infos);
- display_infos->push_back(
- gfx::win::DisplayInfo(MonitorInfoFromHMONITOR(monitor),
- gfx::GetDPIScale()));
+ display_infos->push_back(DisplayInfo(MonitorInfoFromHMONITOR(monitor),
+ gfx::GetDPIScale()));
return TRUE;
}
-std::vector<gfx::win::DisplayInfo> GetDisplayInfosFromSystem() {
- std::vector<gfx::win::DisplayInfo> display_infos;
+std::vector<DisplayInfo> GetDisplayInfosFromSystem() {
+ std::vector<DisplayInfo> display_infos;
EnumDisplayMonitors(nullptr, nullptr, EnumMonitorCallback,
reinterpret_cast<LPARAM>(&display_infos));
DCHECK_EQ(static_cast<size_t>(::GetSystemMetrics(SM_CMONITORS)),
@@ -67,20 +69,18 @@ std::vector<gfx::win::DisplayInfo> GetDisplayInfosFromSystem() {
} // namespace
-namespace gfx {
-
ScreenWin::ScreenWin() {
Initialize();
}
ScreenWin::~ScreenWin() = default;
-HWND ScreenWin::GetHWNDFromNativeView(NativeView window) const {
+HWND ScreenWin::GetHWNDFromNativeView(gfx::NativeView window) const {
NOTREACHED();
return nullptr;
}
-NativeWindow ScreenWin::GetNativeWindowFromHWND(HWND hwnd) const {
+gfx::NativeWindow ScreenWin::GetNativeWindowFromHWND(HWND hwnd) const {
NOTREACHED();
return nullptr;
}
@@ -120,20 +120,20 @@ gfx::Display ScreenWin::GetDisplayNearestWindow(gfx::NativeView window) const {
// scaling factor.
return GetPrimaryDisplay();
}
- gfx::win::ScreenWinDisplay screen_win_display =
+ ScreenWinDisplay screen_win_display =
GetScreenWinDisplayNearestHWND(window_hwnd);
return screen_win_display.display();
}
gfx::Display ScreenWin::GetDisplayNearestPoint(const gfx::Point& point) const {
gfx::Point screen_point(gfx::win::DIPToScreenPoint(point));
- gfx::win::ScreenWinDisplay screen_win_display =
+ ScreenWinDisplay screen_win_display =
GetScreenWinDisplayNearestScreenPoint(screen_point);
return screen_win_display.display();
}
gfx::Display ScreenWin::GetDisplayMatching(const gfx::Rect& match_rect) const {
- gfx::win::ScreenWinDisplay screen_win_display =
+ ScreenWinDisplay screen_win_display =
GetScreenWinDisplayNearestScreenRect(match_rect);
return screen_win_display.display();
}
@@ -142,16 +142,16 @@ gfx::Display ScreenWin::GetPrimaryDisplay() const {
return GetPrimaryScreenWinDisplay().display();
}
-void ScreenWin::AddObserver(DisplayObserver* observer) {
+void ScreenWin::AddObserver(gfx::DisplayObserver* observer) {
change_notifier_.AddObserver(observer);
}
-void ScreenWin::RemoveObserver(DisplayObserver* observer) {
+void ScreenWin::RemoveObserver(gfx::DisplayObserver* observer) {
change_notifier_.RemoveObserver(observer);
}
void ScreenWin::UpdateFromDisplayInfos(
- const std::vector<gfx::win::DisplayInfo>& display_infos) {
+ const std::vector<DisplayInfo>& display_infos) {
screen_win_displays_ = DisplayInfosToScreenWinDisplays(display_infos);
}
@@ -197,27 +197,26 @@ void ScreenWin::OnWndProc(HWND hwnd,
change_notifier_.NotifyDisplaysChanged(old_displays, GetAllDisplays());
}
-gfx::win::ScreenWinDisplay ScreenWin::GetScreenWinDisplayNearestHWND(HWND hwnd)
+ScreenWinDisplay ScreenWin::GetScreenWinDisplayNearestHWND(HWND hwnd)
const {
return GetScreenWinDisplay(MonitorInfoFromWindow(hwnd,
MONITOR_DEFAULTTONEAREST));
}
-gfx::win::ScreenWinDisplay ScreenWin::GetScreenWinDisplayNearestScreenRect(
- const Rect& screen_rect) const {
+ScreenWinDisplay ScreenWin::GetScreenWinDisplayNearestScreenRect(
+ const gfx::Rect& screen_rect) const {
return GetScreenWinDisplay(MonitorInfoFromScreenRect(screen_rect));
}
-gfx::win::ScreenWinDisplay ScreenWin::GetScreenWinDisplayNearestScreenPoint(
- const Point& screen_point) const {
+ScreenWinDisplay ScreenWin::GetScreenWinDisplayNearestScreenPoint(
+ const gfx::Point& screen_point) const {
return GetScreenWinDisplay(MonitorInfoFromScreenPoint(screen_point));
}
-gfx::win::ScreenWinDisplay ScreenWin::GetPrimaryScreenWinDisplay() const {
+ScreenWinDisplay ScreenWin::GetPrimaryScreenWinDisplay() const {
MONITORINFOEX monitor_info = MonitorInfoFromWindow(nullptr,
MONITOR_DEFAULTTOPRIMARY);
- gfx::win::ScreenWinDisplay screen_win_display =
- GetScreenWinDisplay(monitor_info);
+ ScreenWinDisplay screen_win_display = GetScreenWinDisplay(monitor_info);
gfx::Display display = screen_win_display.display();
// The Windows primary monitor is defined to have an origin of (0, 0).
DCHECK_EQ(0, display.bounds().origin().x());
@@ -225,10 +224,9 @@ gfx::win::ScreenWinDisplay ScreenWin::GetPrimaryScreenWinDisplay() const {
return screen_win_display;
}
-gfx::win::ScreenWinDisplay ScreenWin::GetScreenWinDisplay(
+ScreenWinDisplay ScreenWin::GetScreenWinDisplay(
const MONITORINFOEX& monitor_info) const {
- int64_t id =
- gfx::win::DisplayInfo::DeviceIdFromDeviceName(monitor_info.szDevice);
+ int64_t id = DisplayInfo::DeviceIdFromDeviceName(monitor_info.szDevice);
for (const auto& screen_win_display : screen_win_displays_) {
if (screen_win_display.display().id() == id)
return screen_win_display;
@@ -237,7 +235,8 @@ gfx::win::ScreenWinDisplay ScreenWin::GetScreenWinDisplay(
// If we make it here, it means we have no displays and we should hand out the
// default display.
DCHECK_EQ(screen_win_displays_.size(), 0u);
- return gfx::win::ScreenWinDisplay();
+ return ScreenWinDisplay();
}
-} // namespace gfx
+} // namespace win
+} // namespace display

Powered by Google App Engine
This is Rietveld 408576698