Index: chrome/browser/ui/window_sizer_gtk.cc |
diff --git a/chrome/browser/ui/window_sizer_gtk.cc b/chrome/browser/ui/window_sizer_gtk.cc |
index 6746eea4fc5a0d843dfab3ed433fcb3be15b015a..133fb0ca8528f78e333c69b8494c80f51d556956 100644 |
--- a/chrome/browser/ui/window_sizer_gtk.cc |
+++ b/chrome/browser/ui/window_sizer_gtk.cc |
@@ -10,6 +10,7 @@ |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_list.h" |
#include "chrome/browser/ui/browser_window.h" |
+#include "ui/gfx/screen.h" |
// Used to pad the default new window size. On Windows, this is also used for |
// positioning new windows (each window is offset from the previous one). |
@@ -17,93 +18,9 @@ |
// size. |
const int WindowSizer::kWindowTilePixels = 10; |
-// An implementation of WindowSizer::MonitorInfoProvider that gets the actual |
-// monitor information from X via GDK. |
-class DefaultMonitorInfoProvider : public WindowSizer::MonitorInfoProvider { |
- public: |
- DefaultMonitorInfoProvider() { } |
- |
- virtual gfx::Rect GetPrimaryMonitorWorkArea() const { |
- gfx::Rect rect; |
- if (GetScreenWorkArea(&rect)) |
- return rect.Intersect(GetPrimaryMonitorBounds()); |
- |
- // Return the best we've got. |
- return GetPrimaryMonitorBounds(); |
- } |
- |
- virtual gfx::Rect GetPrimaryMonitorBounds() const { |
- GdkScreen* screen = gdk_screen_get_default(); |
- GdkRectangle rect; |
- gdk_screen_get_monitor_geometry(screen, 0, &rect); |
- return gfx::Rect(rect); |
- } |
- |
- virtual gfx::Rect GetMonitorWorkAreaMatching( |
- const gfx::Rect& match_rect) const { |
- // TODO(thestig) Implement multi-monitor support. |
- return GetPrimaryMonitorWorkArea(); |
- } |
- |
- void UpdateWorkAreas() { |
- // TODO(thestig) Implement multi-monitor support. |
- work_areas_.clear(); |
- work_areas_.push_back(GetPrimaryMonitorBounds()); |
- } |
- |
- private: |
- // Get the available screen space as a gfx::Rect, or return false if |
- // if it's unavailable (i.e. the window manager doesn't support |
- // retrieving this). |
- // TODO(thestig) Use _NET_CURRENT_DESKTOP here as well? |
- bool GetScreenWorkArea(gfx::Rect* out_rect) const { |
- gboolean ok; |
- guchar* raw_data = NULL; |
- gint data_len = 0; |
- ok = gdk_property_get(gdk_get_default_root_window(), // a gdk window |
- gdk_atom_intern("_NET_WORKAREA", FALSE), // property |
- gdk_atom_intern("CARDINAL", FALSE), // property type |
- 0, // byte offset into property |
- 0xff, // property length to retrieve |
- false, // delete property after retrieval? |
- NULL, // returned property type |
- NULL, // returned data format |
- &data_len, // returned data len |
- &raw_data); // returned data |
- if (!ok) |
- return false; |
- |
- // We expect to get four longs back: x, y, width, height. |
- if (data_len < static_cast<gint>(4 * sizeof(glong))) { |
- NOTREACHED(); |
- g_free(raw_data); |
- return false; |
- } |
- |
- glong* data = reinterpret_cast<glong*>(raw_data); |
- gint x = data[0]; |
- gint y = data[1]; |
- gint width = data[2]; |
- gint height = data[3]; |
- g_free(raw_data); |
- |
- out_rect->SetRect(x, y, width, height); |
- return true; |
- } |
- |
- DISALLOW_COPY_AND_ASSIGN(DefaultMonitorInfoProvider); |
-}; |
- |
-// static |
-WindowSizer::MonitorInfoProvider* |
-WindowSizer::CreateDefaultMonitorInfoProvider() { |
- return new DefaultMonitorInfoProvider(); |
-} |
- |
// static |
gfx::Point WindowSizer::GetDefaultPopupOrigin(const gfx::Size& size) { |
- scoped_ptr<MonitorInfoProvider> provider(CreateDefaultMonitorInfoProvider()); |
- gfx::Rect monitor_bounds = provider->GetPrimaryMonitorWorkArea(); |
+ gfx::Rect monitor_bounds = gfx::Screen::GetPrimaryMonitorWorkArea(); |
gfx::Point corner(monitor_bounds.x(), monitor_bounds.y()); |
if (Browser* browser = BrowserList::GetLastActive()) { |
GtkWindow* window = |