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

Side by Side Diff: app/x11_util.cc

Issue 661237: This adds in the ability for Chrome to generate windows with snapshots of all... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 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 | « app/x11_util.h ('k') | base/file_descriptor_posix.h » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // This file defines utility functions for X11 (Linux only). This code has been 5 // This file defines utility functions for X11 (Linux only). This code has been
6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support 6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support
7 // remains woefully incomplete. 7 // remains woefully incomplete.
8 8
9 #include "app/x11_util.h" 9 #include "app/x11_util.h"
10 10
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 if (format != 32 || num_items != 1) { 222 if (format != 32 || num_items != 1) {
223 XFree(property); 223 XFree(property);
224 return false; 224 return false;
225 } 225 }
226 226
227 *value = *(reinterpret_cast<int*>(property)); 227 *value = *(reinterpret_cast<int*>(property));
228 XFree(property); 228 XFree(property);
229 return true; 229 return true;
230 } 230 }
231 231
232 bool GetIntArrayProperty(XID window,
233 const std::string& property_name,
234 std::vector<int>* value) {
235 Atom property_atom = gdk_x11_get_xatom_by_name_for_display(
236 gdk_display_get_default(), property_name.c_str());
237
238 Atom type = None;
239 int format = 0; // size in bits of each item in 'property'
240 long unsigned int num_items = 0, remaining_bytes = 0;
241 unsigned char* properties = NULL;
242
243 int result = XGetWindowProperty(GetXDisplay(),
244 window,
245 property_atom,
246 0, // offset into property data to read
247 (~0L), // max length to get (all of them)
248 False, // deleted
249 AnyPropertyType,
250 &type,
251 &format,
252 &num_items,
253 &remaining_bytes,
254 &properties);
255 if (result != Success)
256 return false;
257
258 if (format != 32) {
259 XFree(properties);
260 return false;
261 }
262
263 int* int_properties = reinterpret_cast<int*>(properties);
264 value->clear();
265 value->insert(value->begin(), int_properties, int_properties + num_items);
266 XFree(properties);
267 return true;
268 }
269
232 bool GetStringProperty( 270 bool GetStringProperty(
233 XID window, const std::string& property_name, std::string* value) { 271 XID window, const std::string& property_name, std::string* value) {
234 Atom property_atom = gdk_x11_get_xatom_by_name_for_display( 272 Atom property_atom = gdk_x11_get_xatom_by_name_for_display(
235 gdk_display_get_default(), property_name.c_str()); 273 gdk_display_get_default(), property_name.c_str());
236 274
237 Atom type = None; 275 Atom type = None;
238 int format = 0; // size in bits of each item in 'property' 276 int format = 0; // size in bits of each item in 'property'
239 long unsigned int num_items = 0, remaining_bytes = 0; 277 long unsigned int num_items = 0, remaining_bytes = 0;
240 unsigned char* property = NULL; 278 unsigned char* property = NULL;
241 279
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 event.xclient.format = 32; 780 event.xclient.format = 32;
743 event.xclient.data.l[0] = desktop; 781 event.xclient.data.l[0] = desktop;
744 event.xclient.data.l[1] = 1; // source indication 782 event.xclient.data.l[1] = 1; // source indication
745 783
746 int result = XSendEvent(GetXDisplay(), GetX11RootWindow(), False, 784 int result = XSendEvent(GetXDisplay(), GetX11RootWindow(), False,
747 SubstructureNotifyMask, &event); 785 SubstructureNotifyMask, &event);
748 return result == Success; 786 return result == Success;
749 } 787 }
750 788
751 } // namespace x11_util 789 } // namespace x11_util
OLDNEW
« no previous file with comments | « app/x11_util.h ('k') | base/file_descriptor_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698