Subpixel mouse events

This commit is contained in:
sjorsdonkers
2025-05-06 12:32:47 +02:00
parent 3095f2110e
commit 0dea4c51b7

View File

@@ -32,9 +32,10 @@ pub fn processMessage(cmd: anytype) !void {
// https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-dispatchMouseEvent
fn dispatchMouseEvent(cmd: anytype) !void {
const params = (try cmd.params(struct {
x: i32,
y: i32,
type: Type,
type: Type, // Type of the mouse event.
x: f32, // X coordinate of the event relative to the main frame's viewport.
y: f32, // Y coordinate of the event relative to the main frame's viewport. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
// Many optional parameters are not implemented yet, see documentation url.
const Type = enum {
mousePressed,
@@ -56,8 +57,8 @@ fn dispatchMouseEvent(cmd: anytype) !void {
const page = bc.session.currentPage() orelse return;
const mouse_event = Page.MouseEvent{
.x = params.x,
.y = params.y,
.x = @intFromFloat(params.x), // Decimal pixel values are not understood by netsurf or out rendered
.y = @intFromFloat(params.y), // So we convert them once at intake here
.type = switch (params.type) {
.mousePressed => .pressed,
.mouseReleased => .released,