Anyone know how to make Linux API calls from Xojo?

Like the title says, I’d like to find some information on making Linux API calls from Xojo. There seems to be a lot of info pertaining to calling MS and Apple API’s but precious little for Linux.

I hope there’s a good Samaritan somewhere that can offer some tutorials on this subject.

Specifically, I’m looking for help with this API call.


@Wes Westhaver — All API calls are roughly the same no matter the platform:

  1. You need to figure out the type for each parameter (including the return type)
  2. Do you need to link against a specific library ?
  3. Declare the function/sub in Xojo using compatible Xojo types

For xwarppointer the declaration is:

int XWarpPointer(Display *display, Window src_w, Window dest_w, int src_x, int src_y, unsigned int src_width, unsigned int src_height, int dest_x, int dest_y);

“int” values are integers, “Display *” is a Ptr (because of the *). Only “Window” is a bit tricky as Linux may declare this type as it wants (integer or pointer). I don’t know anything about Linux but I expect you to be able to use the value returned by Xojo’s Window.Handle for that parameter, so just use the same type (Handle is unfortunately an integer in Xojo).

Overall, I think the following should work:

soft declare XWarpPointer lib XXXXXXXXXX (display as Ptr, src as integer, dest as integer, srcx as integer, srcy as integer, srcwidth as integer, srcheight as integer, destx as integer, desty as integer) as integer

The involved lib must be, the parameter structures must be checked at .h sources involved.

A big thank you to StphaneMons and RickAraujo

I managed to find enough information to flesh out the rest of what is required to move the mouse pointer programatically in order to force the mouse pointer change to become active immediately.

Here’s what I came up with:

Soft Declare Function XOpenDisplay Lib "" (display As Ptr) As Ptr
Soft Declare Function XWarpPointer Lib "" (display As Ptr, src_w As Integer, dest_w As Integer, src_x As Integer, src_y As Integer, src_width As Integer, src_height As Integer, dest_x As Integer, dest_y As Integer) As Integer
Soft Declare Sub XCloseDisplay Lib "" (display As Ptr)

Var Display_ptr As Ptr
Var RetVal_int As Integer

' Let the OS know we want to change the mouse pointer.
App.MouseCursor = System.Cursors.InvisibleCursor

' Get pointer to display structure.
Display_ptr = XOpenDisplay(Nil)

' Move mouse pointer programatically.
RetVal_int = XWarpPointer(Display_ptr, 0, 0, 0, 0, 0, 0, 0, 0)

' Release display structure.

Now when the mouse pointer is hidden, it becomes hidden immediately rather than after the mouse pointer is moved. This is great for hiding the mouse pointer on touch-screen based Raspberry Pi applications where you want to hide the mouse pointer immediately and not have the mouse pointer lingering on the screen.

A System.Cursors.Hide() also delays? If so, I think it’s a bug needing a feedback.

I set “xserver-command=X” to “xserver-command=X -nocursor” in “/etc/lightdm/lightdm.con”, this hides it at a system level and has worked well for my proposes although, I would rather use Xojo.

Please file a bug report and I will vote on it.

@Rick Araujo

Under Linux (Ubuntu or Raspbian) the “System.Cursors.Hide()” and “System.Cursors.Show()” have never worked for me. They seem to have no effect whatsoever on the mouse pointer. This is why I resorted to:

App.MouseCursor = System.Cursors.InvisibleCursor

I’ve been using Xojo since 2017 and it seems that Linux fixes are at the bottom of Xojo’s priority list. So I have to find work-arounds.

@Alex Bombay

Yeah, I want the mouse pointer to work normally when I exit my application so hiding the mouse pointer needs to be handled at the application level for me.


[quote=492926:@Wes Westhaver]I’ve been using Xojo since 2017 and it seems that Linux fixes are at the bottom of Xojo’s priority list. So I have to find work-arounds.


Tell me about, I do like the remote debugging though, not having to debug on a 7in screen is nice. Still hoping bugs like threads using 100% CPU <> and 64bit support happen soon.