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 16 matching lines...) Expand all Loading... |
27 #include "base/memory/scoped_ptr.h" | 27 #include "base/memory/scoped_ptr.h" |
28 #include "base/memory/singleton.h" | 28 #include "base/memory/singleton.h" |
29 #include "base/message_loop.h" | 29 #include "base/message_loop.h" |
30 #include "base/string_number_conversions.h" | 30 #include "base/string_number_conversions.h" |
31 #include "base/string_util.h" | 31 #include "base/string_util.h" |
32 #include "base/stringprintf.h" | 32 #include "base/stringprintf.h" |
33 #include "base/sys_byteorder.h" | 33 #include "base/sys_byteorder.h" |
34 #include "base/threading/thread.h" | 34 #include "base/threading/thread.h" |
35 #include "ui/base/keycodes/keyboard_code_conversion_x.h" | 35 #include "ui/base/keycodes/keyboard_code_conversion_x.h" |
36 #include "ui/base/x/x11_util_internal.h" | 36 #include "ui/base/x/x11_util_internal.h" |
| 37 #include "ui/gfx/point_conversions.h" |
37 #include "ui/gfx/rect.h" | 38 #include "ui/gfx/rect.h" |
38 #include "ui/gfx/size.h" | 39 #include "ui/gfx/size.h" |
39 | 40 |
40 #if defined(OS_FREEBSD) | 41 #if defined(OS_FREEBSD) |
41 #include <sys/sysctl.h> | 42 #include <sys/sysctl.h> |
42 #include <sys/types.h> | 43 #include <sys/types.h> |
43 #endif | 44 #endif |
44 | 45 |
45 #if defined(USE_AURA) | 46 #if defined(USE_AURA) |
46 #include <X11/Xcursor/Xcursor.h> | 47 #include <X11/Xcursor/Xcursor.h> |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 float scale = 1.f; | 466 float scale = 1.f; |
466 if (cursor_image->width() > cursor_image->height()) | 467 if (cursor_image->width() > cursor_image->height()) |
467 scale = kMaxPixel / cursor_image->width(); | 468 scale = kMaxPixel / cursor_image->width(); |
468 else | 469 else |
469 scale = kMaxPixel / cursor_image->height(); | 470 scale = kMaxPixel / cursor_image->height(); |
470 | 471 |
471 scaled = skia::ImageOperations::Resize(*cursor_image, | 472 scaled = skia::ImageOperations::Resize(*cursor_image, |
472 skia::ImageOperations::RESIZE_BETTER, | 473 skia::ImageOperations::RESIZE_BETTER, |
473 static_cast<int>(cursor_image->width() * scale), | 474 static_cast<int>(cursor_image->width() * scale), |
474 static_cast<int>(cursor_image->height() * scale)); | 475 static_cast<int>(cursor_image->height() * scale)); |
475 hotspot_point = hotspot.Scale(scale); | 476 hotspot_point = gfx::ToFlooredPoint(hotspot.Scale(scale)); |
476 needs_scale = true; | 477 needs_scale = true; |
477 } | 478 } |
478 | 479 |
479 const SkBitmap* bitmap = needs_scale ? &scaled : cursor_image; | 480 const SkBitmap* bitmap = needs_scale ? &scaled : cursor_image; |
480 XcursorImage* image = XcursorImageCreate(bitmap->width(), bitmap->height()); | 481 XcursorImage* image = XcursorImageCreate(bitmap->width(), bitmap->height()); |
481 image->xhot = hotspot_point.x(); | 482 image->xhot = hotspot_point.x(); |
482 image->yhot = hotspot_point.y(); | 483 image->yhot = hotspot_point.y(); |
483 | 484 |
484 if (bitmap->width() && bitmap->height()) { | 485 if (bitmap->width() && bitmap->height()) { |
485 bitmap->lockPixels(); | 486 bitmap->lockPixels(); |
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 << "request_code " << static_cast<int>(error_event.request_code) << ", " | 1624 << "request_code " << static_cast<int>(error_event.request_code) << ", " |
1624 << "minor_code " << static_cast<int>(error_event.minor_code) | 1625 << "minor_code " << static_cast<int>(error_event.minor_code) |
1625 << " (" << request_str << ")"; | 1626 << " (" << request_str << ")"; |
1626 } | 1627 } |
1627 | 1628 |
1628 // ---------------------------------------------------------------------------- | 1629 // ---------------------------------------------------------------------------- |
1629 // End of x11_util_internal.h | 1630 // End of x11_util_internal.h |
1630 | 1631 |
1631 | 1632 |
1632 } // namespace ui | 1633 } // namespace ui |
OLD | NEW |