mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:37:46 +00:00
Screensaver: Implement mouse hysteresis
Allow the mouse to move a bit before actually closing the app. Fixes #6692
This commit is contained in:
parent
906460e62a
commit
4387a4864c
1 changed files with 8 additions and 2 deletions
|
@ -23,6 +23,7 @@ public:
|
|||
private:
|
||||
Screensaver(int width = 64, int height = 48, int interval = 10000);
|
||||
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||
Gfx::IntPoint m_mouse_origin;
|
||||
|
||||
void draw();
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
|
@ -45,9 +46,14 @@ Screensaver::~Screensaver()
|
|||
{
|
||||
}
|
||||
|
||||
void Screensaver::mousemove_event(GUI::MouseEvent&)
|
||||
void Screensaver::mousemove_event(GUI::MouseEvent& event)
|
||||
{
|
||||
constexpr float max_distance_move = 10;
|
||||
if (m_mouse_origin.is_null()) {
|
||||
m_mouse_origin = event.position();
|
||||
} else if (event.position().distance_from(m_mouse_origin) > max_distance_move) {
|
||||
::exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
void Screensaver::mousedown_event(GUI::MouseEvent&)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue