-
Notifications
You must be signed in to change notification settings - Fork 40
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
Theme preference support on macOS. #127
Conversation
c0f1bd4
to
89b3c86
Compare
89b3c86
to
776b8ff
Compare
d606481
to
2898b63
Compare
@vlsi What settings are there on macOS for changing font sizes. Apparently there is only a choice between standard medium and large text size (only for retina displays). Am I missing something here? |
I'm having trouble finding how to listen to changes for settings on macOS. For example in the documentation of @vlsi Could you run this snippet to see what values appear? Specifically we're looking for changes to the text scaling, dark mode and high contrast mode. |
In practice, I need to figure out the syntax because |
@interface Tst:NSObject {
}
@end
@implementation Tst
-(id)init {
NSDistributedNotificationCenter *center = [NSDistributedNotificationCenter defaultCenter];
NSLog(@"Adding observer to: %@", center);
[center addObserver:self
selector:@selector(notificationEvent:)
name:nil
object:nil];
return self;
}
-(void)notificationEvent:(NSNotification *)notif {
NSLog(@"Notification: %@", notif);
}
@end JNIEXPORT void JNICALL
Java_com_github_weisj_darklaf_platform_macos_JNIDecorationsMacOS_setTitleEnabled(JNIEnv *env, jclass obj, jlong hwnd,
jboolean enabled) {
JNF_COCOA_ENTER(env);
NSLog(@"init");
Tst *tst = [[Tst alloc]init];
NSLog(@"init: %@", tst);
produce the following: dark-light theme change:
accent color change:
switch to "bigger font resolution":
activate "inverted screen colors" (in light theme):
deactivate "inverted screen colors" (in light theme):
|
universal access - increase contrast
|
Thank you very much! Do these names correspond to any named notifications? Or at least: Is |
I guess AXInterfaceIncreaseContrastStatusDidChange corresponds to https://developer.apple.com/documentation/appkit/nsworkspace/1534227-accessibilitydisplayoptionsdidch However, I guess the ids can be coded as string literals. |
Yes that would probably work.
Ok so I guess it has nothing to do with the current state. |
29e0321
to
fed32f2
Compare
Frankly speaking, I've no idea. We should probably find someone with 10.15 :) (I've not updated yet :) )
I do not see UI for adjusting text scaling. Only "resolution". NSDefaults has the following fonts, however, I don't think they are user-changeable.
|
Ok I have implemented the notification listener for dark mode and adjusted the function for checking dark mode. // Does it return the correct value?
JNIThemeInfoMacOS.isDarkThemeEnabled();
// Should be != 0 and a creation message is logged. After creation changes in dark mode should be printed:
long listenerPtr = JNIThemeInfoMacOS.createPreferenceChangeListener();
// A message should be logged that the listener was destroyed:
JNIThemeInfoMacOS.deletePreferenceChangeListener(listenerPtr); |
Definitely needed 👍 If we don't find anyone maybe a github actions script could work (macOS-latest should run on 10.15)
Too bad. Could it be that if the font size is increased [NSFont systemFontSize] simply returns a larger value? |
It does not. The values are the same no matter if I increase or decrease "font size". The font size is adjusted for each monitor individually, so the "font size" is probably reported for each monitor individually as well. |
What exactly does the Btw. If bigger text ist selected does the titlebar still have the correct size (as the window buttons get scaled too)? |
It scales everything. Controls, buttons to close Windows, Swing applications, etc, etc. |
Oh so I guess the setting can simply ignored then? As there is no other system setting for font size I’d just always return the default font size on macOS. As for the other settings:
|
That is indeed handled by OS. I just mean there might be a case for adjusting colors for a better look with inverted colors. I guess "inverting" colors might make contrast worse.
Well, it can probably be ignored, for now, however, it might be a case for "css-like" themes. |
For now I'll not handle this situation. I guess it's rather specific case.
I was thinking of having themes specify two list of colours that are subject to "personalization". These colours could then be hue matched with the current system colours. I think this would be the easiest solution that works in a more cross-platform way (i.e. themes don't have to specify all accent/selection values in multiple colours. For example IntelliJ theme would need to specify 19 different values for all macOS colours) that allows basically all available colours (especially because that is the case for text selection on macOS.) I'll try it out and post some screenshots of how it looks with the macOS colours. |
I guess this could also be done on windows using the accent colour. Though there should probably be a setting to ignore the accent colour (which would also stop it from firing theme preference change events) as there are a lot more accents to choose from some of which might not look that good with some themes (there is no way to guarantee it for arbitrary accents). In this case a program using darklaf should offer the user to select a custom accent colour or use the default accent colour (provided by the theme). I think that accent colours should also be a feature that is disabled by default and has to be explicitly enabled (I'm not quite certain about how and what part exactly i.e. the system accent isn't taken into consideration or accents are ignored altogether). High contrast theme should always ignore these settings as it doesn't make much sense there. |
7163826
to
900a683
Compare
631eb8d
to
dbdb944
Compare
Apparently |
dbdb944
to
f71ed1c
Compare
@vlsi The selection colour should now actually change |
f71ed1c
to
9b12768
Compare
Looks like the check for |
If there are no more objections I’d merge this PR. |
No description provided.