mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 08:41:15 +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
Notes:
sideshowbarker
2024-07-18 19:00:48 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/4387a4864ca Pull-request: https://github.com/SerenityOS/serenity/pull/6698 Issue: https://github.com/SerenityOS/serenity/issues/6692
|
@ -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)
|
||||
{
|
||||
::exit(0);
|
||||
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…
Reference in a new issue