2020-10-28 17:30:54 +01:00
|
|
|
// Copyright 2020 The Chromium Embedded Framework Authors. All rights reserved.
|
2015-11-17 19:20:13 +01:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2020-10-28 17:30:54 +01:00
|
|
|
#include "libcef/browser/native/cursor_util.h"
|
2015-11-17 19:20:13 +01:00
|
|
|
|
2020-10-08 21:54:42 +02:00
|
|
|
#include "ui/base/cursor/cursor_factory.h"
|
2015-11-17 19:20:13 +01:00
|
|
|
|
2019-04-23 19:00:14 +02:00
|
|
|
#if defined(USE_X11)
|
2020-10-08 21:54:42 +02:00
|
|
|
#include "ui/base/x/x11_cursor.h"
|
2021-06-04 03:34:56 +02:00
|
|
|
#elif defined(USE_OZONE)
|
|
|
|
#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
|
2020-10-08 21:54:42 +02:00
|
|
|
#endif
|
2015-11-17 19:20:13 +01:00
|
|
|
|
2020-10-28 17:30:54 +01:00
|
|
|
namespace cursor_util {
|
|
|
|
|
|
|
|
cef_cursor_handle_t GetPlatformCursor(ui::mojom::CursorType type) {
|
2020-10-08 21:54:42 +02:00
|
|
|
auto cursor = ui::CursorFactory::GetInstance()->GetDefaultCursor(type);
|
|
|
|
if (cursor) {
|
2021-04-21 00:52:34 +02:00
|
|
|
return ToCursorHandle(cursor);
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-06-04 03:34:56 +02:00
|
|
|
cef_cursor_handle_t ToCursorHandle(scoped_refptr<ui::PlatformCursor> cursor) {
|
2019-04-23 19:00:14 +02:00
|
|
|
#if defined(USE_X11)
|
2020-10-08 21:54:42 +02:00
|
|
|
// See https://crbug.com/1029142 for background.
|
2020-10-28 17:30:54 +01:00
|
|
|
return static_cast<cef_cursor_handle_t>(
|
2021-06-04 03:34:56 +02:00
|
|
|
ui::X11Cursor::FromPlatformCursor(cursor)->xcursor());
|
|
|
|
#elif defined(USE_OZONE)
|
|
|
|
return static_cast<cef_cursor_handle_t>(
|
|
|
|
ui::BitmapCursorOzone::FromPlatformCursor(cursor)->platform_data());
|
2020-10-08 21:54:42 +02:00
|
|
|
#else
|
2021-06-04 03:34:56 +02:00
|
|
|
return 0;
|
2020-10-08 21:54:42 +02:00
|
|
|
#endif
|
2015-11-17 19:20:13 +01:00
|
|
|
}
|
2020-10-28 17:30:54 +01:00
|
|
|
|
|
|
|
} // namespace cursor_util
|