git: d551e5b93e20 - main - x11-toolkits/swt: update to 4.21

From: Max Brazhnikov <makc_at_FreeBSD.org>
Date: Tue, 07 Jun 2022 12:38:18 UTC
The branch main has been updated by makc:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d551e5b93e20225875d3b682bb6dc93412d03680

commit d551e5b93e20225875d3b682bb6dc93412d03680
Author:     Max Brazhnikov <makc@FreeBSD.org>
AuthorDate: 2022-06-07 12:37:25 +0000
Commit:     Max Brazhnikov <makc@FreeBSD.org>
CommitDate: 2022-06-07 12:38:03 +0000

    x11-toolkits/swt: update to 4.21
    
    - Sync patches with eclipse 4.21
    - Remove patch-org_eclipse_swt_graphics_Device.java (which breaks
      icons in Eclipse) and install missing *.css files
    - Add patch-org_eclipse_swt_widgets_Shell.java to fix layout on HiDPI
      scaled to 200%
    
    PR:             264512 (based on)
    Submmitted by:  huanghwh@gmail.com
---
 x11-toolkits/swt/Makefile                          |  7 +++---
 x11-toolkits/swt/distinfo                          |  6 +++---
 x11-toolkits/swt/files/build.xml                   |  3 +--
 x11-toolkits/swt/files/patch-OS.java               | 22 -------------------
 .../patch-org_eclipse_swt_browser_WebKit.java      | 11 ++++++++++
 .../patch-org_eclipse_swt_graphics_Device.java     | 11 ----------
 .../patch-org_eclipse_swt_internal_Library.java    | 16 ++++++++++++++
 .../patch-org_eclipse_swt_internal_gtk_OS.java     | 13 +++++++++++
 .../files/patch-org_eclipse_swt_widgets_Shell.java | 20 +++++++++++++++++
 x11-toolkits/swt/files/patch-os.c                  |  4 ++--
 x11-toolkits/swt/files/swt_functional_gtk_3_20.css | 13 +++++++++++
 .../swt/files/swt_theming_fixes_gtk_3_20.css       | 25 ++++++++++++++++++++++
 .../swt/files/swt_theming_fixes_gtk_3_24_5.css     |  3 +++
 13 files changed, 111 insertions(+), 43 deletions(-)

diff --git a/x11-toolkits/swt/Makefile b/x11-toolkits/swt/Makefile
index 458e4433a6fe..6be4bf028df8 100644
--- a/x11-toolkits/swt/Makefile
+++ b/x11-toolkits/swt/Makefile
@@ -1,9 +1,9 @@
 # Created by: Robert C. Noland III <rnoland@FreeBSD.org>
 
 PORTNAME=	swt
-DISTVERSION=	4.20
+DISTVERSION=	4.21
 CATEGORIES=	x11-toolkits devel java
-MASTER_SITES=	http://archive.eclipse.org/eclipse/downloads/drops4/R-${DISTVERSION}-202106111600/
+MASTER_SITES=	http://archive.eclipse.org/eclipse/downloads/drops4/R-${DISTVERSION}-202109060500/
 DISTNAME=	${PORTNAME}-${DISTVERSION}-gtk-linux-x86_64
 
 MAINTAINER=	makc@FreeBSD.org
@@ -22,7 +22,7 @@ USE_JAVA=	yes
 USE_XORG=	xtst
 JAVA_OS=	native
 
-SWT_VERSION=	4944r26
+SWT_VERSION=	4946r21
 
 MAKEFILE=	make_freebsd.mak
 MAKE_ENV=	SWT_VERSION=${SWT_VERSION}
@@ -47,6 +47,7 @@ post-extract:
 	@(cd ${WRKSRC} && ${UNZIP_CMD} -qo "*.zip")
 	@${CP} ${FILESDIR}/build.xml ${WRKSRC}/build.xml
 	@${CP} ${WRKSRC}/make_linux.mak ${WRKSRC}/make_freebsd.mak
+	@${CP} ${FILESDIR}/*.css ${WRKSRC}/org/eclipse/swt/internal/gtk/
 
 post-patch:
 	${SED} -e 's|freebsd|dragonfly|g' ${WRKSRC}/make_freebsd.mak \
diff --git a/x11-toolkits/swt/distinfo b/x11-toolkits/swt/distinfo
index eb9b0137ae53..b3ace138ef81 100644
--- a/x11-toolkits/swt/distinfo
+++ b/x11-toolkits/swt/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1627381059
-SHA256 (swt-4.20-gtk-linux-x86_64.zip) = 0d1ab552b95aab6df6c0499c934fd82864100dc638c43b6c1e793e740bb534c2
-SIZE (swt-4.20-gtk-linux-x86_64.zip) = 3808712
+TIMESTAMP = 1654502811
+SHA256 (swt-4.21-gtk-linux-x86_64.zip) = 3e35a4ababf504bcf64df864e4a957aaa2f0dec9696a922d936c7ee224fa4c5f
+SIZE (swt-4.21-gtk-linux-x86_64.zip) = 3851041
diff --git a/x11-toolkits/swt/files/build.xml b/x11-toolkits/swt/files/build.xml
index b25b8819b9ec..7411f76da48b 100644
--- a/x11-toolkits/swt/files/build.xml
+++ b/x11-toolkits/swt/files/build.xml
@@ -39,12 +39,11 @@
 				<exclude name="**/*.java"/>
 				<exclude name="**/*.o"/>
 				<exclude name="**/*.so"/>
-				<!-- exclude CVS archive -->
-				<exclude name="**/CVS/**"/>
 			</fileset>
 			<fileset dir="${basedir}">
 				<include name="**/version.txt"/>
 				<include name="**/*.properties"/>
+				<include name="**/*.css"/>
 			</fileset>
 		</jar>
 	</target>
diff --git a/x11-toolkits/swt/files/patch-OS.java b/x11-toolkits/swt/files/patch-OS.java
deleted file mode 100644
index 5a89171d0b5c..000000000000
--- a/x11-toolkits/swt/files/patch-OS.java
+++ /dev/null
@@ -1,22 +0,0 @@
---- org/eclipse/swt/internal/gtk/OS.java.orig	2021-06-11 17:24:22 UTC
-+++ org/eclipse/swt/internal/gtk/OS.java
-@@ -61,15 +61,16 @@ import org.eclipse.swt.internal.*;
-  */
- public class OS extends C {
- 	/** OS Constants */
--	public static final boolean IsLinux, IsWin32, BIG_ENDIAN;
-+	public static final boolean IsLinux, IsWin32, BIG_ENDIAN, IsFreeBSD;
- 	static {
- 
- 		/* Initialize the OS flags and locale constants */
- 		String osName = System.getProperty ("os.name");
--		boolean isLinux = false, isWin32 = false;
-+		boolean isLinux = false, isWin32 = false, isFreeBSD = false;
- 		if (osName.equals ("Linux")) isLinux = true;
- 		if (osName.startsWith("Windows")) isWin32 = true;
--		IsLinux = isLinux;  IsWin32 = isWin32;
-+		if (osName.equals ("FreeBSD")) isFreeBSD = true;
-+		IsLinux = isLinux;  IsWin32 = isWin32;  IsFreeBSD = isFreeBSD;
- 
- 		byte[] buffer = new byte[4];
- 		long ptr = C.malloc(4);
diff --git a/x11-toolkits/swt/files/patch-org_eclipse_swt_browser_WebKit.java b/x11-toolkits/swt/files/patch-org_eclipse_swt_browser_WebKit.java
new file mode 100644
index 000000000000..463512a1c9b2
--- /dev/null
+++ b/x11-toolkits/swt/files/patch-org_eclipse_swt_browser_WebKit.java
@@ -0,0 +1,11 @@
+--- org/eclipse/swt/browser/WebKit.java.orig	2022-06-06 23:55:44 UTC
++++ org/eclipse/swt/browser/WebKit.java
+@@ -121,7 +121,7 @@ class WebKit extends WebBrowser {
+ 	 * https://www.nczonline.net/blog/2009/01/05/what-determines-that-a-script-is-long-running/
+ 	 * https://stackoverflow.com/questions/3030024/maximum-execution-time-for-javascript
+ 	 */
+-	static final int ASYNC_EXEC_TIMEOUT_MS = 10000;
++	static final int ASYNC_EXEC_TIMEOUT_MS = 100; // Dirty hack for webkit issues on FreeBSD
+ 
+ 	/** Workaround for bug 522733 */
+ 	static boolean bug522733FirstInstanceCreated = false;
diff --git a/x11-toolkits/swt/files/patch-org_eclipse_swt_graphics_Device.java b/x11-toolkits/swt/files/patch-org_eclipse_swt_graphics_Device.java
deleted file mode 100644
index 98789df25c16..000000000000
--- a/x11-toolkits/swt/files/patch-org_eclipse_swt_graphics_Device.java
+++ /dev/null
@@ -1,11 +0,0 @@
---- org/eclipse/swt/graphics/Device.java.orig	2021-06-11 17:24:22 UTC
-+++ org/eclipse/swt/graphics/Device.java
-@@ -740,7 +740,7 @@ protected void init () {
- 	}
- 	systemFont = Font.gtk_new (this, defaultFont);
- 
--	overrideThemeValues();
-+	//overrideThemeValues();
- }
- 
- /**
diff --git a/x11-toolkits/swt/files/patch-org_eclipse_swt_internal_Library.java b/x11-toolkits/swt/files/patch-org_eclipse_swt_internal_Library.java
new file mode 100644
index 000000000000..1442e3986acf
--- /dev/null
+++ b/x11-toolkits/swt/files/patch-org_eclipse_swt_internal_Library.java
@@ -0,0 +1,16 @@
+--- org/eclipse/swt/internal/Library.java.orig	2021-09-06 01:22:24 UTC
++++ org/eclipse/swt/internal/Library.java
+@@ -65,12 +65,12 @@ static {
+ 
+ static String arch() {
+ 	String osArch = System.getProperty("os.arch"); //$NON-NLS-1$
+-	if (osArch.equals ("amd64")) return "x86_64"; //$NON-NLS-1$ $NON-NLS-2$
+ 	return osArch;
+ }
+ 
+ static String os() {
+ 	String osName = System.getProperty("os.name"); //$NON-NLS-1$
++	if (osName.equals ("FreeBSD")) return "freebsd"; //$NON-NLS-1$ $NON-NLS-2$
+ 	if (osName.equals ("Linux")) return "linux"; //$NON-NLS-1$ $NON-NLS-2$
+ 	if (osName.equals ("Mac OS X")) return "macosx"; //$NON-NLS-1$ $NON-NLS-2$
+ 	if (osName.startsWith ("Win")) return "win32"; //$NON-NLS-1$ $NON-NLS-2$
diff --git a/x11-toolkits/swt/files/patch-org_eclipse_swt_internal_gtk_OS.java b/x11-toolkits/swt/files/patch-org_eclipse_swt_internal_gtk_OS.java
new file mode 100644
index 000000000000..741ce3a827f9
--- /dev/null
+++ b/x11-toolkits/swt/files/patch-org_eclipse_swt_internal_gtk_OS.java
@@ -0,0 +1,13 @@
+--- org/eclipse/swt/internal/gtk/OS.java.orig	2021-09-06 01:22:24 UTC
++++ org/eclipse/swt/internal/gtk/OS.java
+@@ -65,8 +65,8 @@ public class OS extends C {
+ 
+ 		/* Initialize the OS flags and locale constants */
+ 		String osName = System.getProperty ("os.name");
+-		boolean isLinux = false, isWin32 = false;
+-		if (osName.equals ("Linux")) isLinux = true;
++		boolean isLinux = osName.equals ("Linux") || osName.equals ("FreeBSD");
++		boolean isWin32 = false;
+ 		if (osName.startsWith("Windows")) isWin32 = true;
+ 		IsLinux = isLinux;  IsWin32 = isWin32;
+ 
diff --git a/x11-toolkits/swt/files/patch-org_eclipse_swt_widgets_Shell.java b/x11-toolkits/swt/files/patch-org_eclipse_swt_widgets_Shell.java
new file mode 100644
index 000000000000..e419013043d9
--- /dev/null
+++ b/x11-toolkits/swt/files/patch-org_eclipse_swt_widgets_Shell.java
@@ -0,0 +1,20 @@
+--- org/eclipse/swt/widgets/Shell.java.orig	2021-09-06 01:22:24 UTC
++++ org/eclipse/swt/widgets/Shell.java
+@@ -1507,6 +1507,8 @@ long gtk_button_press_event (long widget, long event) 
+ long gtk_configure_event (long widget, long event) {
+ 	int [] x = new int [1], y = new int [1];
+ 	GTK3.gtk_window_get_position (shellHandle, x, y);
++	int scale = GTK.gtk_widget_get_scale_factor (shellHandle);
++	x[0] /= scale; y[0] /= scale;
+ 
+ 	if (!isVisible ()) {
+ 		return 0; //We shouldn't handle move/resize events if shell is hidden.
+@@ -3351,6 +3353,8 @@ Rectangle getBoundsInPixels () {
+ 			// TODO: GTK4 GtkWindow no longer has the ability to get position
+ 		} else {
+ 			GTK3.gtk_window_get_position (shellHandle, x, y);
++			int scale = GTK.gtk_widget_get_scale_factor (shellHandle);
++			x[0] /= scale; y[0] /= scale;
+ 		}
+ 	} else {
+ 		if (GTK.GTK4) {
diff --git a/x11-toolkits/swt/files/patch-os.c b/x11-toolkits/swt/files/patch-os.c
index 19b342888fbd..fe393f1299fd 100644
--- a/x11-toolkits/swt/files/patch-os.c
+++ b/x11-toolkits/swt/files/patch-os.c
@@ -1,6 +1,6 @@
---- os.c.orig	2021-06-11 17:24:22 UTC
+--- os.c.orig	2021-09-06 01:22:24 UTC
 +++ os.c
-@@ -16083,11 +16083,16 @@ JNIEXPORT jlong JNICALL OS_NATIVE(realpath)
+@@ -15180,11 +15180,16 @@ JNIEXPORT jlong JNICALL OS_NATIVE(realpath)
  	jlong rc = 0;
  	OS_NATIVE_ENTER(env, that, realpath_FUNC);
  	if (arg0) if ((lparg0 = (*env)->GetByteArrayElements(env, arg0, NULL)) == NULL) goto fail;
diff --git a/x11-toolkits/swt/files/swt_functional_gtk_3_20.css b/x11-toolkits/swt/files/swt_functional_gtk_3_20.css
new file mode 100644
index 000000000000..eb6287a71c65
--- /dev/null
+++ b/x11-toolkits/swt/files/swt_functional_gtk_3_20.css
@@ -0,0 +1,13 @@
+@binding-set SWTTreeViewBinding {
+	bind "Left" { "expand-collapse-cursor-row" (0,0,0)};
+	bind "Right" { "expand-collapse-cursor-row" (0,1,0)};
+}
+
+treeview {
+	-gtk-key-bindings: SWTTreeViewBinding;
+}
+
+scrolledwindow undershoot.top, scrolledwindow undershoot.right,
+	scrolledwindow undershoot.bottom, scrolledwindow undershoot.left {
+	background-image: none;
+}
diff --git a/x11-toolkits/swt/files/swt_theming_fixes_gtk_3_20.css b/x11-toolkits/swt/files/swt_theming_fixes_gtk_3_20.css
new file mode 100644
index 000000000000..ee046e201c43
--- /dev/null
+++ b/x11-toolkits/swt/files/swt_theming_fixes_gtk_3_20.css
@@ -0,0 +1,25 @@
+toolbar {
+	padding-top: 2px;
+	padding-bottom: 2px;
+}
+
+toolbar button {
+	padding: 2px;
+}
+
+toolbar button.popup {
+	padding: 0px;
+}
+
+toolbar toolbutton button {
+	padding: 0px 0px 0px 0px;
+}
+
+entry {
+	min-height: 26px;
+}
+
+tab {
+	padding-left: 6px;
+	padding-right: 6px;
+}
diff --git a/x11-toolkits/swt/files/swt_theming_fixes_gtk_3_24_5.css b/x11-toolkits/swt/files/swt_theming_fixes_gtk_3_24_5.css
new file mode 100644
index 000000000000..3aab49552e75
--- /dev/null
+++ b/x11-toolkits/swt/files/swt_theming_fixes_gtk_3_24_5.css
@@ -0,0 +1,3 @@
+button {
+	padding: 4px 8px;
+}