Huw Davies : user32: If the listbox loses focus while holding capture, release it by essentially simulating a button up event.

Alexandre Julliard julliard at winehq.org
Thu Feb 20 10:08:11 CST 2014


Module: wine
Branch: master
Commit: fb298aed049ed9a002a7a2451ae964f77eaacd59
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=fb298aed049ed9a002a7a2451ae964f77eaacd59

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Feb 20 11:35:18 2014 +0000

user32: If the listbox loses focus while holding capture, release it by essentially simulating a button up event.

---

 dlls/user32/listbox.c       |    1 +
 dlls/user32/tests/listbox.c |   30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c
index 5a78dda..c282d5d 100644
--- a/dlls/user32/listbox.c
+++ b/dlls/user32/listbox.c
@@ -2995,6 +2995,7 @@ LRESULT ListBoxWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
         SEND_NOTIFICATION( descr, LBN_SETFOCUS );
         return 0;
     case WM_KILLFOCUS:
+        LISTBOX_HandleLButtonUp( descr ); /* Release capture if we have it */
         descr->in_focus = FALSE;
         descr->wheel_remain = 0;
         if ((descr->focus_item != -1) && descr->caret_on)
diff --git a/dlls/user32/tests/listbox.c b/dlls/user32/tests/listbox.c
index fdc190d..8e3fbcd 100644
--- a/dlls/user32/tests/listbox.c
+++ b/dlls/user32/tests/listbox.c
@@ -234,6 +234,8 @@ static void check_item_height(void)
     DestroyWindow (hLB);
 }
 
+static int got_selchange;
+
 static LRESULT WINAPI main_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 {
     switch (msg)
@@ -267,6 +269,10 @@ static LRESULT WINAPI main_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARA
         break;
     }
 
+    case WM_COMMAND:
+        if (HIWORD( wparam ) == LBN_SELCHANGE) got_selchange++;
+        break;
+
     default:
         break;
     }
@@ -1588,6 +1594,29 @@ todo_wine
     DestroyWindow(parent);
 }
 
+static void test_missing_lbuttonup( void )
+{
+    HWND listbox, parent, capture;
+
+    parent = create_parent();
+    listbox = create_listbox(WS_CHILD | WS_VISIBLE, parent);
+
+    /* Send button down without a corresponding button up */
+    SendMessageA(listbox, WM_LBUTTONDOWN, 0, MAKELPARAM(10,10));
+    capture = GetCapture();
+    ok(capture == listbox, "got %p expected %p\n", capture, listbox);
+
+    /* Capture is released and LBN_SELCHANGE sent during WM_KILLFOCUS */
+    got_selchange = 0;
+    SetFocus(NULL);
+    capture = GetCapture();
+    ok(capture == NULL, "got %p\n", capture);
+    ok(got_selchange, "got %d\n", got_selchange);
+
+    DestroyWindow(listbox);
+    DestroyWindow(parent);
+}
+
 START_TEST(listbox)
 {
   const struct listbox_test SS =
@@ -1668,4 +1697,5 @@ START_TEST(listbox)
   test_listbox_dlgdir();
   test_set_count();
   test_GetListBoxInfo();
+  test_missing_lbuttonup();
 }




More information about the wine-cvs mailing list