cdp: use Frame.mouse_button consts from cdp.input.zig

This commit is contained in:
Pierre Tachoire
2026-06-08 08:42:54 +02:00
parent e68def97b3
commit fdf6276f39
2 changed files with 8 additions and 11 deletions

View File

@@ -3904,10 +3904,12 @@ fn findFrameByName(frame: *Frame, name: []const u8) ?*Frame {
// DOM MouseEvent.button values.
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
const mouse_button = struct {
const main: i32 = 0; // left
const auxiliary: i32 = 1; // middle
const secondary: i32 = 2; // right
pub const mouse_button = struct {
pub const main: i32 = 0; // left
pub const auxiliary: i32 = 1; // middle
pub const secondary: i32 = 2; // right
pub const fourth: i32 = 3; // back
pub const fifth: i32 = 4; // forward
};
// Dispatch a single trusted mouse event of the given type on `target`, carrying

View File

@@ -19,6 +19,8 @@
const std = @import("std");
const CDP = @import("../CDP.zig");
const dom_button = @import("../../browser/Frame.zig").mouse_button;
pub fn processMessage(cmd: *CDP.Command) !void {
const action = std.meta.stringToEnum(enum {
dispatchKeyEvent,
@@ -113,13 +115,6 @@ fn dispatchMouseEvent(cmd: *CDP.Command) !void {
// Map the CDP button name to the DOM MouseEvent.button value.
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
const dom_button = struct {
const main: i32 = 0;
const auxiliary: i32 = 1;
const secondary: i32 = 2;
const fourth: i32 = 3;
const fifth: i32 = 4;
};
const button: i32 = switch (params.button) {
.none, .left => dom_button.main,
.middle => dom_button.auxiliary,