-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
204 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
macos/src/main/java/com/github/weisj/darklaf/platform/macos/JNIThemeInfoMacOS.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Jannis Weis | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package com.github.weisj.darklaf.platform.macos; | ||
|
||
public class JNIThemeInfoMacOS { | ||
|
||
public static native boolean isDarkThemeEnabled(); | ||
|
||
public static native boolean isHighContrastEnabled(); | ||
|
||
public static native long getFontScaleFactor(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
macos/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSLibrary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Jannis Weis | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package com.github.weisj.darklaf.platform.macos; | ||
|
||
import com.github.weisj.darklaf.platform.NativeUtil; | ||
import com.github.weisj.darklaf.util.SystemInfo; | ||
|
||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
|
||
public class MacOSLibrary { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(MacOSLibrary.class.getName()); | ||
private static boolean loaded; | ||
private static boolean attemptedLoad; | ||
|
||
/** | ||
* Load the decorations-library if necessary. | ||
*/ | ||
public static void updateLibrary() { | ||
if (!loaded && !attemptedLoad) { | ||
loadLibrary(); | ||
} | ||
} | ||
|
||
private static void loadLibrary() { | ||
attemptedLoad = true; | ||
if (!SystemInfo.isMac || loaded) { | ||
return; | ||
} | ||
try { | ||
if (SystemInfo.isX64) { | ||
NativeUtil.loadLibraryFromJar( | ||
"/com/github/weisj/darklaf/platform/darklaf-macos/macos-x86-64/libdarklaf-macos.dylib"); | ||
loaded = true; | ||
LOGGER.info("Loaded libdarklaf-macos.dylib. Decorations are enabled."); | ||
} else { | ||
LOGGER.warning("JRE model '" | ||
+ SystemInfo.jreArchitecture | ||
+ "' not supported. Decorations will be disabled"); | ||
} | ||
} catch (Throwable e) { | ||
//Library not found, SecurityManager prevents library loading etc. | ||
LOGGER.log(Level.SEVERE, "Could not load decorations library libdarklaf-macos.dylib." + | ||
" Decorations will be disabled", e); | ||
} | ||
} | ||
|
||
public static boolean isLoaded() { | ||
return loaded; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...s/src/main/java/com/github/weisj/darklaf/platform/macos/MacOSThemePreferenceProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Jannis Weis | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package com.github.weisj.darklaf.platform.macos; | ||
|
||
import com.github.weisj.darklaf.theme.info.ColorToneRule; | ||
import com.github.weisj.darklaf.theme.info.ContrastRule; | ||
import com.github.weisj.darklaf.theme.info.PreferredThemeStyle; | ||
import com.github.weisj.darklaf.theme.info.ThemePreferenceProvider; | ||
|
||
public class MacOSThemePreferenceProvider implements ThemePreferenceProvider { | ||
|
||
private final PreferredThemeStyle fallbackStyle = new PreferredThemeStyle(ContrastRule.STANDARD, | ||
ColorToneRule.LIGHT); | ||
|
||
@Override | ||
public PreferredThemeStyle getPreference() { | ||
if (!MacOSLibrary.isLoaded()) return fallbackStyle; | ||
return new PreferredThemeStyle(); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
MacOSLibrary.updateLibrary(); | ||
} | ||
|
||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Jannis Weis | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
#import "com_github_weisj_darklaf_platform_macos_JNIThemeInfoMacOS.h" | ||
#import <AppKit/AppKit.h> | ||
|
||
JNIEXPORT jboolean JNICALL | ||
Java_com_github_weisj_darklaf_platform_macos_JNIThemeInfoMacOS_isDarkThemeEnabled(JNIEnv *env, jclass obj) { | ||
return false; | ||
} | ||
|
||
JNIEXPORT jboolean JNICALL | ||
Java_com_github_weisj_darklaf_platform_macos_JNIThemeInfoMacOS_isHighContrastEnabled(JNIEnv *env, jclass obj) { | ||
return [NSWorkspace accessibilityDisplayShouldIncreaseContrast];; | ||
} | ||
|
||
JNIEXPORT jlong JNICALL | ||
Java_com_github_weisj_darklaf_platform_macos_JNIThemeInfoMacOS_getFontScaleFactor(JNIEnv *env, jclass obj) { | ||
return 100; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters