Index: ui/base/x/x11_util.cc |
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc |
index 3a518879aa1b9936cb57b7f16c6a62d86c15838a..3287e7a9fcb77b0de1607374bc2e861df6209b40 100644 |
--- a/ui/base/x/x11_util.cc |
+++ b/ui/base/x/x11_util.cc |
@@ -453,6 +453,29 @@ XcursorImage* SkBitmapToXcursorImage(const SkBitmap* bitmap, |
} |
#endif |
+void HideHostCursor() { |
+ XDefineCursor(ui::GetXDisplay(), DefaultRootWindow(ui::GetXDisplay()), |
+ GetInvisibleCursor()); |
+} |
+ |
+::Cursor GetInvisibleCursor() { |
+ Display* xdisplay = ui::GetXDisplay(); |
+ CR_DEFINE_STATIC_LOCAL(XScopedCursor, invisible_cursor, (0U, xdisplay)); |
+ if (invisible_cursor.get()) |
+ return invisible_cursor.get(); |
+ |
+ // Initialize invisible cursor. |
+ char nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
+ XColor black; |
+ black.red = black.green = black.blue = 0; |
+ Pixmap blank = XCreateBitmapFromData(xdisplay, DefaultRootWindow(xdisplay), |
+ nodata, 8, 8); |
+ invisible_cursor.reset(XCreatePixmapCursor(xdisplay, blank, blank, |
+ &black, &black, 0, 0)); |
+ XFreePixmap(xdisplay, blank); |
+ return invisible_cursor.get(); |
+} |
+ |
XID GetX11RootWindow() { |
return DefaultRootWindow(GetXDisplay()); |
} |
@@ -1336,6 +1359,25 @@ XScopedString::~XScopedString() { |
XFree(string_); |
} |
+XScopedCursor::XScopedCursor(::Cursor cursor, Display* display) |
+ : cursor_(cursor), |
+ display_(display) { |
+} |
+ |
+XScopedCursor::~XScopedCursor() { |
+ reset(0U); |
+} |
+ |
+::Cursor XScopedCursor::get() const { |
+ return cursor_; |
+} |
+ |
+void XScopedCursor::reset(::Cursor cursor) { |
+ if (cursor_) |
+ XFreeCursor(display_, cursor_); |
+ cursor_ = cursor; |
+} |
+ |
// ---------------------------------------------------------------------------- |
// These functions are declared in x11_util_internal.h because they require |
// XLib.h to be included, and it conflicts with many other headers. |