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

Side by Side Diff: ui/base/x/x11_util.h

Issue 17029020: linux_aura: Redo how memory is handled in clipboard/drag code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef UI_BASE_X_X11_UTIL_H_ 5 #ifndef UI_BASE_X_X11_UTIL_H_
6 #define UI_BASE_X_X11_UTIL_H_ 6 #define UI_BASE_X_X11_UTIL_H_
7 7
8 // This file declares utility functions for X11 (Linux only). 8 // This file declares utility functions for X11 (Linux only).
9 // 9 //
10 // These functions do not require the Xlib headers to be included (which is why 10 // These functions do not require the Xlib headers to be included (which is why
11 // we use a void* for Visual*). The Xlib headers are highly polluting so we try 11 // we use a void* for Visual*). The Xlib headers are highly polluting so we try
12 // hard to limit their spread into the rest of the code. 12 // hard to limit their spread into the rest of the code.
13 13
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/basictypes.h" 17 #include "base/basictypes.h"
18 #include "base/event_types.h" 18 #include "base/event_types.h"
19 #include "base/memory/ref_counted_memory.h"
19 #include "ui/base/events/event_constants.h" 20 #include "ui/base/events/event_constants.h"
20 #include "ui/base/keycodes/keyboard_codes.h" 21 #include "ui/base/keycodes/keyboard_codes.h"
21 #include "ui/base/ui_export.h" 22 #include "ui/base/ui_export.h"
22 #include "ui/gfx/point.h" 23 #include "ui/gfx/point.h"
23 24
24 typedef unsigned long Atom; 25 typedef unsigned long Atom;
25 typedef unsigned long XID; 26 typedef unsigned long XID;
26 typedef unsigned long XSharedMemoryId; // ShmSeg in the X headers. 27 typedef unsigned long XSharedMemoryId; // ShmSeg in the X headers.
27 typedef struct _XDisplay Display; 28 typedef struct _XDisplay Display;
28 typedef unsigned long Cursor; 29 typedef unsigned long Cursor;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 UI_EXPORT bool GetWindowRect(XID window, gfx::Rect* rect); 160 UI_EXPORT bool GetWindowRect(XID window, gfx::Rect* rect);
160 161
161 // Returns true if |window| contains the point |screen_loc|. 162 // Returns true if |window| contains the point |screen_loc|.
162 UI_EXPORT bool WindowContainsPoint(XID window, gfx::Point screen_loc); 163 UI_EXPORT bool WindowContainsPoint(XID window, gfx::Point screen_loc);
163 164
164 // Return true if |window| has any property with |property_name|. 165 // Return true if |window| has any property with |property_name|.
165 UI_EXPORT bool PropertyExists(XID window, const std::string& property_name); 166 UI_EXPORT bool PropertyExists(XID window, const std::string& property_name);
166 167
167 // Returns the raw bytes from a property with minimal 168 // Returns the raw bytes from a property with minimal
168 // interpretation. |out_data| should be freed by XFree() after use. 169 // interpretation. |out_data| should be freed by XFree() after use.
169 UI_EXPORT bool GetRawBytesOfProperty(XID window, 170 UI_EXPORT bool GetRawBytesOfProperty(
170 Atom property, 171 XID window,
171 unsigned char** out_data, 172 Atom property,
172 size_t* out_data_bytes, 173 scoped_refptr<base::RefCountedMemory>* out_data,
173 size_t* out_data_items, 174 size_t* out_data_bytes,
174 Atom* out_type); 175 size_t* out_data_items,
176 Atom* out_type);
175 177
176 // Get the value of an int, int array, atom array or string property. On 178 // Get the value of an int, int array, atom array or string property. On
177 // success, true is returned and the value is stored in |value|. 179 // success, true is returned and the value is stored in |value|.
178 // 180 //
179 // TODO(erg): Once we remove the gtk port and are 100% aura, all of these 181 // TODO(erg): Once we remove the gtk port and are 100% aura, all of these
180 // should accept an Atom instead of a string. 182 // should accept an Atom instead of a string.
181 UI_EXPORT bool GetIntProperty(XID window, const std::string& property_name, 183 UI_EXPORT bool GetIntProperty(XID window, const std::string& property_name,
182 int* value); 184 int* value);
183 UI_EXPORT bool GetXIDProperty(XID window, const std::string& property_name, 185 UI_EXPORT bool GetXIDProperty(XID window, const std::string& property_name,
184 XID* value); 186 XID* value);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 // received. 328 // received.
327 UI_EXPORT void UpdateButtonMap(); 329 UI_EXPORT void UpdateButtonMap();
328 330
329 // Initializes a XEvent that holds XKeyEvent for testing. Note that ui::EF_ 331 // Initializes a XEvent that holds XKeyEvent for testing. Note that ui::EF_
330 // flags should be passed as |flags|, not the native ones in <X11/X.h>. 332 // flags should be passed as |flags|, not the native ones in <X11/X.h>.
331 UI_EXPORT void InitXKeyEventForTesting(EventType type, 333 UI_EXPORT void InitXKeyEventForTesting(EventType type,
332 KeyboardCode key_code, 334 KeyboardCode key_code,
333 int flags, 335 int flags,
334 XEvent* event); 336 XEvent* event);
335 337
338 // Manages a piece of X11 allocated memory as a RefCountedMemory segment. This
339 // object takes ownership over the passed in memory and will free it with the
340 // X11 allocator when done.
341 class UI_EXPORT XRefcountedMemory : public base::RefCountedMemory {
342 public:
343 explicit XRefcountedMemory(unsigned char* x11_data, size_t length)
sky 2013/06/24 20:36:18 nit: no explicit
344 : x11_data_(length ? x11_data : NULL), length_(length) {}
sky 2013/06/24 20:36:18 nit: one param per line when you wrap.
345
346 // Overridden from RefCountedMemory:
347 virtual const unsigned char* front() const OVERRIDE;
348 virtual size_t size() const OVERRIDE;
349
350 private:
351 virtual ~XRefcountedMemory();
352
353 unsigned char* x11_data_;
354 size_t length_;
355
356 DISALLOW_COPY_AND_ASSIGN(XRefcountedMemory);
357 };
358
336 // Keeps track of a string returned by an X function (e.g. XGetAtomName) and 359 // Keeps track of a string returned by an X function (e.g. XGetAtomName) and
337 // makes sure it's XFree'd. 360 // makes sure it's XFree'd.
338 class UI_EXPORT XScopedString { 361 class UI_EXPORT XScopedString {
339 public: 362 public:
340 explicit XScopedString(char* str) : string_(str) {} 363 explicit XScopedString(char* str) : string_(str) {}
341 ~XScopedString(); 364 ~XScopedString();
342 365
343 const char* string() const { return string_; } 366 const char* string() const { return string_; }
344 367
345 private: 368 private:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 private: 408 private:
386 ::Cursor cursor_; 409 ::Cursor cursor_;
387 Display* display_; 410 Display* display_;
388 411
389 DISALLOW_COPY_AND_ASSIGN(XScopedCursor); 412 DISALLOW_COPY_AND_ASSIGN(XScopedCursor);
390 }; 413 };
391 414
392 } // namespace ui 415 } // namespace ui
393 416
394 #endif // UI_BASE_X_X11_UTIL_H_ 417 #endif // UI_BASE_X_X11_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698