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 #include "ui/ozone/buildflags.h" 9 10 #if BUILDFLAG(OZONE_PLATFORM_X11) 11 #include "ui/base/x/x11_cursor.h" 12 #elif defined(USE_OZONE) 13 #include "ui/ozone/common/bitmap_cursor.h" 14 #endif 15 16 namespace cursor_util { 17 GetPlatformCursor(ui::mojom::CursorType type)18cef_cursor_handle_t GetPlatformCursor(ui::mojom::CursorType type) { 19 auto cursor = ui::CursorFactory::GetInstance()->GetDefaultCursor(type); 20 if (cursor) { 21 return ToCursorHandle(cursor); 22 } 23 return 0; 24 } 25 ToCursorHandle(scoped_refptr<ui::PlatformCursor> cursor)26cef_cursor_handle_t ToCursorHandle(scoped_refptr<ui::PlatformCursor> cursor) { 27 #if BUILDFLAG(OZONE_PLATFORM_X11) 28 // See https://crbug.com/1029142 for background. 29 return static_cast<cef_cursor_handle_t>( 30 ui::X11Cursor::FromPlatformCursor(cursor)->xcursor()); 31 #elif defined(USE_OZONE) 32 return static_cast<cef_cursor_handle_t>( 33 ui::BitmapCursor::FromPlatformCursor(cursor)->platform_data()); 34 #else 35 return 0; 36 #endif 37 } 38 39 } // namespace cursor_util 40