diff --git a/README.md b/README.md index 88d1e35a..10c90b03 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ Alpha. Expect API breakages. | EventWindowMinimize | ✅ | ✅ | [#96](https://github.com/HumbleUI/JWM/issues/96) | | EventWindowMaximize | ✅ | ✅ | [#96](https://github.com/HumbleUI/JWM/issues/96) | | EventWindowRestore | ✅ | ✅ | [#96](https://github.com/HumbleUI/JWM/issues/96) | -| EventWindowVisible | [#140](https://github.com/HumbleUI/JWM/issues/140) | [#140](https://github.com/HumbleUI/JWM/issues/140) | [#140](https://github.com/HumbleUI/JWM/issues/140) | +| EventWindowVisible | ✅ | [#140](https://github.com/HumbleUI/JWM/issues/140) | [#140](https://github.com/HumbleUI/JWM/issues/140) | | EventWindowScreenChange | [#117](https://github.com/HumbleUI/JWM/issues/117) | [#117](https://github.com/HumbleUI/JWM/issues/117) | [#117](https://github.com/HumbleUI/JWM/issues/117) | | EventWindowFocusIn | ✅ | ❌ | ✅ | | EventWindowFocusOut | ✅ | ❌ | ✅ | diff --git a/shared/cc/impl/Library.cc b/shared/cc/impl/Library.cc index fabcb5d1..e4357ffe 100644 --- a/shared/cc/impl/Library.cc +++ b/shared/cc/impl/Library.cc @@ -404,6 +404,30 @@ namespace jwm { } } + namespace EventWindowAppear { + jobject kInstance; + + void onLoad(JNIEnv* env) { + JNILocal cls(env, env->FindClass("io/github/humbleui/jwm/EventWindowAppear")); + Throwable::exceptionThrown(env); + jfieldID field = env->GetStaticFieldID(cls.get(), "INSTANCE", "Lio/github/humbleui/jwm/EventWindowAppear;"); + jobject instance = env->GetStaticObjectField(cls.get(), field); + kInstance = env->NewGlobalRef(instance); + } + } + + namespace EventWindowDisappear { + jobject kInstance; + + void onLoad(JNIEnv* env) { + JNILocal cls(env, env->FindClass("io/github/humbleui/jwm/EventWindowDisappear")); + Throwable::exceptionThrown(env); + jfieldID field = env->GetStaticFieldID(cls.get(), "INSTANCE", "Lio/github/humbleui/jwm/EventWindowDisappear;"); + jobject instance = env->GetStaticObjectField(cls.get(), field); + kInstance = env->NewGlobalRef(instance); + } + } + namespace EventWindowMove { jclass kCls; jmethodID kCtor; @@ -571,6 +595,8 @@ extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_impl_Library__1nAf jwm::classes::EventWindowMinimize::onLoad(env); jwm::classes::EventWindowFocusIn::onLoad(env); jwm::classes::EventWindowFocusOut::onLoad(env); + jwm::classes::EventWindowAppear::onLoad(env); + jwm::classes::EventWindowDisappear::onLoad(env); jwm::classes::EventWindowMove::onLoad(env); jwm::classes::EventWindowResize::onLoad(env); jwm::classes::EventWindowRestore::onLoad(env); diff --git a/shared/cc/impl/Library.hh b/shared/cc/impl/Library.hh index e14578a3..b07a8f31 100644 --- a/shared/cc/impl/Library.hh +++ b/shared/cc/impl/Library.hh @@ -139,6 +139,14 @@ namespace jwm { extern jobject kInstance; } + namespace EventWindowAppear { + extern jobject kInstance; + } + + namespace EventWindowDisappear { + extern jobject kInstance; + } + namespace EventWindowMove { extern jclass kCls; extern jmethodID kCtor; diff --git a/shared/java/EventWindowAppear.java b/shared/java/EventWindowAppear.java new file mode 100644 index 00000000..ab3628eb --- /dev/null +++ b/shared/java/EventWindowAppear.java @@ -0,0 +1,8 @@ +package io.github.humbleui.jwm; + +import lombok.Data; + +@Data +public class EventWindowAppear implements Event { + public static final EventWindowAppear INSTANCE = new EventWindowAppear(); +} diff --git a/shared/java/EventWindowDisappear.java b/shared/java/EventWindowDisappear.java new file mode 100644 index 00000000..7dfe4beb --- /dev/null +++ b/shared/java/EventWindowDisappear.java @@ -0,0 +1,8 @@ +package io.github.humbleui.jwm; + +import lombok.Data; + +@Data +public class EventWindowDisappear implements Event { + public static final EventWindowDisappear INSTANCE = new EventWindowDisappear(); +} diff --git a/windows/cc/WindowWin32.cc b/windows/cc/WindowWin32.cc index 607b47f7..e94f5da6 100644 --- a/windows/cc/WindowWin32.cc +++ b/windows/cc/WindowWin32.cc @@ -1,23 +1,20 @@ -#include -#include #include -#include -#include #include #include #include -#include #include +#include +#include +#include +#include +#include #include -jwm::WindowWin32::WindowWin32(JNIEnv *env, class WindowManagerWin32 &windowManagerWin32) - : Window(env), _windowManager(windowManagerWin32) { - -} +jwm::WindowWin32::WindowWin32(JNIEnv* env, + class WindowManagerWin32& windowManagerWin32) + : Window(env), _windowManager(windowManagerWin32) {} -jwm::WindowWin32::~WindowWin32() { - _close(); -} +jwm::WindowWin32::~WindowWin32() { _close(); } bool jwm::WindowWin32::init() { int x = CW_USEDEFAULT; @@ -57,8 +54,7 @@ void jwm::WindowWin32::setImeEnabled(bool enabled) { // Re-enabled Windows IME by associating default context. ImmAssociateContextEx(getHWnd(), nullptr, IACE_DEFAULT); JWM_VERBOSE("Enable ime text input") - } - else { + } else { // Disable Windows IME by associating 0 context. ImmAssociateContext(getHWnd(), nullptr); JWM_VERBOSE("Disable ime text input"); @@ -72,8 +68,10 @@ void jwm::WindowWin32::setTitle(const std::wstring& title) { void jwm::WindowWin32::setIcon(const std::wstring& iconPath) { JWM_VERBOSE("Set window icon '" << iconPath << "'"); - // width / height of 0 along with LR_DEFAULTSIZE tells windows to load the default icon size. - HICON hicon = (HICON)LoadImage(NULL, iconPath.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE); + // width / height of 0 along with LR_DEFAULTSIZE tells windows to load the + // default icon size. + HICON hicon = (HICON)LoadImage(NULL, iconPath.c_str(), IMAGE_ICON, 0, 0, + LR_LOADFROMFILE | LR_DEFAULTSIZE); SendMessage(_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hicon); } @@ -83,8 +81,7 @@ void jwm::WindowWin32::setOpacity(float opacity) { float lower = 0.0; float upper = 1.0; float clamped = std::max(lower, std::min(opacity, upper)); - if (clamped == 1.0) - { + if (clamped == 1.0) { LONG reset = previousStyle & ~WS_EX_LAYERED; SetWindowLongPtr(_hWnd, GWL_EXSTYLE, reset); return; @@ -98,12 +95,12 @@ void jwm::WindowWin32::setOpacity(float opacity) { float jwm::WindowWin32::getOpacity() { BYTE alpha; DWORD flags = LWA_ALPHA; - BOOL hasOpacity = GetLayeredWindowAttributes(_hWnd, nullptr, &alpha, &flags); - // GetLayeredWindowAttributes can be invoked iff the application - // has previously called SetLayeredWindowAttributes on the window. + BOOL hasOpacity = + GetLayeredWindowAttributes(_hWnd, nullptr, &alpha, &flags); + // GetLayeredWindowAttributes can be invoked iff the application + // has previously called SetLayeredWindowAttributes on the window. // Otherwise it returns false as failure. - if (!hasOpacity) - { + if (!hasOpacity) { return 1.0; } return static_cast(alpha / 255.0); @@ -154,7 +151,7 @@ void jwm::WindowWin32::setMouseCursor(MouseCursor cursor) { void jwm::WindowWin32::setVisible(bool value) { JWM_VERBOSE("Set visible=" << value << " for window 0x" << this); - ShowWindow(_hWnd, value? SW_SHOWNA: SW_HIDE); + ShowWindow(_hWnd, value ? SW_SHOWNA : SW_HIDE); } void jwm::WindowWin32::maximize() { @@ -203,50 +200,50 @@ jwm::IRect jwm::WindowWin32::getContentRect() const { GetWindowRect(_hWnd, &windowRect); // Convert client area rect to screen space and - POINT corners[] = {POINT{clientRect.left, clientRect.top}, POINT{clientRect.right, clientRect.bottom}}; - MapWindowPoints(getHWnd(), nullptr, corners, sizeof(corners)/sizeof(corners[0])); + POINT corners[] = {POINT{clientRect.left, clientRect.top}, + POINT{clientRect.right, clientRect.bottom}}; + MapWindowPoints(getHWnd(), nullptr, corners, + sizeof(corners) / sizeof(corners[0])); POINT leftTop = corners[0]; POINT rightBottom = corners[1]; - // Build rect with client area rect relative to the window rect to handle title bar + // Build rect with client area rect relative to the window rect to handle + // title bar return IRect{leftTop.x - windowRect.left, leftTop.y - windowRect.top, - rightBottom.x - windowRect.left, rightBottom.y - windowRect.top}; + rightBottom.x - windowRect.left, + rightBottom.y - windowRect.top}; } void jwm::WindowWin32::setWindowPosition(int left, int top) { JWM_VERBOSE("Set window position left=" << left << " top=" << top); - SetWindowPos(_hWnd, nullptr, - left, top, - 0, 0, + SetWindowPos(_hWnd, nullptr, left, top, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE); } void jwm::WindowWin32::setWindowSize(int width, int height) { JWM_VERBOSE("Set window size w=" << width << " h=" << height); - SetWindowPos(_hWnd, HWND_TOP, - 0, 0, - width, - height, - SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOZORDER); + SetWindowPos( + _hWnd, HWND_TOP, 0, 0, width, height, + SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOZORDER); } void jwm::WindowWin32::setContentSize(int width, int height) { RECT rect{0, 0, width, height}; - AdjustWindowRectEx(&rect, _getWindowStyle(), - FALSE, _getWindowExStyle()); + AdjustWindowRectEx(&rect, _getWindowStyle(), FALSE, _getWindowExStyle()); - JWM_VERBOSE("Set content size " << "w=" << width << " h=" << height << " " - << "(adjusted window size" << " w=" << rect.right - rect.left << " h=" << rect.bottom - rect.top << ")"); + JWM_VERBOSE("Set content size " + << "w=" << width << " h=" << height << " " + << "(adjusted window size" + << " w=" << rect.right - rect.left + << " h=" << rect.bottom - rect.top << ")"); - SetWindowPos(_hWnd, HWND_TOP, - 0, 0, - rect.right - rect.left, - rect.bottom - rect.top, - SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOZORDER); + SetWindowPos( + _hWnd, HWND_TOP, 0, 0, rect.right - rect.left, rect.bottom - rect.top, + SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOZORDER); } jwm::ScreenWin32 jwm::WindowWin32::getScreen() const { @@ -254,11 +251,10 @@ jwm::ScreenWin32 jwm::WindowWin32::getScreen() const { return ScreenWin32::fromHMonitor(hMonitor); } -void jwm::WindowWin32::close() { - _close(); -} +void jwm::WindowWin32::close() { _close(); } -LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) { +LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, + LPARAM lParam) { // https://github.com/chromium/chromium/blob/72ceeed2ebcd505b8d8205ed7354e862b871995e/ui/events/blink/web_input_event_builders_win.cc#L331 static const float kScrollbarPixelsPerLine = 100.0f / 3.0f; @@ -270,10 +266,11 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) notifyEvent(Event::SwitchContext); switch (uMsg) { - // HACK: Set timer to get JWM_WM_TIMER_UPDATE_EVENT event. - // When user hold mouse button and drag window, app enter modal loop, - // animation is stopped. This hack allows us to get JWM_WM_TIMER_UPDATE_EVENT - // event with minimum possible delay to repaint window and animate it. + // HACK: Set timer to get JWM_WM_TIMER_UPDATE_EVENT event. + // When user hold mouse button and drag window, app enter modal + // loop, animation is stopped. This hack allows us to get + // JWM_WM_TIMER_UPDATE_EVENT event with minimum possible delay to + // repaint window and animate it. case WM_ENTERSIZEMOVE: setFlag(Flag::EnterSizeMove); @@ -294,36 +291,40 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) bool minimized = wParam == SIZE_MINIMIZED; bool maximized = wParam == SIZE_MAXIMIZED; - bool restored = wParam == SIZE_RESTORED && (_maximized || _minimized); + bool restored = + wParam == SIZE_RESTORED && (_maximized || _minimized); _maximized = maximized; _minimized = minimized; - JWM_VERBOSE("Size event (min="<< minimized << ", max="<< maximized << ", res=" << restored << ") " - << "window w=" << windowWidth << " h=" << windowHeight << " " - << "content w=" << contentWidth << " h=" << contentHeight); - - if (minimized) - dispatch(classes::EventWindowMinimize::kInstance); - if (maximized) - dispatch(classes::EventWindowMaximize::kInstance); - if (restored) - dispatch(classes::EventWindowRestore::kInstance); - - JNILocal eventWindowResize(env, classes::EventWindowResize::make(env, windowWidth, windowHeight, - contentWidth, contentHeight)); + JWM_VERBOSE("Size event (min=" << minimized << ", max=" << maximized + << ", res=" << restored << ") " + << "window w=" << windowWidth + << " h=" << windowHeight << " " + << "content w=" << contentWidth + << " h=" << contentHeight); + + if (minimized) dispatch(classes::EventWindowMinimize::kInstance); + if (maximized) dispatch(classes::EventWindowMaximize::kInstance); + if (restored) dispatch(classes::EventWindowRestore::kInstance); + + JNILocal eventWindowResize( + env, + classes::EventWindowResize::make(env, windowWidth, windowHeight, + contentWidth, contentHeight)); dispatch(eventWindowResize.get()); return 0; } case WM_MOVE: { IRect rect = getWindowRect(); - int windowLeft= rect.fLeft; + int windowLeft = rect.fLeft; int windowTop = rect.fTop; JWM_VERBOSE("Move event left=" << windowLeft << " top" << windowTop) - JNILocal eventMove(env, classes::EventWindowMove::make(env, windowLeft, windowTop)); + JNILocal eventMove(env, classes::EventWindowMove::make( + env, windowLeft, windowTop)); dispatch(eventMove.get()); return 0; } @@ -333,9 +334,10 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_TIMER: { if (wParam == JWM_WM_TIMER_UPDATE_EVENT) { - // HACK: modal event loop on move/resize for focus window blocks background windows. - // Therefore they are freeze. Here we can receive update event inside modal loop - // to get chance to process frame event and etc. + // HACK: modal event loop on move/resize for focus window blocks + // background windows. Therefore they are freeze. Here we can + // receive update event inside modal loop to get chance to + // process frame event and etc. _windowManager.timerUpdate(); } @@ -360,7 +362,9 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) int buttons = _getMouseButtons(); int modifiers = _getModifiers(); - JNILocal eventMouseMove(env, classes::EventMouseMove::make(env, xPos, yPos, buttons, modifiers)); + JNILocal eventMouseMove( + env, classes::EventMouseMove::make(env, xPos, yPos, buttons, + modifiers)); dispatch(eventMouseMove.get()); return 0; } @@ -368,18 +372,25 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_MOUSEWHEEL: { int modifiers = _getModifiers(); auto nativeScroll = static_cast(HIWORD(wParam)); - auto ticks = static_cast(nativeScroll) / static_cast(WHEEL_DELTA); + auto ticks = static_cast(nativeScroll) / + static_cast(WHEEL_DELTA); auto linesPerTick = _getWheelScrollLines(); // assume page scroll // https://github.com/mozilla/gecko-dev/blob/da97cbad6c9f00fc596253feb5964a8adbb45d9e/widget/windows/WinMouseScrollHandler.cpp#L891-L903 if (linesPerTick > WHEEL_DELTA) { - float sign = ticks > 0.0f ? 1.0f : ticks < 0.0f ? -1.0f : 0.0f; - JNILocal eventMouseScroll(env, classes::EventMouseScroll::make(env, 0.0f, getContentRect().getHeight() * sign, 0.0f, 0.0f, sign, modifiers)); + float sign = ticks > 0.0f ? 1.0f : ticks < 0.0f ? -1.0f : 0.0f; + JNILocal eventMouseScroll( + env, classes::EventMouseScroll::make( + env, 0.0f, getContentRect().getHeight() * sign, + 0.0f, 0.0f, sign, modifiers)); dispatch(eventMouseScroll.get()); } else { auto lines = ticks * static_cast(_getWheelScrollLines()); auto scale = _getScale(); - JNILocal eventMouseScroll(env, classes::EventMouseScroll::make(env, 0.0f, lines * kScrollbarPixelsPerLine * scale, 0.0f, lines, 0.0f, modifiers)); + JNILocal eventMouseScroll( + env, classes::EventMouseScroll::make( + env, 0.0f, lines * kScrollbarPixelsPerLine * scale, + 0.0f, lines, 0.0f, modifiers)); dispatch(eventMouseScroll.get()); } return 0; @@ -387,11 +398,15 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_MOUSEHWHEEL: { auto nativeScroll = static_cast(HIWORD(wParam)); - auto ticks = static_cast(nativeScroll) / static_cast(WHEEL_DELTA); + auto ticks = static_cast(nativeScroll) / + static_cast(WHEEL_DELTA); auto chars = ticks * static_cast(_getWheelScrollChars()); auto scale = _getScale(); int modifiers = _getModifiers(); - JNILocal eventMouseScroll(env, classes::EventMouseScroll::make(env, chars * kScrollbarPixelsPerLine * scale, 0.0f, chars, 0.0f, 0.0f, modifiers)); + JNILocal eventMouseScroll( + env, classes::EventMouseScroll::make( + env, chars * kScrollbarPixelsPerLine * scale, 0.0f, + chars, 0.0f, 0.0f, modifiers)); dispatch(eventMouseScroll.get()); return 0; } @@ -413,11 +428,8 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_RBUTTONUP: case WM_MBUTTONUP: case WM_XBUTTONUP: { - bool isPressed = - uMsg == WM_LBUTTONDOWN || - uMsg == WM_RBUTTONDOWN || - uMsg == WM_MBUTTONDOWN || - uMsg == WM_XBUTTONDOWN; + bool isPressed = uMsg == WM_LBUTTONDOWN || uMsg == WM_RBUTTONDOWN || + uMsg == WM_MBUTTONDOWN || uMsg == WM_XBUTTONDOWN; int modifiers = _getModifiers(); MouseButton button; @@ -433,7 +445,9 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) else button = MouseButton::FORWARD; - JNILocal eventMouseButton(env, classes::EventMouseButton::make(env, button, isPressed, modifiers)); + JNILocal eventMouseButton( + env, classes::EventMouseButton::make(env, button, isPressed, + modifiers)); dispatch(eventMouseButton.get()); break; } @@ -447,7 +461,7 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) WORD flags = HIWORD(lParam); bool isPressed = !(flags & KF_UP); bool isExtended = flags & KF_EXTENDED; - int keycode = (int) wParam; + int keycode = (int)wParam; int scancode = (HIWORD(lParam) & (KF_EXTENDED | 0xff)); int modifiers = _getModifiers(); auto& table = _windowManager.getKeyTable(); @@ -457,21 +471,23 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) JWM_VERBOSE("Keycode=" << keycode << " scancode=" << scancode); // Ignore system keys (unknown on java side) - if (ignoreList.find(keycode) != ignoreList.end()) - break; + if (ignoreList.find(keycode) != ignoreList.end()) break; auto mapping = table.find(keycode); - Key key = mapping != table.end()? mapping->second: Key::UNDEFINED; + Key key = mapping != table.end() ? mapping->second : Key::UNDEFINED; KeyLocation location = KeyLocation::DEFAULT; // Right/numpad keys location handling - if (isExtended || scancode == MapVirtualKeyW(VK_RSHIFT, MAPVK_VK_TO_VSC)) { + if (isExtended || + scancode == MapVirtualKeyW(VK_RSHIFT, MAPVK_VK_TO_VSC)) { auto locationMapping = locations.find(keycode); if (locationMapping != locations.end()) location = locationMapping->second; } - JNILocal eventKey(env, classes::EventKey::make(env, key, isPressed, modifiers, location)); + JNILocal eventKey( + env, classes::EventKey::make(env, key, isPressed, modifiers, + location)); dispatch(eventKey.get()); break; } @@ -480,8 +496,7 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_SYSCHAR: { if (HIGH_SURROGATE_L <= wParam && wParam <= HIGH_SURROGATE_U) { _highSurrogate = static_cast(wParam); - } - else { + } else { jsize len = 0; jchar text[2]; int modifiers = _getModifiers(); @@ -497,8 +512,7 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) text[len] = _highSurrogate; len += 1; } - } - else if (wParam == VK_BACK) { + } else if (wParam == VK_BACK) { break; } @@ -508,12 +522,12 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) len += 1; JNILocal jtext(env, env->NewString(text, len)); - JNILocal eventTextInput(env, classes::EventTextInput::make(env, jtext.get())); + JNILocal eventTextInput( + env, classes::EventTextInput::make(env, jtext.get())); dispatch(eventTextInput.get()); } - if (uMsg == WM_SYSCHAR) - break; + if (uMsg == WM_SYSCHAR) break; return 0; } @@ -535,49 +549,58 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) HIMC hImc = ImmGetContext(getHWnd()); - if (!hImc) - return false; + if (!hImc) return false; if (iParam & (GCS_COMPSTR | GCS_COMPATTR | GCS_CURSORPOS)) { // Read partial composition result - // NOTE: accessible in WM_IME_COMPOSITION or WM_IME_STARTCOMPOSITION message. - _compositionStr = std::move(_imeGetCompositionString(hImc, GCS_COMPSTR)); - _compositionPos = ImmGetCompositionStringW(hImc, GCS_CURSORPOS, nullptr, 0); + // NOTE: accessible in WM_IME_COMPOSITION or + // WM_IME_STARTCOMPOSITION message. + _compositionStr = + std::move(_imeGetCompositionString(hImc, GCS_COMPSTR)); + _compositionPos = + ImmGetCompositionStringW(hImc, GCS_CURSORPOS, nullptr, 0); int selectedFrom, selectedTo; - _imeGetCompositionStringConvertedRange(hImc, selectedFrom, selectedTo); + _imeGetCompositionStringConvertedRange(hImc, selectedFrom, + selectedTo); if ((lParam & CS_INSERTCHAR) && (lParam & CS_NOMOVECARET)) { selectedFrom = 0; selectedTo = static_cast(_compositionStr.length()); } - if (!selectedTo) - selectedFrom = 0; + if (!selectedTo) selectedFrom = 0; if (!selectedFrom && !selectedTo) { selectedFrom = _compositionPos; selectedTo = static_cast(_compositionStr.length()); } - auto jcharText = reinterpret_cast(_compositionStr.c_str()); + auto jcharText = + reinterpret_cast(_compositionStr.c_str()); auto jlength = static_cast(_compositionStr.length()); JNILocal text(env, env->NewString(jcharText, jlength)); - JNILocal eventTextInputMarked(env, classes::EventTextInputMarked::make(env, text.get(), selectedFrom, selectedTo)); + JNILocal eventTextInputMarked( + env, classes::EventTextInputMarked::make( + env, text.get(), selectedFrom, selectedTo)); dispatch(eventTextInputMarked.get()); } if (iParam & (GCS_RESULTSTR)) { // If composition result, we must read its result string here. - // NOTE: accessible in WM_IME_COMPOSITION or WM_IME_STARTCOMPOSITION message. - _compositionStr = std::move(_imeGetCompositionString(hImc, GCS_RESULTSTR)); + // NOTE: accessible in WM_IME_COMPOSITION or + // WM_IME_STARTCOMPOSITION message. + _compositionStr = + std::move(_imeGetCompositionString(hImc, GCS_RESULTSTR)); - auto jcharText = reinterpret_cast(_compositionStr.c_str()); + auto jcharText = + reinterpret_cast(_compositionStr.c_str()); auto jlength = static_cast(_compositionStr.length()); JNILocal text(env, env->NewString(jcharText, jlength)); - JNILocal eventTextInput(env, classes::EventTextInput::make(env, text.get())); + JNILocal eventTextInput( + env, classes::EventTextInput::make(env, text.get())); dispatch(eventTextInput.get()); } @@ -592,9 +615,11 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) _compositionStr.resize(0); _compositionPos = 0; - // Send commit message. This is required, for example if user suddenly closes ime window + // Send commit message. This is required, for example if user + // suddenly closes ime window JNILocal text(env, env->NewString(nullptr, 0)); - JNILocal eventTextInput(env, classes::EventTextInput::make(env, text.get())); + JNILocal eventTextInput( + env, classes::EventTextInput::make(env, text.get())); dispatch(eventTextInput.get()); break; } @@ -604,16 +629,17 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) IRect IRect{}; // If no text client set, simply break - if (!_imeGetRectForMarkedRange(IRect)) - break; + if (!_imeGetRectForMarkedRange(IRect)) break; - // Cursor upper left corner (doc requires baseline, but its enough) + // Cursor upper left corner (doc requires baseline, but its + // enough) POINT cursorPos; cursorPos.x = IRect.fLeft; cursorPos.y = IRect.fTop; ClientToScreen(getHWnd(), &cursorPos); - // Area of the window (interpreted as document area (where we can place ime window)) + // Area of the window (interpreted as document area (where we + // can place ime window)) RECT documentArea; GetWindowRect(getHWnd(), &documentArea); @@ -627,6 +653,14 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) return true; } break; + case WM_SHOWWINDOW: + JWM_VERBOSE("On window visibility change"); + if (wParam == TRUE) { + dispatch(classes::EventWindowAppear::kInstance); + } else { + dispatch(classes::EventWindowDisappear::kInstance); + } + return 0; case WM_SETFOCUS: JWM_VERBOSE("ON FOCUS"); dispatch(classes::EventWindowFocusIn::kInstance); @@ -636,7 +670,6 @@ LRESULT jwm::WindowWin32::processEvent(UINT uMsg, WPARAM wParam, LPARAM lParam) dispatch(classes::EventWindowFocusOut::kInstance); break; - case WM_CLOSE: JWM_VERBOSE("Event close"); dispatch(classes::EventWindowCloseRequest::kInstance); @@ -666,17 +699,14 @@ void jwm::WindowWin32::removeEventListener(int callbackID) { } void jwm::WindowWin32::notifyEvent(Event event) { - for (auto& entry: _eventListeners) - entry.second(event); + for (auto& entry : _eventListeners) entry.second(event); } DWORD jwm::WindowWin32::_getWindowStyle() const { return WS_OVERLAPPEDWINDOW | WS_CAPTION | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; } -DWORD jwm::WindowWin32::_getWindowExStyle() const { - return 0; -} +DWORD jwm::WindowWin32::_getWindowExStyle() const { return 0; } UINT jwm::WindowWin32::_getWheelScrollLines() const { UINT numLines; @@ -696,7 +726,7 @@ float jwm::WindowWin32::_getScale() const { GetScaleFactorForMonitor(hMonitor, &scaleFactor); if (scaleFactor == DEVICE_SCALE_FACTOR_INVALID) scaleFactor = JWM_DEFAULT_DEVICE_SCALE; - return (float) scaleFactor / 100.0f; + return (float)scaleFactor / 100.0f; } int jwm::WindowWin32::_getModifiers() const { @@ -738,9 +768,7 @@ int jwm::WindowWin32::_getMouseButtons() const { return buttons; } -int jwm::WindowWin32::_getNextCallbackID() { - return _nextCallbackID++; -} +int jwm::WindowWin32::_getNextCallbackID() { return _nextCallbackID++; } void jwm::WindowWin32::_setFrameTimer() { SetTimer(_hWnd, JWM_WM_TIMER_UPDATE_EVENT, USER_TIMER_MINIMUM, nullptr); @@ -750,7 +778,8 @@ void jwm::WindowWin32::_killFrameTimer() { KillTimer(_hWnd, JWM_WM_TIMER_UPDATE_EVENT); } -bool jwm::WindowWin32::_createInternal(int x, int y, int w, int h, const wchar_t *caption) { +bool jwm::WindowWin32::_createInternal(int x, int y, int w, int h, + const wchar_t* caption) { DWORD style = _getWindowStyle(); DWORD exStyle = _getWindowExStyle(); @@ -759,18 +788,9 @@ bool jwm::WindowWin32::_createInternal(int x, int y, int w, int h, const wchar_t HINSTANCE hInstance = GetModuleHandle(nullptr); LPVOID lpParam = nullptr; - _hWnd = CreateWindowExW( - exStyle, - JWM_WIN32_WINDOW_CLASS_NAME, - caption, - style, - x, y, - w, h, - hWndParent, - hMenu, - hInstance, - lpParam - ); + _hWnd = + CreateWindowExW(exStyle, JWM_WIN32_WINDOW_CLASS_NAME, caption, style, x, + y, w, h, hWndParent, hMenu, hInstance, lpParam); if (!_hWnd) { JWM_LOG("Failed to init WindowWin32"); @@ -781,7 +801,7 @@ bool jwm::WindowWin32::_createInternal(int x, int y, int w, int h, const wchar_t SetPropW(_hWnd, L"JWM", this); // Set default mouse cursor - _hDefaultMouseCursor = LoadCursorW(nullptr,IDC_ARROW); + _hDefaultMouseCursor = LoadCursorW(nullptr, IDC_ARROW); // Register window, so manager can process its update _windowManager._registerWindow(*this); @@ -819,7 +839,7 @@ void jwm::WindowWin32::_close() { } void jwm::WindowWin32::_setMouseCursorInternal() { - if(_hMouseCursor == nullptr) { + if (_hMouseCursor == nullptr) { SetCursor(_hDefaultMouseCursor); } else { SetCursor(_hMouseCursor); @@ -829,8 +849,7 @@ void jwm::WindowWin32::_setMouseCursorInternal() { void jwm::WindowWin32::_imeResetComposition() { HIMC hImc = ImmGetContext(getHWnd()); - if (!hImc) - return; + if (!hImc) return; ImmNotifyIME(hImc, NI_COMPOSITIONSTR, CPS_CANCEL, 0); ImmReleaseContext(getHWnd(), hImc); @@ -843,13 +862,11 @@ void jwm::WindowWin32::_imeChangeCursorPos() const { IRect IRect{}; // If no text client set, simply break - if (!_imeGetRectForMarkedRange(IRect)) - return; + if (!_imeGetRectForMarkedRange(IRect)) return; HIMC hImc = ImmGetContext(getHWnd()); - if (!hImc) - return; + if (!hImc) return; COMPOSITIONFORM compositionform; compositionform.dwStyle = CFS_FORCE_POSITION; @@ -859,7 +876,8 @@ void jwm::WindowWin32::_imeChangeCursorPos() const { CANDIDATEFORM candidateform; candidateform.dwIndex = 0; candidateform.dwStyle = CFS_EXCLUDE; - candidateform.ptCurrentPos.x = IRect.fLeft;; + candidateform.ptCurrentPos.x = IRect.fLeft; + ; candidateform.ptCurrentPos.y = IRect.fTop; candidateform.rcArea.left = IRect.fLeft; candidateform.rcArea.top = IRect.fTop; @@ -871,7 +889,8 @@ void jwm::WindowWin32::_imeChangeCursorPos() const { ImmReleaseContext(getHWnd(), hImc); } -void jwm::WindowWin32::_imeGetCompositionStringConvertedRange(HIMC hImc, int &selFrom, int &selTo) const { +void jwm::WindowWin32::_imeGetCompositionStringConvertedRange( + HIMC hImc, int& selFrom, int& selTo) const { selFrom = selTo = 0; // Size in bytes without terminating null character @@ -883,13 +902,15 @@ void jwm::WindowWin32::_imeGetCompositionStringConvertedRange(HIMC hImc, int &se int start = 0; - while (start < static_cast(sizeBytes) && !(buffer[start] & ATTR_TARGET_CONVERTED)) + while (start < static_cast(sizeBytes) && + !(buffer[start] & ATTR_TARGET_CONVERTED)) start += 1; if (start < static_cast(sizeBytes)) { int end = start + 1; - while (end < static_cast(sizeBytes) && (buffer[end] & ATTR_TARGET_CONVERTED)) + while (end < static_cast(sizeBytes) && + (buffer[end] & ATTR_TARGET_CONVERTED)) end += 1; selFrom = start; @@ -898,7 +919,7 @@ void jwm::WindowWin32::_imeGetCompositionStringConvertedRange(HIMC hImc, int &se } } -bool jwm::WindowWin32::_imeGetRectForMarkedRange(IRect &rect) const { +bool jwm::WindowWin32::_imeGetRectForMarkedRange(IRect& rect) const { // Query current cursor position // If composition starts, Pos will be always 0 auto selectionStart = static_cast(_compositionPos); @@ -906,7 +927,8 @@ bool jwm::WindowWin32::_imeGetRectForMarkedRange(IRect &rect) const { return getRectForMarkedRange(selectionStart, selectionEnd, rect); } -std::wstring jwm::WindowWin32::_imeGetCompositionString(HIMC hImc, DWORD compType) const { +std::wstring jwm::WindowWin32::_imeGetCompositionString(HIMC hImc, + DWORD compType) const { // Size in bytes without terminating null character DWORD sizeBytes = ImmGetCompositionStringW(hImc, compType, nullptr, 0); @@ -914,7 +936,8 @@ std::wstring jwm::WindowWin32::_imeGetCompositionString(HIMC hImc, DWORD compTyp // Get actual string and copy into tmp buffer std::unique_ptr buffer{new uint8_t[sizeBytes]}; ImmGetCompositionStringW(hImc, compType, buffer.get(), sizeBytes); - return std::wstring(reinterpret_cast(buffer.get()), sizeBytes / sizeof(wchar_t)); + return std::wstring(reinterpret_cast(buffer.get()), + sizeBytes / sizeof(wchar_t)); } return std::wstring(); @@ -922,145 +945,191 @@ std::wstring jwm::WindowWin32::_imeGetCompositionString(HIMC hImc, DWORD compTyp // JNI -extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nMake - (JNIEnv* env, jclass jclass) { - std::unique_ptr instance(new jwm::WindowWin32(env, jwm::AppWin32::getInstance().getWindowManager())); +extern "C" JNIEXPORT jlong JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nMake(JNIEnv* env, jclass jclass) { + std::unique_ptr instance(new jwm::WindowWin32( + env, jwm::AppWin32::getInstance().getWindowManager())); if (instance->init()) return reinterpret_cast(instance.release()); else return 0; } -extern "C" JNIEXPORT jobject JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nSetTextInputEnabled - (JNIEnv* env, jobject obj, jboolean enabled) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT jobject JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nSetTextInputEnabled( + JNIEnv* env, jobject obj, jboolean enabled) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); instance->setImeEnabled(enabled); return obj; } -extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nUnmarkText - (JNIEnv* env, jobject obj) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT void JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nUnmarkText(JNIEnv* env, + jobject obj) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); instance->unmarkText(); } -extern "C" JNIEXPORT jobject JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nGetWindowRect - (JNIEnv* env, jobject obj) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT jobject JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nGetWindowRect(JNIEnv* env, + jobject obj) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); jwm::IRect rect = instance->getWindowRect(); return jwm::classes::IRect::toJava(env, rect); } -extern "C" JNIEXPORT jobject JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nGetContentRect - (JNIEnv* env, jobject obj) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT jobject JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nGetContentRect(JNIEnv* env, + jobject obj) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); jwm::IRect rect = instance->getContentRect(); return jwm::classes::IRect::toJava(env, rect); } -extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nSetWindowPosition - (JNIEnv* env, jobject obj, int left, int top) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT void JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nSetWindowPosition(JNIEnv* env, + jobject obj, + int left, + int top) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); instance->setWindowPosition(left, top); } -extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nSetWindowSize - (JNIEnv* env, jobject obj, int width, int height) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT void JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nSetWindowSize(JNIEnv* env, + jobject obj, int width, + int height) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); instance->setWindowSize(width, height); } -extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nSetContentSize - (JNIEnv* env, jobject obj, int width, int height) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT void JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nSetContentSize(JNIEnv* env, + jobject obj, + int width, + int height) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); instance->setContentSize(width, height); } -extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nSetTitle - (JNIEnv* env, jobject obj, jstring title) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT void JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nSetTitle(JNIEnv* env, jobject obj, + jstring title) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); const jchar* titleStr = env->GetStringChars(title, nullptr); jsize length = env->GetStringLength(title); - instance->setTitle(std::wstring(reinterpret_cast(titleStr), length)); + instance->setTitle( + std::wstring(reinterpret_cast(titleStr), length)); env->ReleaseStringChars(title, titleStr); } -extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nSetIcon - (JNIEnv* env, jobject obj, jstring iconPath) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT void JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nSetIcon(JNIEnv* env, jobject obj, + jstring iconPath) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); const jchar* iconPathStr = env->GetStringChars(iconPath, nullptr); jsize length = env->GetStringLength(iconPath); - instance->setIcon(std::wstring(reinterpret_cast(iconPathStr), length)); + instance->setIcon( + std::wstring(reinterpret_cast(iconPathStr), length)); env->ReleaseStringChars(iconPath, iconPathStr); } -extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nSetVisible - (JNIEnv* env, jobject obj, jboolean isVisible) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT void JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nSetVisible(JNIEnv* env, jobject obj, + jboolean isVisible) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); instance->setVisible(isVisible); } -extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nSetOpacity - (JNIEnv* env, jobject obj,float opacity) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT void JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nSetOpacity(JNIEnv* env, jobject obj, + float opacity) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); instance->setOpacity(opacity); } -extern "C" JNIEXPORT float JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nGetOpacity - (JNIEnv* env, jobject obj) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT float JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nGetOpacity(JNIEnv* env, + jobject obj) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); return instance->getOpacity(); } -extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nSetMouseCursor - (JNIEnv* env, jobject obj, jint cursorId) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT void JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nSetMouseCursor(JNIEnv* env, + jobject obj, + jint cursorId) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); instance->setMouseCursor(static_cast(cursorId)); } -extern "C" JNIEXPORT jobject JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nGetScreen - (JNIEnv* env, jobject obj) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT jobject JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nGetScreen(JNIEnv* env, jobject obj) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); jwm::ScreenWin32 screen = instance->getScreen(); return screen.toJni(env); } -extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nRequestFrame - (JNIEnv* env, jobject obj) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT void JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nRequestFrame(JNIEnv* env, + jobject obj) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); instance->requestFrame(); } -extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nMaximize - (JNIEnv* env, jobject obj) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT void JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nMaximize(JNIEnv* env, jobject obj) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); instance->maximize(); } -extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nMinimize - (JNIEnv* env, jobject obj) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT void JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nMinimize(JNIEnv* env, jobject obj) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); instance->minimize(); } -extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nRestore - (JNIEnv* env, jobject obj) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT void JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nRestore(JNIEnv* env, jobject obj) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); instance->restore(); } -extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nFocus - (JNIEnv* env, jobject obj) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT void JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nFocus(JNIEnv* env, jobject obj) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); instance->focus(); } -extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nClose - (JNIEnv* env, jobject obj) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); +extern "C" JNIEXPORT void JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nClose(JNIEnv* env, jobject obj) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); instance->close(); } -extern "C" JNIEXPORT void JNICALL Java_io_github_humbleui_jwm_WindowWin32__1nWinSetParent - (JNIEnv* env, jobject obj, jlong hwnd) { - jwm::WindowWin32* instance = reinterpret_cast(jwm::classes::Native::fromJava(env, obj)); - SetParent(instance->getHWnd(), (HWND) hwnd); +extern "C" JNIEXPORT void JNICALL +Java_io_github_humbleui_jwm_WindowWin32__1nWinSetParent(JNIEnv* env, + jobject obj, + jlong hwnd) { + jwm::WindowWin32* instance = reinterpret_cast( + jwm::classes::Native::fromJava(env, obj)); + SetParent(instance->getHWnd(), (HWND)hwnd); }