Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Features

Bug Fixes
---------
* [#1745](https://github.com/java-native-access/jna/issues/1745): Add correctly typed `User32.SetCursorPos(int, int)` mapping and deprecate the previous `long` overload, retained for binary compatibility - [@OKAN-SOFTWARE](https://github.com/OKAN-SOFTWARE).
* [#1740](https://github.com/java-native-access/jna/issues/1740): Fix `c.s.j.p.unix.solaris.LibKstat.KstatCtl` mapping `kc_chain` as an inline `Kstat` instead of a pointer, which made every call taking a `KstatCtl` write past the end of the structure `kstat_open()` allocated, and map the `Kstat` function pointers `ks_update` and `ks_snapshot` as `Pointer` instead of `int` - [@dbwiddis](https://github.com/dbwiddis).

Breaking Changes
Expand Down
15 changes: 15 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/win32/User32.java
Original file line number Diff line number Diff line change
Expand Up @@ -2326,6 +2326,21 @@ LRESULT SendMessageTimeout(HWND hWnd, int msg, WPARAM wParam, LPARAM lParam,
* Returns nonzero if successful or zero otherwise. To get extended
* error information, call GetLastError.
*/
boolean SetCursorPos(int x, int y);

/**
* Moves the cursor to the specified screen coordinates.
*
* @param x
* The new x-coordinate of the cursor.
* @param y
* The new y-coordinate of the cursor.
* @return Whether the call succeeded.
* @deprecated Windows expects 32-bit coordinates, so this declaration has
* the wrong calling convention on 32-bit Windows. Use
* {@link #SetCursorPos(int, int)} instead.
*/
@Deprecated
boolean SetCursorPos(long x, long y);

/**
Expand Down
14 changes: 13 additions & 1 deletion contrib/platform/test/com/sun/jna/platform/win32/User32Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ public void testNoDuplicateMethodsNames() {
// has 2 overloads since the original API accepts both MONITORINFO and MONITORINFOEX
"GetMonitorInfo" // has 2 overloads since there was a broken binding for MonitorFromPoint
,
"MonitorFromPoint"
"MonitorFromPoint",
// Keep the deprecated long overload for binary compatibility.
"SetCursorPos"
}) {
dupSet.remove(name);
}
Expand Down Expand Up @@ -413,6 +415,14 @@ public void testGetCursorPos() {
assertTrue("Y coordinate in POINT should be >= 0", cursorPos.y >= 0);
}

@Test
public void testSetCursorPosNativeSignature() throws NoSuchMethodException {
assertEquals(boolean.class,
User32.class.getMethod("SetCursorPos", int.class, int.class).getReturnType());
assertTrue(User32.class.getMethod("SetCursorPos", long.class, long.class)
.isAnnotationPresent(Deprecated.class));
}

@Test
public void testSetCursorPos() {
POINT cursorPos = new POINT();
Expand All @@ -432,6 +442,8 @@ public void testSetCursorPos() {
),
cursorPos2.x == cursorPos.x + 20
);
assertEquals("Y coordinate should be preserved after SetCursorPos",
cursorPos.y, cursorPos2.y);
}

@Test
Expand Down