[SDK:SCRNSAVE] Implement mouse move threshold.

This makes it easier to start the screensavers by double-clicking.
This commit is contained in:
Mark Jansen 2023-03-01 21:35:17 +01:00
parent f91b92c3f9
commit 5bc045c041
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B

View file

@ -14,6 +14,7 @@
#include <wingdi.h> #include <wingdi.h>
#include <winuser.h> #include <winuser.h>
#include <tchar.h> #include <tchar.h>
#include <stdlib.h>
#include <scrnsave.h> #include <scrnsave.h>
// Screen Saver window class // Screen Saver window class
@ -33,6 +34,7 @@ UINT MyHelpMessage;
// Local house keeping // Local house keeping
static POINT pt_orig; static POINT pt_orig;
static BOOL pt_init = FALSE;
static int ISSPACE(TCHAR c) static int ISSPACE(TCHAR c)
{ {
@ -65,11 +67,6 @@ static LRESULT WINAPI SysScreenSaverProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP
{ {
switch(uMsg) switch(uMsg)
{ {
case WM_CREATE:
// Mouse is not supposed to move from this position
GetCursorPos(&pt_orig);
break;
case WM_DESTROY: case WM_DESTROY:
PostQuitMessage(0); PostQuitMessage(0);
break; break;
@ -114,12 +111,17 @@ LRESULT WINAPI DefScreenSaverProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
{ {
POINT pt; POINT pt;
GetCursorPos(&pt); GetCursorPos(&pt);
// TODO: Implement mouse move threshold. See:
// http://svn.reactos.org/svn/reactos/trunk/rosapps/applications/screensavers/starfield/screensaver.c?r1=67455&r2=67454&pathrev=67455
if (pt.x == pt_orig.x && pt.y == pt_orig.y)
break;
// Fall through if (!pt_init)
{
pt_orig = pt;
pt_init = TRUE;
break;
}
if (abs(pt.x-pt_orig.x) > 10 || abs(pt.y-pt_orig.y) > 10)
PostMessage(hWnd, WM_CLOSE, 0, 0);
break;
} }
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN: