mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-06-11 01:25:53 -04:00
cdp: use Frame.mouse_button consts from cdp.input.zig
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user