Skip to content

Commit 966f9d1

Browse files
authored
Merge branch 'eclipse-platform:master' into master
2 parents 23c8c11 + a71bea9 commit 966f9d1

File tree

47 files changed

+1881
-1778
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1881
-1778
lines changed

.github/workflows/maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
runs-on: ${{ matrix.config.os }}
4141
steps:
4242
- name: checkout swt
43-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
43+
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
4444
with:
4545
fetch-depth: 0 # required for jgit timestamp provider to work
4646
lfs: false # lfs-pull is not necessary, the natives are re-build in each run

bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public class Browser extends Composite {
5656
static final String PACKAGE_PREFIX = "org.eclipse.swt.browser."; //$NON-NLS-1$
5757
static final String PROPERTY_DEFAULTTYPE = "org.eclipse.swt.browser.DefaultType"; //$NON-NLS-1$
5858

59+
static final String WEBIEW_UNAVAILABLE_DISABLED = "org.eclipse.swt.browser.DisableWebViewUnavailableDialog"; //$NON-NLS-1$
60+
5961
/**
6062
* Constructs a new instance of this class given its parent
6163
* and a style value describing its behavior and appearance.
@@ -144,7 +146,7 @@ private record DialogOption(int index, String message) {};
144146
private static final DialogOption CANCEL_OPTION = new DialogOption(SWT.CANCEL, "Cancel");
145147

146148
private static final String DIALOG_TITLE = "Default browser engine not available";
147-
private static final String DIALOG_MESSAGE = "Microsoft Edge (WebView2) is not available. Do you want to use the legacy Internet Explorer?\n\nNote: It is necessary to reopen browsers for the change to take effect.";
149+
private static final String DIALOG_MESSAGE = "Microsoft Edge (WebView2) is not available. Do you want to use the legacy Internet Explorer?\n\nNote: It is necessary to reopen browsers for the change to take effect and the effect will be lost at next application start. For information on how to permanently switch to Internet Explorer, press the \"Information\" button.";
148150
private static final String FAQ_URL = "https://github.com/eclipse-platform/eclipse.platform/tree/master/docs/FAQ/FAQ_How_do_I_use_Edge-IE_as_the_Browser's_underlying_renderer.md";
149151

150152
private static final int DIALOG_OPTION_FLAGS = USE_IE_OPTION.index | MORE_INFORMATION_OPTION.index | CANCEL_OPTION.index;
@@ -156,7 +158,8 @@ private record DialogOption(int index, String message) {};
156158
private static boolean shownOnce;
157159

158160
static void showAsync(Shell parentShell) {
159-
if (shownOnce) {
161+
if (shownOnce || Boolean.getBoolean(WEBIEW_UNAVAILABLE_DISABLED)) {
162+
shownOnce = true;
160163
return;
161164
}
162165
shownOnce = true;

bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ void browserDispose(Event event) {
840840
if (inCallback > 0) {
841841
ICoreWebView2Controller controller1 = controller;
842842
controller.put_IsVisible(false);
843-
browser.getDisplay().asyncExec(() -> {
843+
asyncExec(() -> {
844844
controller1.Close();
845845
controller1.Release();
846846
});
@@ -1004,7 +1004,7 @@ private String getExposedUrl(String url) {
10041004
}
10051005

10061006
int handleCloseRequested(long pView, long pArgs) {
1007-
browser.getDisplay().asyncExec(() -> {
1007+
asyncExec(() -> {
10081008
if (browser.isDisposed()) return;
10091009
WindowEvent event = new WindowEvent(browser);
10101010
event.display = browser.getDisplay();
@@ -1022,7 +1022,7 @@ int handleDocumentTitleChanged(long pView, long pArgs) {
10221022
long[] ppsz = new long[1];
10231023
webViewProvider.getWebView(false).get_DocumentTitle(ppsz);
10241024
String title = wstrToString(ppsz[0], true);
1025-
browser.getDisplay().asyncExec(() -> {
1025+
asyncExec(() -> {
10261026
if (browser.isDisposed()) return;
10271027
TitleEvent event = new TitleEvent(browser);
10281028
event.display = browser.getDisplay();
@@ -1152,7 +1152,7 @@ int handleSourceChanged(long pView, long pArgs) {
11521152
} else {
11531153
location = url;
11541154
}
1155-
browser.getDisplay().asyncExec(() -> {
1155+
asyncExec(() -> {
11561156
if (browser.isDisposed()) return;
11571157
LocationEvent event = new LocationEvent(browser);
11581158
event.display = browser.getDisplay();
@@ -1169,7 +1169,7 @@ int handleSourceChanged(long pView, long pArgs) {
11691169
}
11701170

11711171
void sendProgressCompleted() {
1172-
browser.getDisplay().asyncExec(() -> {
1172+
asyncExec(() -> {
11731173
if (browser.isDisposed()) return;
11741174
ProgressEvent event = new ProgressEvent(browser);
11751175
event.display = browser.getDisplay();
@@ -1326,7 +1326,7 @@ int handleNavigationCompleted(long pView, long pArgs, boolean top) {
13261326
int[] pIsSuccess = new int[1];
13271327
args.get_IsSuccess(pIsSuccess);
13281328
if (pIsSuccess[0] != 0) {
1329-
browser.getDisplay().asyncExec(() -> {
1329+
asyncExec(() -> {
13301330
if (browser.isDisposed()) return;
13311331
LocationEvent event = new LocationEvent(browser);
13321332
event.display = browser.getDisplay();
@@ -1426,12 +1426,17 @@ int handleNewWindowRequested(long pView, long pArgs) {
14261426
if (inEvaluate) {
14271427
openWindowHandler.run();
14281428
} else {
1429-
browser.getDisplay().asyncExec(openWindowHandler);
1429+
asyncExec(openWindowHandler);
14301430
}
14311431

14321432
return COM.S_OK;
14331433
}
14341434

1435+
private void asyncExec(Runnable r) {
1436+
if (browser.isDisposed()) return;
1437+
browser.getDisplay().asyncExec(r);
1438+
}
1439+
14351440
int handleGotFocus(long pView, long pArg) {
14361441
if (ignoreGotFocus) {
14371442
ignoreGotFocus = false;

bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void createCOMInterfaces() {
242242
public long method2(long[] args) {return Release();}
243243
@Override
244244
public long method3(long[] args) {
245-
return Win32DPIUtils.runWithProperDPIAwareness(() -> {
245+
return Win32DPIUtils.runWithProperDPIAwareness(getDisplay(), () -> {
246246
if (args.length == 5) {
247247
return DragEnter(args[0], (int)args[1], (int)args[2], (int)args[3], args[4]);
248248
} else {
@@ -252,7 +252,7 @@ public long method3(long[] args) {
252252
}
253253
@Override
254254
public long method4(long[] args) {
255-
return Win32DPIUtils.runWithProperDPIAwareness(() -> {
255+
return Win32DPIUtils.runWithProperDPIAwareness(getDisplay(), () -> {
256256
if (args.length == 4) {
257257
return DragOver((int)args[0], (int)args[1], (int)args[2], args[3]);
258258
} else {
@@ -264,7 +264,7 @@ public long method4(long[] args) {
264264
public long method5(long[] args) {return DragLeave();}
265265
@Override
266266
public long method6(long[] args) {
267-
return Win32DPIUtils.runWithProperDPIAwareness(() -> {
267+
return Win32DPIUtils.runWithProperDPIAwareness(getDisplay(), () -> {
268268
if (args.length == 5) {
269269
return Drop(args[0], (int)args[1], (int)args[2], (int)args[3], args[4]);
270270
} else {

bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/ResetMonitorSpecificScalingExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ protected ResetMonitorSpecificScalingExtension() {
2525

2626
@Override
2727
public void beforeEach(ExtensionContext context) throws Exception {
28-
wasMonitorSpecificScalingActive = DPIUtil.isMonitorSpecificScalingActive();
28+
wasMonitorSpecificScalingActive = Win32DPIUtils.isMonitorSpecificScalingActive();
2929
Display.getDefault().dispose();
3030
}
3131

3232
@Override
3333
public void afterEach(ExtensionContext context) throws Exception {
34-
DPIUtil.setMonitorSpecificScaling(wasMonitorSpecificScalingActive);
34+
Win32DPIUtils.setMonitorSpecificScaling(wasMonitorSpecificScalingActive);
3535
Display.getDefault().dispose();
3636
}
3737

bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/internal/WithMonitorSpecificScalingExtension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private WithMonitorSpecificScalingExtension() {
2424
@Override
2525
public void beforeEach(ExtensionContext context) throws Exception {
2626
super.beforeEach(context);
27-
DPIUtil.setMonitorSpecificScaling(true);
27+
Win32DPIUtils.setMonitorSpecificScaling(true);
2828
}
2929

3030
}

bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/ControlWin32Tests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ControlWin32Tests {
3636

3737
@Test
3838
public void testScaleFontCorrectlyInAutoScaleScenario() {
39-
DPIUtil.setMonitorSpecificScaling(true);
39+
Win32DPIUtils.setMonitorSpecificScaling(true);
4040
Display display = Display.getDefault();
4141

4242
assertTrue("Autoscale property is not set to true", display.isRescalingAtRuntime());
@@ -48,7 +48,7 @@ public void testScaleFontCorrectlyInAutoScaleScenario() {
4848

4949
@Test
5050
public void testSetFontWithMonitorSpecificScalingEnabled() {
51-
DPIUtil.setMonitorSpecificScaling(true);
51+
Win32DPIUtils.setMonitorSpecificScaling(true);
5252
Display display = Display.getDefault();
5353
Image colorImage = new Image(display, 10, 10);
5454
GC gc = new GC(colorImage);
@@ -59,7 +59,7 @@ public void testSetFontWithMonitorSpecificScalingEnabled() {
5959

6060
@Test
6161
public void testScaleFontCorrectlyInNoAutoScaleScenario() {
62-
DPIUtil.setMonitorSpecificScaling(false);
62+
Win32DPIUtils.setMonitorSpecificScaling(false);
6363
Display display = Display.getDefault();
6464

6565
assertFalse("Autoscale property is not set to false", display.isRescalingAtRuntime());
@@ -71,7 +71,7 @@ public void testScaleFontCorrectlyInNoAutoScaleScenario() {
7171

7272
@Test
7373
public void testDoNotScaleFontInNoAutoScaleScenarioWithLegacyFontRegistry() {
74-
DPIUtil.setMonitorSpecificScaling(false);
74+
Win32DPIUtils.setMonitorSpecificScaling(false);
7575
String originalValue = System.getProperty("swt.fontRegistry");
7676
System.setProperty("swt.fontRegistry", "legacy");
7777
try {
@@ -93,7 +93,7 @@ public void testDoNotScaleFontInNoAutoScaleScenarioWithLegacyFontRegistry() {
9393

9494
@Test
9595
public void testCorrectScaleUpUsingDifferentSetBoundsMethod() {
96-
DPIUtil.setMonitorSpecificScaling(true);
96+
Win32DPIUtils.setMonitorSpecificScaling(true);
9797
Display display = Display.getDefault();
9898
Shell shell = new Shell(display);
9999
Button button = new Button(shell, SWT.PUSH);
@@ -114,7 +114,7 @@ public void testCorrectScaleUpUsingDifferentSetBoundsMethod() {
114114
@CsvSource({ "0.5, 100, true", "1.0, 200, true", "2.0, 200, true", "2.0, quarter, true", "0.5, 100, false",
115115
"1.0, 200, false", "2.0, 200, false", "2.0, quarter, false", })
116116
public void testAutoScaleImageData(float scaleFactor, String autoScale, boolean monitorSpecificScaling) {
117-
DPIUtil.setMonitorSpecificScaling(monitorSpecificScaling);
117+
Win32DPIUtils.setMonitorSpecificScaling(monitorSpecificScaling);
118118
DPIUtil.runWithAutoScaleValue(autoScale, () -> {
119119
Display display = new Display();
120120
try {

bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/DisplayWin32Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ class DisplayWin32Test {
1313

1414
@Test
1515
public void monitorSpecificScaling_activate() {
16-
DPIUtil.setMonitorSpecificScaling(true);
16+
Win32DPIUtils.setMonitorSpecificScaling(true);
1717
Display display = Display.getDefault();
1818
assertTrue(display.isRescalingAtRuntime());
1919
assertEquals(OS.DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, OS.GetThreadDpiAwarenessContext());
2020
}
2121

2222
@Test
2323
public void monitorSpecificScaling_deactivate() {
24-
DPIUtil.setMonitorSpecificScaling(false);
24+
Win32DPIUtils.setMonitorSpecificScaling(false);
2525
Display display = Display.getDefault();
2626
assertFalse(display.isRescalingAtRuntime());
2727
}

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Image.java

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,9 @@ public Image(Device device, ImageDataProvider imageDataProvider) {
850850
try {
851851
init (data, 100);
852852
init ();
853+
StrictChecks.runIfStrictChecksEnabled(() -> {
854+
DPIUtil.validateLinearScaling(imageDataProvider);
855+
});
853856
ImageData data2x = imageDataProvider.getImageData (200);
854857
if (data2x != null) {
855858
alphaInfo_200 = new AlphaInfo();
@@ -1822,30 +1825,18 @@ public String toString () {
18221825
* @noreference This method is not intended to be referenced by clients.
18231826
*/
18241827
public static void drawScaled(GC gc, ImageData imageData, int width, int height, float scaleFactor) {
1825-
Image imageToDraw = new Image(gc.device, (ImageDataProvider) zoom -> imageData);
1826-
gc.drawImage (imageToDraw, 0, 0, CocoaDPIUtil.pixelToPoint (width), CocoaDPIUtil.pixelToPoint (height),
1827-
/* E.g. destWidth here is effectively DPIUtil.autoScaleDown (scaledWidth), but avoiding rounding errors.
1828-
* Nevertheless, we still have some rounding errors due to the point-based API GC#drawImage(..).
1829-
*/
1830-
0, 0, Math.round (CocoaDPIUtil.pixelToPoint (width * scaleFactor)), Math.round (CocoaDPIUtil.pixelToPoint (height * scaleFactor)));
1831-
imageToDraw.dispose();
1832-
}
1833-
1834-
private final class CocoaDPIUtil {
1835-
1836-
/**
1837-
* Auto-scale down int dimensions.
1838-
*/
1839-
public static int pixelToPoint(int size) {
1840-
return DPIUtil.pixelToPoint(size, DPIUtil.getDeviceZoom());
1841-
}
1842-
1843-
/**
1844-
* Auto-scale down float dimensions.
1845-
*/
1846-
public static float pixelToPoint(float size) {
1847-
return DPIUtil.pixelToPoint(size, DPIUtil.getDeviceZoom());
1848-
}
1828+
StrictChecks.runWithStrictChecksDisabled(() -> {
1829+
Image imageToDraw = new Image(gc.device, (ImageDataProvider) zoom -> imageData);
1830+
gc.drawImage(imageToDraw, 0, 0, CocoaDPIUtil.pixelToPoint(width), CocoaDPIUtil.pixelToPoint(height),
1831+
/*
1832+
* E.g. destWidth here is effectively DPIUtil.autoScaleDown (scaledWidth), but
1833+
* avoiding rounding errors. Nevertheless, we still have some rounding errors
1834+
* due to the point-based API GC#drawImage(..).
1835+
*/
1836+
0, 0, Math.round(CocoaDPIUtil.pixelToPoint(width * scaleFactor)),
1837+
Math.round(CocoaDPIUtil.pixelToPoint(height * scaleFactor)));
1838+
imageToDraw.dispose();
1839+
});
18491840
}
18501841

18511842
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Yatta Solutions and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* Yatta Solutions - initial API and implementation
13+
*******************************************************************************/
14+
package org.eclipse.swt.internal;
15+
16+
public class CocoaDPIUtil {
17+
18+
/**
19+
* Auto-scale down int dimensions.
20+
*/
21+
public static int pixelToPoint(int size) {
22+
return DPIUtil.pixelToPoint(size, DPIUtil.getDeviceZoom());
23+
}
24+
25+
/**
26+
* Auto-scale down float dimensions.
27+
*/
28+
public static float pixelToPoint(float size) {
29+
return DPIUtil.pixelToPoint(size, DPIUtil.getDeviceZoom());
30+
}
31+
32+
}

0 commit comments

Comments
 (0)