diff options
12 files changed, 155 insertions, 12 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java index 46d4b4f50c..3be3036d24 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java @@ -383,7 +383,8 @@ private int GiveFeedback(int dwEffect) { private int QueryContinueDrag(int fEscapePressed, int grfKeyState) { if (fEscapePressed != 0) return COM.DRAGDROP_S_CANCEL; - if ((grfKeyState & (OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON)) == 0) + int mask = OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON | OS.MK_XBUTTON1 | OS.MK_XBUTTON2; + if ((grfKeyState & mask) == 0) return COM.DRAGDROP_S_DROP; return COM.S_OK; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java index d4514e16ec..131365a9a8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java @@ -723,6 +723,8 @@ public class OS extends Platform { public static final int MK_MBUTTON = 0x10; public static final int MK_RBUTTON = 0x2; public static final int MK_SHIFT = 0x4; + public static final int MK_XBUTTON1 = 0x20; + public static final int MK_XBUTTON2 = 0x40; public static final int MM_TEXT = 0x1; public static final int MNC_CLOSE = 0x1; public static final int MNS_CHECKORBMP = 0x4000000; @@ -1292,6 +1294,8 @@ public class OS extends Platform { public static final int VK_SUBTRACT = 0x6D; public static final int VK_TAB = 0x9; public static final int VK_UP = 0x26; + public static final int VK_XBUTTON1 = 0x05; + public static final int VK_XBUTTON2 = 0x06; public static final int VK_ADD = 0x6B; public static final int VK_APP1 = 0xc1; public static final int VK_APP2 = 0xc2; @@ -1435,6 +1439,11 @@ public class OS extends Platform { public static final int WS_THICKFRAME = 0x40000; public static final int WS_VISIBLE = 0x10000000; public static final int WS_VSCROLL = 0x200000; + public static final int WM_XBUTTONDOWN = 0x020B; + public static final int WM_XBUTTONUP = 0x020C; + public static final int WM_XBUTTONDBLCLK = 0x020D; + public static final int XBUTTON1 = 0x1; + public static final int XBUTTON2 = 0x2; public static int VERSION (int major, int minor) { return major << 16 | minor; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java index 3e3994b749..26b15a8ecb 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java @@ -68,7 +68,7 @@ public class SWT { public static final int KeyUp = 2; /** - * mouse down event type (value is 3) + * The mouse down event type (value is 3) */ public static final int MouseDown = 3; @@ -257,7 +257,14 @@ public class SWT { * @since 3.0 */ public static final int SetData = 36; - + + /** + * The mouse wheel event type (value is 37). + * + * @since 3.1 + */ + public static final int MouseWheel = 37; + /* Event Details */ /** @@ -1121,6 +1128,22 @@ public class SWT { public static final int BUTTON3 = 1 << 21; /** + * Keyboard and/or mouse event mask indicating that mouse button four + * was pushed when the event was generated. (value is 1<<23). + * + * @since 3.1 + */ + public static final int BUTTON4 = 1 << 23; + + /** + * Keyboard and/or mouse event mask indicating that mouse button five + * was pushed when the event was generated. (value is 1<<25). + * + * @since 3.1 + */ + public static final int BUTTON5 = 1 << 25; + + /** * Keyboard and/or mouse event mask indicating all possible * mouse buttons. * @@ -1173,6 +1196,26 @@ public class SWT { public static final int MOD4; /** + * Constants to indicate line scrolling (value is 1). + * <p><b>Used By:</b><ul> + * <li><code>Control</code></li> + * </ul></p> + * + * @since 3.1 + */ + public static final int SCROLL_LINE = 1; + + /** + * Constants to indicate page scrolling (value is 2). + * <p><b>Used By:</b><ul> + * <li><code>Control</code></li> + * </ul></p> + * + * @since 3.1 + */ + public static final int SCROLL_PAGE = 2; + + /** * Accelerator constant used to differentiate a key code from a * unicode character. * @@ -2825,7 +2868,7 @@ static { * expand in the future. Therefore they are not initialized * in the declaration to stop the compiler from inlining. */ - BUTTON_MASK = BUTTON1 | BUTTON2 | BUTTON3; + BUTTON_MASK = BUTTON1 | BUTTON2 | BUTTON3 | BUTTON4 | BUTTON5; MODIFIER_MASK = ALT | SHIFT | CTRL | COMMAND; /* diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Event.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Event.java index 7ecd5e90a4..0c06c06715 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Event.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Event.java @@ -99,9 +99,10 @@ public class Event { public int height; /** - * the number of following paint events which - * are pending which may always be zero on - * some platforms + * depending on the event type, the number of following + * paint events which are pending which may always be zero + * on some platforms or the number of lines or pages to + * scroll using the mouse wheel */ public int count; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java index 947323abde..6963fd7003 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java @@ -1714,6 +1714,9 @@ int windowProc (int hwnd, int msg, int wParam, int lParam) { case OS.WM_RBUTTONDBLCLK: result = wmRButtonDblClk (hwnd, wParam, lParam); break; case OS.WM_RBUTTONDOWN: result = wmRButtonDown (hwnd, wParam, lParam); break; case OS.WM_RBUTTONUP: result = wmRButtonUp (hwnd, wParam, lParam); break; + case OS.WM_XBUTTONDBLCLK: result = wmXButtonDblClk (hwnd, wParam, lParam); break; + case OS.WM_XBUTTONDOWN: result = wmXButtonDown (hwnd, wParam, lParam); break; + case OS.WM_XBUTTONUP: result = wmXButtonUp (hwnd, wParam, lParam); break; /* Paint messages */ case OS.WM_PAINT: result = wmPaint (hwnd, wParam, lParam); break; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java index bc3f752fb9..b2cde8ca5e 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java @@ -3063,6 +3063,9 @@ int windowProc (int hwnd, int msg, int wParam, int lParam) { case OS.WM_VSCROLL: result = WM_VSCROLL (wParam, lParam); break; case OS.WM_WINDOWPOSCHANGED: result = WM_WINDOWPOSCHANGED (wParam, lParam); break; case OS.WM_WINDOWPOSCHANGING: result = WM_WINDOWPOSCHANGING (wParam, lParam); break; + case OS.WM_XBUTTONDBLCLK: result = WM_XBUTTONDBLCLK (wParam, lParam); break; + case OS.WM_XBUTTONDOWN: result = WM_XBUTTONDOWN (wParam, lParam); break; + case OS.WM_XBUTTONUP: result = WM_XBUTTONUP (wParam, lParam); break; } if (result != null) return result.value; return callWindowProc (hwnd, msg, wParam, lParam); @@ -3467,6 +3470,21 @@ LRESULT WM_MOUSEMOVE (int wParam, int lParam) { } LRESULT WM_MOUSEWHEEL (int wParam, int lParam) { + if (hooks (SWT.MouseWheel) || filters (SWT.MouseWheel)) { + int delta = wParam >> 16; + Event event = new Event (); + int [] value = new int [1]; + OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, value, 0); + if (value [0] == OS.WHEEL_PAGESCROLL) { + event.detail = SWT.SCROLL_PAGE; + event.count = delta / OS.WHEEL_DELTA; + } else { + event.detail = SWT.SCROLL_LINE; + event.count = value [0] * delta / OS.WHEEL_DELTA; + } + sendEvent (SWT.MouseWheel, event); + if (!event.doit) return LRESULT.ZERO; + } return null; } @@ -3740,6 +3758,18 @@ LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) { return null; } +LRESULT WM_XBUTTONDBLCLK (int wParam, int lParam) { + return wmXButtonDblClk (handle, wParam, lParam); +} + +LRESULT WM_XBUTTONDOWN (int wParam, int lParam) { + return wmXButtonDown (handle, wParam, lParam); +} + +LRESULT WM_XBUTTONUP (int wParam, int lParam) { + return wmXButtonUp (handle, wParam, lParam); +} + LRESULT wmColorChild (int wParam, int lParam) { if (background == -1 && foreground == -1) return null; int forePixel = foreground, backPixel = background; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java index 05e41623ad..460c5cc126 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java @@ -258,7 +258,7 @@ LRESULT WM_MOUSEWHEEL (int wParam, int lParam) { int code = 0, count = 0; if (value [0] == OS.WHEEL_PAGESCROLL) { code = delta < 0 ? OS.SB_PAGEDOWN : OS.SB_PAGEUP; - count = 1; + count = Math.abs (delta / OS.WHEEL_DELTA); } else { code = delta < 0 ? OS.SB_LINEDOWN : OS.SB_LINEUP; delta = Math.abs (delta); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java index f6a2129d81..bce0a8445a 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java @@ -1712,6 +1712,7 @@ LRESULT WM_SETCURSOR (int wParam, int lParam) { case OS.WM_LBUTTONDOWN: case OS.WM_RBUTTONDOWN: case OS.WM_MBUTTONDOWN: + case OS.WM_XBUTTONDOWN: OS.MessageBeep (OS.MB_OK); } return LRESULT.ONE; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java index 69b574fec9..3a40506897 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java @@ -872,6 +872,9 @@ int windowProc (int hwnd, int msg, int wParam, int lParam) { case OS.WM_RBUTTONDBLCLK: result = wmRButtonDblClk (hwnd, wParam, lParam); break; case OS.WM_RBUTTONDOWN: result = wmRButtonDown (hwnd, wParam, lParam); break; case OS.WM_RBUTTONUP: result = wmRButtonUp (hwnd, wParam, lParam); break; + case OS.WM_XBUTTONDBLCLK: result = wmXButtonDblClk (hwnd, wParam, lParam); break; + case OS.WM_XBUTTONDOWN: result = wmXButtonDown (hwnd, wParam, lParam); break; + case OS.WM_XBUTTONUP: result = wmXButtonUp (hwnd, wParam, lParam); break; /* Focus Messages */ case OS.WM_SETFOCUS: result = wmSetFocus (hwnd, wParam, lParam); break; 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 0611ae1f38..93c96824d0 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 @@ -144,7 +144,8 @@ int callWindowProc (int hwnd, int msg, int wParam, int lParam) { */ case OS.WM_LBUTTONDOWN: case OS.WM_MBUTTONDOWN: - case OS.WM_RBUTTONDOWN: { + case OS.WM_RBUTTONDOWN: + case OS.WM_XBUTTONDOWN: { display.ignoreMsgFilter = true; int code = OS.CallWindowProc (TableProc, hwnd, msg, wParam, lParam); display.ignoreMsgFilter = false; 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 4768f28d4f..f07b77080e 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 @@ -179,6 +179,7 @@ int callWindowProc (int hwnd, int msg, int wParam, int lParam) { case OS.WM_LBUTTONDOWN: case OS.WM_MBUTTONDOWN: case OS.WM_RBUTTONDOWN: + case OS.WM_XBUTTONDOWN: display.ignoreMsgFilter = true; int code = OS.CallWindowProc (TreeProc, hwnd, msg, wParam, lParam); display.ignoreMsgFilter = false; 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 83364396d3..93cab26a43 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 @@ -987,17 +987,23 @@ boolean setInputState (Event event, int type) { if (OS.GetKeyState (OS.VK_LBUTTON) < 0) event.stateMask |= SWT.BUTTON1; if (OS.GetKeyState (OS.VK_MBUTTON) < 0) event.stateMask |= SWT.BUTTON2; if (OS.GetKeyState (OS.VK_RBUTTON) < 0) event.stateMask |= SWT.BUTTON3; + if (OS.GetKeyState (OS.VK_XBUTTON1) < 0) event.stateMask |= SWT.BUTTON4; + if (OS.GetKeyState (OS.VK_XBUTTON2) < 0) event.stateMask |= SWT.BUTTON5; switch (type) { case SWT.MouseDown: case SWT.MouseDoubleClick: if (event.button == 1) event.stateMask &= ~SWT.BUTTON1; if (event.button == 2) event.stateMask &= ~SWT.BUTTON2; if (event.button == 3) event.stateMask &= ~SWT.BUTTON3; + if (event.button == 4) event.stateMask &= ~SWT.BUTTON4; + if (event.button == 5) event.stateMask &= ~SWT.BUTTON5; break; case SWT.MouseUp: if (event.button == 1) event.stateMask |= SWT.BUTTON1; if (event.button == 2) event.stateMask |= SWT.BUTTON2; if (event.button == 3) event.stateMask |= SWT.BUTTON3; + if (event.button == 4) event.stateMask |= SWT.BUTTON4; + if (event.button == 5) event.stateMask |= SWT.BUTTON5; break; case SWT.KeyDown: case SWT.Traverse: @@ -1649,7 +1655,8 @@ LRESULT wmLButtonDown (int hwnd, int wParam, int lParam) { LRESULT wmLButtonUp (int hwnd, int wParam, int lParam) { sendMouseEvent (SWT.MouseUp, 1, hwnd, OS.WM_LBUTTONUP, wParam, lParam); int result = callWindowProc (hwnd, OS.WM_LBUTTONUP, wParam, lParam); - if ((wParam & (OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON)) == 0) { + int mask = OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON | OS.MK_XBUTTON1 | OS.MK_XBUTTON2; + if (((wParam & 0xFFFF) & mask) == 0) { if (OS.GetCapture () == hwnd) OS.ReleaseCapture (); } return new LRESULT (result); @@ -1686,7 +1693,8 @@ LRESULT wmMButtonDown (int hwnd, int wParam, int lParam) { LRESULT wmMButtonUp (int hwnd, int wParam, int lParam) { sendMouseEvent (SWT.MouseUp, 2, hwnd, OS.WM_MBUTTONUP, wParam, lParam); int result = callWindowProc (hwnd, OS.WM_MBUTTONUP, wParam, lParam); - if ((wParam & (OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON)) == 0) { + int mask = OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON | OS.MK_XBUTTON1 | OS.MK_XBUTTON2; + if (((wParam & 0xFFFF) & mask) == 0) { if (OS.GetCapture () == hwnd) OS.ReleaseCapture (); } return new LRESULT (result); @@ -1841,7 +1849,8 @@ LRESULT wmRButtonDown (int hwnd, int wParam, int lParam) { LRESULT wmRButtonUp (int hwnd, int wParam, int lParam) { sendMouseEvent (SWT.MouseUp, 3, hwnd, OS.WM_RBUTTONUP, wParam, lParam); int result = callWindowProc (hwnd, OS.WM_RBUTTONUP, wParam, lParam); - if ((wParam & (OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON)) == 0) { + int mask = OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON | OS.MK_XBUTTON1 | OS.MK_XBUTTON2; + if (((wParam & 0xFFFF) & mask) == 0) { if (OS.GetCapture () == hwnd) OS.ReleaseCapture (); } return new LRESULT (result); @@ -1990,4 +1999,45 @@ LRESULT wmSysKeyDown (int hwnd, int wParam, int lParam) { LRESULT wmSysKeyUp (int hwnd, int wParam, int lParam) { return wmKeyUp (hwnd, wParam, lParam); } + +LRESULT wmXButtonDblClk (int hwnd, int wParam, int lParam) { + /* + * Feature in Windows. Windows sends the following + * messages when the user double clicks the mouse: + * + * WM_XBUTTONDOWN - mouse down + * WM_XBUTTONUP - mouse up + * WM_XLBUTTONDBLCLK - double click + * WM_XBUTTONUP - mouse up + * + * Applications that expect matching mouse down/up + * pairs will not see the second mouse down. The + * fix is to send a mouse down event. + */ + int button = (wParam >> 16 == OS.XBUTTON1) ? 4 : 5; + sendMouseEvent (SWT.MouseDown, button, hwnd, OS.WM_XBUTTONDOWN, wParam, lParam); + sendMouseEvent (SWT.MouseDoubleClick, button, hwnd, OS.WM_XBUTTONDBLCLK, wParam, lParam); + int result = callWindowProc (hwnd, OS.WM_XBUTTONDBLCLK, wParam, lParam); + if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + return new LRESULT (result); +} + +LRESULT wmXButtonDown (int hwnd, int wParam, int lParam) { + int button = (wParam >> 16 == OS.XBUTTON1) ? 4 : 5; + sendMouseEvent (SWT.MouseDown, button, hwnd, OS.WM_XBUTTONDOWN, wParam, lParam); + int result = callWindowProc (hwnd, OS.WM_XBUTTONDOWN, wParam, lParam); + if (OS.GetCapture () != hwnd) OS.SetCapture (hwnd); + return new LRESULT (result); +} + +LRESULT wmXButtonUp (int hwnd, int wParam, int lParam) { + int button = (wParam >> 16 == OS.XBUTTON1) ? 4 : 5; + sendMouseEvent (SWT.MouseUp, button, hwnd, OS.WM_XBUTTONUP, wParam, lParam); + int result = callWindowProc (hwnd, OS.WM_XBUTTONUP, wParam, lParam); + int mask = OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON | OS.MK_XBUTTON1 | OS.MK_XBUTTON2; + if (((wParam & 0xFFFF) & mask) == 0) { + if (OS.GetCapture () == hwnd) OS.ReleaseCapture (); + } + return new LRESULT (result); +} } |