| 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" |
| 21 | 22 |
| 22 typedef unsigned long Atom; | 23 typedef unsigned long Atom; |
| 23 typedef unsigned long XID; | 24 typedef unsigned long XID; |
| 24 typedef unsigned long XSharedMemoryId; // ShmSeg in the X headers. | 25 typedef unsigned long XSharedMemoryId; // ShmSeg in the X headers. |
| 25 typedef struct _XDisplay Display; | 26 typedef struct _XDisplay Display; |
| 26 typedef unsigned long Cursor; | 27 typedef unsigned long Cursor; |
| 27 typedef struct _XcursorImage XcursorImage; | 28 typedef struct _XcursorImage XcursorImage; |
| 28 | 29 |
| 29 #if defined(TOOLKIT_GTK) | 30 #if defined(TOOLKIT_GTK) |
| 30 typedef struct _GdkDrawable GdkWindow; | 31 typedef struct _GdkDrawable GdkWindow; |
| 31 typedef struct _GtkWidget GtkWidget; | 32 typedef struct _GtkWidget GtkWidget; |
| 32 typedef struct _GtkWindow GtkWindow; | 33 typedef struct _GtkWindow GtkWindow; |
| 33 #endif | 34 #endif |
| 34 | 35 |
| 35 namespace gfx { | 36 namespace gfx { |
| 36 class Rect; | 37 class Rect; |
| 37 } | 38 } |
| 39 class SkBitmap; |
| 38 | 40 |
| 39 namespace ui { | 41 namespace ui { |
| 40 | 42 |
| 41 // These functions use the GDK default display and this /must/ be called from | 43 // These functions use the GDK default display and this /must/ be called from |
| 42 // the UI thread. Thus, they don't support multiple displays. | 44 // the UI thread. Thus, they don't support multiple displays. |
| 43 | 45 |
| 44 // These functions cache their results --------------------------------- | 46 // These functions cache their results --------------------------------- |
| 45 | 47 |
| 46 // Check if there's an open connection to an X server. | 48 // Check if there's an open connection to an X server. |
| 47 UI_EXPORT bool XDisplayExists(); | 49 UI_EXPORT bool XDisplayExists(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // Creates a custom X cursor from the image. This takes ownership of image. The | 84 // Creates a custom X cursor from the image. This takes ownership of image. The |
| 83 // caller must not free/modify the image. The refcount of the newly created | 85 // caller must not free/modify the image. The refcount of the newly created |
| 84 // cursor is set to 1. | 86 // cursor is set to 1. |
| 85 UI_EXPORT ::Cursor CreateReffedCustomXCursor(XcursorImage* image); | 87 UI_EXPORT ::Cursor CreateReffedCustomXCursor(XcursorImage* image); |
| 86 | 88 |
| 87 // Increases the refcount of the custom cursor. | 89 // Increases the refcount of the custom cursor. |
| 88 UI_EXPORT void RefCustomXCursor(::Cursor cursor); | 90 UI_EXPORT void RefCustomXCursor(::Cursor cursor); |
| 89 | 91 |
| 90 // Decreases the refcount of the custom cursor, and destroys it if it reaches 0. | 92 // Decreases the refcount of the custom cursor, and destroys it if it reaches 0. |
| 91 UI_EXPORT void UnrefCustomXCursor(::Cursor cursor); | 93 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); |
| 92 #endif | 99 #endif |
| 93 | 100 |
| 94 // These functions do not cache their results -------------------------- | 101 // These functions do not cache their results -------------------------- |
| 95 | 102 |
| 96 // Get the X window id for the default root window | 103 // Get the X window id for the default root window |
| 97 UI_EXPORT XID GetX11RootWindow(); | 104 UI_EXPORT XID GetX11RootWindow(); |
| 98 | 105 |
| 99 // Returns the user's current desktop. | 106 // Returns the user's current desktop. |
| 100 bool GetCurrentDesktop(int* desktop); | 107 bool GetCurrentDesktop(int* desktop); |
| 101 | 108 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 287 |
| 281 private: | 288 private: |
| 282 char* string_; | 289 char* string_; |
| 283 | 290 |
| 284 DISALLOW_COPY_AND_ASSIGN(XScopedString); | 291 DISALLOW_COPY_AND_ASSIGN(XScopedString); |
| 285 }; | 292 }; |
| 286 | 293 |
| 287 } // namespace ui | 294 } // namespace ui |
| 288 | 295 |
| 289 #endif // UI_BASE_X_X11_UTIL_H_ | 296 #endif // UI_BASE_X_X11_UTIL_H_ |
| OLD | NEW |