Skip to content

Commit

Permalink
WindowServer: Added IPC requests for getting and setting mouse settings
Browse files Browse the repository at this point in the history
These include the mouse acceleration factor and the scroll length
step size.
  • Loading branch information
IdanHo authored and awesomekling committed Dec 30, 2020
1 parent db409db commit 8159ce3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Services/WindowServer/ClientConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,35 @@ OwnPtr<Messages::WindowServer::GetGlobalCursorPositionResponse> ClientConnection
return make<Messages::WindowServer::GetGlobalCursorPositionResponse>(Screen::the().cursor_location());
}

OwnPtr<Messages::WindowServer::SetMouseAccelerationResponse> ClientConnection::handle(const Messages::WindowServer::SetMouseAcceleration& message)
{
if (message.factor() < mouse_accel_min || message.factor() > mouse_accel_max) {
did_misbehave("SetMouseAcceleration with bad acceleration factor");
return nullptr;
}
WindowManager::the().set_acceleration_factor(message.factor());
return make<Messages::WindowServer::SetMouseAccelerationResponse>();
}

OwnPtr<Messages::WindowServer::GetMouseAccelerationResponse> ClientConnection::handle(const Messages::WindowServer::GetMouseAcceleration&)
{
return make<Messages::WindowServer::GetMouseAccelerationResponse>(Screen::the().acceleration_factor());
}

OwnPtr<Messages::WindowServer::SetScrollStepSizeResponse> ClientConnection::handle(const Messages::WindowServer::SetScrollStepSize& message)
{
if (message.step_size() < scroll_step_size_min) {
did_misbehave("SetScrollStepSize with bad scroll step size");
return nullptr;
}
WindowManager::the().set_scroll_step_size(message.step_size());
return make<Messages::WindowServer::SetScrollStepSizeResponse>();
}
OwnPtr<Messages::WindowServer::GetScrollStepSizeResponse> ClientConnection::handle(const Messages::WindowServer::GetScrollStepSize&)
{
return make<Messages::WindowServer::GetScrollStepSizeResponse>(Screen::the().scroll_step_size());
}

void ClientConnection::set_unresponsive(bool unresponsive)
{
if (m_unresponsive == unresponsive)
Expand Down
4 changes: 4 additions & 0 deletions Services/WindowServer/ClientConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ class ClientConnection final
virtual void handle(const Messages::WindowServer::SetWindowProgress&) override;
virtual void handle(const Messages::WindowServer::Pong&) override;
virtual OwnPtr<Messages::WindowServer::GetGlobalCursorPositionResponse> handle(const Messages::WindowServer::GetGlobalCursorPosition&) override;
virtual OwnPtr<Messages::WindowServer::SetMouseAccelerationResponse> handle(const Messages::WindowServer::SetMouseAcceleration&) override;
virtual OwnPtr<Messages::WindowServer::GetMouseAccelerationResponse> handle(const Messages::WindowServer::GetMouseAcceleration&) override;
virtual OwnPtr<Messages::WindowServer::SetScrollStepSizeResponse> handle(const Messages::WindowServer::SetScrollStepSize&) override;
virtual OwnPtr<Messages::WindowServer::GetScrollStepSizeResponse> handle(const Messages::WindowServer::GetScrollStepSize&) override;

Window* window_from_id(i32 window_id);

Expand Down
6 changes: 6 additions & 0 deletions Services/WindowServer/WindowServer.ipc
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,11 @@ endpoint WindowServer = 2

GetGlobalCursorPosition() => (Gfx::IntPoint position)

SetMouseAcceleration(float factor) => ()
GetMouseAcceleration() => (float factor)

SetScrollStepSize(u32 step_size) => ()
GetScrollStepSize() => (u32 step_size)

Pong() =|
}

0 comments on commit 8159ce3

Please sign in to comment.