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

Unified Diff: chrome/browser/window_sizer_linux.cc

Issue 113877: linux: fix CHECK fail in window_sizer. (Closed)
Patch Set: Created 11 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/window_sizer_linux.cc
diff --git a/chrome/browser/window_sizer_linux.cc b/chrome/browser/window_sizer_linux.cc
index cd44490c04408bbcd66cbada048a5f696aaaac2d..4cee1907625c22d5e3f69d4feabd98ffe70b7f22 100644
--- a/chrome/browser/window_sizer_linux.cc
+++ b/chrome/browser/window_sizer_linux.cc
@@ -21,8 +21,12 @@ class DefaultMonitorInfoProvider : public WindowSizer::MonitorInfoProvider {
DefaultMonitorInfoProvider() { }
virtual gfx::Rect GetPrimaryMonitorWorkArea() const {
- gfx::Rect rect = GetScreenWorkArea();
- return rect.Intersect(GetPrimaryMonitorBounds());
+ gfx::Rect rect;
+ if (GetScreenWorkArea(&rect))
+ return rect.Intersect(GetPrimaryMonitorBounds());
+
+ // Return the best we've got.
+ return GetPrimaryMonitorBounds();
}
virtual gfx::Rect GetPrimaryMonitorBounds() const {
@@ -51,29 +55,42 @@ class DefaultMonitorInfoProvider : public WindowSizer::MonitorInfoProvider {
}
private:
- gfx::Rect GetScreenWorkArea() const {
- gboolean r;
- guchar* raw_data;
- gint data_len;
- r = 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
- CHECK(r);
- CHECK(data_len >= 16);
+ // 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).
+ 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: x1, y1, x2, y2.
+ if (data_len != 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[0] + data[2];
gint height = data[1] + data[3];
- g_free(data);
- return gfx::Rect(x, y, width, height);
+ g_free(raw_data);
+
+ out_rect->SetRect(x, y, width, height);
+ return true;
}
DISALLOW_COPY_AND_ASSIGN(DefaultMonitorInfoProvider);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698