Bug 522349 - [macOS] Use system cursor for SWT.CURSOR_WAIT
Summary: [macOS] Use system cursor for SWT.CURSOR_WAIT
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.7   Edit
Hardware: PC Mac OS X
: P3 enhancement (vote)
Target Milestone: 4.8 M3   Edit
Assignee: Karsten Thoms CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy, usability
Depends on:
Blocks:
 
Reported: 2017-09-15 05:18 EDT by Karsten Thoms CLA
Modified: 2017-10-18 02:30 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Karsten Thoms CLA 2017-09-15 05:18:03 EDT
For CURSOR_WAIT and CURSOR_IBEAM SWT/Cocoa does not use the system's cursor, but a custom hard-coded image in org.eclipse.swt.graphics.Cursor.

These cursors should also use the platform cursors, defined by the selectors 'busyButClickableCursor' and 'IBeamCursor'.

The waiting cursor on macOS is animated and blue, while the current one is an ugly black/white filled circle.
Comment 1 Eclipse Genie CLA 2017-09-15 05:20:21 EDT
New Gerrit change created: https://git.eclipse.org/r/105187
Comment 2 Lakshmi P Shanmugam CLA 2017-09-18 05:12:10 EDT
Thanks for the patch.
SWT doesn't use the NSCursor.IBeamCursor() because it's almost invisible on a black background. It uses a custom Shadowed IBeam cursor to fix this. Please see Bug 358022 for more details.

Regarding busyButClickableCursor, it works well. But, it is not there anywhere in the Apple reference for NSCursor?
Comment 3 Karsten Thoms CLA 2017-09-18 06:50:22 EDT
Ah, I see. I do not use the dark theme, so I was not aware of that requirement. I will change the patch to just use the waiting cursor and leave IBeam as is.

I found a reference to the 'busyButClickableCursor' selector in this code:
https://opensource.apple.com/source/tcl/tcl-95/tk/tk/macosx/tkMacOSXCursor.c

I came to that while searching for a 'wait cursor selector'.
Comment 4 Lakshmi P Shanmugam CLA 2017-09-18 08:48:14 EDT
(In reply to Karsten Thoms from comment #3)
> I found a reference to the 'busyButClickableCursor' selector in this code:
> https://opensource.apple.com/source/tcl/tcl-95/tk/tk/macosx/tkMacOSXCursor.c
> 
> I came to that while searching for a 'wait cursor selector'.
Since it's not part of the NSCursor API & not documented, how safe is it to use the selector?

Comments on the patch:

The methods in NSCursor.java and the selectors in OS.java are auto-generated by MacGenerator[1] tool (content comes from the *.bridgesupport files in the project). Any other non-generated content will be overwritten by the tool.

To include new methods from a Cocoa Class we use the MacGenerator. But, in this case, the method is not part of the API for NSCursor and hence it can't be selected via the tool. You can move the selector from the autogenerated section to editable section of OS.java and call OS.objc_msgSend directly from Cursor class.

Since the selector is undocumented, I suggest we add a respondsToSelector() check before calling the selector and use the old code as fallback if it returns false.

[1]https://www.eclipse.org/swt/macgen.php
Comment 5 Karsten Thoms CLA 2017-09-18 09:26:24 EDT
Thanks for your pointers. I'm not sure how safe it is, maybe I should try to have a fallback for the case that the selector is unknown. I will consider your recommendations and provide an update.
Comment 6 Karsten Thoms CLA 2017-09-18 18:52:33 EDT
Updated the patch. When NSCursor does not respond to the 'busyButClickableCursor', OS.busyButClickableCursor() will return null and Cursor.java will fall back to its old cursor. Tried this by making a typo in the selector name.
Comment 8 Lakshmi P Shanmugam CLA 2017-09-25 05:35:52 EDT
(In reply to Eclipse Genie from comment #7)
> Gerrit change https://git.eclipse.org/r/105187 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=00720b46e1bebb3f6d678aaeece1a01bc020b17f
> 

Thanks for the patch, Karsten!
Comment 9 Eclipse Genie CLA 2017-09-26 21:42:08 EDT
New Gerrit change created: https://git.eclipse.org/r/105814
Comment 11 Lakshmi P Shanmugam CLA 2017-10-18 02:30:02 EDT
Verified with Build I20171016-2000