OLD | NEW |
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 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 // Decreases the refcount of the custom cursor, and destroys it if it reaches 0. | 91 // Decreases the refcount of the custom cursor, and destroys it if it reaches 0. |
92 UI_EXPORT void UnrefCustomXCursor(::Cursor cursor); | 92 UI_EXPORT void UnrefCustomXCursor(::Cursor cursor); |
93 | 93 |
94 // Creates a XcursorImage and copies the SkBitmap |bitmap| on it. |bitmap| | 94 // Creates a XcursorImage and copies the SkBitmap |bitmap| on it. |bitmap| |
95 // should be non-null. Caller owns the returned object. | 95 // should be non-null. Caller owns the returned object. |
96 UI_EXPORT XcursorImage* SkBitmapToXcursorImage(const SkBitmap* bitmap, | 96 UI_EXPORT XcursorImage* SkBitmapToXcursorImage(const SkBitmap* bitmap, |
97 const gfx::Point& hotspot); | 97 const gfx::Point& hotspot); |
98 #endif | 98 #endif |
99 | 99 |
| 100 // Hides the host cursor. |
| 101 UI_EXPORT void HideHostCursor(); |
| 102 |
| 103 // Returns an invisible cursor. |
| 104 UI_EXPORT ::Cursor CreateInvisibleCursor(); |
| 105 |
100 // These functions do not cache their results -------------------------- | 106 // These functions do not cache their results -------------------------- |
101 | 107 |
102 // Get the X window id for the default root window | 108 // Get the X window id for the default root window |
103 UI_EXPORT XID GetX11RootWindow(); | 109 UI_EXPORT XID GetX11RootWindow(); |
104 | 110 |
105 // Returns the user's current desktop. | 111 // Returns the user's current desktop. |
106 bool GetCurrentDesktop(int* desktop); | 112 bool GetCurrentDesktop(int* desktop); |
107 | 113 |
108 #if defined(TOOLKIT_GTK) | 114 #if defined(TOOLKIT_GTK) |
109 // Get the X window id for the given GTK widget. | 115 // Get the X window id for the given GTK widget. |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 ~XScopedString(); | 315 ~XScopedString(); |
310 | 316 |
311 const char* string() const { return string_; } | 317 const char* string() const { return string_; } |
312 | 318 |
313 private: | 319 private: |
314 char* string_; | 320 char* string_; |
315 | 321 |
316 DISALLOW_COPY_AND_ASSIGN(XScopedString); | 322 DISALLOW_COPY_AND_ASSIGN(XScopedString); |
317 }; | 323 }; |
318 | 324 |
| 325 // Keeps track of a cursor returned by an X function and makes sure it's |
| 326 // XFreeCursor'd. |
| 327 class UI_EXPORT XScopedCursor { |
| 328 public: |
| 329 // Keeps track of |cursor| created with |display|. |
| 330 XScopedCursor(::Cursor cursor, Display* display); |
| 331 ~XScopedCursor(); |
| 332 |
| 333 ::Cursor get() const; |
| 334 void reset(::Cursor cursor); |
| 335 |
| 336 private: |
| 337 ::Cursor cursor_; |
| 338 Display* display_; |
| 339 |
| 340 DISALLOW_COPY_AND_ASSIGN(XScopedCursor); |
| 341 }; |
| 342 |
319 } // namespace ui | 343 } // namespace ui |
320 | 344 |
321 #endif // UI_BASE_X_X11_UTIL_H_ | 345 #endif // UI_BASE_X_X11_UTIL_H_ |
OLD | NEW |