Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 268235 - [MouseEvents] Wrong mouse x,y coordinates
Summary: [MouseEvents] Wrong mouse x,y coordinates
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 1.2 M7   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-11 18:12 EDT by Ivan Furnadjiev CLA
Modified: 2009-04-08 16:06 EDT (History)
0 users

See Also:


Attachments
Proposed patch (19.70 KB, patch)
2009-03-13 20:08 EDT, Ivan Furnadjiev CLA
no flags Details | Diff
Updated patch. (24.47 KB, patch)
2009-03-27 05:19 EDT, Ivan Furnadjiev CLA
no flags Details | Diff
Updated patch. (24.97 KB, patch)
2009-04-06 04:12 EDT, Ivan Furnadjiev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Furnadjiev CLA 2009-03-11 18:12:11 EDT
To reproduce it with the Control Demo -> ButtonTab add mouse listener to the push button:
---- line 77 ----
pushButton.addMouseListener( new MouseAdapter() {
  public void mouseDown( final MouseEvent e ) {
    log( "SWT.MouseDown event: " + e );
  }
  public void mouseUp( final MouseEvent e ) {
    log( "SWT.MouseUp event: " + e );
  }
} );
----------
Try to click on the top left corner of the push button. The MouseEvent (x, y) are (2, 2) instead of (0, 0). This is related to number of parents border that are set. In the current example we have 1px border of the shell and 1px border of the CTabFolder. And the mouse coordinates are shifted with 2 pixels. In more complex layouts (more parents borders set), this offset become significant.
Comment 1 Ivan Furnadjiev CLA 2009-03-13 20:08:57 EDT
Created attachment 128809 [details]
Proposed patch

This patch do the folowing:
1. Display#map - add border width to bounds.x and bounds.y for both from and to controls.
2. Fix the JUnit tests and added a new one in Display_Test. Now all the tests related to Display#map method are tested and running succefully both in RAP and SWT.
3. Fix the MouseEvent tests when the mouse coordinates are checked. Add a new one for testing that no mouse event is fired when you click on the control border.
4. In ControlLCAUtil#processMouseEvents prevent fireing of mouse event if the coordinates after the mapping are negative (we have a negative coordinates when you click on the border). In SWT the MouseEvents are not fired when you click on the border too.
Comment 2 Ivan Furnadjiev CLA 2009-03-27 05:19:18 EDT
Created attachment 130072 [details]
Updated patch.

In addition the shell mouse events are fixed - only client area process mouse events. The shell mouse event with x,y (0,0) is the client area (0,0).
Comment 3 Ivan Furnadjiev CLA 2009-04-06 04:12:16 EDT
Created attachment 130963 [details]
Updated patch.

Display#map now checks for Scrollable and substract the trimming too.
Comment 4 Ivan Furnadjiev CLA 2009-04-07 06:08:37 EDT
Fixed in CVS HEAD.
Comment 5 Ivan Furnadjiev CLA 2009-04-08 04:36:42 EDT
We found some side effects in the workbench. Changes are reverted.
Comment 6 Rüdiger Herrmann CLA 2009-04-08 07:00:19 EDT
Maybe bug 232967(PerspectiveSwitcher's dropdown menu is misaligned) depends on this issue. Ivan, could you have a look, once this bug is resolved?
Comment 7 Ivan Furnadjiev CLA 2009-04-08 16:03:17 EDT
Two problems related to CTabFolder are fixed:
1. CTabFolder#getBorderWidth() always returns 0 despite of SWT.BORDER style flag (same in SWT).
2. CTabFolder tabs area is "active" - process mouse events. It is possible to map a point from/to "tabs" area.
Comment 8 Ivan Furnadjiev CLA 2009-04-08 16:06:48 EDT
(In reply to comment #6)
> Maybe bug 232967(PerspectiveSwitcher's dropdown menu is misaligned) depends on
> this issue. Ivan, could you have a look, once this bug is resolved?
No... bug 232967 does not depend on this issue.