summaryrefslogtreecommitdiff
path: root/Userland/Services/WindowServer
diff options
context:
space:
mode:
authordavidot <davidot@serenityos.org>2022-10-22 14:41:52 +0200
committerLinus Groh <mail@linusgroh.de>2022-10-23 15:48:45 +0200
commit97dc1585b19eab7addcd23f24cb1b8718e2eb472 (patch)
tree77a593e8ff105718baf5bf3c6da3d5ae3799c63c /Userland/Services/WindowServer
parent1ab6cb1ee91b161c130bbfe266edf1f59e1242bd (diff)
downloadserenity-97dc1585b19eab7addcd23f24cb1b8718e2eb472.zip
WindowServer: Reset mouse acceleration if out of range
Before if the mouse acceleration was out of range the WindowServer would crash, this could happen if the config had an out of range or non double vaule.
Diffstat (limited to 'Userland/Services/WindowServer')
-rw-r--r--Userland/Services/WindowServer/main.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/Userland/Services/WindowServer/main.cpp b/Userland/Services/WindowServer/main.cpp
index 05852851ba..8771a01412 100644
--- a/Userland/Services/WindowServer/main.cpp
+++ b/Userland/Services/WindowServer/main.cpp
@@ -128,7 +128,13 @@ ErrorOr<int> serenity_main(Main::Arguments)
auto& screen_input = WindowServer::ScreenInput::the();
screen_input.set_cursor_location(WindowServer::Screen::main().rect().center());
- screen_input.set_acceleration_factor(atof(wm_config->read_entry("Mouse", "AccelerationFactor", "1.0").characters()));
+ double f = atof(wm_config->read_entry("Mouse", "AccelerationFactor", "1.0").characters());
+ if (f < WindowServer::mouse_accel_min || f > WindowServer::mouse_accel_max) {
+ dbgln("Mouse.AccelerationFactor out of range resetting to 1.0");
+ f = 1.0;
+ wm_config->write_entry("Mouse", "AccelerationFactor", "1.0");
+ }
+ screen_input.set_acceleration_factor(f);
screen_input.set_scroll_step_size(wm_config->read_num_entry("Mouse", "ScrollStepSize", 4));
WindowServer::Compositor::the();