Skip to content

Commit

Permalink
Conditional jigsaw flags support (qzind#826)
Browse files Browse the repository at this point in the history
Conditional jigsaw flags support
Closes qzind#824
  • Loading branch information
tresf authored Jun 22, 2021
1 parent 04b2d6e commit aca87ff
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 5 deletions.
10 changes: 10 additions & 0 deletions .idea/runConfigurations/PrintSocketServer.xml

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

4 changes: 4 additions & 0 deletions ant/apple/apple.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# Apple build properties
apple.packager.signid=P5DMU6659X
# jdk9+ flags
# - Tray icon requires workaround https://github.com/dyorgio/macos-tray-icon-fixer/issues/9
# - Dark theme requires workaround https://github.com/bobbylight/Darcula/issues/8
apple.launch.jigsaw=--add-opens java.desktop/sun.lwawt.macosx=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-exports java.desktop/com.apple.laf=ALL-UNNAMED
4 changes: 3 additions & 1 deletion ant/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ project.datadir=qz

install.opts=-Djna.nosys=true
launch.opts=-Xms512m ${install.opts}
launch.jigsaw=--add-opens java.desktop/sun.lwawt.macosx=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED
# jdk9+ flags
# - Dark theme requires workaround https://github.com/bobbylight/Darcula/issues/8
launch.jigsaw=--add-exports java.desktop/sun.swing=ALL-UNNAMED
launch.overrides=QZ_OPTS

src.dir=${basedir}/src
Expand Down
3 changes: 3 additions & 0 deletions ant/unix/unix-launcher.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ if [ "$jigsaw" != "$actual" ]; then
else
echo -e "$SUCCESS Java >= 9.0, adding jigsaw options"
LAUNCH_OPTS="$LAUNCH_OPTS ${launch.jigsaw}"
if [[ "$OSTYPE" == "darwin"* ]]; then
LAUNCH_OPTS="$LAUNCH_OPTS ${apple.launch.jigsaw}"
fi
fi

if command -v java &>/dev/null; then
Expand Down
18 changes: 18 additions & 0 deletions ant/windows/nsis/Include/FindJava.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

!include StrRep.nsh
!include IndexOf.nsh
!include StrTok.nsh

; Resulting variable
Var /GLOBAL java
Var /GLOBAL javaw
Var /GLOBAL java_major

; Constants
!define EXE "java.exe"
Expand Down Expand Up @@ -80,6 +82,22 @@ Var /GLOBAL javaw
StrCpy $java $0
${StrRep} '$java' '$java' 'javaw.exe' '${EXE}' ; AdoptOpenJDK returns "javaw.exe"
${StrRep} '$javaw' '$java' '${EXE}' 'javaw.exe'

; Detect java version
nsExec::ExecToStack '"$java" -version'
Pop $0
Pop $1
; Isolate version number, e.g. "1.8.0"
${StrTok} $0 "$1" "$\"" "1" "1"
; Isolate major version
${StrTok} $R0 "$0" "." "0" "1"
; Handle old 1.x.x version format
${If} "$R0" == "1"
${StrTok} $R0 "$0" "." "1" "1"
${EndIf}

; Convert to integer
IntOp $java_major $R0 + 0
FunctionEnd
!macroend

Expand Down
150 changes: 150 additions & 0 deletions ant/windows/nsis/Include/StrTok.nsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
!define StrTok "!insertmacro StrTok"

!macro StrTok ResultVar String Separators ResultPart SkipEmptyParts
Push "${String}"
Push "${Separators}"
Push "${ResultPart}"
Push "${SkipEmptyParts}"
Call StrTok
Pop "${ResultVar}"
!macroend

Function StrTok
/*After this point:
------------------------------------------
$0 = SkipEmptyParts (input)
$1 = ResultPart (input)
$2 = Separators (input)
$3 = String (input)
$4 = SeparatorsLen (temp)
$5 = StrLen (temp)
$6 = StartCharPos (temp)
$7 = TempStr (temp)
$8 = CurrentLoop
$9 = CurrentSepChar
$R0 = CurrentSepCharNum
*/

;Get input from user
Exch $0
Exch
Exch $1
Exch
Exch 2
Exch $2
Exch 2
Exch 3
Exch $3
Exch 3
Push $4
Push $5
Push $6
Push $7
Push $8
Push $9
Push $R0

;Parameter defaults
${IfThen} $2 == `` ${|} StrCpy $2 `|` ${|}
${IfThen} $1 == `` ${|} StrCpy $1 `L` ${|}
${IfThen} $0 == `` ${|} StrCpy $0 `0` ${|}

;Get "String" and "Separators" length
StrLen $4 $2
StrLen $5 $3
;Start "StartCharPos" and "ResultPart" counters
StrCpy $6 0
StrCpy $8 -1

;Loop until "ResultPart" is met, "Separators" is found or
;"String" reaches its end
ResultPartLoop: ;"CurrentLoop" Loop

;Increase "CurrentLoop" counter
IntOp $8 $8 + 1

StrSearchLoop:
${Do} ;"String" Loop
;Remove everything before and after the searched part ("TempStr")
StrCpy $7 $3 1 $6

;Verify if it's the "String" end
${If} $6 >= $5
;If "CurrentLoop" is what the user wants, remove the part
;after "TempStr" and itself and get out of here
${If} $8 == $1
${OrIf} $1 == `L`
StrCpy $3 $3 $6
${Else} ;If not, empty "String" and get out of here
StrCpy $3 ``
${EndIf}
StrCpy $R0 `End`
${ExitDo}
${EndIf}

;Start "CurrentSepCharNum" counter (for "Separators" Loop)
StrCpy $R0 0

${Do} ;"Separators" Loop
;Use one "Separators" character at a time
${If} $R0 <> 0
StrCpy $9 $2 1 $R0
${Else}
StrCpy $9 $2 1
${EndIf}

;Go to the next "String" char if it's "Separators" end
${IfThen} $R0 >= $4 ${|} ${ExitDo} ${|}

;Or, if "TempStr" equals "CurrentSepChar", then...
${If} $7 == $9
StrCpy $7 $3 $6

;If "String" is empty because this result part doesn't
;contain data, verify if "SkipEmptyParts" is activated,
;so we don't return the output to user yet

${If} $7 == ``
${AndIf} $0 = 1 ;${TRUE}
IntOp $6 $6 + 1
StrCpy $3 $3 `` $6
StrCpy $6 0
Goto StrSearchLoop
${ElseIf} $8 == $1
StrCpy $3 $3 $6
StrCpy $R0 "End"
${ExitDo}
${EndIf} ;If not, go to the next result part
IntOp $6 $6 + 1
StrCpy $3 $3 `` $6
StrCpy $6 0
Goto ResultPartLoop
${EndIf}

;Increase "CurrentSepCharNum" counter
IntOp $R0 $R0 + 1
${Loop}
${IfThen} $R0 == "End" ${|} ${ExitDo} ${|}

;Increase "StartCharPos" counter
IntOp $6 $6 + 1
${Loop}

/*After this point:
------------------------------------------
$3 = ResultVar (output)*/

;Return output to user

Pop $R0
Pop $9
Pop $8
Pop $7
Pop $6
Pop $5
Pop $4
Pop $0
Pop $1
Pop $2
Exch $3
FunctionEnd
4 changes: 4 additions & 0 deletions ant/windows/windows-launcher.nsi.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Section

Var /GLOBAL opts
StrCpy $opts "${launch.opts}"
; Handle jdk9+ flags
${If} $java_major >= 9
StrCpy $opts "${launch.opts} ${launch.jigsaw}"
${EndIf}

; Check for user overridable launch options
ClearErrors
Expand Down
4 changes: 0 additions & 4 deletions src/qz/utils/SystemUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,6 @@ public static boolean setSystemLookAndFeel() {
if(!isMac() && (isUnix() && UbuntuUtilities.isDarkMode())) {
darculaThemeNeeded = false;
}
// Disable darcula on JDK16+ per https://github.com/bobbylight/Darcula/issues/8
if(Constants.JAVA_VERSION.greaterThanOrEqualTo(Version.valueOf("16.0.0"))) {
darculaThemeNeeded = false;
}
if(isDarkDesktop() && darculaThemeNeeded) {
UIManager.setLookAndFeel("com.bulenkov.darcula.DarculaLaf");
} else {
Expand Down

0 comments on commit aca87ff

Please sign in to comment.