--- old/modules/graphics/src/main/java/com/sun/glass/ui/Window.java 2013-09-03 18:06:33.000000000 +0400 +++ new/modules/graphics/src/main/java/com/sun/glass/ui/Window.java 2013-09-03 18:06:33.000000000 +0400 @@ -288,6 +288,17 @@ } } + private boolean cursorUpdateEnabled = true; + + public void setUpdatesCursor(boolean updatesCursor) { + cursorUpdateEnabled = updatesCursor; + _setUpdatesCursor(this.ptr, updatesCursor); + } + + protected void _setUpdatesCursor(long ptr, boolean updatesCursor) { + // The native field should be set only on Windows + } + protected abstract boolean _close(long ptr); public void close() { Application.checkEventThread(); @@ -1021,7 +1032,9 @@ */ public void setCursor(Cursor cursor) { Application.checkEventThread(); - _setCursor(this.ptr, cursor); + if (cursorUpdateEnabled) { + _setCursor(this.ptr, cursor); + } } protected abstract void _toFront(long ptr); --- old/modules/graphics/src/main/java/com/sun/glass/ui/win/WinWindow.java 2013-09-03 18:06:34.000000000 +0400 +++ new/modules/graphics/src/main/java/com/sun/glass/ui/win/WinWindow.java 2013-09-03 18:06:34.000000000 +0400 @@ -79,6 +79,7 @@ @Override native protected int _getEmbeddedX(long ptr); @Override native protected int _getEmbeddedY(long ptr); @Override native protected void _setCursor(long ptr, Cursor cursor); + @Override native protected void _setUpdatesCursor(long prt, boolean updatesCursor); @Override protected void _requestInput(long ptr, String text, int type, double width, double height, --- old/modules/graphics/src/main/java/com/sun/javafx/tk/TKStage.java 2013-09-03 18:06:35.000000000 +0400 +++ new/modules/graphics/src/main/java/com/sun/javafx/tk/TKStage.java 2013-09-03 18:06:35.000000000 +0400 @@ -116,6 +116,8 @@ public void setFullScreen(boolean fullScreen); + public void setUpdatesCursor(boolean updatesCursor); + // ================================================================================================================= // Functions --- old/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedStage.java 2013-09-03 18:06:36.000000000 +0400 +++ new/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedStage.java 2013-09-03 18:06:36.000000000 +0400 @@ -148,6 +148,14 @@ } @Override + public void setUpdatesCursor(boolean updatesCursor) { + if (QuantumToolkit.verbose) { + // Not implemented + System.err.println("EmbeddedStage.setUpdatesCursor " + updatesCursor); + } + } + + @Override public void requestFocus() { if (!host.requestFocus()) { return; --- old/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java 2013-09-03 18:06:37.000000000 +0400 +++ new/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java 2013-09-03 18:06:36.000000000 +0400 @@ -403,6 +403,10 @@ platformWindow.setTitle(title); } + @Override public void setUpdatesCursor(boolean updatesCursor) { + platformWindow.setUpdatesCursor(updatesCursor); + } + @Override public void setVisible(final boolean visible) { // Before setting visible to false on the native window, we unblock // other windows. --- old/modules/graphics/src/main/native-glass/win/BaseWnd.cpp 2013-09-03 18:06:37.000000000 +0400 +++ new/modules/graphics/src/main/native-glass/win/BaseWnd.cpp 2013-09-03 18:06:37.000000000 +0400 @@ -39,7 +39,8 @@ m_ancestor(ancestor), m_wndClassAtom(0), m_isCommonDialogOwner(false), - m_hCursor(NULL) + m_hCursor(NULL), + m_updatesCursor(true) { } @@ -177,7 +178,9 @@ switch (msg) { case WM_SETCURSOR: if (LOWORD(lParam) == HTCLIENT) { - ::SetCursor(m_hCursor); + if (m_updatesCursor) { + ::SetCursor(m_hCursor); + } return TRUE; } break; @@ -197,3 +200,8 @@ ::SetCursor(m_hCursor); } +void BaseWnd::SetUpdatesCursor(bool updatesCursor) +{ + m_updatesCursor = updatesCursor; +} + --- old/modules/graphics/src/main/native-glass/win/BaseWnd.h 2013-09-03 18:06:38.000000000 +0400 +++ new/modules/graphics/src/main/native-glass/win/BaseWnd.h 2013-09-03 18:06:38.000000000 +0400 @@ -66,6 +66,7 @@ void SetCommonDialogOwner(bool owner) { m_isCommonDialogOwner = owner; } void SetCursor(HCURSOR cursor); + void SetUpdatesCursor(bool updatesCursor); private: HWND m_hWnd; @@ -78,6 +79,7 @@ ATOM m_wndClassAtom; bool m_isCommonDialogOwner; HCURSOR m_hCursor; + bool m_updatesCursor; protected: virtual LRESULT WindowProc(UINT msg, WPARAM wParam, LPARAM lParam) = 0; virtual MessageResult CommonWindowProc(UINT msg, WPARAM wParam, LPARAM lParam); --- old/modules/graphics/src/main/native-glass/win/GlassWindow.cpp 2013-09-03 18:06:39.000000000 +0400 +++ new/modules/graphics/src/main/native-glass/win/GlassWindow.cpp 2013-09-03 18:06:39.000000000 +0400 @@ -1754,4 +1754,21 @@ PERFORM(); } +JNIEXPORT void JNICALL Java_com_sun_glass_ui_win_WinWindow__1setUpdatesCursor + (JNIEnv *env, jobject jThis, jlong ptr, jboolean jUpdatesCursor) +{ + ENTER_MAIN_THREAD() + { + GlassWindow *pWindow = GlassWindow::FromHandle(hWnd); + if (pWindow) { + pWindow->SetUpdatesCursor(jUpdatesCursor == JNI_TRUE ? true : false); + } + } + jboolean jUpdatesCursor; + LEAVE_MAIN_THREAD_WITH_hWnd; + + ARG(jUpdatesCursor) = jUpdatesCursor; + PERFORM(); +} + } // extern "C" --- old/modules/graphics/src/test/java/com/sun/javafx/pgstub/StubStage.java 2013-09-03 18:06:40.000000000 +0400 +++ new/modules/graphics/src/test/java/com/sun/javafx/pgstub/StubStage.java 2013-09-03 18:06:40.000000000 +0400 @@ -193,6 +193,10 @@ } @Override + public void setUpdatesCursor(boolean updatesCursor) { + } + + @Override public void requestFocus() { notificationSender.changedFocused(true, FocusCause.ACTIVATED); } --- old/modules/swing/src/main/java/javafx/embed/swing/SwingNode.java 2013-09-03 18:06:41.000000000 +0400 +++ new/modules/swing/src/main/java/javafx/embed/swing/SwingNode.java 2013-09-03 18:06:41.000000000 +0400 @@ -40,8 +40,7 @@ import javafx.beans.value.ObservableValue; import javafx.event.EventHandler; import javafx.geometry.Point2D; -import javafx.scene.Node; -import javafx.scene.Scene; +import javafx.scene.*; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseButton; @@ -135,7 +134,7 @@ focusedProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Boolean oldValue, final Boolean newValue) { - activateLwFrame(newValue); + activateLwFrame(newValue); } }); } @@ -641,6 +640,10 @@ } }); } + @Override + public void invokeOnContentsThread(Runnable runnable) { + Platform.runLater(runnable); + } } private void ungrabFocus(boolean postUngrabEvent) { @@ -672,7 +675,12 @@ private class SwingMouseEventHandler implements EventHandler { @Override public void handle(MouseEvent event) { - if (event.getEventType() == MouseEvent.MOUSE_PRESSED && + // Disable the FX cursor updates when mouse enters SwingNode and enable bask when exits + if (event.getEventType() == MouseEvent.MOUSE_ENTERED) { + getScene().getWindow().impl_getPeer().setUpdatesCursor(false); + } else if (event.getEventType() == MouseEvent.MOUSE_EXITED) { + getScene().getWindow().impl_getPeer().setUpdatesCursor(true); + } else if (event.getEventType() == MouseEvent.MOUSE_PRESSED && !SwingNode.this.isFocused() && SwingNode.this.isFocusTraversable()) { SwingNode.this.requestFocus();