diff options
author | Steve Northover <steve> | 2005-11-21 20:59:45 +0000 |
---|---|---|
committer | Steve Northover <steve> | 2005-11-21 20:59:45 +0000 |
commit | 9747fcc7eb584ce2c813fb0967618ef7da3ebd5c (patch) | |
tree | 7159991f30a0227380161bca207b142c28c0595d | |
parent | 8279a8b06331b103825d014a5f212fc818455bf3 (diff) | |
download | eclipse.platform.swt-9747fcc7eb584ce2c813fb0967618ef7da3ebd5c.tar.gz eclipse.platform.swt-9747fcc7eb584ce2c813fb0967618ef7da3ebd5c.tar.xz eclipse.platform.swt-9747fcc7eb584ce2c813fb0967618ef7da3ebd5c.zip |
117195 - Regression: Shell ignores first mouse-click after dialog closed
4 files changed, 113 insertions, 25 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java index f18ef9efc2..cacc407c0f 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java @@ -2500,8 +2500,12 @@ LRESULT sendMouseDownEvent (int type, int button, int msg, int wParam, int lPara pinfo.x = (short) (lParam & 0xFFFF); pinfo.y = (short) (lParam >> 16); OS.SendMessage (handle, OS.LVM_HITTEST, 0, pinfo); + Display display = this.display; + display.captureChanged = false; if (!sendMouseEvent (type, button, handle, msg, wParam, lParam)) { - if (OS.GetCapture () != handle) OS.SetCapture (handle); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } return LRESULT.ZERO; } @@ -2523,7 +2527,9 @@ LRESULT sendMouseDownEvent (int type, int button, int msg, int wParam, int lPara * case and avoid calling the window proc. */ if (pinfo.iItem == -1) { - if (OS.GetCapture () != handle) OS.SetCapture (handle); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } return LRESULT.ZERO; } @@ -2550,7 +2556,9 @@ LRESULT sendMouseDownEvent (int type, int button, int msg, int wParam, int lPara dragStarted = false; int code = callWindowProc (handle, msg, wParam, lParam, forceSelect); if (dragStarted) { - if (OS.GetCapture () != handle) OS.SetCapture (handle); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } } else { int flags = OS.LVHT_ONITEMLABEL | OS.LVHT_ONITEMICON; boolean fakeMouseUp = (pinfo.flags & flags) != 0; @@ -3937,13 +3945,19 @@ LRESULT WM_LBUTTONDBLCLK (int wParam, int lParam) { pinfo.x = (short) (lParam & 0xFFFF); pinfo.y = (short) (lParam >> 16); int index = OS.SendMessage (handle, OS.LVM_HITTEST, 0, pinfo); + Display display = this.display; + display.captureChanged = false; sendMouseEvent (SWT.MouseDown, 1, handle, OS.WM_LBUTTONDOWN, wParam, lParam); if (!sendMouseEvent (SWT.MouseDoubleClick, 1, handle, OS.WM_LBUTTONDBLCLK, wParam, lParam)) { - if (OS.GetCapture () != handle) OS.SetCapture (handle); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } return LRESULT.ZERO; } if (pinfo.iItem != -1) callWindowProc (handle, OS.WM_LBUTTONDBLCLK, wParam, lParam); - if (OS.GetCapture () != handle) OS.SetCapture (handle); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } /* Look for check/uncheck */ if ((style & SWT.CHECK) != 0) { @@ -4229,11 +4243,15 @@ LRESULT WM_RBUTTONDBLCLK (int wParam, int lParam) { pinfo.x = (short) (lParam & 0xFFFF); pinfo.y = (short) (lParam >> 16); OS.SendMessage (handle, OS.LVM_HITTEST, 0, pinfo); + Display display = this.display; + display.captureChanged = false; sendMouseEvent (SWT.MouseDown, 3, handle, OS.WM_RBUTTONDOWN, wParam, lParam); if (sendMouseEvent (SWT.MouseDoubleClick, 3, handle, OS.WM_RBUTTONDBLCLK, wParam, lParam)) { if (pinfo.iItem != -1) callWindowProc (handle, OS.WM_RBUTTONDBLCLK, wParam, lParam); } - if (OS.GetCapture () != handle) OS.SetCapture (handle); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } return LRESULT.ZERO; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java index 2dac7530e6..7b5f59c915 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java @@ -1946,7 +1946,9 @@ LRESULT WM_LBUTTONDBLCLK (int wParam, int lParam) { if (!sendMouseEvent (SWT.MouseDoubleClick, 1, handle, OS.WM_LBUTTONDBLCLK, wParam, lParam)) { result = LRESULT.ZERO; } - if (OS.GetCapture () != handle) OS.SetCapture (handle); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } if (!doubleClick) return LRESULT.ZERO; /* @@ -1974,6 +1976,8 @@ LRESULT WM_LBUTTONDBLCLK (int wParam, int lParam) { LRESULT WM_LBUTTONDOWN (int wParam, int lParam) { if (OS.IsPPC) { LRESULT result = null; + Display display = this.display; + display.captureChanged = false; boolean dispatch = sendMouseEvent (SWT.MouseDown, 1, handle, OS.WM_LBUTTONDOWN, wParam, lParam); /* * Note: On WinCE PPC, only attempt to recognize the gesture for @@ -2005,7 +2009,9 @@ LRESULT WM_LBUTTONDOWN (int wParam, int lParam) { } else { result = LRESULT.ZERO; } - if (OS.GetCapture () != handle) OS.SetCapture (handle); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } return result; } return super.WM_LBUTTONDOWN (wParam, lParam); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java index 13dae70761..0144118e85 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java @@ -3795,12 +3795,18 @@ LRESULT WM_LBUTTONDBLCLK (int wParam, int lParam) { if (lpht.hItem != 0) { if ((style & SWT.CHECK) != 0) { if ((lpht.flags & OS.TVHT_ONITEMSTATEICON) != 0) { + Display display = this.display; + display.captureChanged = false; sendMouseEvent (SWT.MouseDown, 1, handle, OS.WM_LBUTTONDOWN, wParam, lParam); if (!sendMouseEvent (SWT.MouseDoubleClick, 1, handle, OS.WM_LBUTTONDBLCLK, wParam, lParam)) { - if (OS.GetCapture () != handle) OS.SetCapture (handle); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } return LRESULT.ZERO; } - if (OS.GetCapture () != handle) OS.SetCapture (handle); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } TVITEM tvItem = new TVITEM (); tvItem.hItem = lpht.hItem; tvItem.mask = OS.TVIF_PARAM | OS.TVIF_STATE; @@ -3858,8 +3864,12 @@ LRESULT WM_LBUTTONDOWN (int wParam, int lParam) { lpht.y = (short) (lParam >> 16); OS.SendMessage (handle, OS.TVM_HITTEST, 0, lpht); if (lpht.hItem == 0 || (lpht.flags & OS.TVHT_ONITEMBUTTON) != 0) { + Display display = this.display; + display.captureChanged = false; if (!sendMouseEvent (SWT.MouseDown, 1, handle, OS.WM_LBUTTONDOWN, wParam, lParam)) { - if (OS.GetCapture () != handle) OS.SetCapture (handle); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } return LRESULT.ZERO; } boolean fixSelection = false, deselected = false; @@ -3891,7 +3901,11 @@ LRESULT WM_LBUTTONDOWN (int wParam, int lParam) { if (fixSelection) ignoreDeselect = ignoreSelect = lockSelection = true; int code = callWindowProc (handle, OS.WM_LBUTTONDOWN, wParam, lParam); if (fixSelection) ignoreDeselect = ignoreSelect = lockSelection = false; - if (dragStarted && OS.GetCapture () != handle) OS.SetCapture (handle); + if (dragStarted) { + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } + } if (deselected) { TVITEM tvItem = new TVITEM (); tvItem.mask = OS.TVIF_PARAM; @@ -3907,11 +3921,17 @@ LRESULT WM_LBUTTONDOWN (int wParam, int lParam) { /* Look for check/uncheck */ if ((style & SWT.CHECK) != 0) { if ((lpht.flags & OS.TVHT_ONITEMSTATEICON) != 0) { + Display display = this.display; + display.captureChanged = false; if (!sendMouseEvent (SWT.MouseDown, 1, handle, OS.WM_LBUTTONDOWN, wParam, lParam)) { - if (OS.GetCapture () != handle) OS.SetCapture (handle); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } return LRESULT.ZERO; } - if (OS.GetCapture () != handle) OS.SetCapture (handle); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } TVITEM tvItem = new TVITEM (); tvItem.hItem = lpht.hItem; tvItem.mask = OS.TVIF_PARAM | OS.TVIF_STATE; @@ -3973,15 +3993,23 @@ LRESULT WM_LBUTTONDOWN (int wParam, int lParam) { } /* Do the selection */ + Display display = this.display; + display.captureChanged = false; if (!sendMouseEvent (SWT.MouseDown, 1, handle, OS.WM_LBUTTONDOWN, wParam, lParam)) { - if (OS.GetCapture () != handle) OS.SetCapture (handle); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } return LRESULT.ZERO; } dragStarted = gestureCompleted = false; ignoreDeselect = ignoreSelect = true; int code = callWindowProc (handle, OS.WM_LBUTTONDOWN, wParam, lParam); ignoreDeselect = ignoreSelect = false; - if (dragStarted && OS.GetCapture () != handle) OS.SetCapture (handle); + if (dragStarted) { + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } + } int hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0); /* @@ -4334,8 +4362,12 @@ LRESULT WM_RBUTTONDOWN (int wParam, int lParam) { * WM_RBUTTONUP. The fix is to avoid calling the window proc for * the tree. */ + Display display = this.display; + display.captureChanged = false; if (!sendMouseEvent (SWT.MouseDown, 3, handle, OS.WM_RBUTTONDOWN, wParam, lParam)) { - if (OS.GetCapture () != handle) OS.SetCapture (handle); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != handle) OS.SetCapture (handle); + } return LRESULT.ZERO; } /* diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java index 6b035ace25..50632eec45 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java @@ -1676,13 +1676,17 @@ LRESULT wmLButtonDblClk (int hwnd, int wParam, int lParam) { * fix is to send a mouse down event. */ LRESULT result = null; + Display display = this.display; + display.captureChanged = false; sendMouseEvent (SWT.MouseDown, 1, hwnd, OS.WM_LBUTTONDOWN, wParam, lParam); if (sendMouseEvent (SWT.MouseDoubleClick, 1, hwnd, OS.WM_LBUTTONDBLCLK, wParam, lParam)) { result = new LRESULT (callWindowProc (hwnd, OS.WM_LBUTTONDBLCLK, wParam, lParam)); } else { result = LRESULT.ZERO; } - if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + } return result; } @@ -1708,6 +1712,8 @@ LRESULT wmLButtonDown (int hwnd, int wParam, int lParam) { mouseDown = OS.GetKeyState (OS.VK_LBUTTON) < 0; } } + Display display = this.display; + display.captureChanged = false; if (sendMouseEvent (SWT.MouseDown, 1, hwnd, OS.WM_LBUTTONDOWN, wParam, lParam)) { result = new LRESULT (callWindowProc (hwnd, OS.WM_LBUTTONDOWN, wParam, lParam)); } else { @@ -1735,7 +1741,9 @@ LRESULT wmLButtonDown (int hwnd, int wParam, int lParam) { } } if (mouseDown) { - if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + } } if (dragging) { sendDragEvent ((short) (lParam & 0xFFFF), (short) (lParam >> 16)); @@ -1798,24 +1806,32 @@ LRESULT wmMButtonDblClk (int hwnd, int wParam, int lParam) { * fix is to send a mouse down event. */ LRESULT result = null; + Display display = this.display; + display.captureChanged = false; sendMouseEvent (SWT.MouseDown, 2, hwnd, OS.WM_MBUTTONDOWN, wParam, lParam); if (sendMouseEvent (SWT.MouseDoubleClick, 2, hwnd, OS.WM_MBUTTONDBLCLK, wParam, lParam)) { result = new LRESULT (callWindowProc (hwnd, OS.WM_MBUTTONDBLCLK, wParam, lParam)); } else { result = LRESULT.ZERO; } - if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + } return result; } LRESULT wmMButtonDown (int hwnd, int wParam, int lParam) { LRESULT result = null; + Display display = this.display; + display.captureChanged = false; if (sendMouseEvent (SWT.MouseDown, 2, hwnd, OS.WM_MBUTTONDOWN, wParam, lParam)) { result = new LRESULT (callWindowProc (hwnd, OS.WM_MBUTTONDOWN, wParam, lParam)); } else { result = LRESULT.ZERO; } - if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + } return result; } @@ -2024,24 +2040,32 @@ LRESULT wmRButtonDblClk (int hwnd, int wParam, int lParam) { * fix is to send a mouse down event. */ LRESULT result = null; + Display display = this.display; + display.captureChanged = false; sendMouseEvent (SWT.MouseDown, 3, hwnd, OS.WM_RBUTTONDOWN, wParam, lParam); if (sendMouseEvent (SWT.MouseDoubleClick, 3, hwnd, OS.WM_RBUTTONDBLCLK, wParam, lParam)) { result = new LRESULT (callWindowProc (hwnd, OS.WM_RBUTTONDBLCLK, wParam, lParam)); } else { result = LRESULT.ZERO; } - if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + } return result; } LRESULT wmRButtonDown (int hwnd, int wParam, int lParam) { LRESULT result = null; + Display display = this.display; + display.captureChanged = false; if (sendMouseEvent (SWT.MouseDown, 3, hwnd, OS.WM_RBUTTONDOWN, wParam, lParam)) { result = new LRESULT (callWindowProc (hwnd, OS.WM_RBUTTONDOWN, wParam, lParam)); } else { result = LRESULT.ZERO; } - if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + } return result; } @@ -2220,6 +2244,8 @@ LRESULT wmXButtonDblClk (int hwnd, int wParam, int lParam) { * fix is to send a mouse down event. */ LRESULT result = null; + Display display = this.display; + display.captureChanged = false; int button = (wParam >> 16 == OS.XBUTTON1) ? 4 : 5; sendMouseEvent (SWT.MouseDown, button, hwnd, OS.WM_XBUTTONDOWN, wParam, lParam); if (sendMouseEvent (SWT.MouseDoubleClick, button, hwnd, OS.WM_XBUTTONDBLCLK, wParam, lParam)) { @@ -2227,19 +2253,25 @@ LRESULT wmXButtonDblClk (int hwnd, int wParam, int lParam) { } else { result = LRESULT.ZERO; } - if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + } return result; } LRESULT wmXButtonDown (int hwnd, int wParam, int lParam) { LRESULT result = null; + Display display = this.display; + display.captureChanged = false; int button = (wParam >> 16 == OS.XBUTTON1) ? 4 : 5; if (sendMouseEvent (SWT.MouseDown, button, hwnd, OS.WM_XBUTTONDOWN, wParam, lParam)) { result = new LRESULT (callWindowProc (hwnd, OS.WM_XBUTTONDOWN, wParam, lParam)); } else { result = LRESULT.ZERO; } - if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + if (!display.captureChanged && !isDisposed ()) { + if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + } return result; } |