Skip to content

Commit 0dea4c5

Browse files
committed
Subpixel mouse events
1 parent 3095f21 commit 0dea4c5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/cdp/domains/input.zig

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ pub fn processMessage(cmd: anytype) !void {
3232
// https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-dispatchMouseEvent
3333
fn dispatchMouseEvent(cmd: anytype) !void {
3434
const params = (try cmd.params(struct {
35-
x: i32,
36-
y: i32,
37-
type: Type,
35+
type: Type, // Type of the mouse event.
36+
x: f32, // X coordinate of the event relative to the main frame's viewport.
37+
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.
38+
// Many optional parameters are not implemented yet, see documentation url.
3839

3940
const Type = enum {
4041
mousePressed,
@@ -56,8 +57,8 @@ fn dispatchMouseEvent(cmd: anytype) !void {
5657
const page = bc.session.currentPage() orelse return;
5758

5859
const mouse_event = Page.MouseEvent{
59-
.x = params.x,
60-
.y = params.y,
60+
.x = @intFromFloat(params.x), // Decimal pixel values are not understood by netsurf or out rendered
61+
.y = @intFromFloat(params.y), // So we convert them once at intake here
6162
.type = switch (params.type) {
6263
.mousePressed => .pressed,
6364
.mouseReleased => .released,

0 commit comments

Comments
 (0)