This repository was archived by the owner on Apr 17, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -163,14 +163,24 @@ public class GlobalUserEventHandler : IMessageFilter
163
163
private const int WM_KEYDOWN = 0x100 ;
164
164
private const int WM_KEYUP = 0x101 ;
165
165
166
+ // screensavers and especially multi-window apps can get spurrious WM_MOUSEMOVE events
167
+ // that don't actually involve any movement (cursor chnages and some mouse driver software
168
+ // can generate them, for example) - so we record the actual mouse position and compare against it for actual movement.
169
+ private Point ? lastMousePos ;
170
+
166
171
public event UserEvent Event ;
167
172
168
173
public bool PreFilterMessage ( ref Message m )
169
174
{
170
- if ( ( m . Msg >= WM_MOUSEMOVE && m . Msg <= WM_MBUTTONDBLCLK )
171
- || m . Msg == WM_KEYDOWN
172
- || m . Msg == WM_KEYUP )
175
+ if ( ( m . Msg == WM_MOUSEMOVE ) && ( this . lastMousePos == null ) )
173
176
{
177
+ this . lastMousePos = Cursor . Position ;
178
+ }
179
+
180
+ if ( ( ( m . Msg == WM_MOUSEMOVE ) && ( Cursor . Position != this . lastMousePos ) )
181
+ || ( m . Msg > WM_MOUSEMOVE && m . Msg <= WM_MBUTTONDBLCLK ) || m . Msg == WM_KEYDOWN || m . Msg == WM_KEYUP )
182
+ {
183
+
174
184
if ( Event != null )
175
185
{
176
186
Event ( ) ;
You can’t perform that action at this time.
0 commit comments