Guard monitor.zoom with isRescalingAtRuntime flag
This contribution protects the unintended usage of different zoom levels of different monitors in trasnlating the points and rectangles from control to display coordinate system when the isRescalingAtRuntime flag is disabled.
contributes to #62 and #127
###How To Test
- Disable rescaling
- Create a snippet where you can programatically move a shell to a different monitor with a different zoom level after opening it. eg:
Display display = new Display();
Shell shell = new Shell(display);
shell.open();
TimeUnit.SECONDS.sleep(3);
Point location = display.getCursorLocation();
location.x -= 600;
shell.setLocation(location);
- The movement should be expected relative to the zoom level of the IDE and not with the zoom level of the monitor.
Test Results
486 files ±0 486 suites ±0 7m 24s :stopwatch: -14s 4 154 tests ±0 4 146 :white_check_mark: ±0 8 :zzz: ±0 0 :x: ±0 16 370 runs ±0 16 278 :white_check_mark: ±0 92 :zzz: ±0 0 :x: ±0
Results for commit d491442c. ± Comparison against base commit 8fe0fb0f.
:recycle: This comment has been updated with latest results.
@amartya4256 it's not clear to me what the error was (i.e. what does this PR fix?).
I tested with this snippet:
/*******************************************************************************
* Copyright (c) 2024 Yatta Solutions
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Yatta Solutions - initial API and implementation
*******************************************************************************/
package org.eclipse.swt.snippets;
import java.util.concurrent.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
public class Snippet384 {
public static void main(String[] args) throws InterruptedException {
Display display = new Display();
// Open a shell where the mouse currently is
Shell shell = new Shell(display);
shell.setSize(100, 50);
shell.setLocation(180, 220);
shell.open();
// Move slowly to the left
for (int i = 0; i < 15; i++) {
TimeUnit.SECONDS.sleep(1);
Point location = shell.getLocation();
location.x -= 20; // to the left
System.out.println("Moving to position: (" + location.x + ", " + location.y + ")");
shell.setLocation(location);
}
display.dispose();
}
}
Both without any VM-arguments and also with -Dswt.autoScale.updateOnRuntime=false
The result before and after this PR what the same:
- No visual differences
- Console output was:
Moving to position: (160, 220)
Moving to position: (140, 220)
Moving to position: (120, 220)
Moving to position: (100, 220)
Moving to position: (80, 220)
Moving to position: (-1753, 220)
Moving to position: (-1773, 220)
Moving to position: (-1793, 220)
Moving to position: (-1813, 220)
Moving to position: (-1833, 220)
Moving to position: (-1853, 220)
Moving to position: (-1873, 220)
Moving to position: (-1893, 220)
Moving to position: (-1913, 220)
Moving to position: (-1933, 220)
Am I testing this wrong?
Could you please add more details to the description of this PR?
I tested with this snippet:
Did you use monitors with different zoom values? From my understanding the issue only occurs in such a setup. But an extended description of the actualy issue and how to reproduce it would be helpful.
In addition, the issue sounds as if it could be covered with a proper regression test rather easily, can't it? Providing one would be the best way of documenting the issue and for preventing regressions.
Did you use monitors with different zoom values?
Yes: 100% on the left and 200% on the right.
Reported API issues on Jenkins are incorrect / not related to this PR. An only reference build (759) is taken:
The current master build (762) has the same issues as this PR: https://ci.eclipse.org/releng/job/eclipse.platform.swt/job/master/762/