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 // This file defines utility functions for X11 (Linux only). This code has been | 5 // This file defines utility functions for X11 (Linux only). This code has been |
6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support | 6 // ported from XCB since we can't use XCB on Ubuntu while its 32-bit support |
7 // remains woefully incomplete. | 7 // remains woefully incomplete. |
8 | 8 |
9 #include "ui/base/x/x11_util.h" | 9 #include "ui/base/x/x11_util.h" |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "ui/gfx/rect.h" | 30 #include "ui/gfx/rect.h" |
31 #include "ui/gfx/size.h" | 31 #include "ui/gfx/size.h" |
32 | 32 |
33 #if defined(OS_FREEBSD) | 33 #if defined(OS_FREEBSD) |
34 #include <sys/sysctl.h> | 34 #include <sys/sysctl.h> |
35 #include <sys/types.h> | 35 #include <sys/types.h> |
36 #endif | 36 #endif |
37 | 37 |
38 #if defined(USE_AURA) | 38 #if defined(USE_AURA) |
39 #include <X11/Xcursor/Xcursor.h> | 39 #include <X11/Xcursor/Xcursor.h> |
| 40 #include "third_party/skia/include/core/SkBitmap.h" |
| 41 #include "ui/gfx/skia_util.h" |
40 #endif | 42 #endif |
41 | 43 |
42 #if defined(TOOLKIT_GTK) | 44 #if defined(TOOLKIT_GTK) |
43 #include <gdk/gdk.h> | 45 #include <gdk/gdk.h> |
44 #include <gdk/gdkx.h> | 46 #include <gdk/gdkx.h> |
45 #include <gtk/gtk.h> | 47 #include <gtk/gtk.h> |
46 #include "ui/base/gtk/gdk_x_compat.h" | 48 #include "ui/base/gtk/gdk_x_compat.h" |
47 #include "ui/base/gtk/gtk_compat.h" | 49 #include "ui/base/gtk/gtk_compat.h" |
48 #else | 50 #else |
49 // TODO(sad): Use the new way of handling X errors when | 51 // TODO(sad): Use the new way of handling X errors when |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 return XCustomCursorCache::GetInstance()->InstallCustomCursor(image); | 406 return XCustomCursorCache::GetInstance()->InstallCustomCursor(image); |
405 } | 407 } |
406 | 408 |
407 void RefCustomXCursor(::Cursor cursor) { | 409 void RefCustomXCursor(::Cursor cursor) { |
408 XCustomCursorCache::GetInstance()->Ref(cursor); | 410 XCustomCursorCache::GetInstance()->Ref(cursor); |
409 } | 411 } |
410 | 412 |
411 void UnrefCustomXCursor(::Cursor cursor) { | 413 void UnrefCustomXCursor(::Cursor cursor) { |
412 XCustomCursorCache::GetInstance()->Unref(cursor); | 414 XCustomCursorCache::GetInstance()->Unref(cursor); |
413 } | 415 } |
| 416 |
| 417 XcursorImage* SkBitmapToXcursorImage(const SkBitmap* bitmap, |
| 418 const gfx::Point& hotspot) { |
| 419 DCHECK(bitmap->config() == SkBitmap::kARGB_8888_Config); |
| 420 XcursorImage* image = XcursorImageCreate(bitmap->width(), bitmap->height()); |
| 421 image->xhot = hotspot.x(); |
| 422 image->yhot = hotspot.y(); |
| 423 |
| 424 if (bitmap->width() && bitmap->height()) { |
| 425 bitmap->lockPixels(); |
| 426 gfx::ConvertSkiaToRGBA( |
| 427 static_cast<const unsigned char*>(bitmap->getPixels()), |
| 428 bitmap->width() * bitmap->height(), |
| 429 reinterpret_cast<unsigned char*>(image->pixels)); |
| 430 bitmap->unlockPixels(); |
| 431 } |
| 432 |
| 433 return image; |
| 434 } |
414 #endif | 435 #endif |
415 | 436 |
416 XID GetX11RootWindow() { | 437 XID GetX11RootWindow() { |
417 return DefaultRootWindow(GetXDisplay()); | 438 return DefaultRootWindow(GetXDisplay()); |
418 } | 439 } |
419 | 440 |
420 bool GetCurrentDesktop(int* desktop) { | 441 bool GetCurrentDesktop(int* desktop) { |
421 return GetIntProperty(GetX11RootWindow(), "_NET_CURRENT_DESKTOP", desktop); | 442 return GetIntProperty(GetX11RootWindow(), "_NET_CURRENT_DESKTOP", desktop); |
422 } | 443 } |
423 | 444 |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 << "request_code " << static_cast<int>(error_event.request_code) << ", " | 1247 << "request_code " << static_cast<int>(error_event.request_code) << ", " |
1227 << "minor_code " << static_cast<int>(error_event.minor_code) | 1248 << "minor_code " << static_cast<int>(error_event.minor_code) |
1228 << " (" << request_str << ")"; | 1249 << " (" << request_str << ")"; |
1229 } | 1250 } |
1230 | 1251 |
1231 // ---------------------------------------------------------------------------- | 1252 // ---------------------------------------------------------------------------- |
1232 // End of x11_util_internal.h | 1253 // End of x11_util_internal.h |
1233 | 1254 |
1234 | 1255 |
1235 } // namespace ui | 1256 } // namespace ui |
OLD | NEW |