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

Side by Side Diff: chrome/browser/window_sizer_linux.cc

Issue 113884: Fix comparison in window_sizer_linux. There can be multiple desktops so data_... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/window_sizer.h" 5 #include "chrome/browser/window_sizer.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "chrome/browser/browser.h" 10 #include "chrome/browser/browser.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 void UpdateWorkAreas() { 51 void UpdateWorkAreas() {
52 // TODO(thestig) Implement multi-monitor support. 52 // TODO(thestig) Implement multi-monitor support.
53 work_areas_.clear(); 53 work_areas_.clear();
54 work_areas_.push_back(GetPrimaryMonitorBounds()); 54 work_areas_.push_back(GetPrimaryMonitorBounds());
55 } 55 }
56 56
57 private: 57 private:
58 // Get the available screen space as a gfx::Rect, or return false if 58 // Get the available screen space as a gfx::Rect, or return false if
59 // if it's unavailable (i.e. the window manager doesn't support 59 // if it's unavailable (i.e. the window manager doesn't support
60 // retrieving this). 60 // retrieving this).
61 // TODO(thestig) Use _NET_CURRENT_DESKTOP here as well?
61 bool GetScreenWorkArea(gfx::Rect* out_rect) const { 62 bool GetScreenWorkArea(gfx::Rect* out_rect) const {
62 gboolean ok; 63 gboolean ok;
63 guchar* raw_data = NULL; 64 guchar* raw_data = NULL;
64 gint data_len = 0; 65 gint data_len = 0;
65 ok = gdk_property_get(gdk_get_default_root_window(), // a gdk window 66 ok = gdk_property_get(gdk_get_default_root_window(), // a gdk window
66 gdk_atom_intern("_NET_WORKAREA", FALSE), // property 67 gdk_atom_intern("_NET_WORKAREA", FALSE), // property
67 gdk_atom_intern("CARDINAL", FALSE), // property type 68 gdk_atom_intern("CARDINAL", FALSE), // property type
68 0, // byte offset into property 69 0, // byte offset into property
69 0xff, // property length to retrieve 70 0xff, // property length to retrieve
70 false, // delete property after retrieval? 71 false, // delete property after retrieval?
71 NULL, // returned property type 72 NULL, // returned property type
72 NULL, // returned data format 73 NULL, // returned data format
73 &data_len, // returned data len 74 &data_len, // returned data len
74 &raw_data); // returned data 75 &raw_data); // returned data
75 if (!ok) 76 if (!ok)
76 return false; 77 return false;
77 78
78 // We expect to get four longs back: x1, y1, x2, y2. 79 // We expect to get four longs back: x1, y1, x2, y2.
79 if (data_len != 4 * sizeof(glong)) { 80 if (data_len < static_cast<gint>(4 * sizeof(glong))) {
80 NOTREACHED(); 81 NOTREACHED();
81 g_free(raw_data); 82 g_free(raw_data);
82 return false; 83 return false;
83 } 84 }
84 85
85 glong* data = reinterpret_cast<glong*>(raw_data); 86 glong* data = reinterpret_cast<glong*>(raw_data);
86 gint x = data[0]; 87 gint x = data[0];
87 gint y = data[1]; 88 gint y = data[1];
88 gint width = data[0] + data[2]; 89 gint width = data[0] + data[2];
89 gint height = data[1] + data[3]; 90 gint height = data[1] + data[3];
90 g_free(raw_data); 91 g_free(raw_data);
91 92
92 out_rect->SetRect(x, y, width, height); 93 out_rect->SetRect(x, y, width, height);
93 return true; 94 return true;
94 } 95 }
95 96
96 DISALLOW_COPY_AND_ASSIGN(DefaultMonitorInfoProvider); 97 DISALLOW_COPY_AND_ASSIGN(DefaultMonitorInfoProvider);
97 }; 98 };
98 99
99 // static 100 // static
100 WindowSizer::MonitorInfoProvider* 101 WindowSizer::MonitorInfoProvider*
101 WindowSizer::CreateDefaultMonitorInfoProvider() { 102 WindowSizer::CreateDefaultMonitorInfoProvider() {
102 return new DefaultMonitorInfoProvider(); 103 return new DefaultMonitorInfoProvider();
103 } 104 }
OLDNEW
« 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