2023-01-30 18:43:54 +01:00
|
|
|
// Copyright 2023 The Chromium Embedded Framework Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be found
|
|
|
|
// in the LICENSE file.
|
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/libcef/browser/native/cursor_util.h"
|
2023-01-30 18:43:54 +01:00
|
|
|
|
2024-04-30 17:45:07 +02:00
|
|
|
#include "cef/include/internal/cef_types_mac.h"
|
2023-01-30 18:43:54 +01:00
|
|
|
#import "ui/base/cocoa/cursor_utils.h"
|
|
|
|
|
|
|
|
namespace cursor_util {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
class ScopedCursorHandleImpl : public ScopedCursorHandle {
|
|
|
|
public:
|
|
|
|
explicit ScopedCursorHandleImpl(NSCursor* native_cursor) {
|
|
|
|
if (native_cursor) {
|
2023-05-05 13:17:14 +02:00
|
|
|
cursor_ = native_cursor;
|
2023-01-30 18:43:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-05 13:17:14 +02:00
|
|
|
cef_cursor_handle_t GetCursorHandle() override {
|
|
|
|
return CAST_NSCURSOR_TO_CEF_CURSOR_HANDLE(cursor_);
|
|
|
|
}
|
2023-01-30 18:43:54 +01:00
|
|
|
|
|
|
|
private:
|
2023-05-05 13:17:14 +02:00
|
|
|
NSCursor* __strong cursor_;
|
2023-01-30 18:43:54 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
// static
|
|
|
|
std::unique_ptr<ScopedCursorHandle> ScopedCursorHandle::Create(
|
|
|
|
CefRefPtr<CefBrowser> /*browser*/,
|
|
|
|
const ui::Cursor& ui_cursor) {
|
|
|
|
return std::make_unique<ScopedCursorHandleImpl>(
|
|
|
|
ui::GetNativeCursor(ui_cursor));
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace cursor_util
|