Skip to content
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

Translate points in display coordinate space gap #1524

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amartya4256
Copy link
Contributor

This contribution fixes the current behaviour of the display coordinate system of eclipse where a point can be manually set to somewhere in the gap between the 2 monitor in the coordinate space (in the points system). This fix translates those points to inside the scaled down space of a monitor providing it the right coordinates in the display coordinate space.
e.g.:
image

If the client sets a shell's location like:

Point p = shell.getLocation();
p.x -= 20;
shell.setLocation(p);

It would be trasnlated to the proper display coordinate space so that it's scaled in the right way.

contributes to #62 and #127

Copy link
Contributor

github-actions bot commented Oct 9, 2024

Test Results

   486 files  ±0     486 suites  ±0   6m 40s ⏱️ - 1m 18s
 4 154 tests ±0   4 146 ✅ ±0   8 💤 ±0  0 ❌ ±0 
16 370 runs  ±0  16 278 ✅ ±0  92 💤 ±0  0 ❌ ±0 

Results for commit 8a157cb. ± Comparison against base commit 209d75a.

♻️ This comment has been updated with latest results.

@@ -1586,7 +1586,8 @@ public void setLocation(Point location) {

@Override
public void setLocation(int x, int y) {
Point location = display.translateLocationInPixelsInDisplayCoordinateSystem(x, y);
Point translatedPoint = display.translatePointIfInDisplayCoordinateGap(x, y);
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this something that should be hidden in the Display class, i.e., performed implicitly when calling translateLocationInPixelsInDisplayCoordinateSystem? Otherwise consumers of the display coordinate system need to know about this potential gap and handle it manually instead of having the display class guarantee the calculation of valid coordinates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah makes sense. I have moved it inside and also added the translation to a all the places (like map) where it was relevant.

Comment on lines 5379 to 5467
private Monitor getContainingMonitor(int x, int y) {
return getContainingMonitorOptional(x, y).orElse(getPrimaryMonitor());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

getContainingMonitorOptional() is not that self explaining and the distinction to getContainingMonitor() is not that clear, as both sound similar (except for the "optional") but have different semants: the latter will never return null (or empty) but return the primary monitor instead.
So maybe better call these methods getContainingMonitor (returning Optional<Monitor>) and getContainingOrPrimaryMonitor() or the like?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright I have renamed them. Also for while searching in pixels

This contribution fixes the current behaviour of the display coordinate
system of eclipse where a point can be manually set to somewhere in the
gap between the 2 monitor in the coordinate space (in the points
system). This fix translates those points to inside the scaled down
space of a monitor providing it the right coordinates in the display
coordinate space.

contributes to eclipse-platform#62 and eclipse-platform#127
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