mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:27:34 +00:00
LibDesktop: Do not quit screensaver on immediate mouse move
Let's delay this way of quitting the screensavers by 750ms. :^)
This commit is contained in:
parent
18b6bdb563
commit
7d5839f793
2 changed files with 13 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
|||
namespace Desktop {
|
||||
|
||||
static constexpr int mouse_max_distance_move = 10;
|
||||
static constexpr int mouse_tracking_delay_milliseconds = 750;
|
||||
|
||||
ErrorOr<NonnullRefPtr<GUI::Window>> Screensaver::create_window(StringView title, StringView icon)
|
||||
{
|
||||
|
@ -39,6 +40,10 @@ void Screensaver::mousedown_event(GUI::MouseEvent&)
|
|||
|
||||
void Screensaver::mousemove_event(GUI::MouseEvent& event)
|
||||
{
|
||||
auto now = AK::Time::now_monotonic();
|
||||
if ((now - m_start_time).to_milliseconds() < mouse_tracking_delay_milliseconds)
|
||||
return;
|
||||
|
||||
if (!m_mouse_origin.has_value())
|
||||
m_mouse_origin = event.position();
|
||||
else if (event.position().distance_from(m_mouse_origin.value()) > mouse_max_distance_move)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue