Skip to content

Implement macOS cursor setting and hiding support#280

Open
SpruceCloud wants to merge 1 commit into
RustAudio:masterfrom
SpruceCloud:mouse-cursor
Open

Implement macOS cursor setting and hiding support#280
SpruceCloud wants to merge 1 commit into
RustAudio:masterfrom
SpruceCloud:mouse-cursor

Conversation

@SpruceCloud

Copy link
Copy Markdown

As mentioned in #211 , merging the mouse changes as a separate commit.

Took a bit longer, but now I am focused on finishing the changes.

@prokopyl prokopyl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, and thanks for this PR!

The main issue I have is that you should use the safe APIs provided by objc2, instead of using the error-prone and unsafe msg_send! macro.

Other than that, this looks pretty good to me!

self.state.closed.set(true);
if self.state.cursor_hidden.get() {
unsafe {
let _: () = objc2::msg_send![objc2_app_kit::NSCursor::class(), unhide];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use NSCursor::unhide directly, instead of using a raw, unsafe msg_send call

unsafe {
if let Some(loaded_cursor) = native_cursor.load() {
if self.inner.state.cursor_hidden.get() {
let _: () = objc2::msg_send![objc2_app_kit::NSCursor::class(), unhide];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, this should use the safe APIs instead of msg_send here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants