• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Chromium Embedded Framework Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "libcef/browser/native/cursor_util.h"
6 
7 #include "ui/base/cursor/cursor_factory.h"
8 
9 #if defined(USE_X11)
10 #include "ui/base/x/x11_cursor.h"
11 #endif
12 
13 namespace cursor_util {
14 
GetPlatformCursor(ui::mojom::CursorType type)15 cef_cursor_handle_t GetPlatformCursor(ui::mojom::CursorType type) {
16   auto cursor = ui::CursorFactory::GetInstance()->GetDefaultCursor(type);
17   if (cursor) {
18     return ToCursorHandle(cursor);
19   }
20   return 0;
21 }
22 
ToCursorHandle(ui::PlatformCursor cursor)23 cef_cursor_handle_t ToCursorHandle(ui::PlatformCursor cursor) {
24 #if defined(USE_X11)
25   // See https://crbug.com/1029142 for background.
26   return static_cast<cef_cursor_handle_t>(
27       static_cast<ui::X11Cursor*>(cursor)->xcursor());
28 #else
29   return cursor;
30 #endif
31 }
32 
33 }  // namespace cursor_util
34