Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move away from "Monocle" in favor of "Headless" #1225

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: [ubuntu-latest]
strategy:
matrix:
java: [11, 17]
java: [21]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
Expand All @@ -24,7 +24,7 @@ jobs:
runs-on: [macos-latest]
strategy:
matrix:
java: [11, 17]
java: [21]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
Expand All @@ -47,7 +47,7 @@ jobs:
runs-on: [windows-latest]
strategy:
matrix:
java: [11, 17]
java: [21]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
Expand Down
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/App.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions ant/javafx.xml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,28 @@
</not>
</condition>

<!-- FIXME:
- Temporary johan mirror URL
- x86_64 only
- Experimental "headless" build which no longer requires "monocle"
-->

<property name="headless.version" value="22"/>
<!-- FIXME: Ideally, these should all match -->
<condition property="headless.patch" value="312">
<equals arg1="${fx.os}" arg2="linux"/>
</condition>
<condition property="headless.patch" value="313">
<equals arg1="${fx.os}" arg2="mac"/>
</condition>
<property description="fallback value" name="headless.patch" value="314"/>

<property name="headless.base" value="https://download2.gluonhq.com/openjfx/forks/johan/headless"/>

<condition property="fx.url" value="${headless.base}/openjfx-${headless.version}+${headless.patch}_headless_${fx.os}-${fx.arch}_bin-sdk.zip">
<equals arg1="${fx.arch}" arg2="x86_64"/>
</condition>

<property name="fx.url" value="${javafx.mirror}/${fx.majver}/openjfx-${fx.urlver}-${fx.os.fixed}-${fx.arch.fixed}_bin-sdk.zip"/>
<property name="fx.zip" value="${out.dir}/${fx.id}.zip"/>

Expand Down
1 change: 1 addition & 0 deletions ant/linux/installer.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<project name="linux-installer" basedir="../../">
<property file="ant/project.properties"/>
<property file="ant/linux/linux.properties"/>
<import file="${basedir}/ant/version.xml"/>
<import file="${basedir}/ant/platform-detect.xml"/>

Expand Down
2 changes: 2 additions & 0 deletions ant/linux/linux.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Expose UNIXToolkit.getGtkVersion
linux.launch.jigsaw=--add-opens java.desktop/sun.awt=ALL-UNNAMED
10 changes: 5 additions & 5 deletions ant/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ jar.index=true
separate.static.libs=true

# See also qz.common.Constants.java
javac.source=1.8
javac.target=1.8
javac.source=11
javac.target=21
java.download=https://bell-sw.com/pages/downloads/#/java-11-lts

# Java vendor to bundle into software (e.g. "*BellSoft|Adoptium|Microsoft|Amazon|IBM")
jlink.java.vendor="BellSoft"
# Java vendor to bundle into software (e.g. "11.0.17+7")
jlink.java.version="11.0.20.1+1"
# Java vendor to bundle into software (e.g. "21.0.1+12")
jlink.java.version="21.0.1+12"
# Java garbage collector flavor to use (e.g. "hotspot|openj9")
jlink.java.gc="hotspot"
# Java garbage collector version to use (e.g. openj9: "0.35.0", zulu: "11.62.17")
Expand All @@ -48,7 +48,7 @@ jlink.java.gc.version="gc-ver-is-empty"
# jre.skip=true

# JavaFX version
javafx.version=19_monocle
javafx.version=21_monocle
javafx.mirror=https://download2.gluonhq.com/openjfx

# Mask tray toggle (Apple only)
Expand Down
2 changes: 2 additions & 0 deletions ant/unix/unix-launcher.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ else
LAUNCH_OPTS="$LAUNCH_OPTS ${launch.jigsaw}"
if [[ "$OSTYPE" == "darwin"* ]]; then
LAUNCH_OPTS="$LAUNCH_OPTS ${apple.launch.jigsaw}"
else
LAUNCH_OPTS="$LAUNCH_OPTS ${linux.launch.jigsaw}"
fi
fi

Expand Down
6 changes: 5 additions & 1 deletion src/qz/build/JLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ private JLink deployJre() throws IOException {
Files.copy(jmodsPath.resolve("../../MacOS/libjli.dylib").normalize(), jliLib, StandardCopyOption.REPLACE_EXISTING);
} catch(IOException ignore) {
// Fallback to flat format
Files.copy(jmodsPath.resolve("../lib/jli/libjli.dylib").normalize(), jliLib, StandardCopyOption.REPLACE_EXISTING);
String libjli = "../lib/jli/libjli.dylib";
if(javaSemver.getMajorVersion() >= 21) {
libjli = "../lib/libjli.dylib";
}
Files.copy(jmodsPath.resolve(libjli).normalize(), jliLib, StandardCopyOption.REPLACE_EXISTING);
}

// Deploy Contents/Info.plist
Expand Down
6 changes: 3 additions & 3 deletions src/qz/common/TrayManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,10 @@ private void addMenuItems() {
monocleItem.setToolTipText("Use monocle platform for HTML printing (restart required)");
monocleItem.setMnemonic(KeyEvent.VK_U);
monocleItem.setState(getPref(TRAY_MONOCLE));
if(!SystemUtilities.hasMonocle()) {
log.warn("Monocle engine was not detected");
if(Constants.JAVA_VERSION.getMajorVersion() <= 8) {
log.warn("Monocle engine is not available for this Java version");
monocleItem.setEnabled(false);
monocleItem.setToolTipText("Monocle HTML engine was not detected");
monocleItem.setToolTipText("Monocle HTML engine is not available.");
}
monocleItem.addActionListener(monocleListener);

Expand Down
18 changes: 2 additions & 16 deletions src/qz/printer/action/html/WebApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,23 +181,9 @@ public static synchronized void initialize() throws IOException {
// Fallback for JDK11+
headless = true;
}
if (useMonocle && SystemUtilities.hasMonocle()) {
if (useMonocle) {
log.trace("Initializing monocle platform");
System.setProperty("javafx.platform", "monocle");
// Don't set glass.platform on Linux per https://github.com/qzind/tray/issues/702
switch(SystemUtilities.getOsType()) {
case WINDOWS:
case MAC:
System.setProperty("glass.platform", "Monocle");
break;
default:
// don't set "glass.platform"
}

//software rendering required headless environments
if (headless) {
System.setProperty("prism.order", "sw");
}
System.setProperty("glass.platform", "Headless");
} else {
log.warn("Monocle platform will not be used");
}
Expand Down
13 changes: 0 additions & 13 deletions src/qz/utils/SystemUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public class SystemUtilities {

private static Boolean darkDesktop;
private static Boolean darkTaskbar;
private static Boolean hasMonocle;
private static String classProtocol;
private static Version osVersion;
private static String osName;
Expand Down Expand Up @@ -691,18 +690,6 @@ public static boolean isJDK() {
return false;
}

public static boolean hasMonocle() {
if(hasMonocle == null) {
try {
Class.forName("com.sun.glass.ui.monocle.MonoclePlatformFactory");
hasMonocle = true;
} catch (ClassNotFoundException | UnsupportedClassVersionError e) {
hasMonocle = false;
}
}
return hasMonocle;
}

public static final Version[] JDK_8266929_VERSIONS = {
Version.valueOf("11.0.11"),
Version.valueOf("1.8.0+291"),
Expand Down
3 changes: 2 additions & 1 deletion test/qz/printer/action/WebAppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ private static WebAppModel buildModel(String index, double width, double height,
}

private static PrinterJob buildVectorJob(String name) throws Throwable {
Printer defaultPrinter = Printer.getDefaultPrinter();
// Get "PDF" printer
Printer defaultPrinter = Printer.getAllPrinters().stream().filter(printer -> printer.getName().contains("PDF")).findFirst().get();
PrinterJob job = PrinterJob.createPrinterJob(defaultPrinter);

// All this to remove margins
Expand Down