mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
Subpixel mouse events
This commit is contained in:
@@ -32,9 +32,10 @@ pub fn processMessage(cmd: anytype) !void {
|
|||||||
// https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-dispatchMouseEvent
|
// https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-dispatchMouseEvent
|
||||||
fn dispatchMouseEvent(cmd: anytype) !void {
|
fn dispatchMouseEvent(cmd: anytype) !void {
|
||||||
const params = (try cmd.params(struct {
|
const params = (try cmd.params(struct {
|
||||||
x: i32,
|
type: Type, // Type of the mouse event.
|
||||||
y: i32,
|
x: f32, // X coordinate of the event relative to the main frame's viewport.
|
||||||
type: Type,
|
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 {
|
const Type = enum {
|
||||||
mousePressed,
|
mousePressed,
|
||||||
@@ -56,8 +57,8 @@ fn dispatchMouseEvent(cmd: anytype) !void {
|
|||||||
const page = bc.session.currentPage() orelse return;
|
const page = bc.session.currentPage() orelse return;
|
||||||
|
|
||||||
const mouse_event = Page.MouseEvent{
|
const mouse_event = Page.MouseEvent{
|
||||||
.x = params.x,
|
.x = @intFromFloat(params.x), // Decimal pixel values are not understood by netsurf or out rendered
|
||||||
.y = params.y,
|
.y = @intFromFloat(params.y), // So we convert them once at intake here
|
||||||
.type = switch (params.type) {
|
.type = switch (params.type) {
|
||||||
.mousePressed => .pressed,
|
.mousePressed => .pressed,
|
||||||
.mouseReleased => .released,
|
.mouseReleased => .released,
|
||||||
|
|||||||
Reference in New Issue
Block a user