Ivan Leo : dinput: Add some error checks to mouse.c.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Sep 26 05:30:01 CDT 2006
Module: wine
Branch: master
Commit: db782fe04a34319b249c91d6af751689f9e2ddf6
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=db782fe04a34319b249c91d6af751689f9e2ddf6
Author: Ivan Leo <ivanleo at gmail.com>
Date: Fri Sep 22 19:36:07 2006 +0100
dinput: Add some error checks to mouse.c.
---
dlls/dinput/mouse.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c
index dff65df..aae5e9a 100644
--- a/dlls/dinput/mouse.c
+++ b/dlls/dinput/mouse.c
@@ -551,12 +551,13 @@ static LRESULT CALLBACK dinput_mouse_hoo
return CallNextHookEx( 0, code, wparam, lparam );
}
-static void dinput_window_check(SysMouseImpl* This) {
+static BOOL dinput_window_check(SysMouseImpl* This) {
RECT rect;
DWORD centerX, centerY;
-
+
/* make sure the window hasn't moved */
- GetWindowRect(This->win, &rect);
+ if(!GetWindowRect(This->win, &rect))
+ return FALSE;
centerX = (rect.right - rect.left) / 2;
centerY = (rect.bottom - rect.top ) / 2;
if (This->win_centerX != centerX || This->win_centerY != centerY) {
@@ -566,6 +567,7 @@ static void dinput_window_check(SysMouse
This->mapped_center.x = This->win_centerX;
This->mapped_center.y = This->win_centerY;
MapWindowPoints(This->win, HWND_DESKTOP, &This->mapped_center, 1);
+ return TRUE;
}
@@ -700,7 +702,8 @@ static HRESULT WINAPI SysMouseAImpl_GetD
/* Check if we need to do a mouse warping */
if (This->need_warp == WARP_NEEDED && (GetCurrentTime() - This->last_warped > 10)) {
- dinput_window_check(This);
+ if(!dinput_window_check(This))
+ return DIERR_GENERIC;
TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
This->last_warped = GetCurrentTime();
@@ -794,7 +797,8 @@ static HRESULT WINAPI SysMouseAImpl_GetD
/* Check if we need to do a mouse warping */
if (This->need_warp == WARP_NEEDED && (GetCurrentTime() - This->last_warped > 10)) {
- dinput_window_check(This);
+ if(!dinput_window_check(This))
+ return DIERR_GENERIC;
TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
This->last_warped = GetCurrentTime();
More information about the wine-cvs
mailing list