eclipse.platform.swt icon indicating copy to clipboard operation
eclipse.platform.swt copied to clipboard

Guard monitor.zoom with isRescalingAtRuntime flag

Open amartya4256 opened this issue 1 year ago • 1 comments

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.

amartya4256 avatar Oct 07 '24 13:10 amartya4256

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.

github-actions[bot] avatar Oct 07 '24 13:10 github-actions[bot]

@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:

  1. No visual differences
  2. 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?

fedejeanne avatar Oct 11 '24 13:10 fedejeanne

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.

HeikoKlare avatar Oct 11 '24 14:10 HeikoKlare

Did you use monitors with different zoom values?

Yes: 100% on the left and 200% on the right.

fedejeanne avatar Oct 14 '24 05:10 fedejeanne

Reported API issues on Jenkins are incorrect / not related to this PR. An only reference build (759) is taken: {D8E536B3-2411-4E2C-B606-68E18E8F8E22}

The current master build (762) has the same issues as this PR: https://ci.eclipse.org/releng/job/eclipse.platform.swt/job/master/762/ {CA2BF2AC-85D0-4B7E-A896-DA7DCD6547C4}

HeikoKlare avatar Oct 14 '24 19:10 HeikoKlare