Restore equality for all kinds of Point/Rectangle #1952
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The MonitorAwarePoint and MonitorAwareRectangle classes have been introduced as specializations of the existing Point and Rectangle classes solely to support monitor-specific scaling and only used in the context of that feature. They are not supposed to be used outside of SWT but just an internal construct. However, instances of those classes reach consumers of SWT API, e.g., via the Shell class. This broke equality assumptions for consumers, as, e.g., a comparison between a Point and a MonitorAwarePoint (returned by methods of Shell) are never equal, even though the consumers is not supposed to even know that a MonitorAwarePoint can be returned here.
To restore equality, this change aligns equality of the monitor-aware implementations of point and rectangle with their original implementations. In consequence, a Point and a MonitorAwarePoint will be considered equal if their x/y coordinates match. The monitor stored in a MonitorAwarePoint will be ignored. This analogously applies to MonitorAwareRectangle. Since those classes are only used internally, no one may rely on any other kind of equality specification for the monitor-aware implementations of point and rectangle, but existing equality for Points and Rectangles in general is restored.
Note:
MonitorAwarePoint/MonitorAwareRectangleare not part of public API and are currently only used when monitor-specific scaling on Windows is active, which is marked as an experimental feature. This is why no one currently relies on specific equality handling of those added types, allowing to correct their equality relation.See also #1711 (comment) and other comments in that PR.