| 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" | |
| 42 #endif | 40 #endif |
| 43 | 41 |
| 44 #if defined(TOOLKIT_GTK) | 42 #if defined(TOOLKIT_GTK) |
| 45 #include <gdk/gdk.h> | 43 #include <gdk/gdk.h> |
| 46 #include <gdk/gdkx.h> | 44 #include <gdk/gdkx.h> |
| 47 #include <gtk/gtk.h> | 45 #include <gtk/gtk.h> |
| 48 #include "ui/base/gtk/gdk_x_compat.h" | 46 #include "ui/base/gtk/gdk_x_compat.h" |
| 49 #include "ui/base/gtk/gtk_compat.h" | 47 #include "ui/base/gtk/gtk_compat.h" |
| 50 #else | 48 #else |
| 51 // TODO(sad): Use the new way of handling X errors when | 49 // TODO(sad): Use the new way of handling X errors when |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 return XCustomCursorCache::GetInstance()->InstallCustomCursor(image); | 404 return XCustomCursorCache::GetInstance()->InstallCustomCursor(image); |
| 407 } | 405 } |
| 408 | 406 |
| 409 void RefCustomXCursor(::Cursor cursor) { | 407 void RefCustomXCursor(::Cursor cursor) { |
| 410 XCustomCursorCache::GetInstance()->Ref(cursor); | 408 XCustomCursorCache::GetInstance()->Ref(cursor); |
| 411 } | 409 } |
| 412 | 410 |
| 413 void UnrefCustomXCursor(::Cursor cursor) { | 411 void UnrefCustomXCursor(::Cursor cursor) { |
| 414 XCustomCursorCache::GetInstance()->Unref(cursor); | 412 XCustomCursorCache::GetInstance()->Unref(cursor); |
| 415 } | 413 } |
| 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 } | |
| 435 #endif | 414 #endif |
| 436 | 415 |
| 437 XID GetX11RootWindow() { | 416 XID GetX11RootWindow() { |
| 438 return DefaultRootWindow(GetXDisplay()); | 417 return DefaultRootWindow(GetXDisplay()); |
| 439 } | 418 } |
| 440 | 419 |
| 441 bool GetCurrentDesktop(int* desktop) { | 420 bool GetCurrentDesktop(int* desktop) { |
| 442 return GetIntProperty(GetX11RootWindow(), "_NET_CURRENT_DESKTOP", desktop); | 421 return GetIntProperty(GetX11RootWindow(), "_NET_CURRENT_DESKTOP", desktop); |
| 443 } | 422 } |
| 444 | 423 |
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 << "request_code " << static_cast<int>(error_event.request_code) << ", " | 1226 << "request_code " << static_cast<int>(error_event.request_code) << ", " |
| 1248 << "minor_code " << static_cast<int>(error_event.minor_code) | 1227 << "minor_code " << static_cast<int>(error_event.minor_code) |
| 1249 << " (" << request_str << ")"; | 1228 << " (" << request_str << ")"; |
| 1250 } | 1229 } |
| 1251 | 1230 |
| 1252 // ---------------------------------------------------------------------------- | 1231 // ---------------------------------------------------------------------------- |
| 1253 // End of x11_util_internal.h | 1232 // End of x11_util_internal.h |
| 1254 | 1233 |
| 1255 | 1234 |
| 1256 } // namespace ui | 1235 } // namespace ui |
| OLD | NEW |