Skip to content

xtst: XTestFakeRelativeMotionEvent has wrong signature #182

@boltzmannrain

Description

@boltzmannrain

According to
https://refspecs.linuxfoundation.org/LSB_4.0.0/LSB-Desktop-generic/LSB-Desktop-generic.html
signature is

extern int XTestFakeRelativeMotionEvent(Display *, int, int,
					unsigned long int);

same in https://gitlab.freedesktop.org/xorg/lib/libxtst/-/blob/master/include/X11/extensions/XTest.h?ref_type=heads

extern int XTestFakeRelativeMotionEvent(
    Display*		/* dpy */,
    int			/* x */,
    int			/* y */,
    unsigned long	/* delay */
);

and in implementation https://cgit.freedesktop.org/xorg/lib/libXtst/tree/src/XTest.c

But some manpages like https://man.freebsd.org/cgi/man.cgi?query=XTestFakeRelativeMotionEvent&sektion=3&manpath=freebsd-ports have it wrong

       int XTestFakeRelativeMotionEvent(display, screen_number,	x, y, delay);

					 Display *display;
					 int screen_number;
					 int x,	y;
					 unsigned long delay;

as well as this doc https://www.x.org/releases/X11R7.7/doc/libXtst/xtestlib.html
and same in this crate https://github.com/AltF02/x11-rs/blob/master/src/xtest.rs#L25

It seems like manpages were always wrong
https://cgit.freedesktop.org/xorg/lib/libXtst/commit/?id=d9514f97f54b47630b645ef44a5d40262a10d33a - adds manpages
and it doesn't match actual signature from same tree https://cgit.freedesktop.org/xorg/lib/libXtst/tree/src/XTest.c?id=d9514f97f54b47630b645ef44a5d40262a10d33a

So, signature without screen_number should be used.

I have also tested that correct signature behaves without weird randomness or crashes I saw in current signature.
Tested via manual linking of correct signature under different name

extern "C" {
  #[link_name = "XTestFakeRelativeMotionEvent"]
  pub fn XTestFakeRelativeMotionEvent_fixed (_5: *mut _XDisplay, _3: c_int, _2: c_int, _1: c_ulong) -> c_int;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions