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 #pragma once | 7 #pragma once |
8 | 8 |
9 // This file declares utility functions for X11 (Linux only). | 9 // This file declares utility functions for X11 (Linux only). |
10 // | 10 // |
11 // These functions do not require the Xlib headers to be included (which is why | 11 // These functions do not require the Xlib headers to be included (which is why |
12 // we use a void* for Visual*). The Xlib headers are highly polluting so we try | 12 // we use a void* for Visual*). The Xlib headers are highly polluting so we try |
13 // hard to limit their spread into the rest of the code. | 13 // hard to limit their spread into the rest of the code. |
14 | 14 |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "base/basictypes.h" | 18 #include "base/basictypes.h" |
19 #include "ui/base/events.h" | 19 #include "ui/base/events.h" |
20 #include "ui/base/ui_export.h" | 20 #include "ui/base/ui_export.h" |
21 #include "ui/gfx/point.h" | |
22 | 21 |
23 typedef unsigned long Atom; | 22 typedef unsigned long Atom; |
24 typedef unsigned long XID; | 23 typedef unsigned long XID; |
25 typedef unsigned long XSharedMemoryId; // ShmSeg in the X headers. | 24 typedef unsigned long XSharedMemoryId; // ShmSeg in the X headers. |
26 typedef struct _XDisplay Display; | 25 typedef struct _XDisplay Display; |
27 typedef unsigned long Cursor; | 26 typedef unsigned long Cursor; |
28 typedef struct _XcursorImage XcursorImage; | 27 typedef struct _XcursorImage XcursorImage; |
29 | 28 |
30 #if defined(TOOLKIT_GTK) | 29 #if defined(TOOLKIT_GTK) |
31 typedef struct _GdkDrawable GdkWindow; | 30 typedef struct _GdkDrawable GdkWindow; |
32 typedef struct _GtkWidget GtkWidget; | 31 typedef struct _GtkWidget GtkWidget; |
33 typedef struct _GtkWindow GtkWindow; | 32 typedef struct _GtkWindow GtkWindow; |
34 #endif | 33 #endif |
35 | 34 |
36 namespace gfx { | 35 namespace gfx { |
37 class Rect; | 36 class Rect; |
38 } | 37 } |
39 class SkBitmap; | |
40 | 38 |
41 namespace ui { | 39 namespace ui { |
42 | 40 |
43 // These functions use the GDK default display and this /must/ be called from | 41 // These functions use the GDK default display and this /must/ be called from |
44 // the UI thread. Thus, they don't support multiple displays. | 42 // the UI thread. Thus, they don't support multiple displays. |
45 | 43 |
46 // These functions cache their results --------------------------------- | 44 // These functions cache their results --------------------------------- |
47 | 45 |
48 // Check if there's an open connection to an X server. | 46 // Check if there's an open connection to an X server. |
49 UI_EXPORT bool XDisplayExists(); | 47 UI_EXPORT bool XDisplayExists(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // Creates a custom X cursor from the image. This takes ownership of image. The | 82 // Creates a custom X cursor from the image. This takes ownership of image. The |
85 // caller must not free/modify the image. The refcount of the newly created | 83 // caller must not free/modify the image. The refcount of the newly created |
86 // cursor is set to 1. | 84 // cursor is set to 1. |
87 UI_EXPORT ::Cursor CreateReffedCustomXCursor(XcursorImage* image); | 85 UI_EXPORT ::Cursor CreateReffedCustomXCursor(XcursorImage* image); |
88 | 86 |
89 // Increases the refcount of the custom cursor. | 87 // Increases the refcount of the custom cursor. |
90 UI_EXPORT void RefCustomXCursor(::Cursor cursor); | 88 UI_EXPORT void RefCustomXCursor(::Cursor cursor); |
91 | 89 |
92 // Decreases the refcount of the custom cursor, and destroys it if it reaches 0. | 90 // Decreases the refcount of the custom cursor, and destroys it if it reaches 0. |
93 UI_EXPORT void UnrefCustomXCursor(::Cursor cursor); | 91 UI_EXPORT void UnrefCustomXCursor(::Cursor cursor); |
94 | |
95 // Creates a XcursorImage and copies the SkBitmap |bitmap| on it. |bitmap| | |
96 // should be non-null. Caller owns the returned object. | |
97 UI_EXPORT XcursorImage* SkBitmapToXcursorImage(const SkBitmap* bitmap, | |
98 const gfx::Point& hotspot); | |
99 #endif | 92 #endif |
100 | 93 |
101 // These functions do not cache their results -------------------------- | 94 // These functions do not cache their results -------------------------- |
102 | 95 |
103 // Get the X window id for the default root window | 96 // Get the X window id for the default root window |
104 UI_EXPORT XID GetX11RootWindow(); | 97 UI_EXPORT XID GetX11RootWindow(); |
105 | 98 |
106 // Returns the user's current desktop. | 99 // Returns the user's current desktop. |
107 bool GetCurrentDesktop(int* desktop); | 100 bool GetCurrentDesktop(int* desktop); |
108 | 101 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 280 |
288 private: | 281 private: |
289 char* string_; | 282 char* string_; |
290 | 283 |
291 DISALLOW_COPY_AND_ASSIGN(XScopedString); | 284 DISALLOW_COPY_AND_ASSIGN(XScopedString); |
292 }; | 285 }; |
293 | 286 |
294 } // namespace ui | 287 } // namespace ui |
295 | 288 |
296 #endif // UI_BASE_X_X11_UTIL_H_ | 289 #endif // UI_BASE_X_X11_UTIL_H_ |
OLD | NEW |