diff options
author | Your Name | 2022-03-14 19:38:48 +0800 |
---|---|---|
committer | Your Name | 2022-03-14 19:38:48 +0800 |
commit | 04a2dde8b011f2b6f75389fc8c4b26ba973ab6d5 (patch) | |
tree | fa587a5ee410de52e5d4f72618f1d952ef6c2c6e | |
download | aur-04a2dde8b011f2b6f75389fc8c4b26ba973ab6d5.tar.gz |
Pack java17-jetbrains-imfix
-rw-r--r-- | .SRCINFO | 99 | ||||
-rw-r--r-- | PKGBUILD | 271 | ||||
-rw-r--r-- | freedesktop-java.desktop | 12 | ||||
-rw-r--r-- | freedesktop-jconsole.desktop | 11 | ||||
-rw-r--r-- | freedesktop-jshell.desktop | 9 | ||||
-rw-r--r-- | idea.patch | 420 | ||||
-rw-r--r-- | install_jdk-jetbrains.sh | 50 | ||||
-rw-r--r-- | install_jre-jetbrains.sh | 48 |
8 files changed, 920 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..b980a7be007b --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,99 @@ +pkgbase = java17-jetbrains-imfix + pkgver = 17.0.2.b315.1 + pkgrel = 1 + url = https://confluence.jetbrains.com/display/JBR/JetBrains+Runtime + arch = x86_64 + license = custom + makedepends = java-environment=17 + makedepends = java-environment=11 + makedepends = cpio + makedepends = unzip + makedepends = zip + makedepends = libelf + makedepends = libcups + makedepends = libx11 + makedepends = libxrender + makedepends = libxtst + makedepends = libxt + makedepends = libxext + makedepends = libxrandr + makedepends = alsa-lib + makedepends = pandoc + makedepends = graphviz + makedepends = freetype2 + makedepends = libjpeg-turbo + makedepends = giflib + makedepends = libpng + makedepends = lcms2 + makedepends = libnet + makedepends = bash + makedepends = harfbuzz + makedepends = gcc-libs + makedepends = glibc + makedepends = ant + makedepends = git + makedepends = rsync + makedepends = cmake + makedepends = python + makedepends = at-spi2-atk + makedepends = libxkbcommon + makedepends = libxcomposite + makedepends = mesa + source = git+https://github.com/JetBrains/JetBrainsRuntime.git#tag=jb17_0_2-b315.1 + source = git+https://github.com/JetBrains/jcef.git#commit=316db138ea00b1a814f92e3d2f853320e8ce73b5 + source = idea.patch + source = freedesktop-java.desktop + source = freedesktop-jconsole.desktop + source = freedesktop-jshell.desktop + sha256sums = SKIP + sha256sums = SKIP + sha256sums = 5f984d2e050fb6a9cbc1d48df62cd3ca2ff705a8aaa7286913c337c02da9beda + sha256sums = 3d5ab2d5eaa994377de0554de5e59596f1fc7ab773e02d84aee83a568042b5ec + sha256sums = 442d17b0de7ddd4c49a392f4ccc60f3378b9cf54908081b802d98b89597b3ab8 + sha256sums = bdc910ffa896f92cca1d28cf9930276cb9bafbd13bfab97286b25fd7f7a6e11e + +pkgname = jre17-jetbrains-imfix + pkgdesc = JetBrains Java 17 full runtime environment + install = install_jre-jetbrains.sh + depends = java-runtime-common>=3 + depends = ca-certificates-utils + depends = nss + depends = libjpeg-turbo + depends = lcms2 + depends = libnet + depends = freetype2 + depends = giflib + optdepends = java-rhino: for some JavaScript support + optdepends = alsa-lib: for basic sound support + optdepends = gtk2: for the Gtk+ 2 look and feel - desktop usage + optdepends = gtk3: for the Gtk+ 3 look and feel - desktop usage + provides = java-runtime=17 + provides = java-runtime-jetbrains=17 + provides = jre17-jetbrains=17.0.2.b315.1-1 + conflicts = jre17-jetbrains + backup = etc/java17-jetbrains/logging.propertopenjdkies + backup = etc/java17-jetbrains/management/jmxremote.access + backup = etc/java17-jetbrains/management/jmxremote.password.template + backup = etc/java17-jetbrains/management/management.properties + backup = etc/java17-jetbrains/net.properties + backup = etc/java17-jetbrains/security/java.policy + backup = etc/java17-jetbrains/security/java.security + backup = etc/java17-jetbrains/security/policy/README.txt + backup = etc/java17-jetbrains/security/policy/limited/default_US_export.policy + backup = etc/java17-jetbrains/security/policy/limited/default_local.policy + backup = etc/java17-jetbrains/security/policy/limited/exempt_local.policy + backup = etc/java17-jetbrains/security/policy/unlimited/default_US_export.policy + backup = etc/java17-jetbrains/security/policy/unlimited/default_local.policy + backup = etc/java17-jetbrains/sound.properties + +pkgname = jdk17-jetbrains-imfix + pkgdesc = JetBrains Java 17 development kit + install = install_jdk-jetbrains.sh + depends = jre17-jetbrains=17.0.2.b315.1-1 + depends = java-environment-common=3 + depends = hicolor-icon-theme + depends = libelf + provides = java-environment=17 + provides = java-environment-jetbrains=17 + provides = jdk17-jetbrains=17.0.2.b315.1-1 + conflicts = jdk17-jetbrains diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..bcbcb0a26758 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,271 @@ +# Contributer: Levente Polyak <anthraxx[at]archlinux[dot]org> +# Contributer: Guillaume ALAUX <guillaume@archlinux.org> +# Contributer: Github user RikudouPatrickstar + +# This PKGBUILD is directly modified from community/java11-openjdk +# Methods to build JBR with JCEF support is from https://github.com/RikudouPatrickstar/JetBrainsRuntime-for-Linux-x64/blob/master/.github/workflows/jbr-linux-x64.yml + +# TODO add test, see about packaging jtreg and using it here +# TODO see about building with OpenJDK10 +# TODO add javazi +# TODO when IcedTea provides it, package icedtea-web and add it as optdepends +# TODO package OpenJFX for OpenJDK10 and add it as optdepends + +## EXPLORATIONS +# TODO extract a jmods package from jdk10-openjdk? +# TODO extract a jdk-headless package? + +pkgbase=java17-jetbrains-imfix +_pkgbase=java17-jetbrains +pkgname=('jre17-jetbrains-imfix' 'jdk17-jetbrains-imfix') +_majorver=17 +_ver=17.0.2 +_hgver=17_0_2 +_updatever=8 +_jbver1=315 +_jbver2=1 +pkgrel=1 +pkgver=${_ver}.b${_jbver1}.${_jbver2} +_hg_tag=jb${_hgver}-b${_jbver1}.${_jbver2} +_jcef_commit=316db138ea00b1a814f92e3d2f853320e8ce73b5 +arch=('x86_64') +url='https://confluence.jetbrains.com/display/JBR/JetBrains+Runtime' +license=('custom') +makedepends=('java-environment=17' 'java-environment=11' 'cpio' 'unzip' 'zip' 'libelf' 'libcups' 'libx11' + 'libxrender' 'libxtst' 'libxt' 'libxext' 'libxrandr' 'alsa-lib' 'pandoc' + 'graphviz' 'freetype2' 'libjpeg-turbo' 'giflib' 'libpng' 'lcms2' + 'libnet' 'bash' 'harfbuzz' 'gcc-libs' 'glibc' 'ant' 'git' 'rsync' 'cmake' 'python' 'at-spi2-atk' 'libxkbcommon' 'libxcomposite' 'mesa') +source=(git+https://github.com/JetBrains/JetBrainsRuntime.git#tag=$_hg_tag + git+https://github.com/JetBrains/jcef.git#commit=$_jcef_commit + idea.patch + freedesktop-java.desktop + freedesktop-jconsole.desktop + freedesktop-jshell.desktop) +sha256sums=('SKIP' + 'SKIP' + '5f984d2e050fb6a9cbc1d48df62cd3ca2ff705a8aaa7286913c337c02da9beda' + '3d5ab2d5eaa994377de0554de5e59596f1fc7ab773e02d84aee83a568042b5ec' + '442d17b0de7ddd4c49a392f4ccc60f3378b9cf54908081b802d98b89597b3ab8' + 'bdc910ffa896f92cca1d28cf9930276cb9bafbd13bfab97286b25fd7f7a6e11e') + +case "${CARCH}" in + x86_64) _JARCH='x86_64';; + i686) _JARCH='x86';; +esac + +_jvmdir=/usr/lib/jvm/java-${_majorver}-jetbrains +_jdkdir=JetBrainsRuntime +_imgdir=${_jdkdir}/build/linux-${_JARCH}-server-release/images + +build() { + + # build jcef + cd $srcdir/jcef + sed -i "s/4.46/5.4/g" tools/buildtools/download_from_google_storage.py + mkdir jcef_build && cd jcef_build + cmake -DCMAKE_BUILD_TYPE=Release .. + make + cd ../jb/tools/linux + JDK_11=/usr/lib/jvm/$(ls /usr/lib/jvm | grep 11 | head -n 1) ./build.sh all + + # build jbr + cd $srcdir/${_jdkdir} + + # Include jcef + git apply -p0 < jb/project/tools/patches/add_jcef_module.patch + # Fix im cursor follow + patch -Np1 -i ${srcdir}/idea.patch + + NUM_PROC_OPT='' + MAKEFLAG_J=$(echo ${MAKEFLAGS} | sed -En 's/.*-j([0-9]+).*/\1/p') + if [ -n "${MAKEFLAG_J}" ]; then + # http://hg.openjdk.java.net/jdk10/jdk10/file/85e6cb013b98/make/InitSupport.gmk#l105 + echo "Removing '-j${MAKEFLAG_J}' from MAKEFLAGS to prevent build fail. Passing it directly to ./configure." + export MAKEFLAGS=${MAKEFLAGS/-j${MAKEFLAG_J}/} + NUM_PROC_OPT="--with-num-cores=${MAKEFLAG_J}" + fi + + # Avoid optimization of HotSpot being lowered from O3 to O2 + local _CFLAGS="${CFLAGS//-O2/-O3} ${CPPFLAGS} -fcommon" + local _CXXFLAGS="${CXXFLAGS//-O2/-O3} ${CPPFLAGS} -fcommon" + local _LDFLAGS=${LDFLAGS} + if [[ ${CARCH} = i686 ]]; then + echo "Removing '-fno-plt' from CFLAGS and CXXFLAGS to prevent build fail with this architecture" + _CFLAGS=${CFLAGS/-fno-plt/} + _CXXFLAGS=${CXXFLAGS/-fno-plt/} + fi + + # TODO: Should be rechecked for the next releases + # compiling with -fexceptions leads to: + # /usr/bin/ld: /build/java-openjdk/src/jdk17u-jdk-17.0.3-2/build/linux-x86_64-server-release/hotspot/variant-server/libjvm/objs/zPhysicalMemory.o: in function `ZList<ZMemory>::~ZList()': + # /build/java-openjdk/src/jdk17u-jdk-17.0.3-2/src/hotspot/share/gc/z/zList.hpp:54: undefined reference to `ZListNode<ZMemory>::~ZListNode()' + # collect2: error: ld returned 1 exit status + _CFLAGS=${CFLAGS/-fexceptions/} + _CXXFLAGS=${CXXFLAGS/-fexceptions/} + + # CFLAGS, CXXFLAGS and LDFLAGS are ignored as shown by a warning + # in the output of ./configure unless used like such: + # --with-extra-cflags="${CFLAGS}" + # --with-extra-cxxflags="${CXXFLAGS}" + # --with-extra-ldflags="${LDFLAGS}" + # See also paragraph "Configure Control Variables from "jdk${_majorver}-${_hg_tag}/common/doc/building.md + unset CFLAGS + unset CXXFLAGS + unset LDFLAGS + + bash configure \ + --with-version-build="${_updatever}" \ + --with-version-pre="" \ + --with-version-opt="b${_jbver1}.${_jbver2}" \ + --with-stdc++lib=dynamic \ + --with-extra-cflags="${_CFLAGS}" \ + --with-extra-cxxflags="${_CXXFLAGS}" \ + --with-extra-ldflags="${_LDFLAGS}" \ + --with-libjpeg=system \ + --with-giflib=system \ + --with-libpng=system \ + --with-lcms=system \ + --with-zlib=system \ + --with-harfbuzz=system \ + --with-jvm-features=zgc \ + --enable-unlimited-crypto \ + --enable-warnings-as-errors=no \ + ${NUM_PROC_OPT} \ + --with-import-modules=$srcdir/jcef/out/linux64/modular-sdk + #--disable-javac-server + + make images legacy-jre-image + + # https://bugs.openjdk.java.net/browse/JDK-8173610 + find "../${_imgdir}" -iname '*.so' -exec chmod +x {} \; +} + +check() { + cd ${_jdkdir} + # TODO package jtreg + # make -k check +} + +package_jre17-jetbrains-imfix() { + pkgdesc="JetBrains Java ${_majorver} full runtime environment" + depends=('java-runtime-common>=3' 'ca-certificates-utils' 'nss' 'libjpeg-turbo' 'lcms2' 'libnet' 'freetype2' 'giflib') + optdepends=('java-rhino: for some JavaScript support' + 'alsa-lib: for basic sound support' + 'gtk2: for the Gtk+ 2 look and feel - desktop usage' + 'gtk3: for the Gtk+ 3 look and feel - desktop usage') + provides=("java-runtime=${_majorver}" "java-runtime-jetbrains=${_majorver}" "jre${_majorver}-jetbrains=${pkgver}-${pkgrel}") + conflicts=("jre17-jetbrains") + _pkgname="jre17-jetbrains" + backup=(etc/${_pkgbase}/logging.propertopenjdkies + etc/${_pkgbase}/management/jmxremote.access + etc/${_pkgbase}/management/jmxremote.password.template + etc/${_pkgbase}/management/management.properties + etc/${_pkgbase}/net.properties + etc/${_pkgbase}/security/java.policy + etc/${_pkgbase}/security/java.security + etc/${_pkgbase}/security/policy/README.txt + etc/${_pkgbase}/security/policy/limited/default_US_export.policy + etc/${_pkgbase}/security/policy/limited/default_local.policy + etc/${_pkgbase}/security/policy/limited/exempt_local.policy + etc/${_pkgbase}/security/policy/unlimited/default_US_export.policy + etc/${_pkgbase}/security/policy/unlimited/default_local.policy + etc/${_pkgbase}/sound.properties) + install=install_jre-jetbrains.sh + + cd ${_imgdir}/jre + + install -dm 755 "${pkgdir}${_jvmdir}" + + cp -a bin lib \ + "${pkgdir}${_jvmdir}" + + # Include jcef libs + rsync -av $srcdir/jcef/jcef_build/native/Release/ ${pkgdir}${_jvmdir}/lib --exclude="modular-sdk" + + cp ../jdk/release "${pkgdir}${_jvmdir}" + cp ../jdk/lib/modules "${pkgdir}${_jvmdir}/lib" + + # Conf + install -dm 755 "${pkgdir}/etc" + cp -r conf "${pkgdir}/etc/${_pkgbase}" + ln -s /etc/${_pkgbase} "${pkgdir}/${_jvmdir}/conf" + + # Legal + install -dm 755 "${pkgdir}/usr/share/licenses" + cp -r legal "${pkgdir}/usr/share/licenses/${_pkgbase}" + ln -s ${_pkgbase} "${pkgdir}/usr/share/licenses/${_pkgname}" + ln -s /usr/share/licenses/${_pkgbase} "${pkgdir}/${_jvmdir}/legal" + + # Man pages + for f in bin/*; do + f=$(basename "${f}") + _man=../jdk/man/man1/"${f}.1" + test -f "${_man}" && install -Dm 644 "${_man}" "${pkgdir}/usr/share/man/man1/${f}-jetbrains${_majorver}.1" + done + ln -s /usr/share/man "${pkgdir}/${_jvmdir}/man" + + # Link JKS keystore from ca-certificates-utils + rm -f "${pkgdir}${_jvmdir}/lib/security/cacerts" + ln -sf /etc/ssl/certs/java/cacerts "${pkgdir}${_jvmdir}/lib/security/cacerts" +} + +package_jdk17-jetbrains-imfix() { + pkgdesc="JetBrains Java ${_majorver} development kit" + depends=("jre${_majorver}-jetbrains=${pkgver}-${pkgrel}" 'java-environment-common=3' 'hicolor-icon-theme' 'libelf') + provides=("java-environment=${_majorver}" "java-environment-jetbrains=${_majorver}" "jdk${_majorver}-jetbrains=${pkgver}-${pkgrel}") + conflicts=("jdk17-jetbrains") + _pkgname="jdk17-jetbrains" + install=install_jdk-jetbrains.sh + + cd ${_imgdir}/jdk + + install -dm 755 "${pkgdir}${_jvmdir}" + + cp -a bin demo include jmods lib \ + "${pkgdir}${_jvmdir}" + + rm "${pkgdir}${_jvmdir}/lib/src.zip" + + # Remove files held by JRE + pushd ../jre + for d in bin lib; do + find ${d} ! -type d -exec rm "${pkgdir}${_jvmdir}/{}" \; + done + popd + find "${pkgdir}${_jvmdir}/lib" -type d -empty -delete + + # Conf files all belong to JRE + + # Legal + install -dm 755 "${pkgdir}/usr/share/licenses" + cp -r legal "${pkgdir}/usr/share/licenses/${_pkgbase}" + pushd ../jre/legal + find . ! -type d -exec rm "${pkgdir}/usr/share/licenses/${_pkgbase}/{}" \; + popd + find "${pkgdir}/usr/share/licenses" -type d -empty -delete + ln -s ${_pkgbase} "${pkgdir}/usr/share/licenses/${_pkgname}" + + # Man pages + for f in bin/*; do + f=$(basename "${f}") + _man=man/man1/"${f}.1" + test -f "../jre/bin/${f}" && continue + test -f "${_man}" && install -Dm 644 "${_man}" "${pkgdir}/usr/share/man/man1/${f}-jetbrains${_majorver}.1" + done + + # Icons + for s in 16 24 32 48; do + install -Dm 644 \ + "${srcdir}/${_jdkdir}/src/java.desktop/unix/classes/sun/awt/X11/java-icon${s}.png" \ + "${pkgdir}/usr/share/icons/hicolor/${s}x${s}/apps/${_pkgbase}.png" + done + + # Desktop files + for f in jconsole java jshell; do + install -Dm 644 \ + "${srcdir}/freedesktop-${f}.desktop" \ + "${pkgdir}/usr/share/applications/${f}-${_pkgbase}.desktop" + done +} + +# vim: ts=2 sw=2 et: diff --git a/freedesktop-java.desktop b/freedesktop-java.desktop new file mode 100644 index 000000000000..d00f4293fb88 --- /dev/null +++ b/freedesktop-java.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Name=JetBrains Java 17 Runtime +Name[fi]=JetBrains Java 17 - ajonaikainen ympäristö +Comment=JetBrains Java 17 Runtime +Comment[fi]=JetBrains Java 17 - ajonaikainen ympäristö +Keywords=java;runtime +Exec=/usr/lib/jvm/java-17-jetbrains/bin/java -jar +Terminal=false +Type=Application +Icon=java17-jetbrains +MimeType=application/x-java-archive;application/java-archive;application/x-jar; +NoDisplay=true diff --git a/freedesktop-jconsole.desktop b/freedesktop-jconsole.desktop new file mode 100644 index 000000000000..2a7e281d8e13 --- /dev/null +++ b/freedesktop-jconsole.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=JetBrains Java 17 Console +Name[fi]=JetBrains Java 17 - konsoli +Comment=JetBrains Java 17 Monitoring & Management Console +Comment[fi]=JetBrains Java 17 - valvonta- ja hallintakonsoli +Keywords=java;console;monitoring +Exec=/usr/lib/jvm/java-17-jetbrains/bin/jconsole +Terminal=false +Type=Application +Icon=java17-jetbrains +Categories=Application;System; diff --git a/freedesktop-jshell.desktop b/freedesktop-jshell.desktop new file mode 100644 index 000000000000..3bd7085d23a5 --- /dev/null +++ b/freedesktop-jshell.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=JetBrains Java 17 Shell +Comment=JetBrains Java 17 Shell +Keywords=java;shell +Exec=/usr/lib/jvm/java-17-jetbrains/bin/jshell +Terminal=true +Type=Application +Icon=java17-jetbrains +Categories=Application;System; diff --git a/idea.patch b/idea.patch new file mode 100644 index 000000000000..8590215d6bb5 --- /dev/null +++ b/idea.patch @@ -0,0 +1,420 @@ +diff --git a/src/java.desktop/share/classes/javax/swing/JTextArea.java b/src/java.desktop/share/classes/javax/swing/JTextArea.java +index ecc9342f05a..c3bee6dd119 100644 +--- a/src/java.desktop/share/classes/javax/swing/JTextArea.java ++++ b/src/java.desktop/share/classes/javax/swing/JTextArea.java +@@ -562,6 +562,14 @@ public class JTextArea extends JTextComponent { + return rowHeight; + } + ++ /** ++ * Add by the "imfix" patch ++ * @return FontMetrics ++ */ ++ public FontMetrics getFontMetrics() { ++ return getFontMetrics(getFont()); ++ } ++ + /** + * Returns the number of columns in the TextArea. + * +diff --git a/src/java.desktop/share/classes/javax/swing/JTextField.java b/src/java.desktop/share/classes/javax/swing/JTextField.java +index 3abe09d0565..d952d9fd678 100644 +--- a/src/java.desktop/share/classes/javax/swing/JTextField.java ++++ b/src/java.desktop/share/classes/javax/swing/JTextField.java +@@ -426,7 +426,15 @@ public class JTextField extends JTextComponent implements SwingConstants { + } + return columnWidth; + } +- ++ ++ /** ++ * Add by the "imfix" patch ++ * @return FontMetrics ++ */ ++ public FontMetrics getFontMetrics() { ++ return getFontMetrics(getFont()); ++ } ++ + /** + * Returns the preferred size <code>Dimensions</code> needed for this + * <code>TextField</code>. If a non-zero number of columns has been +diff --git a/src/java.desktop/share/classes/sun/awt/im/InputContext.java b/src/java.desktop/share/classes/sun/awt/im/InputContext.java +index bb955dc5089..29392b3399a 100644 +--- a/src/java.desktop/share/classes/sun/awt/im/InputContext.java ++++ b/src/java.desktop/share/classes/sun/awt/im/InputContext.java +@@ -28,6 +28,7 @@ package sun.awt.im; + import java.awt.AWTEvent; + import java.awt.AWTKeyStroke; + import java.awt.Component; ++import java.awt.Cursor; + import java.awt.EventQueue; + import java.awt.Frame; + import java.awt.Rectangle; +@@ -39,6 +40,7 @@ import java.awt.event.FocusEvent; + import java.awt.event.InputEvent; + import java.awt.event.InputMethodEvent; + import java.awt.event.KeyEvent; ++import java.awt.event.MouseEvent; + import java.awt.event.WindowEvent; + import java.awt.event.WindowListener; + import java.awt.im.InputMethodRequests; +@@ -54,6 +56,7 @@ import java.util.prefs.BackingStoreException; + import java.util.prefs.Preferences; + import sun.util.logging.PlatformLogger; + import sun.awt.SunToolkit; ++import sun.awt.X11InputMethod; + + /** + * This InputContext class contains parts of the implementation of +@@ -249,13 +252,26 @@ public class InputContext extends java.awt.im.InputContext + focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary()); + break; + ++ case MouseEvent.MOUSE_RELEASED: ++ if(checkTextCursor((Component)event.getSource())) { ++ // focusGained((Component) event.getSource()); ++ transCaretPositionToXIM((Component)event.getSource()); ++ break; ++ } ++ + case KeyEvent.KEY_PRESSED: +- if (checkInputMethodSelectionKey((KeyEvent)event)) { ++ if (event instanceof KeyEvent && checkInputMethodSelectionKey((KeyEvent)event)) { + // pop up the input method selection menu + InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component)event.getSource()); + break; + } + ++ case KeyEvent.KEY_RELEASED: ++ if (event instanceof KeyEvent && checkDirectionKey((KeyEvent)event)) { ++ transCaretPositionToXIM((Component) event.getSource()); ++ break; ++ } ++ + // fall through + + default: +@@ -359,7 +375,65 @@ public class InputContext extends java.awt.im.InputContext + } + } + } +- ++ /** ++ * fix fcitx position ++ */ ++ private void transCaretPositionToXIM(Component source) { ++ synchronized (source.getTreeLock()) { ++ synchronized (this) { ++ if ("sun.awt.im.CompositionArea".equals(source.getClass().getName())) { ++ // no special handling for this one ++ } else if (getComponentWindow(source) instanceof InputMethodWindow) { ++ // no special handling for this one either ++ } else { ++ if (!source.isDisplayable()) { ++ // Component is being disposed ++ return; ++ } ++ currentClientComponent = source; ++ } ++ awtFocussedComponent = source; ++ if (inputMethod != null && inputMethod instanceof X11InputMethod) { ++ ((X11InputMethod)inputMethod).setXICTextCursorPosition(source); ++ } ++ InputMethodContext inputContext = ((InputMethodContext)this); ++ if (!inputContext.isCompositionAreaVisible()) { ++ InputMethodRequests req = source.getInputMethodRequests(); ++ if (req != null && inputContext.useBelowTheSpotInput()) { ++ inputContext.setCompositionAreaUndecorated(true); ++ } else { ++ inputContext.setCompositionAreaUndecorated(false); ++ } ++ } ++ // restores the composition area if it was set to invisible ++ // when focus got lost ++ if (compositionAreaHidden == true) { ++ ((InputMethodContext)this).setCompositionAreaVisible(true); ++ compositionAreaHidden = false; ++ } ++ ++ } ++ } ++ } ++ /** ++ * fix fcitx position ++ */ ++ private boolean checkDirectionKey(KeyEvent event) { ++ // if (event.getKeyCode() >= 37 && event.getKeyCode() <=40) { ++ // return true; ++ // } else { ++ // return false; ++ // } ++ return true; ++ } ++ /** ++ * fix fcitx position ++ */ ++ private boolean checkTextCursor(Component source) { ++ if(source.getCursor().getType()==Cursor.TEXT_CURSOR) ++ return true; ++ return false; ++ } + /** + * Activates the current input method of this input context, and grabs + * the composition area for use by this input context. +diff --git a/src/java.desktop/unix/classes/sun/awt/X11/XInputMethod.java b/src/java.desktop/unix/classes/sun/awt/X11/XInputMethod.java +index 07c1334b83f..269fbdd3d4c 100644 +--- a/src/java.desktop/unix/classes/sun/awt/X11/XInputMethod.java ++++ b/src/java.desktop/unix/classes/sun/awt/X11/XInputMethod.java +@@ -28,15 +28,27 @@ package sun.awt.X11; + import java.awt.AWTException; + import java.awt.Component; + import java.awt.Container; ++import java.awt.geom.Point2D; ++import java.awt.FontMetrics; ++import java.awt.Point; + import java.awt.Rectangle; + import java.awt.im.spi.InputMethodContext; + import java.awt.peer.ComponentPeer; + ++import java.lang.reflect.Field; ++import java.lang.reflect.InvocationTargetException; ++import java.lang.reflect.Method; ++ ++import javax.swing.JTextArea; ++import javax.swing.JTextField; ++import javax.swing.text.JTextComponent; ++ + import sun.awt.AWTAccessor; + import sun.awt.X11InputMethod; + + import sun.util.logging.PlatformLogger; + ++ + /** + * Input Method Adapter for XIM (without Motif) + * +@@ -83,8 +95,20 @@ public class XInputMethod extends X11InputMethod { + return 0; + return releaseXICNative(pData); + } +- ++ ++ + private static volatile long xicFocus = 0; ++ ++ public void setXICTextCursorOffXY(ComponentPeer peer) { ++ ++ if (peer == null) { ++ return; ++ } ++ xicFocus = ((XComponentPeer)peer).getContentWindow(); ++ int[] result = getOffXYRelateToFrame(peer ,true); ++ setXICFocusNative(((XComponentPeer)peer).getContentWindow(),true,true,result); ++ // setXICTextCursorOffXYNative(((XComponentPeer)peer).getContentWindow(),result); ++ } + + protected void setXICFocus(ComponentPeer peer, + boolean value, boolean active) { +@@ -92,9 +116,11 @@ public class XInputMethod extends X11InputMethod { + return; + } + xicFocus = ((XComponentPeer)peer).getContentWindow(); ++ int[] result = getOffXYRelateToFrame(peer ,value); + setXICFocusNative(((XComponentPeer)peer).getContentWindow(), + value, +- active); ++ active, ++ result); + } + + public static long getXICFocus() { +@@ -156,6 +182,74 @@ public class XInputMethod extends X11InputMethod { + return peer.getContentWindow(); + } + ++ protected int[] getOffXYRelateToFrame(ComponentPeer peer, boolean value) { ++ int[] result = null; ++ if(value && this.awtFocussedComponent!=null && this.awtFocussedComponent instanceof JTextComponent){ ++ try { ++ Method method_getFontMetrics = null; ++ Method method_getEditor = null; ++ FontMetrics font_metrics = null; ++ Object editor = null; ++ int font_height = 0; ++ int caret_x = 0; ++ int caret_y = 0; ++ if(this.awtFocussedComponent instanceof JTextArea || this.awtFocussedComponent instanceof JTextField){ ++ method_getFontMetrics = this.awtFocussedComponent.getClass().getMethod("getFontMetrics"); ++ font_metrics = (FontMetrics)method_getFontMetrics.invoke(this.awtFocussedComponent); ++ font_height = font_metrics.getHeight(); ++ JTextComponent jc = (JTextComponent)this.awtFocussedComponent; ++ if( jc.getCaret().getMagicCaretPosition() != null) { ++ caret_x = jc.getCaret().getMagicCaretPosition().x; ++ caret_y = jc.getCaret().getMagicCaretPosition().y; ++ } ++ }else { ++ method_getEditor = this.awtFocussedComponent.getClass().getMethod("getEditor"); ++ ++ editor = method_getEditor.invoke(this.awtFocussedComponent); ++ ++ method_getFontMetrics = editor.getClass().getMethod("getFontMetrics",int.class); ++ font_metrics = (FontMetrics)method_getFontMetrics.invoke(editor, 0); ++ font_height = font_metrics.getHeight(); ++ Method getCaretLocations = editor.getClass().getMethod("getCaretLocations", boolean.class); ++ Object[] locations = (Object[])getCaretLocations.invoke(editor, false); ++ Field point = locations[0].getClass().getField("myPoint"); ++ // Point2D.Double pd = (Point2D.Double)point.get(locations[0]); ++ // caret_x = (int)pd.x; ++ // caret_y = (int)pd.y; ++ Point2D pd = (Point2D)point.get(locations[0]); ++ caret_x = (int)pd.getX(); ++ caret_y = (int)pd.getY(); ++ } ++ ++ ++ Method method_getLocationOnScreen = this.awtFocussedComponent.getClass().getMethod("getLocationOnScreen"); ++ ++ Point point = (Point)method_getLocationOnScreen.invoke(this.awtFocussedComponent); ++ ++ Method method_getNativeContainer = Component.class.getDeclaredMethod("getNativeContainer"); ++ method_getNativeContainer.setAccessible(true); ++ Component c = (Component)method_getNativeContainer.invoke(awtFocussedComponent); ++ if(c!=null) ++ result = new int[]{point.x - getPeer(c).getLocationOnScreen().x + caret_x, point.y - getPeer(c).getLocationOnScreen().y + font_height + caret_y}; ++ ++ return result; ++ } catch (IllegalAccessException e) { ++ e.printStackTrace(); ++ } catch (IllegalArgumentException e) { ++ e.printStackTrace(); ++ } catch (InvocationTargetException e) { ++ e.printStackTrace(); ++ } catch (NoSuchMethodException e) { ++ e.printStackTrace(); ++ } catch (SecurityException e) { ++ e.printStackTrace(); ++ } catch(NoSuchFieldException e) { ++ e.printStackTrace(); ++ } ++ } ++ return result; ++ } ++ + /* + * Native methods + */ +@@ -164,6 +258,6 @@ public class XInputMethod extends X11InputMethod { + private native boolean recreateXICNative(long window, long px11data, int ctxid); + private native int releaseXICNative(long px11data); + private native void setXICFocusNative(long window, +- boolean value, boolean active); ++ boolean value, boolean active, int[] offxy); + private native void adjustStatusWindow(long window); + } +diff --git a/src/java.desktop/unix/classes/sun/awt/X11InputMethod.java b/src/java.desktop/unix/classes/sun/awt/X11InputMethod.java +index 18e0ba1e7e4..c56805d9b31 100644 +--- a/src/java.desktop/unix/classes/sun/awt/X11InputMethod.java ++++ b/src/java.desktop/unix/classes/sun/awt/X11InputMethod.java +@@ -33,6 +33,7 @@ import java.awt.AWTException; + import java.awt.event.InputMethodEvent; + import java.awt.font.TextAttribute; + import java.awt.font.TextHitInfo; ++import java.awt.Component; + import java.awt.peer.ComponentPeer; + import java.text.AttributedString; + import java.util.Map; +@@ -56,6 +57,10 @@ public abstract class X11InputMethod extends X11InputMethodBase { + public X11InputMethod() throws AWTException { + super(); + } ++ /** ++ * fix fcitx position ++ */ ++ public abstract void setXICTextCursorOffXY(ComponentPeer peer); + + /** + * Reset the composition state to the current composition state. +@@ -380,6 +385,30 @@ public abstract class X11InputMethod extends X11InputMethodBase { + } + } + ++ /** ++ * fix fcitx position ++ */ ++ public synchronized void setXICTextCursorPosition(Component component){ ++ if (component == null) { ++ return; ++ } ++ if (isActive) { ++ // deactivate/activate are being suppressed during a focus change - ++ // this may happen when an input method window is made visible ++ // boolean ac = haveActiveClient(); already set true in awt_InputMethod.c ++ setXICTextCursorOffXY(getPeer(awtFocussedComponent)); ++ ++ } ++ awtFocussedComponent = component; ++ // ComponentPeer lastXICFocussedComponentPeer = null; ++ // if (lastXICFocussedComponent != null) { ++ // lastXICFocussedComponentPeer = getPeer(lastXICFocussedComponent); ++ // } ++ ComponentPeer awtFocussedComponentPeer = getPeer(awtFocussedComponent); ++ if(awtFocussedComponent !=null ) ++ setXICTextCursorOffXY(awtFocussedComponentPeer); ++ } ++ + protected abstract boolean recreateXIC(int ctxid); + protected abstract int releaseXIC(); + private static native boolean recreateX11InputMethod(); +diff --git a/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c b/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c +index 5709fd59797..51fe9bc5cb9 100644 +--- a/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c ++++ b/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c +@@ -427,13 +427,17 @@ setXICFocus(XIC ic, unsigned short req) + * Sets the focus window to the given XIC. + */ + static void +-setXICWindowFocus(XIC ic, Window w) ++setXICWindowFocus(XIC ic, Window w, int arr[2]) + { + if (ic == NULL) { + (void)fprintf(stderr, "Couldn't find X Input Context\n"); + return; + } +- (void) XSetICValues(ic, XNFocusWindow, w, NULL); ++ XPoint spot; ++ spot.x = arr[0]; ++ spot.y = arr[1]; ++ XVaNestedList xy = (XVaNestedList)XVaCreateNestedList(0, XNSpotLocation, &spot, NULL); ++ (void) XSetICValues(ic, XNFocusWindow, w, XNPreeditAttributes, xy, NULL); + } + + /* +@@ -1462,7 +1466,8 @@ Java_sun_awt_X11_XInputMethod_setXICFocusNative(JNIEnv *env, + jobject this, + jlong w, + jboolean req, +- jboolean active) ++ jboolean active, ++ jintArray arr) + { + X11InputMethodData *pX11IMData; + AWT_LOCK(); +@@ -1483,7 +1488,17 @@ Java_sun_awt_X11_XInputMethod_setXICFocusNative(JNIEnv *env, + * On Solaris2.6, setXICWindowFocus() has to be invoked + * before setting focus. + */ +- setXICWindowFocus(pX11IMData->current_ic, w); ++ int positions[2] = {100,50}; ++ if (arr) ++ { ++ int length = (*env)->GetArrayLength(env,arr); ++ int *addArr = (*env)->GetIntArrayElements(env, arr, NULL); ++ for (int i= 0; i < length; ++i) { ++ positions[i] = *(addArr + i); ++ } ++ (*env)->ReleaseIntArrayElements(env, arr, addArr, 0); ++ } ++ setXICWindowFocus(pX11IMData->current_ic, w, positions); + setXICFocus(pX11IMData->current_ic, req); + currentX11InputMethodInstance = pX11IMData->x11inputmethod; + currentFocusWindow = w; diff --git a/install_jdk-jetbrains.sh b/install_jdk-jetbrains.sh new file mode 100644 index 000000000000..9ea85bc4065d --- /dev/null +++ b/install_jdk-jetbrains.sh @@ -0,0 +1,50 @@ +THIS_JDK='java-17-jetbrains' + +fix_default() { + if [ ! -x /usr/bin/java ]; then + /usr/bin/archlinux-java unset + echo "" + else + /usr/bin/archlinux-java get + fi +} + +post_install() { + default=$(fix_default) + case ${default} in + "") + /usr/bin/archlinux-java set ${THIS_JDK} + ;; + ${THIS_JDK}) + # Nothing + ;; + *) + echo "Default Java environment is already set to '${default}'" + echo "See 'archlinux-java help' to change it" + ;; + esac + + if [ ! -f /etc/ssl/certs/java/cacerts ]; then + /usr/bin/update-ca-trust + fi +} + +post_upgrade() { + default=$(fix_default) + if [ -z "${default}" ]; then + /usr/bin/archlinux-java set ${THIS_JDK} + fi + + if [ ! -f /etc/ssl/certs/java/cacerts ]; then + /usr/bin/update-ca-trust + fi +} + +pre_remove() { + if [ "x$(fix_default)" = "x${THIS_JDK}" ]; then + # Check JRE is still available + if [ -x /usr/lib/jvm/${THIS_JDK}/bin/java ]; then + /usr/bin/archlinux-java unset + fi + fi +} diff --git a/install_jre-jetbrains.sh b/install_jre-jetbrains.sh new file mode 100644 index 000000000000..dd3078a2267d --- /dev/null +++ b/install_jre-jetbrains.sh @@ -0,0 +1,48 @@ +THIS_JRE='java-17-jetbrains' + +fix_default() { + if [ ! -x /usr/bin/java ]; then + /usr/bin/archlinux-java unset + echo "" + else + /usr/bin/archlinux-java get + fi +} + +post_install() { + default=$(fix_default) + case ${default} in + "") + /usr/bin/archlinux-java set ${THIS_JRE} + ;; + ${THIS_JRE}) + # Nothing + ;; + *) + echo "Default Java environment is already set to '${default}'" + echo "See 'archlinux-java help' to change it" + ;; + esac + + if [ ! -f /etc/ssl/certs/java/cacerts ]; then + /usr/bin/update-ca-trust + fi +} + +post_upgrade() { + if [ -z "$(fix_default)" ]; then + /usr/bin/archlinux-java set ${THIS_JRE} + fi + + if [ ! -f /etc/ssl/certs/java/cacerts ]; then + /usr/bin/update-ca-trust + fi +} + +pre_remove() { + default=$(fix_default) + if [ "x${default}" = "x${THIS_JRE}" ]; then + /usr/bin/archlinux-java unset + echo "No Java environment is set as default anymore" + fi +} |