Skip to content

Commit

Permalink
0.4.5 App::openSymbolsPalette
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsky committed Aug 13, 2022
1 parent 8767c48 commit 612dea3
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 9 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# 0.4.5 - Aug 13, 2022

Added:

- macOS: App::openSymbolsPalette
- X11: Window::setTitleBarVisible #235 via @mgxm

Fixed:

- X11: Fixed mouse scroll amount #236
- macOS: Fix cursor resetting to arrow #234 via @LuisThiamNye

# 0.4.4 - June 23, 2022

Added:
Expand Down
8 changes: 8 additions & 0 deletions examples/dashboard/java/PanelTextInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ else if (!ee.isPressed())
}
}
}
case SPACE -> {
if (Platform.CURRENT == Platform.MACOS
&& ee.isModifierDown(KeyModifier.CONTROL)
&& ee.isModifierDown(KeyModifier.MAC_COMMAND))
{
App.openSymbolsPalette();
}
}
}

if (ee.isModifierDown(Example.MODIFIER)) {
Expand Down
6 changes: 6 additions & 0 deletions macos/cc/App.mm
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,9 @@
std::cerr << "Failed to AttachCurrentThread: " << ret << std::endl;
});
}

extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_App__1nOpenSymbolsPalette
(JNIEnv* env, jclass cls) {
NSApplication* app = [NSApplication sharedApplication];
[app orderFrontCharacterPalette:nil];
}
8 changes: 4 additions & 4 deletions macos/cc/WindowMac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
}

extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowMac__1nSetFullSizeContentView
(JNIEnv* env, jobject obj, jboolean value) {
(JNIEnv* env, jobject obj, jboolean value) {
jwm::WindowMac* instance = reinterpret_cast<jwm::WindowMac*>(jwm::classes::Native::fromJava(env, obj));
NSWindow* nsWindow = instance->fNSWindow;

Expand All @@ -346,7 +346,7 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt

#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowMac__1nSetTitlebarStyle
(JNIEnv* env, jobject obj, jint titlebarStyle) {
(JNIEnv* env, jobject obj, jint titlebarStyle) {
if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_15) {
jwm::classes::Throwable::throwRuntimeException(env, "WindowMac::setSubtitle is only available on macOS 11+");
return;
Expand Down Expand Up @@ -377,7 +377,7 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
#endif

extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowMac__1nSetTrafficLightPosition
(JNIEnv* env, jobject obj, jint left, jint top) {
(JNIEnv* env, jobject obj, jint left, jint top) {
jwm::WindowMac* instance = reinterpret_cast<jwm::WindowMac*>(jwm::classes::Native::fromJava(env, obj));
NSWindow* nsWindow = instance->fNSWindow;

Expand Down Expand Up @@ -418,7 +418,7 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
}

extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowMac__1nSetTrafficLightsVisible
(JNIEnv* env, jobject obj, jboolean value) {
(JNIEnv* env, jobject obj, jboolean value) {
jwm::WindowMac* instance = reinterpret_cast<jwm::WindowMac*>(jwm::classes::Native::fromJava(env, obj));
NSWindow* nsWindow = instance->fNSWindow;

Expand Down
9 changes: 4 additions & 5 deletions macos/java/WindowMac.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,37 +126,36 @@ public Window setTitlebarVisible(boolean isVisible) {
return this;
}

@NotNull @Contract("-> this")
@NotNull @Contract("_ -> this")
public WindowMac setFullSizeContentView(boolean isFullSizeContentView) {
assert _onUIThread();
_nSetFullSizeContentView(isFullSizeContentView);
accept(new EventWindowResize(this));
return this;
}

@NotNull @Contract("-> this")
@NotNull @Contract("_, -> this")
public WindowMac setTitlebarStyle(WindowMacTitlebarStyle titlebarStyle) {
assert _onUIThread();
_nSetTitlebarStyle(titlebarStyle.ordinal());
accept(new EventWindowResize(this));
return this;
}

@NotNull @Contract("-> this")
@NotNull @Contract("_, _ -> this")
public WindowMac setTrafficLightPosition(int left, int top) {
assert _onUIThread();
_nSetTrafficLightPosition(left, top);
return this;
}

@NotNull @Contract("-> this")
@NotNull @Contract("_ -> this")
public WindowMac setTrafficLightsVisible(boolean isVisible) {
assert _onUIThread();
_nSetTrafficLightsVisible(isVisible);
return this;
}


@ApiStatus.Internal @Override
public native void _nSetMouseCursor(int cursorIdx);

Expand Down
9 changes: 9 additions & 0 deletions shared/java/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ public static Screen getPrimaryScreen() {
throw new IllegalStateException("Can't find primary screen");
}

public static void openSymbolsPalette() {
assert _onUIThread();
if (Platform.CURRENT == Platform.MACOS)
_nOpenSymbolsPalette();
else
throw new RuntimeException("Not supported on " + Platform.CURRENT);
}

@ApiStatus.Internal public static boolean _onUIThread() {
return _uiThreadId == Thread.currentThread().getId();
}
Expand All @@ -111,4 +119,5 @@ public static Screen getPrimaryScreen() {
@ApiStatus.Internal public static native void _nTerminate();
@ApiStatus.Internal public static native Screen[] _nGetScreens();
@ApiStatus.Internal public static native void _nRunOnUIThread(Runnable callback);
@ApiStatus.Internal public static native void _nOpenSymbolsPalette();
}

0 comments on commit 612dea3

Please sign in to comment.