-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various cursors cannot be displayed on macOS #3724
Comments
Can reproduce on macOS 14.4.1 and a checkout of 3a624e0 --
|
Can reproduce on macOS Sequoia 15.1 on 0.30.5. Is there any hope to see this addressed? I'll be available to help test alternative implementations.
As stated here: https://stackoverflow.com/questions/10733228/native-osx-lion-resize-cursor-for-custom-nswindow-or-nsview/46635398#46635398 WebKit contains images that look exactly the same as the cursors used by the system, maybe we could replace them with custom cursors for the macOS platform? |
The frame resize, column resize, row resize, and zoom cursors became public API in macOS Sequoia (15.0): These are accessible via:
These don't seem to be exposed in Though, strangely enough, trying to access these cursors privately via Swift still works: Digging into this more, winit uses winit/src/platform_impl/apple/appkit/cursor.rs Lines 70 to 76 in e47081e
This invokes the Apple's guidance seems to generally recommend the latter as well:
We can send that message from Rust: use objc2::{msg_send, sel, ClassType};
use objc2_app_kit::*;
fn main() {
let private_cursor_sel = sel!(_windowResizeNorthEastCursor);
println!(
"responds via class_respondsToSelector? {}",
NSCursor::class().responds_to(private_cursor_sel)
);
let responds: bool =
unsafe { msg_send![NSCursor::class(), respondsToSelector: private_cursor_sel] };
println!("responds via -[NSObject respondsToSelector:]? {}", responds);
} Running this code on my system (currently macOS 15.1.1, 24B91) yields:
FWICT, there doesn't seem to be a non- From the relevant section in Apple's documentation archive (there's a relevant StackOverflow question, too):
So, despite This is probably what |
Thanks for the detailed investigation! You are right that we should be using And yeah, they're not exposed in the current version of I'd accept a PR implementing this ;) |
@madsmtm Thanks for the insight. I'm interested in helping! Just to clarify, by "this" do you mean sending diff --git a/src/platform_impl/apple/appkit/cursor.rs b/src/platform_impl/apple/appkit/cursor.rs
index 70a36e11..b8befe11 100644
--- a/src/platform_impl/apple/appkit/cursor.rs
+++ b/src/platform_impl/apple/appkit/cursor.rs
@@ -4,7 +4,7 @@ use std::sync::OnceLock;
use objc2::rc::Retained;
use objc2::runtime::Sel;
-use objc2::{msg_send_id, sel, ClassType};
+use objc2::{msg_send, msg_send_id, sel, ClassType};
use objc2_app_kit::{NSBitmapImageRep, NSCursor, NSDeviceRGBColorSpace, NSImage};
use objc2_foundation::{
ns_string, NSData, NSDictionary, NSNumber, NSObject, NSObjectProtocol, NSPoint, NSSize,
@@ -67,7 +67,7 @@ pub(crate) fn default_cursor() -> Retained<NSCursor> {
unsafe fn try_cursor_from_selector(sel: Sel) -> Option<Retained<NSCursor>> {
let cls = NSCursor::class();
- if cls.responds_to(sel) {
+ if msg_send![cls, respondsToSelector: sel] {
let cursor: Retained<NSCursor> = unsafe { msg_send_id![cls, performSelector: sel] };
Some(cursor)
} else { |
The answer is yes to both ;) |
I've opened #4034 for using the documented cursors |
Description
Running the
window
example and pressing CTRL+C to cycle through the available cursors reveals that not all cursors can be displayed.When a cursor cannot be displayed the following warning is emitted and the cursor reverts to the default cursor.
Here is the log of relevant events from the window example:
macOS version
Winit version
0.30.0
The text was updated successfully, but these errors were encountered: