From 7d8ef2e19e8f1d5d6143c5e3969481180d7016ca Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <julliard@winehq.org>
Date: Wed, 25 Oct 2006 17:42:42 +0200
Subject: [PATCH] user32: Properly handle negative coordinates for mouse
 events.

---
 dlls/user/button.c  | 4 ++--
 dlls/user/combo.c   | 8 ++++----
 dlls/user/listbox.c | 4 ++--
 dlls/user/menu.c    | 2 +-
 dlls/user/message.c | 4 ++--
 dlls/user/win.c     | 4 ++--
 6 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/dlls/user/button.c b/dlls/user/button.c
index c10be0f3b9a..b42aa0cdd41 100644
--- a/dlls/user/button.c
+++ b/dlls/user/button.c
@@ -227,8 +227,8 @@ static LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
     LONG state;
     HANDLE oldHbitmap;
 
-    pt.x = LOWORD(lParam);
-    pt.y = HIWORD(lParam);
+    pt.x = (short)LOWORD(lParam);
+    pt.y = (short)HIWORD(lParam);
 
     switch (uMsg)
     {
diff --git a/dlls/user/combo.c b/dlls/user/combo.c
index c2c49bb1f97..a2c720924eb 100644
--- a/dlls/user/combo.c
+++ b/dlls/user/combo.c
@@ -1703,8 +1703,8 @@ static void COMBO_LButtonDown( LPHEADCOMBO lphc, LPARAM lParam )
    BOOL      bButton;
    HWND      hWnd = lphc->self;
 
-   pt.x = LOWORD(lParam);
-   pt.y = HIWORD(lParam);
+   pt.x = (short)LOWORD(lParam);
+   pt.y = (short)HIWORD(lParam);
    bButton = PtInRect(&lphc->buttonRect, pt);
 
    if( (CB_GETTYPE(lphc) == CBS_DROPDOWNLIST) ||
@@ -1780,8 +1780,8 @@ static void COMBO_MouseMove( LPHEADCOMBO lphc, WPARAM wParam, LPARAM lParam )
    POINT  pt;
    RECT   lbRect;
 
-   pt.x = LOWORD(lParam);
-   pt.y = HIWORD(lParam);
+   pt.x = (short)LOWORD(lParam);
+   pt.y = (short)HIWORD(lParam);
 
    if( lphc->wState & CBF_BUTTONDOWN )
    {
diff --git a/dlls/user/listbox.c b/dlls/user/listbox.c
index 701e91b6778..ae9a8e37347 100644
--- a/dlls/user/listbox.c
+++ b/dlls/user/listbox.c
@@ -2732,8 +2732,8 @@ static LRESULT WINAPI ListBoxWndProc_common( HWND hwnd, UINT msg,
             POINT pt;
             RECT rect;
 
-	    pt.x = LOWORD(lParam);
-	    pt.y = HIWORD(lParam);
+	    pt.x = (short)LOWORD(lParam);
+	    pt.y = (short)HIWORD(lParam);
 	    rect.left = 0;
 	    rect.top = 0;
 	    rect.right = descr->width;
diff --git a/dlls/user/menu.c b/dlls/user/menu.c
index e157e04cdc9..43bb11e4b67 100644
--- a/dlls/user/menu.c
+++ b/dlls/user/menu.c
@@ -1771,7 +1771,7 @@ static BOOL MENU_ShowPopup( HWND hwndOwner, HMENU hmenu, UINT id,
                               INT x, INT y, INT xanchor, INT yanchor )
 {
     POPUPMENU *menu;
-    UINT width, height;
+    INT width, height;
     POINT pt;
     HMONITOR monitor;
     MONITORINFO info;
diff --git a/dlls/user/message.c b/dlls/user/message.c
index b92951c7de1..df3dcd4e3c1 100644
--- a/dlls/user/message.c
+++ b/dlls/user/message.c
@@ -2785,8 +2785,8 @@ BOOL WINAPI PeekMessageW( MSG *msg_out, HWND hwnd, UINT first, UINT last, UINT f
     }
 
     thread_info->GetMessageTimeVal = msg.time;
-    msg.pt.x = LOWORD( thread_info->GetMessagePosVal );
-    msg.pt.y = HIWORD( thread_info->GetMessagePosVal );
+    msg.pt.x = (short)LOWORD( thread_info->GetMessagePosVal );
+    msg.pt.y = (short)HIWORD( thread_info->GetMessagePosVal );
 
     HOOK_CallHooks( WH_GETMESSAGE, HC_ACTION, flags & PM_REMOVE, (LPARAM)&msg, TRUE );
 
diff --git a/dlls/user/win.c b/dlls/user/win.c
index 1c3d9e4741f..6eac41cd996 100644
--- a/dlls/user/win.c
+++ b/dlls/user/win.c
@@ -3023,8 +3023,8 @@ BOOL WINAPI DragDetect( HWND hWnd, POINT pt )
             if( msg.message == WM_MOUSEMOVE )
             {
                 POINT tmp;
-                tmp.x = LOWORD(msg.lParam);
-                tmp.y = HIWORD(msg.lParam);
+                tmp.x = (short)LOWORD(msg.lParam);
+                tmp.y = (short)HIWORD(msg.lParam);
                 if( !PtInRect( &rect, tmp ))
                 {
                     ReleaseCapture();
-- 
GitLab