diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-23 17:08:51 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-23 17:08:51 +0000 |
commit | 1cee30c1a41f9122cfcbb3a7db6fccc591ebcc20 (patch) | |
tree | 061b0fc6ed53e2174fd1e28f7bd5b4452afb5e35 | |
parent | 8a35afd5a12341513ffb7806de903b584fda9b72 (diff) | |
download | chromium_src-1cee30c1a41f9122cfcbb3a7db6fccc591ebcc20.zip chromium_src-1cee30c1a41f9122cfcbb3a7db6fccc591ebcc20.tar.gz chromium_src-1cee30c1a41f9122cfcbb3a7db6fccc591ebcc20.tar.bz2 |
Refactor display_info_provider_chrmoeos and provide standard impl for other
platforms.
Added gfx::Screen::GetAllDisplays()
I moved QueryInfo on Windows to UI thread as this gfx::Screen is already
querying this info on UI thread, and supposed to be fast.
Next Step:
Implement GetAllDisplays for win/mac/gtk.
BUG=122863
R=hongbo.min@intel.com, sky@chromium.org
Review URL: https://codereview.chromium.org/23205029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219293 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/display/display_manager.h | 2 | ||||
-rw-r--r-- | ash/screen_ash.cc | 6 | ||||
-rw-r--r-- | ash/screen_ash.h | 3 | ||||
-rw-r--r-- | chrome/browser/extensions/api/system_display/display_info_provider.cc | 74 | ||||
-rw-r--r-- | chrome/browser/extensions/api/system_display/display_info_provider.h | 10 | ||||
-rw-r--r-- | chrome/browser/extensions/api/system_display/display_info_provider_chromeos.cc | 99 | ||||
-rw-r--r-- | chrome/browser/extensions/api/system_display/display_info_provider_mac.cc | 12 | ||||
-rw-r--r-- | chrome/browser/extensions/api/system_display/display_info_provider_win.cc | 12 | ||||
-rw-r--r-- | chrome/browser/extensions/api/system_display/display_info_provider_x11.cc | 12 | ||||
-rw-r--r-- | ui/aura/test/test_screen.cc | 6 | ||||
-rw-r--r-- | ui/aura/test/test_screen.h | 3 | ||||
-rw-r--r-- | ui/gfx/screen.h | 7 | ||||
-rw-r--r-- | ui/gfx/screen_android.cc | 6 | ||||
-rw-r--r-- | ui/gfx/screen_gtk.cc | 7 | ||||
-rw-r--r-- | ui/gfx/screen_ios.mm | 7 | ||||
-rw-r--r-- | ui/gfx/screen_mac.mm | 7 | ||||
-rw-r--r-- | ui/gfx/screen_win.cc | 7 | ||||
-rw-r--r-- | ui/gfx/screen_win.h | 3 | ||||
-rw-r--r-- | ui/views/widget/desktop_aura/desktop_screen_x11.cc | 10 |
19 files changed, 182 insertions, 111 deletions
diff --git a/ash/display/display_manager.h b/ash/display/display_manager.h index b2ef8d1..4699eee 100644 --- a/ash/display/display_manager.h +++ b/ash/display/display_manager.h @@ -181,6 +181,8 @@ class ASH_EXPORT DisplayManager // when displays are mirrored. size_t GetNumDisplays() const; + const std::vector<gfx::Display>& displays() const { return displays_; } + // Returns the number of connected displays. This returns 2 // when displays are mirrored. size_t num_connected_displays() const { return num_connected_displays_; } diff --git a/ash/screen_ash.cc b/ash/screen_ash.cc index f2217d7..4ba2868 100644 --- a/ash/screen_ash.cc +++ b/ash/screen_ash.cc @@ -123,10 +123,14 @@ gfx::NativeWindow ScreenAsh::GetWindowAtCursorScreenPoint() { return wm::GetRootWindowAt(point)->GetTopWindowContainingPoint(point); } -int ScreenAsh::GetNumDisplays() { +int ScreenAsh::GetNumDisplays() const { return DisplayController::GetNumDisplays(); } +std::vector<gfx::Display> ScreenAsh::GetAllDisplays() const { + return GetDisplayManager()->displays(); +} + gfx::Display ScreenAsh::GetDisplayNearestWindow(gfx::NativeView window) const { return GetDisplayController()->GetDisplayNearestWindow(window); } diff --git a/ash/screen_ash.h b/ash/screen_ash.h index 649c3d9..95869b0 100644 --- a/ash/screen_ash.h +++ b/ash/screen_ash.h @@ -66,7 +66,8 @@ class ASH_EXPORT ScreenAsh : public gfx::Screen { virtual bool IsDIPEnabled() OVERRIDE; virtual gfx::Point GetCursorScreenPoint() OVERRIDE; virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE; - virtual int GetNumDisplays() OVERRIDE; + virtual int GetNumDisplays() const OVERRIDE; + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE; virtual gfx::Display GetDisplayNearestWindow( gfx::NativeView view) const OVERRIDE; virtual gfx::Display GetDisplayNearestPoint( diff --git a/chrome/browser/extensions/api/system_display/display_info_provider.cc b/chrome/browser/extensions/api/system_display/display_info_provider.cc index e01bb72..064688d 100644 --- a/chrome/browser/extensions/api/system_display/display_info_provider.cc +++ b/chrome/browser/extensions/api/system_display/display_info_provider.cc @@ -4,8 +4,56 @@ #include "chrome/browser/extensions/api/system_display/display_info_provider.h" +#include "base/strings/string_number_conversions.h" +#include "ui/gfx/display.h" +#include "ui/gfx/screen.h" + namespace extensions { +namespace { + +// Converts Rotation enum to integer. +int RotationToDegrees(gfx::Display::Rotation rotation) { + switch (rotation) { + case gfx::Display::ROTATE_0: + return 0; + case gfx::Display::ROTATE_90: + return 90; + case gfx::Display::ROTATE_180: + return 180; + case gfx::Display::ROTATE_270: + return 270; + } + return 0; +} + +// Creates new DisplayUnitInfo struct for |display| and adds it at the end of +// |list|. +extensions::api::system_display::DisplayUnitInfo* +CreateDisplayUnitInfo(const gfx::Display& display, + int64 primary_display_id) { + extensions::api::system_display::DisplayUnitInfo* unit = + new extensions::api::system_display::DisplayUnitInfo(); + const gfx::Rect& bounds = display.bounds(); + const gfx::Rect& work_area = display.work_area(); + unit->id = base::Int64ToString(display.id()); + unit->is_primary = (display.id() == primary_display_id); + unit->is_internal = display.IsInternal(); + unit->is_enabled = true; + unit->rotation = RotationToDegrees(display.rotation()); + unit->bounds.left = bounds.x(); + unit->bounds.top = bounds.y(); + unit->bounds.width = bounds.width(); + unit->bounds.height = bounds.height(); + unit->work_area.left = work_area.x(); + unit->work_area.top = work_area.y(); + unit->work_area.width = work_area.width(); + unit->work_area.height = work_area.height(); + return unit; +} + +} // namespace + DisplayInfoProvider::DisplayInfoProvider() { } @@ -26,6 +74,32 @@ void DisplayInfoProvider::InitializeForTesting( provider_.Get() = provider; } +void DisplayInfoProvider::RequestInfo(const RequestInfoCallback& callback) { + bool success = QueryInfo(); + + base::MessageLoopProxy::current()->PostTask( + FROM_HERE, + base::Bind(callback, success)); +} + +#if !defined(OS_WIN) +bool DisplayInfoProvider::QueryInfo() { + info_.clear(); + + // TODO(scottmg): Native is wrong http://crbug.com/133312 + gfx::Screen* screen = gfx::Screen::GetNativeScreen(); + int64 primary_id = screen->GetPrimaryDisplay().id(); + std::vector<gfx::Display> displays = screen->GetAllDisplays(); + for (int i = 0; i < screen->GetNumDisplays(); ++i) { + linked_ptr<extensions::api::system_display::DisplayUnitInfo> unit( + CreateDisplayUnitInfo(displays[i], primary_id)); + UpdateDisplayUnitInfoForPlatform(displays[i], unit.get()); + info_.push_back(unit); + } + return true; +} +#endif + // static DisplayInfoProvider* DisplayInfoProvider::Get() { if (provider_.Get().get() == NULL) diff --git a/chrome/browser/extensions/api/system_display/display_info_provider.h b/chrome/browser/extensions/api/system_display/display_info_provider.h index ac9c654..65f94eb 100644 --- a/chrome/browser/extensions/api/system_display/display_info_provider.h +++ b/chrome/browser/extensions/api/system_display/display_info_provider.h @@ -11,6 +11,10 @@ #include "chrome/browser/extensions/api/system_info/system_info_provider.h" #include "chrome/common/extensions/api/system_display.h" +namespace gfx { +class Display; +} + namespace extensions { typedef std::vector<linked_ptr< @@ -65,6 +69,12 @@ class DisplayInfoProvider : public SystemInfoProvider { // The implementation is platform specific. virtual bool QueryInfo() OVERRIDE; + // Update the content of the |unit| obtained for |display| using + // platform specific method. + void UpdateDisplayUnitInfoForPlatform( + const gfx::Display& display, + extensions::api::system_display::DisplayUnitInfo* unit); + static base::LazyInstance<scoped_refptr<DisplayInfoProvider> > provider_; DISALLOW_COPY_AND_ASSIGN(DisplayInfoProvider); diff --git a/chrome/browser/extensions/api/system_display/display_info_provider_chromeos.cc b/chrome/browser/extensions/api/system_display/display_info_provider_chromeos.cc index 712bc528..dba99e0 100644 --- a/chrome/browser/extensions/api/system_display/display_info_provider_chromeos.cc +++ b/chrome/browser/extensions/api/system_display/display_info_provider_chromeos.cc @@ -35,21 +35,6 @@ bool IsValidRotationValue(int rotation) { return rotation == 0 || rotation == 90 || rotation == 180 || rotation == 270; } -// Converts Rotation enum to integer. -int RotationToDegrees(gfx::Display::Rotation rotation) { - switch (rotation) { - case gfx::Display::ROTATE_0: - return 0; - case gfx::Display::ROTATE_90: - return 90; - case gfx::Display::ROTATE_180: - return 180; - case gfx::Display::ROTATE_270: - return 270; - } - return 0; -} - // Converts integer integer value in degrees to Rotation enum value. gfx::Display::Rotation DegreesToRotation(int degrees) { DCHECK(IsValidRotationValue(degrees)); @@ -67,48 +52,6 @@ gfx::Display::Rotation DegreesToRotation(int degrees) { } } -// Creates new DisplayUnitInfo struct for |display| and adds it at the end of -// |list|. -void AddInfoForDisplay(const gfx::Display& display, - DisplayManager* display_manager, - int64 primary_display_id, - DisplayInfo* list) { - linked_ptr<extensions::api::system_display::DisplayUnitInfo> unit( - new extensions::api::system_display::DisplayUnitInfo()); - const gfx::Rect& bounds = display.bounds(); - const gfx::Rect& work_area = display.work_area(); - const float dpi = display.device_scale_factor() * kDpi96; - const gfx::Insets overscan_insets = - display_manager->GetOverscanInsets(display.id()); - - unit->id = base::Int64ToString(display.id()); - unit->name = display_manager->GetDisplayNameForId(display.id()); - unit->is_primary = (display.id() == primary_display_id); - unit->is_internal = display.IsInternal(); - unit->is_enabled = true; - if (display_manager->IsMirrored()) { - unit->mirroring_source_id = - base::Int64ToString(display_manager->mirrored_display().id()); - } - unit->dpi_x = dpi; - unit->dpi_y = dpi; - unit->rotation = RotationToDegrees(display.rotation()); - unit->bounds.left = bounds.x(); - unit->bounds.top = bounds.y(); - unit->bounds.width = bounds.width(); - unit->bounds.height = bounds.height(); - unit->overscan.left = overscan_insets.left(); - unit->overscan.top = overscan_insets.top(); - unit->overscan.right = overscan_insets.right(); - unit->overscan.bottom = overscan_insets.bottom(); - unit->work_area.left = work_area.x(); - unit->work_area.top = work_area.y(); - unit->work_area.width = work_area.width(); - unit->work_area.height = work_area.height(); - - list->push_back(unit); -} - // Checks if the given point is over the radius vector described by it's end // point |vector|. The point is over a vector if it's on its positive (left) // side. The method sees a point on the same line as the vector as being over @@ -359,7 +302,9 @@ bool SetInfoImpl(const std::string& display_id_str, } int64 display_id = target.id(); - const gfx::Display& primary = ash::Shell::GetScreen()->GetPrimaryDisplay(); + // TODO(scottmg): Native is wrong http://crbug.com/133312 + const gfx::Display& primary = + gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(); if (!ValidateParamsForDisplay(info, target, display_manager, primary.id(), error)) { @@ -410,14 +355,6 @@ bool SetInfoImpl(const std::string& display_id_str, } // namespace -void DisplayInfoProvider::RequestInfo(const RequestInfoCallback& callback) { - bool success = QueryInfo(); - - base::MessageLoopProxy::current()->PostTask( - FROM_HERE, - base::Bind(callback, success)); -} - void DisplayInfoProvider::SetInfo(const std::string& display_id, const DisplayProperties& info, const SetInfoCallback& callback) { @@ -428,20 +365,28 @@ void DisplayInfoProvider::SetInfo(const std::string& display_id, base::Bind(callback, success, error)); } -bool DisplayInfoProvider::QueryInfo() { - info_.clear(); +void DisplayInfoProvider::UpdateDisplayUnitInfoForPlatform( + const gfx::Display& display, + extensions::api::system_display::DisplayUnitInfo* unit) { - DisplayManager* display_manager = - ash::Shell::GetInstance()->display_manager(); - DCHECK(display_manager); - - int64 primary_id = ash::Shell::GetScreen()->GetPrimaryDisplay().id(); - for (size_t i = 0; i < display_manager->GetNumDisplays(); ++i) { - AddInfoForDisplay(display_manager->GetDisplayAt(i), display_manager, - primary_id, &info_); + ash::internal::DisplayManager* display_manager + = ash::Shell::GetInstance()->display_manager(); + unit->name = display_manager->GetDisplayNameForId(display.id()); + if (display_manager->IsMirrored()) { + unit->mirroring_source_id = + base::Int64ToString(display_manager->mirrored_display().id()); } - return true; + const float dpi = display.device_scale_factor() * kDpi96; + unit->dpi_x = dpi; + unit->dpi_y = dpi; + + const gfx::Insets overscan_insets = + display_manager->GetOverscanInsets(display.id()); + unit->overscan.left = overscan_insets.left(); + unit->overscan.top = overscan_insets.top(); + unit->overscan.right = overscan_insets.right(); + unit->overscan.bottom = overscan_insets.bottom(); } } // namespace extensions diff --git a/chrome/browser/extensions/api/system_display/display_info_provider_mac.cc b/chrome/browser/extensions/api/system_display/display_info_provider_mac.cc index 2b22e1e..3776bf9 100644 --- a/chrome/browser/extensions/api/system_display/display_info_provider_mac.cc +++ b/chrome/browser/extensions/api/system_display/display_info_provider_mac.cc @@ -6,11 +6,6 @@ namespace extensions { -void DisplayInfoProvider::RequestInfo(const RequestInfoCallback& callback) { - // Redirect the request to a worker pool thread. - StartQueryInfo(callback); -} - void DisplayInfoProvider::SetInfo( const std::string& display_id, const api::system_display::DisplayProperties& info, @@ -20,9 +15,10 @@ void DisplayInfoProvider::SetInfo( base::Bind(callback, false, "Not implemented")); } -// TODO(hongbo): implement display info querying on Mac OS X. -bool DisplayInfoProvider::QueryInfo() { - return false; +void DisplayInfoProvider::UpdateDisplayUnitInfoForPlatform( + const gfx::Display& display, + extensions::api::system_display::DisplayUnitInfo* unit) { + NOTIMPLEMENTED(); } } // namespace extensions diff --git a/chrome/browser/extensions/api/system_display/display_info_provider_win.cc b/chrome/browser/extensions/api/system_display/display_info_provider_win.cc index 9d21278..846d777 100644 --- a/chrome/browser/extensions/api/system_display/display_info_provider_win.cc +++ b/chrome/browser/extensions/api/system_display/display_info_provider_win.cc @@ -67,11 +67,6 @@ BOOL CALLBACK EnumMonitorCallback(HMONITOR monitor, } // namespace -void DisplayInfoProvider::RequestInfo(const RequestInfoCallback& callback) { - // Redirect the request to a worker pool thread. - StartQueryInfo(callback); -} - void DisplayInfoProvider::SetInfo( const std::string& display_id, const api::system_display::DisplayProperties& info, @@ -81,6 +76,7 @@ void DisplayInfoProvider::SetInfo( base::Bind(callback, false, "Not implemented")); } +// TODO(hongbo): consolidate implementation using gfx::Display/gfx::Screen. bool DisplayInfoProvider::QueryInfo() { info_.clear(); @@ -90,4 +86,10 @@ bool DisplayInfoProvider::QueryInfo() { return false; } +void DisplayInfoProvider::UpdateDisplayUnitInfoForPlatform( + const gfx::Display& display, + extensions::api::system_display::DisplayUnitInfo* unit) { + NOTIMPLEMENTED(); +} + } // namespace extensions diff --git a/chrome/browser/extensions/api/system_display/display_info_provider_x11.cc b/chrome/browser/extensions/api/system_display/display_info_provider_x11.cc index adfdb14..3776bf9 100644 --- a/chrome/browser/extensions/api/system_display/display_info_provider_x11.cc +++ b/chrome/browser/extensions/api/system_display/display_info_provider_x11.cc @@ -6,11 +6,6 @@ namespace extensions { -void DisplayInfoProvider::RequestInfo(const RequestInfoCallback& callback) { - // Redirect the request to a worker pool thread. - StartQueryInfo(callback); -} - void DisplayInfoProvider::SetInfo( const std::string& display_id, const api::system_display::DisplayProperties& info, @@ -20,9 +15,10 @@ void DisplayInfoProvider::SetInfo( base::Bind(callback, false, "Not implemented")); } -// TODO(hongbo): implement X11 display info querying. -bool DisplayInfoProvider::QueryInfo() { - return false; +void DisplayInfoProvider::UpdateDisplayUnitInfoForPlatform( + const gfx::Display& display, + extensions::api::system_display::DisplayUnitInfo* unit) { + NOTIMPLEMENTED(); } } // namespace extensions diff --git a/ui/aura/test/test_screen.cc b/ui/aura/test/test_screen.cc index 13d1232..474ac29 100644 --- a/ui/aura/test/test_screen.cc +++ b/ui/aura/test/test_screen.cc @@ -113,10 +113,14 @@ gfx::NativeWindow TestScreen::GetWindowAtCursorScreenPoint() { return root_window_->GetTopWindowContainingPoint(point); } -int TestScreen::GetNumDisplays() { +int TestScreen::GetNumDisplays() const { return 1; } +std::vector<gfx::Display> TestScreen::GetAllDisplays() const { + return std::vector<gfx::Display>(1, display_); +} + gfx::Display TestScreen::GetDisplayNearestWindow( gfx::NativeWindow window) const { return display_; diff --git a/ui/aura/test/test_screen.h b/ui/aura/test/test_screen.h index c4615c7..00d684b 100644 --- a/ui/aura/test/test_screen.h +++ b/ui/aura/test/test_screen.h @@ -48,7 +48,8 @@ class TestScreen : public gfx::Screen, virtual bool IsDIPEnabled() OVERRIDE; virtual gfx::Point GetCursorScreenPoint() OVERRIDE; virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE; - virtual int GetNumDisplays() OVERRIDE; + virtual int GetNumDisplays() const OVERRIDE; + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE; virtual gfx::Display GetDisplayNearestWindow( gfx::NativeView view) const OVERRIDE; virtual gfx::Display GetDisplayNearestPoint( diff --git a/ui/gfx/screen.h b/ui/gfx/screen.h index 9410d02..7958f65 100644 --- a/ui/gfx/screen.h +++ b/ui/gfx/screen.h @@ -5,6 +5,8 @@ #ifndef UI_GFX_SCREEN_H_ #define UI_GFX_SCREEN_H_ +#include <vector> + #include "base/basictypes.h" #include "ui/base/ui_export.h" #include "ui/gfx/display.h" @@ -55,7 +57,10 @@ class UI_EXPORT Screen { // Returns the number of displays. // Mirrored displays are excluded; this method is intended to return the // number of distinct, usable displays. - virtual int GetNumDisplays() = 0; + virtual int GetNumDisplays() const = 0; + + // Returns the list of displays that are currently available. + virtual std::vector<gfx::Display> GetAllDisplays() const = 0; // Returns the display nearest the specified window. virtual gfx::Display GetDisplayNearestWindow(NativeView view) const = 0; diff --git a/ui/gfx/screen_android.cc b/ui/gfx/screen_android.cc index 6c4d633..1376136 100644 --- a/ui/gfx/screen_android.cc +++ b/ui/gfx/screen_android.cc @@ -50,7 +50,11 @@ class ScreenAndroid : public Screen { return GetPrimaryDisplay(); } - virtual int GetNumDisplays() OVERRIDE { return 1; } + virtual int GetNumDisplays() const OVERRIDE { return 1; } + + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { + return std::vector<gfx::Display>(1, GetPrimaryDisplay()); + } virtual gfx::Display GetDisplayMatching( const gfx::Rect& match_rect) const OVERRIDE { diff --git a/ui/gfx/screen_gtk.cc b/ui/gfx/screen_gtk.cc index 8ef803d..85dd87e 100644 --- a/ui/gfx/screen_gtk.cc +++ b/ui/gfx/screen_gtk.cc @@ -107,13 +107,18 @@ class ScreenGtk : public gfx::Screen { // Returns the number of displays. // Mirrored displays are excluded; this method is intended to return the // number of distinct, usable displays. - virtual int GetNumDisplays() OVERRIDE { + virtual int GetNumDisplays() const OVERRIDE { // 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. GdkScreen* screen = gdk_screen_get_default(); return gdk_screen_get_n_monitors(screen); } + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { + NOTIMPLEMENTED(); + return std::vector<gfx::Display>(1, GetPrimaryDisplay()); + } + // Returns the display nearest the specified window. virtual gfx::Display GetDisplayNearestWindow( gfx::NativeView view) const OVERRIDE { diff --git a/ui/gfx/screen_ios.mm b/ui/gfx/screen_ios.mm index dfb0d1b..6450e14 100644 --- a/ui/gfx/screen_ios.mm +++ b/ui/gfx/screen_ios.mm @@ -26,7 +26,7 @@ class ScreenIos : public gfx::Screen { return gfx::NativeWindow(); } - virtual int GetNumDisplays() OVERRIDE { + virtual int GetNumDisplays() const OVERRIDE { #if TARGET_IPHONE_SIMULATOR // UIScreen does not reliably return correct results on the simulator. return 1; @@ -35,6 +35,11 @@ class ScreenIos : public gfx::Screen { #endif } + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { + NOTIMPLEMENTED(); + return std::vector<gfx::Display>(1, GetPrimaryDisplay()); + } + // Returns the display nearest the specified window. virtual gfx::Display GetDisplayNearestWindow( gfx::NativeView view) const OVERRIDE { diff --git a/ui/gfx/screen_mac.mm b/ui/gfx/screen_mac.mm index d9e1f0a..8f85ae6 100644 --- a/ui/gfx/screen_mac.mm +++ b/ui/gfx/screen_mac.mm @@ -89,7 +89,7 @@ class ScreenMac : public gfx::Screen { return gfx::NativeWindow(); } - virtual int GetNumDisplays() OVERRIDE { + virtual int GetNumDisplays() const OVERRIDE { // 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 // tempting to use the count returned by CGGetActiveDisplayList, but active @@ -123,6 +123,11 @@ class ScreenMac : public gfx::Screen { return display_count; } + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE { + NOTIMPLEMENTED(); + return std::vector<gfx::Display>(1, GetPrimaryDisplay()); + } + virtual gfx::Display GetDisplayNearestWindow( gfx::NativeView view) const OVERRIDE { NSWindow* window = [view window]; diff --git a/ui/gfx/screen_win.cc b/ui/gfx/screen_win.cc index 8bb1548..23dbc9d 100644 --- a/ui/gfx/screen_win.cc +++ b/ui/gfx/screen_win.cc @@ -55,10 +55,15 @@ gfx::NativeWindow ScreenWin::GetWindowAtCursorScreenPoint() { return GetNativeWindowFromHWND(window_hwnd); } -int ScreenWin::GetNumDisplays() { +int ScreenWin::GetNumDisplays() const { return GetSystemMetrics(SM_CMONITORS); } +std::vector<gfx::Display> ScreenWin::GetAllDisplays() const { + NOTIMPLEMENTED(); + return std::vector<gfx::Display>(1, GetPrimaryDisplay()); +} + gfx::Display ScreenWin::GetDisplayNearestWindow(gfx::NativeView window) const { HWND window_hwnd = GetHWNDFromNativeView(window); if (!window_hwnd) { diff --git a/ui/gfx/screen_win.h b/ui/gfx/screen_win.h index f6b7d40a..cc59352 100644 --- a/ui/gfx/screen_win.h +++ b/ui/gfx/screen_win.h @@ -21,7 +21,8 @@ class UI_EXPORT ScreenWin : public gfx::Screen { virtual bool IsDIPEnabled() OVERRIDE; virtual gfx::Point GetCursorScreenPoint() OVERRIDE; virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE; - virtual int GetNumDisplays() OVERRIDE; + virtual int GetNumDisplays() const OVERRIDE; + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE; virtual gfx::Display GetDisplayNearestWindow( gfx::NativeView window) const OVERRIDE; virtual gfx::Display GetDisplayNearestPoint( diff --git a/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/ui/views/widget/desktop_aura/desktop_screen_x11.cc index 77dbaa4..a462da7 100644 --- a/ui/views/widget/desktop_aura/desktop_screen_x11.cc +++ b/ui/views/widget/desktop_aura/desktop_screen_x11.cc @@ -39,7 +39,8 @@ class DesktopScreenX11 : public gfx::Screen { virtual bool IsDIPEnabled() OVERRIDE; virtual gfx::Point GetCursorScreenPoint() OVERRIDE; virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE; - virtual int GetNumDisplays() OVERRIDE; + virtual int GetNumDisplays() const OVERRIDE; + virtual std::vector<gfx::Display> GetAllDisplays() const OVERRIDE; virtual gfx::Display GetDisplayNearestWindow( gfx::NativeView window) const OVERRIDE; virtual gfx::Display GetDisplayNearestPoint( @@ -95,12 +96,17 @@ gfx::NativeWindow DesktopScreenX11::GetWindowAtCursorScreenPoint() { return NULL; } -int DesktopScreenX11::GetNumDisplays() { +int DesktopScreenX11::GetNumDisplays() const { // TODO(erg): Figure this out with oshima or piman because I have no clue // about the XRandR implications here. return 1; } +std::vector<gfx::Display> DesktopScreenX11::GetAllDisplays() const { + // TODO(erg): Do the right thing once we know what that is. + return std::vector<gfx::Display>(1, GetPrimaryDisplay()); +} + gfx::Display DesktopScreenX11::GetDisplayNearestWindow( gfx::NativeView window) const { // TODO(erg): Do the right thing once we know what that is. |