1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 06:17:34 +00:00

LibWeb: Refactor WebContentServer mouse input message to DevicePixel

This commit is contained in:
Bastiaan van der Plaat 2023-12-15 17:46:09 +01:00 committed by Alexander Kalenik
parent 1f171cb60b
commit b73ae80d8b
11 changed files with 90 additions and 93 deletions

View file

@ -192,14 +192,12 @@ void ConnectionFromClient::process_next_input_event()
switch (event.type) {
case QueuedMouseEvent::Type::MouseDown:
report_finished_handling_input_event(page().page().handle_mousedown(
event.position.to_type<Web::DevicePixels>(),
event.screen_position.to_type<Web::DevicePixels>(),
event.position, event.screen_position,
event.button, event.buttons, event.modifiers));
break;
case QueuedMouseEvent::Type::MouseUp:
report_finished_handling_input_event(page().page().handle_mouseup(
event.position.to_type<Web::DevicePixels>(),
event.screen_position.to_type<Web::DevicePixels>(),
event.position, event.screen_position,
event.button, event.buttons, event.modifiers));
break;
case QueuedMouseEvent::Type::MouseMove:
@ -209,14 +207,12 @@ void ConnectionFromClient::process_next_input_event()
report_finished_handling_input_event(false);
}
report_finished_handling_input_event(page().page().handle_mousemove(
event.position.to_type<Web::DevicePixels>(),
event.screen_position.to_type<Web::DevicePixels>(),
event.position, event.screen_position,
event.buttons, event.modifiers));
break;
case QueuedMouseEvent::Type::DoubleClick:
report_finished_handling_input_event(page().page().handle_doubleclick(
event.position.to_type<Web::DevicePixels>(),
event.screen_position.to_type<Web::DevicePixels>(),
event.position, event.screen_position,
event.button, event.buttons, event.modifiers));
break;
case QueuedMouseEvent::Type::MouseWheel:
@ -224,9 +220,9 @@ void ConnectionFromClient::process_next_input_event()
report_finished_handling_input_event(false);
}
report_finished_handling_input_event(page().page().handle_mousewheel(
event.position.to_type<Web::DevicePixels>(),
event.screen_position.to_type<Web::DevicePixels>(),
event.button, event.buttons, event.modifiers, event.wheel_delta_x, event.wheel_delta_y));
event.position, event.screen_position,
event.button, event.buttons, event.modifiers,
event.wheel_delta_x, event.wheel_delta_y));
break;
}
},
@ -245,7 +241,7 @@ void ConnectionFromClient::process_next_input_event()
m_input_event_queue_timer->start();
}
void ConnectionFromClient::mouse_down(Gfx::IntPoint position, Gfx::IntPoint screen_position, unsigned int button, unsigned int buttons, unsigned int modifiers)
void ConnectionFromClient::mouse_down(Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, unsigned int button, unsigned int buttons, unsigned int modifiers)
{
enqueue_input_event(
QueuedMouseEvent {
@ -258,7 +254,7 @@ void ConnectionFromClient::mouse_down(Gfx::IntPoint position, Gfx::IntPoint scre
});
}
void ConnectionFromClient::mouse_move(Gfx::IntPoint position, Gfx::IntPoint screen_position, [[maybe_unused]] unsigned int button, unsigned int buttons, unsigned int modifiers)
void ConnectionFromClient::mouse_move(Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, [[maybe_unused]] unsigned int button, unsigned int buttons, unsigned int modifiers)
{
auto event = QueuedMouseEvent {
.type = QueuedMouseEvent::Type::MouseMove,
@ -281,7 +277,7 @@ void ConnectionFromClient::mouse_move(Gfx::IntPoint position, Gfx::IntPoint scre
enqueue_input_event(move(event));
}
void ConnectionFromClient::mouse_up(Gfx::IntPoint position, Gfx::IntPoint screen_position, unsigned int button, unsigned int buttons, unsigned int modifiers)
void ConnectionFromClient::mouse_up(Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, unsigned int button, unsigned int buttons, unsigned int modifiers)
{
enqueue_input_event(
QueuedMouseEvent {
@ -294,7 +290,7 @@ void ConnectionFromClient::mouse_up(Gfx::IntPoint position, Gfx::IntPoint screen
});
}
void ConnectionFromClient::mouse_wheel(Gfx::IntPoint position, Gfx::IntPoint screen_position, unsigned int button, unsigned int buttons, unsigned int modifiers, i32 wheel_delta_x, i32 wheel_delta_y)
void ConnectionFromClient::mouse_wheel(Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, unsigned int button, unsigned int buttons, unsigned int modifiers, Web::DevicePixels wheel_delta_x, Web::DevicePixels wheel_delta_y)
{
auto event = QueuedMouseEvent {
.type = QueuedMouseEvent::Type::MouseWheel,
@ -322,7 +318,7 @@ void ConnectionFromClient::mouse_wheel(Gfx::IntPoint position, Gfx::IntPoint scr
enqueue_input_event(move(event));
}
void ConnectionFromClient::doubleclick(Gfx::IntPoint position, Gfx::IntPoint screen_position, unsigned int button, unsigned int buttons, unsigned int modifiers)
void ConnectionFromClient::doubleclick(Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, unsigned int button, unsigned int buttons, unsigned int modifiers)
{
enqueue_input_event(
QueuedMouseEvent {

View file

@ -60,11 +60,11 @@ private:
virtual void load_html(DeprecatedString const&) override;
virtual void paint(Web::DevicePixelRect const&, i32) override;
virtual void set_viewport_rect(Web::DevicePixelRect const&) override;
virtual void mouse_down(Gfx::IntPoint, Gfx::IntPoint, unsigned, unsigned, unsigned) override;
virtual void mouse_move(Gfx::IntPoint, Gfx::IntPoint, unsigned, unsigned, unsigned) override;
virtual void mouse_up(Gfx::IntPoint, Gfx::IntPoint, unsigned, unsigned, unsigned) override;
virtual void mouse_wheel(Gfx::IntPoint, Gfx::IntPoint, unsigned, unsigned, unsigned, i32, i32) override;
virtual void doubleclick(Gfx::IntPoint, Gfx::IntPoint, unsigned, unsigned, unsigned) override;
virtual void mouse_down(Web::DevicePixelPoint, Web::DevicePixelPoint, unsigned, unsigned, unsigned) override;
virtual void mouse_move(Web::DevicePixelPoint, Web::DevicePixelPoint, unsigned, unsigned, unsigned) override;
virtual void mouse_up(Web::DevicePixelPoint, Web::DevicePixelPoint, unsigned, unsigned, unsigned) override;
virtual void mouse_wheel(Web::DevicePixelPoint, Web::DevicePixelPoint, unsigned, unsigned, unsigned, Web::DevicePixels, Web::DevicePixels) override;
virtual void doubleclick(Web::DevicePixelPoint, Web::DevicePixelPoint, unsigned, unsigned, unsigned) override;
virtual void key_down(i32, unsigned, u32) override;
virtual void key_up(i32, unsigned, u32) override;
virtual void add_backing_store(i32, Gfx::ShareableBitmap const&) override;
@ -164,13 +164,13 @@ private:
DoubleClick,
};
Type type {};
Gfx::IntPoint position {};
Gfx::IntPoint screen_position {};
Web::DevicePixelPoint position {};
Web::DevicePixelPoint screen_position {};
unsigned button {};
unsigned buttons {};
unsigned modifiers {};
int wheel_delta_x {};
int wheel_delta_y {};
Web::DevicePixels wheel_delta_x {};
Web::DevicePixels wheel_delta_y {};
size_t coalesced_event_count { 0 };
};

View file

@ -28,11 +28,11 @@ endpoint WebContentServer
paint(Web::DevicePixelRect content_rect, i32 backing_store_id) =|
set_viewport_rect(Web::DevicePixelRect rect) =|
mouse_down(Gfx::IntPoint position, Gfx::IntPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers) =|
mouse_move(Gfx::IntPoint position, Gfx::IntPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers) =|
mouse_up(Gfx::IntPoint position, Gfx::IntPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers) =|
mouse_wheel(Gfx::IntPoint position, Gfx::IntPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers, i32 wheel_delta_x, i32 wheel_delta_y) =|
doubleclick(Gfx::IntPoint position, Gfx::IntPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers) =|
mouse_down(Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers) =|
mouse_move(Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers) =|
mouse_up(Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers) =|
mouse_wheel(Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers, Web::DevicePixels wheel_delta_x, Web::DevicePixels wheel_delta_y) =|
doubleclick(Web::DevicePixelPoint position, Web::DevicePixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers) =|
key_down(i32 key, unsigned modifiers, u32 code_point) =|
key_up(i32 key, unsigned modifiers, u32 code_point) =|