Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 349812

Summary: Rotate gesture not working on 64bit build
Product: [Eclipse Project] Platform Reporter: Lakshmi P Shanmugam <lshanmug>
Component: SWTAssignee: Silenio Quarti <Silenio_Quarti>
Status: VERIFIED FIXED QA Contact: Silenio Quarti <Silenio_Quarti>
Severity: normal    
Priority: P3    
Version: 3.7   
Target Milestone: 3.8 M2   
Hardware: PC   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
test patch none

Description Lakshmi P Shanmugam CLA 2011-06-20 09:01:52 EDT
Cocoa 64 bit build
Version: 3.7.0
Build id: I20110603-0909 


Steps:
1) Run Snippet 353
2) Try the rotate gesture on the trackpad
The gesture is recognized but event.rotation field is always 0.
This works fine on 32 bit build.
Comment 1 Lakshmi P Shanmugam CLA 2011-08-24 09:52:16 EDT
Hi Silenio, 
The problem is that NSEvent.rotation() is not returning the correct value.
public float rotation() {
	return (float)OS.objc_msgSend_fpret(this.id, OS.sel_rotation);
}
The method objc_msgSend_fpret() doesn't return the correct float value only in 64 bit build.

The native code for objc_msgSend_fpret() in os.c uses (jdouble) as the return type in the function pointer. But, since NSEvent rotation() returns float shouldn't we use (jfloat) as the return type in the function pointer?
Also, I'm not sure why this is not a problem on 32 bit build.

In SWT code, we use 2 methods that returns float value --> NSEvent.rotation() and NSNumber.floatValue(). NSNumber.floatValue() too has the same problem, i.e, works on 32 bit but not on 64 bit.
Comment 2 Lakshmi P Shanmugam CLA 2011-08-24 10:00:21 EDT
Created attachment 202087 [details]
test patch

Created this test patch to test if using float instead of double fixes the problem. 
OS.java already has objc_msgSend_fpret(int, int) so I have added objc_msgSend_fpret with float return type with a different method name and defined it in os_custom.c. This works on both 32 & 64 bit.
Comment 3 Silenio Quarti CLA 2011-08-24 15:43:07 EDT
I changed the Mac Generator tool to generate the appropriate code when the return type is float on 64 bit.

Fixed.

http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=2f42a694a040beadb46715d86b45bb678c89d78c
Comment 4 Lakshmi P Shanmugam CLA 2011-09-13 04:58:27 EDT
Verified in I20110912-2126