diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-09 17:26:19 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-09 17:26:19 +0000 |
commit | f1ddc1da13daa47d4513ead413cd167faadd4c71 (patch) | |
tree | 15b5e919b8b43a92f38adbf6ba2bdd296327a3ef /ui | |
parent | 7e2d6e1cdbc0f6c05c5db1262f9d2a8d2eec1edb (diff) | |
download | chromium_src-f1ddc1da13daa47d4513ead413cd167faadd4c71.zip chromium_src-f1ddc1da13daa47d4513ead413cd167faadd4c71.tar.gz chromium_src-f1ddc1da13daa47d4513ead413cd167faadd4c71.tar.bz2 |
Cleanup:
- added GetRootWindowForDisplay
- Hookup GetDisplayMatching to DisplayManager
- Fixed comments
- Moved the display code from Shell to MultiDisplayManager
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10697071
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145690 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/desktop/desktop_screen_win.cc | 5 | ||||
-rw-r--r-- | ui/aura/desktop/desktop_screen_win.h | 2 | ||||
-rw-r--r-- | ui/aura/desktop/desktop_screen_x11.cc | 8 | ||||
-rw-r--r-- | ui/aura/display_manager.h | 7 | ||||
-rw-r--r-- | ui/aura/single_display_manager.cc | 5 | ||||
-rw-r--r-- | ui/aura/single_display_manager.h | 2 | ||||
-rw-r--r-- | ui/aura/test/test_screen.cc | 4 | ||||
-rw-r--r-- | ui/aura/test/test_screen.h | 2 | ||||
-rw-r--r-- | ui/gfx/screen.h | 6 | ||||
-rw-r--r-- | ui/gfx/screen_aura.cc | 11 | ||||
-rw-r--r-- | ui/gfx/screen_gtk.cc | 12 | ||||
-rw-r--r-- | ui/gfx/screen_impl.h | 6 | ||||
-rw-r--r-- | ui/gfx/screen_mac.mm | 12 | ||||
-rw-r--r-- | ui/gfx/screen_win.cc | 16 |
14 files changed, 66 insertions, 32 deletions
diff --git a/ui/aura/desktop/desktop_screen_win.cc b/ui/aura/desktop/desktop_screen_win.cc index 5738d9b..593f4f2 100644 --- a/ui/aura/desktop/desktop_screen_win.cc +++ b/ui/aura/desktop/desktop_screen_win.cc @@ -85,6 +85,11 @@ gfx::Display DesktopScreenWin::GetDisplayNearestPoint( return gfx::Display(); } +gfx::Display DesktopScreenWin::GetDisplayMatching( + const gfx::Rect& match_rect) const { + return GetDisplayNearestPoint(match_rect.CenterPoint()); +} + gfx::Display DesktopScreenWin::GetPrimaryDisplay() const { MONITORINFO mi = GetMonitorInfoForMonitor( MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY)); diff --git a/ui/aura/desktop/desktop_screen_win.h b/ui/aura/desktop/desktop_screen_win.h index 97eddb0..51c4f81 100644 --- a/ui/aura/desktop/desktop_screen_win.h +++ b/ui/aura/desktop/desktop_screen_win.h @@ -24,6 +24,8 @@ public: gfx::NativeView window) const OVERRIDE; virtual gfx::Display GetDisplayNearestPoint( const gfx::Point& point) const OVERRIDE; + virtual gfx::Display GetDisplayMatching( + const gfx::Rect& match_rect) const OVERRIDE; virtual gfx::Display GetPrimaryDisplay() const OVERRIDE; private: diff --git a/ui/aura/desktop/desktop_screen_x11.cc b/ui/aura/desktop/desktop_screen_x11.cc index e8f2e66..9577037 100644 --- a/ui/aura/desktop/desktop_screen_x11.cc +++ b/ui/aura/desktop/desktop_screen_x11.cc @@ -43,6 +43,8 @@ class DesktopScreenX11 : public gfx::ScreenImpl { gfx::NativeView window) const OVERRIDE; virtual gfx::Display GetDisplayNearestPoint( const gfx::Point& point) const OVERRIDE; + virtual gfx::Display GetDisplayMatching( + const gfx::Rect& match_rect) const OVERRIDE; virtual gfx::Display GetPrimaryDisplay() const OVERRIDE; private: @@ -104,6 +106,12 @@ gfx::Display DesktopScreenX11::GetDisplayNearestPoint( return gfx::Display(0, gfx::Rect(GetPrimaryDisplaySize())); } +gfx::Display DesktopScreenX11::GetDisplayMatching( + const gfx::Rect& match_rect) const { + // TODO(erg): Do the right thing once we know what that is. + return gfx::Display(0, gfx::Rect(GetPrimaryDisplaySize())); +} + gfx::Display DesktopScreenX11::GetPrimaryDisplay() const { // TODO(erg): Do the right thing once we know what that is. return gfx::Display(0, gfx::Rect(GetPrimaryDisplaySize())); diff --git a/ui/aura/display_manager.h b/ui/aura/display_manager.h index 49f65c0..023d76b 100644 --- a/ui/aura/display_manager.h +++ b/ui/aura/display_manager.h @@ -16,6 +16,7 @@ namespace gfx { class Display; class Point; +class Rect; class Size; } @@ -76,10 +77,14 @@ class AURA_EXPORT DisplayManager { virtual const gfx::Display& GetDisplayNearestWindow( const Window* window) const = 0; - // Returns the display object nearest given |pint|. + // Returns the display object nearest given |point|. virtual const gfx::Display& GetDisplayNearestPoint( const gfx::Point& point) const = 0; + // Returns the display that most closely intersects |match_rect|. + virtual const gfx::Display& GetDisplayMatching( + const gfx::Rect& match_rect) const = 0; + protected: // Calls observers' OnDisplayBoundsChanged methods. void NotifyBoundsChanged(const gfx::Display& display); diff --git a/ui/aura/single_display_manager.cc b/ui/aura/single_display_manager.cc index 64b8d07..384c3c3 100644 --- a/ui/aura/single_display_manager.cc +++ b/ui/aura/single_display_manager.cc @@ -72,6 +72,11 @@ const gfx::Display& SingleDisplayManager::GetDisplayNearestPoint( return display_; } +const gfx::Display& SingleDisplayManager::GetDisplayMatching( + const gfx::Rect& match_rect) const { + return display_; +} + void SingleDisplayManager::OnWindowBoundsChanged( Window* window, const gfx::Rect& old_bounds, const gfx::Rect& new_bounds) { if (!use_fullscreen_host_window()) { diff --git a/ui/aura/single_display_manager.h b/ui/aura/single_display_manager.h index dca839a..82bfc35 100644 --- a/ui/aura/single_display_manager.h +++ b/ui/aura/single_display_manager.h @@ -38,6 +38,8 @@ class AURA_EXPORT SingleDisplayManager : public DisplayManager, const Window* window) const OVERRIDE; virtual const gfx::Display& GetDisplayNearestPoint( const gfx::Point& point) const OVERRIDE; + virtual const gfx::Display& GetDisplayMatching( + const gfx::Rect& match_rect) const OVERRIDE; // WindowObserver overrides: virtual void OnWindowBoundsChanged(Window* window, diff --git a/ui/aura/test/test_screen.cc b/ui/aura/test/test_screen.cc index 95019a4..5d0a497 100644 --- a/ui/aura/test/test_screen.cc +++ b/ui/aura/test/test_screen.cc @@ -41,6 +41,10 @@ gfx::Display TestScreen::GetDisplayNearestPoint(const gfx::Point& point) const { return GetMonitor(); } +gfx::Display TestScreen::GetDisplayMatching(const gfx::Rect& match_rect) const { + return GetMonitor(); +} + gfx::Display TestScreen::GetPrimaryDisplay() const { return GetMonitor(); } diff --git a/ui/aura/test/test_screen.h b/ui/aura/test/test_screen.h index 399b486..143a979 100644 --- a/ui/aura/test/test_screen.h +++ b/ui/aura/test/test_screen.h @@ -27,6 +27,8 @@ class TestScreen : public gfx::ScreenImpl { gfx::NativeView view) const OVERRIDE; virtual gfx::Display GetDisplayNearestPoint( const gfx::Point& point) const OVERRIDE; + virtual gfx::Display GetDisplayMatching( + const gfx::Rect& match_rect) const OVERRIDE; virtual gfx::Display GetPrimaryDisplay() const OVERRIDE; private: diff --git a/ui/gfx/screen.h b/ui/gfx/screen.h index 69a6726..1819a9d 100644 --- a/ui/gfx/screen.h +++ b/ui/gfx/screen.h @@ -47,12 +47,12 @@ class UI_EXPORT Screen { // Returns the the display nearest the specified point. static gfx::Display GetDisplayNearestPoint(const gfx::Point& point); - // Returns the bounds of the work area of the primary display. - static gfx::Display GetPrimaryDisplay(); - // Returns the display that most closely intersects the provided bounds. static gfx::Display GetDisplayMatching(const gfx::Rect& match_rect); + // Returns the primary display. + static gfx::Display GetPrimaryDisplay(); + private: DISALLOW_IMPLICIT_CONSTRUCTORS(Screen); }; diff --git a/ui/gfx/screen_aura.cc b/ui/gfx/screen_aura.cc index 851b976..befdeaf 100644 --- a/ui/gfx/screen_aura.cc +++ b/ui/gfx/screen_aura.cc @@ -23,9 +23,6 @@ void Screen::SetInstance(ScreenImpl* screen) { g_instance_ = screen; } -// TODO(oshima): Implement ScreenImpl for Linux/aura and remove this -// ifdef. - // static bool Screen::IsDIPEnabled() { return true; @@ -57,13 +54,13 @@ Display Screen::GetDisplayNearestPoint(const Point& point) { } // static -Display Screen::GetPrimaryDisplay() { - return g_instance_->GetPrimaryDisplay(); +Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) { + return g_instance_->GetDisplayMatching(match_rect); } // static -Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) { - return g_instance_->GetDisplayNearestPoint(match_rect.CenterPoint()); +Display Screen::GetPrimaryDisplay() { + return g_instance_->GetPrimaryDisplay(); } } // namespace gfx diff --git a/ui/gfx/screen_gtk.cc b/ui/gfx/screen_gtk.cc index 3cae772..7b0b34c 100644 --- a/ui/gfx/screen_gtk.cc +++ b/ui/gfx/screen_gtk.cc @@ -129,6 +129,12 @@ gfx::Display Screen::GetDisplayNearestPoint(const gfx::Point& point) { } // static +gfx::Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) { + // TODO(thestig) Implement multi-monitor support. + return GetPrimaryDisplay(); +} + +// static gfx::Display Screen::GetPrimaryDisplay() { gfx::Rect bounds = NativePrimaryMonitorBounds(); // TODO(oshima): Implement ID and Observer. @@ -144,12 +150,6 @@ gfx::Display Screen::GetPrimaryDisplay() { } // static -gfx::Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) { - // TODO(thestig) Implement multi-monitor support. - return GetPrimaryDisplay(); -} - -// static int Screen::GetNumDisplays() { // This query is kinda bogus for Linux -- do we want number of X screens? // The number of monitors Xinerama has? We'll just use whatever GDK uses. diff --git a/ui/gfx/screen_impl.h b/ui/gfx/screen_impl.h index 39e8f25..d75dbc5 100644 --- a/ui/gfx/screen_impl.h +++ b/ui/gfx/screen_impl.h @@ -8,9 +8,11 @@ #include "ui/gfx/display.h" #include "ui/gfx/native_widget_types.h" -#include "ui/gfx/point.h" namespace gfx { +class Display; +class Point; +class Rect; // A class that provides |gfx::Screen|'s implementation on aura. class UI_EXPORT ScreenImpl { @@ -25,6 +27,8 @@ class UI_EXPORT ScreenImpl { gfx::NativeView window) const = 0; virtual gfx::Display GetDisplayNearestPoint( const gfx::Point& point) const = 0; + virtual gfx::Display GetDisplayMatching( + const gfx::Rect& match_rect) const = 0; virtual gfx::Display GetPrimaryDisplay() const = 0; }; diff --git a/ui/gfx/screen_mac.mm b/ui/gfx/screen_mac.mm index 018e954..927970a 100644 --- a/ui/gfx/screen_mac.mm +++ b/ui/gfx/screen_mac.mm @@ -98,6 +98,12 @@ gfx::Display Screen::GetDisplayNearestWindow(gfx::NativeView view) { } // static +gfx::Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) { + NSScreen* match_screen = GetMatchingScreen(match_rect); + return GetDisplayForScreen(match_screen, false /* may not be primary */); +} + +// static gfx::Display Screen::GetPrimaryDisplay() { // Primary display is defined as the display with the menubar, // which is always at index 0. @@ -107,12 +113,6 @@ gfx::Display Screen::GetPrimaryDisplay() { } // static -gfx::Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) { - NSScreen* match_screen = GetMatchingScreen(match_rect); - return GetDisplayForScreen(match_screen, false /* may not be primary */); -} - -// static int Screen::GetNumDisplays() { // Don't just return the number of online displays. It includes displays // that mirror other displays, which are not desired in the count. It's diff --git a/ui/gfx/screen_win.cc b/ui/gfx/screen_win.cc index 5f1d7de..4758360 100644 --- a/ui/gfx/screen_win.cc +++ b/ui/gfx/screen_win.cc @@ -73,6 +73,14 @@ gfx::Display Screen::GetDisplayNearestPoint(const gfx::Point& point) { } // static +gfx::Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) { + RECT other_bounds_rect = match_rect.ToRECT(); + MONITORINFO monitor_info = GetMonitorInfoForMonitor(MonitorFromRect( + &other_bounds_rect, MONITOR_DEFAULTTONEAREST)); + return GetDisplay(monitor_info); +} + +// static gfx::Display Screen::GetPrimaryDisplay() { MONITORINFO mi = GetMonitorInfoForMonitor( MonitorFromWindow(NULL, MONITOR_DEFAULTTOPRIMARY)); @@ -82,12 +90,4 @@ gfx::Display Screen::GetPrimaryDisplay() { return display; } -// static -gfx::Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) { - RECT other_bounds_rect = match_rect.ToRECT(); - MONITORINFO monitor_info = GetMonitorInfoForMonitor(MonitorFromRect( - &other_bounds_rect, MONITOR_DEFAULTTONEAREST)); - return GetDisplay(monitor_info); -} - } // namespace gfx |