Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mstr2 committed Oct 18, 2024
1 parent 13630a3 commit 2063df3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,19 @@ public NonClientHandler getNonClientHandler() {
};
}

private native boolean _isRightToLeftLayoutDirection();

private ObservableValue<WindowOverlayMetrics> windowOverlayMetrics;

@Override
public ObservableValue<WindowOverlayMetrics> windowOverlayMetrics() {
if (windowOverlayMetrics == null) {
HorizontalDirection direction = _isRightToLeftLayoutDirection()
? HorizontalDirection.RIGHT
: HorizontalDirection.LEFT;

windowOverlayMetrics = ObjectConstant.valueOf(
new WindowOverlayMetrics(HorizontalDirection.LEFT, new Dimension2D(78, 38)));
new WindowOverlayMetrics(direction, new Dimension2D(78, 38)));
}

return windowOverlayMetrics;
Expand Down
27 changes: 26 additions & 1 deletion modules/javafx.graphics/src/main/native-glass/mac/GlassWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -1500,4 +1500,29 @@ static jlong _createWindowCommonDo(JNIEnv *env, jobject jWindow, jlong jOwnerPtr
}
GLASS_POOL_EXIT;
GLASS_CHECK_EXCEPTION(env);
}
}

/*
* Class: com_sun_glass_ui_mac_MacWindow
* Method: _isRightToLeftLayoutDirection
* Signature: ()Z;
*/
JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_mac_MacWindow__1isRightToLeftLayoutDirection
(JNIEnv *env, jobject self)
{
LOG("Java_com_sun_glass_ui_mac_MacWindow__1isRightToLeftLayoutDirection");
jboolean result = false;

GLASS_ASSERT_MAIN_JAVA_THREAD(env);
GLASS_POOL_ENTER;
{
NSString* preferredLanguage = [[NSLocale preferredLanguages] objectAtIndex:0];
NSLocale* locale = [NSLocale localeWithLocaleIdentifier:preferredLanguage];
NSString* languageCode = [locale objectForKey:NSLocaleLanguageCode];
result = [NSLocale characterDirectionForLanguage:languageCode] == NSLocaleLanguageDirectionRightToLeft;
}
GLASS_POOL_EXIT;
GLASS_CHECK_EXCEPTION(env);

return result;
}

0 comments on commit 2063df3

Please sign in to comment.