GetCursorPos patch for half-life
Ove Kaaven
ovehk at ping.uio.no
Tue Jun 19 11:28:57 CDT 2001
This patch fixes in-game mouse unresponsiveness in Half-Life.
The problem is that GetCursorPos must return the latest cursor position,
since it's followed immediately by a SetCursorPos. And there's a whole
frame rendering run between the last event processing (PeekMessage) and
this GetCursorPos, so it's necessary to do something other than returning
the last known mouse position.
After a lot of thinking, I realized that finding the last known mouse
position from the X event queues in the new event processing model would
be rather futile, since it would be necessary to process events in *all* X
connections in all threads (and compare event timestamps) to get the last
position.
Thus, the only sane way seems to have GetCursorPos call XQueryPointer.
I also added a TSXFlush to the MoveCursor for good measure.
Log:
Ove Kaaven <ovek at transgaming.com>
Make GetCursorPos call XQueryPointer.
Index: dlls/ttydrv/ttydrv.spec
===================================================================
RCS file: /home/wine/wine/dlls/ttydrv/ttydrv.spec,v
retrieving revision 1.13
diff -u -r1.13 ttydrv.spec
--- dlls/ttydrv/ttydrv.spec 2001/06/06 21:26:50 1.13
+++ dlls/ttydrv/ttydrv.spec 2001/06/19 16:12:16
@@ -22,6 +22,7 @@
@ cdecl InitMouse(ptr) TTYDRV_InitMouse
@ cdecl SetCursor(ptr) TTYDRV_SetCursor
@ cdecl MoveCursor(long long) TTYDRV_MoveCursor
+@ cdecl GetCursorPos(ptr) TTYDRV_GetCursorPos
@ cdecl GetScreenSaveActive() TTYDRV_GetScreenSaveActive
@ cdecl SetScreenSaveActive(long) TTYDRV_SetScreenSaveActive
@ cdecl GetScreenSaveTimeout() TTYDRV_GetScreenSaveTimeout
Index: dlls/ttydrv/user.c
===================================================================
RCS file: /home/wine/wine/dlls/ttydrv/user.c,v
retrieving revision 1.5
diff -u -r1.5 user.c
--- dlls/ttydrv/user.c 2001/05/16 19:52:29 1.5
+++ dlls/ttydrv/user.c 2001/06/19 16:12:16
@@ -102,6 +102,13 @@
}
/***********************************************************************
+ * TTYDRV_GetCursorPos
+ */
+void TTYDRV_GetCursorPos(LPPOINT pos)
+{
+}
+
+/***********************************************************************
* TTYDRV_GetScreenSaveActive
*
* Returns the active status of the screen saver
Index: dlls/user/user_main.c
===================================================================
RCS file: /home/wine/wine/dlls/user/user_main.c,v
retrieving revision 1.23
diff -u -r1.23 user_main.c
--- dlls/user/user_main.c 2001/06/04 21:55:17 1.23
+++ dlls/user/user_main.c 2001/06/19 16:12:16
@@ -71,6 +71,7 @@
GET_USER_FUNC(InitMouse);
GET_USER_FUNC(SetCursor);
GET_USER_FUNC(MoveCursor);
+ GET_USER_FUNC(GetCursorPos);
GET_USER_FUNC(GetScreenSaveActive);
GET_USER_FUNC(SetScreenSaveActive);
GET_USER_FUNC(GetScreenSaveTimeout);
Index: dlls/x11drv/x11drv.spec
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/x11drv.spec,v
retrieving revision 1.16
diff -u -r1.16 x11drv.spec
--- dlls/x11drv/x11drv.spec 2001/06/06 21:26:50 1.16
+++ dlls/x11drv/x11drv.spec 2001/06/19 16:12:17
@@ -22,6 +22,7 @@
@ cdecl InitMouse(ptr) X11DRV_InitMouse
@ cdecl SetCursor(ptr) X11DRV_SetCursor
@ cdecl MoveCursor(long long) X11DRV_MoveCursor
+@ cdecl GetCursorPos(ptr) X11DRV_GetCursorPos
@ cdecl GetScreenSaveActive() X11DRV_GetScreenSaveActive
@ cdecl SetScreenSaveActive(long) X11DRV_SetScreenSaveActive
@ cdecl GetScreenSaveTimeout() X11DRV_GetScreenSaveTimeout
Index: include/user.h
===================================================================
RCS file: /home/wine/wine/include/user.h,v
retrieving revision 1.24
diff -u -r1.24 user.h
--- include/user.h 2001/06/06 21:26:50 1.24
+++ include/user.h 2001/06/19 16:12:20
@@ -51,6 +51,7 @@
void (*pInitMouse)(LPMOUSE_EVENT_PROC);
void (*pSetCursor)(struct tagCURSORICONINFO *);
void (*pMoveCursor)(WORD, WORD);
+ void (*pGetCursorPos)(LPPOINT);
/* screen saver functions */
BOOL (*pGetScreenSaveActive)(void);
void (*pSetScreenSaveActive)(BOOL);
Index: windows/cursoricon.c
===================================================================
RCS file: /home/wine/wine/windows/cursoricon.c,v
retrieving revision 1.31
diff -u -r1.31 cursoricon.c
--- windows/cursoricon.c 2001/04/25 19:54:22 1.31
+++ windows/cursoricon.c 2001/06/19 16:12:25
@@ -1468,25 +1468,6 @@
/***********************************************************************
- * SetCursorPos (USER.70)
- */
-void WINAPI SetCursorPos16( INT16 x, INT16 y )
-{
- SetCursorPos( x, y );
-}
-
-
-/***********************************************************************
- * SetCursorPos (USER32.@)
- */
-BOOL WINAPI SetCursorPos( INT x, INT y )
-{
- USER_Driver.pMoveCursor( x, y );
- return TRUE;
-}
-
-
-/***********************************************************************
* ShowCursor (USER.71)
*/
INT16 WINAPI ShowCursor16( BOOL16 bShow )
Index: windows/input.c
===================================================================
RCS file: /home/wine/wine/windows/input.c,v
retrieving revision 1.47
diff -u -r1.47 input.c
--- windows/input.c 2001/05/18 20:56:59 1.47
+++ windows/input.c 2001/06/19 16:12:25
@@ -346,9 +346,11 @@
*/
BOOL16 WINAPI GetCursorPos16( POINT16 *pt )
{
+ POINT pos;
if (!pt) return 0;
- pt->x = PosX;
- pt->y = PosY;
+ GetCursorPos(&pos);
+ pt->x = pos.x;
+ pt->y = pos.y;
return 1;
}
@@ -361,7 +363,29 @@
if (!pt) return 0;
pt->x = PosX;
pt->y = PosY;
+ USER_Driver.pGetCursorPos(pt);
return 1;
+}
+
+
+/***********************************************************************
+ * SetCursorPos (USER.70)
+ */
+void WINAPI SetCursorPos16( INT16 x, INT16 y )
+{
+ SetCursorPos( x, y );
+}
+
+
+/***********************************************************************
+ * SetCursorPos (USER32.@)
+ */
+BOOL WINAPI SetCursorPos( INT x, INT y )
+{
+ USER_Driver.pMoveCursor( x, y );
+ PosX = x;
+ PosY = y;
+ return TRUE;
}
Index: windows/x11drv/mouse.c
===================================================================
RCS file: /home/wine/wine/windows/x11drv/mouse.c,v
retrieving revision 1.27
diff -u -r1.27 mouse.c
--- windows/x11drv/mouse.c 2001/06/04 21:55:18 1.27
+++ windows/x11drv/mouse.c 2001/06/19 16:12:25
@@ -218,7 +218,7 @@
* are supposed to move to; if so, we don't need to do anything.
*/
- Display *display = thread_display();
+ Display *display = thread_display();
Window root, child;
int rootX, rootY, winX, winY;
unsigned int xstate;
@@ -235,6 +235,27 @@
TRACE("(%d,%d): moving from (%d,%d)\n", wAbsX, wAbsY, winX, winY );
TSXWarpPointer( display, root_window, root_window, 0, 0, 0, 0, wAbsX, wAbsY );
+ TSXFlush( display ); /* just in case */
+}
+
+/***********************************************************************
+ * GetCursorPos (X11DRV.@)
+ */
+void X11DRV_GetCursorPos(LPPOINT pos)
+{
+ Display *display = thread_display();
+ Window root, child;
+ int rootX, rootY, winX, winY;
+ unsigned int xstate;
+
+ if (X11DRV_MOUSE_WarpPointer < 0) return;
+
+ if (!TSXQueryPointer( display, root_window, &root, &child,
+ &rootX, &rootY, &winX, &winY, &xstate ))
+ return;
+
+ TRACE("pointer at (%d,%d)\n", winX, winY );
+ pos->x = winX; pos->y = winY;
}
/***********************************************************************
More information about the wine-patches
mailing list