| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 ~XCursorCache() { | 112 ~XCursorCache() { |
| 113 Clear(); | 113 Clear(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 ::Cursor GetCursor(int cursor_shape) { | 116 ::Cursor GetCursor(int cursor_shape) { |
| 117 // Lookup cursor by attempting to insert a null value, which avoids | 117 // Lookup cursor by attempting to insert a null value, which avoids |
| 118 // a second pass through the map after a cache miss. | 118 // a second pass through the map after a cache miss. |
| 119 std::pair<std::map<int, ::Cursor>::iterator, bool> it = cache_.insert( | 119 std::pair<std::map<int, ::Cursor>::iterator, bool> it = cache_.insert( |
| 120 std::make_pair(cursor_shape, 0)); | 120 std::make_pair(cursor_shape, 0)); |
| 121 if (it.second) { | 121 if (it.second) { |
| 122 XDisplay* display = base::MessagePumpForUI::GetDefaultXDisplay(); | 122 XDisplay* display = gfx::GetXDisplay(); |
| 123 it.first->second = XCreateFontCursor(display, cursor_shape); | 123 it.first->second = XCreateFontCursor(display, cursor_shape); |
| 124 } | 124 } |
| 125 return it.first->second; | 125 return it.first->second; |
| 126 } | 126 } |
| 127 | 127 |
| 128 void Clear() { | 128 void Clear() { |
| 129 XDisplay* display = base::MessagePumpForUI::GetDefaultXDisplay(); | 129 XDisplay* display = gfx::GetXDisplay(); |
| 130 for (std::map<int, ::Cursor>::iterator it = | 130 for (std::map<int, ::Cursor>::iterator it = |
| 131 cache_.begin(); it != cache_.end(); ++it) { | 131 cache_.begin(); it != cache_.end(); ++it) { |
| 132 XFreeCursor(display, it->second); | 132 XFreeCursor(display, it->second); |
| 133 } | 133 } |
| 134 cache_.clear(); | 134 cache_.clear(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 private: | 137 private: |
| 138 // Maps X11 font cursor shapes to Cursor IDs. | 138 // Maps X11 font cursor shapes to Cursor IDs. |
| 139 std::map<int, ::Cursor> cache_; | 139 std::map<int, ::Cursor> cache_; |
| (...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1352 << "request_code " << static_cast<int>(error_event.request_code) << ", " | 1352 << "request_code " << static_cast<int>(error_event.request_code) << ", " |
| 1353 << "minor_code " << static_cast<int>(error_event.minor_code) | 1353 << "minor_code " << static_cast<int>(error_event.minor_code) |
| 1354 << " (" << request_str << ")"; | 1354 << " (" << request_str << ")"; |
| 1355 } | 1355 } |
| 1356 | 1356 |
| 1357 // ---------------------------------------------------------------------------- | 1357 // ---------------------------------------------------------------------------- |
| 1358 // End of x11_util_internal.h | 1358 // End of x11_util_internal.h |
| 1359 | 1359 |
| 1360 | 1360 |
| 1361 } // namespace ui | 1361 } // namespace ui |
| OLD | NEW |