Raspian issue with hiding cursor, not a Xojo problem!

Hi All,

I am having a great time developing an application across Mac, Linux, Raspberry and win that uses the serial port to control a device I have developed.

All that has gone along without much issue until I get to the Raspberry port, which is by and large identical to the Mac, where it was created.

The Raspberry port is to be touch based only, it will boot up into a full screen with a totally touch based interface, capacitive as it happens, none of this is directly anything to do with the issue.

What I am finding is an issue with Raspian, therefore my question is for anyone with a bit of knowledge regarding the idiosyncrasies of linux/Pi that might shed some light upon this silly issue.

I have spent (wasted) plenty of time searching the endless linux stuff on duckduckgo where you get a thousand results with virtually nothing of any use, which I am finding is a thread within this linux lark.

There issue is staggeringly simple, get rid of the mouse cursor when the system is booted up, there is obviously no need for a mouse cursor of any type when using a touch interface.

After finding a solution that is supposed to fix it, editing “/etc/X11/xinit/xserverrc” by adding “-nocursor” I found it did absolutely nothing, the cursor was there at every boot up.

At this point I gave up and posted on the Pi forum to ask for anyone else’s experience and also thought I should ask here too.

During this time I re-booted the Pi and had changed it to boot to CLI.

Then I typed in the terminal (or should I say the stone age interface, which I detest!) startx as is expected.

Upon boot there was no mouse pointer!, hoorah! I thought, so I now went to preferences and set the boot to GUI, mmmmmm goes what happens…
Yup the mouse comes back, therefore it appears if you boot into the GUI it completely ignores the changes in the “/etc/X11/xinit/xserverrc” file and has its own ideas, or does it???

That is the question, are there more silly hidden magic files in this crazy linux world that anyone knows of which might be able to help!

Please can we have PiOSX…

Any help would be very much appreciated

P.S. this ere Xojo is damn great to develop on Pi, you can’t get enough Pi

Gracias a todos!

I had some success with unclutter for a touch project.
http://raspberrypi.stackexchange.com/questions/2092/hide-cursor-in-raspbian

I think you can set it to always hide the cursor…
If not, it’s hidden after a second when not used.

Thanks Albin, unclutter is not seemingly the answer for me.
I have seen the link you posted, along with I don’t know how many others, none of which end up with anything that suits what I wish to achieve.

I have tried more on my issue, I now have a clean install of raspian and modified the “xserverrc” file as described in my original post.
This now throws me a new problem.
If you boot to CLI and then type “startx” the cursor does actually disappear as expected.
But if you boot to GUI the cursor is there all the time.

It seems like when booting to GUI in this manner somehow ignores the modified startup script.
Now my question is what the heck does it use to start the GUI if not simply “startx”???

Any ideas out there?

Mark - I’ve recently made a touch-only app for RPi, and was vexed by many of your same issues. I’ve gotten thru about 99% of them, and I’ll paste in my solutions that address your questions (some of them) in a couple posts later tonight when I get home. Hoping to help!

Regarding booting into a GUI:

I used the following cmd to edit the autostart config for the user ‘pi’. When you login as ‘pi’ (or any user) the autostart file apparently gets called. If you open it for edit you’ll see several entries you can copy. Essentially it’s about adding an entry starting with and “@” with the path to your app.

sudo nano /home/pi/.config/lxsession/LXDE-pi/autostart

Regarding “hiding mouse/cursor”:

I’ve got an open post on this right now, with a final suggestion posted that I haven’t tried yet. Read the whole thread and I bet something jumps out at you. Good luck!

http://forum.xojo.com/29223-how-to-programmatically-move-mousecursor-to-make-invisiblecurso/unread

Hello William, thank you for the information.

I already tried some of it, and I even got in touch with the author of raps config, who no longer maintains the code, he was unable to help.
It does seem a very simple problem with a very complex answer, all too often the case with linux I am finding.

I will check it and see what happens and report back

Regards

Update to my entries for "hiding cursor’: I’ve been using a new copy of RASPBIAN STRETCH WITH DESKTOP (Linux version 4.14.34-v7+) and having inconsistent results with “unclutter” (and app for hiding the cursor), so did some poking around and found that many people are adding a line to ‘xserver’ settings to prevent a cursor altogether. I’m having great results, here’s what I did…

…Used this command to locate the file that loads ‘xserver’…

grep -r “xserver-command”

…and somehow stubbled onto ‘01_debian.conf’ file.

#edit this file:
/usr/share/lightdm/lightdm.conf.d/01_debian.conf

…below are the contents of the ‘01_debian.conf’ file, where I’ve added xserver-command=X -nocursor to the end

Debian specific defaults

- use lightdm-greeter session greeter, points to the etc-alternatives managed

greeter

- hide users list by default, we don’t want to expose them

- use Debian specific session wrapper, to gain support for

/etc/X11/Xsession.d scripts

[Seat:*]
greeter-session=lightdm-greeter
greeter-hide-users=true
session-wrapper=/etc/X11/Xsession
xserver-command=X -nocursor

Thanks for posting this. I’m also using unclutter to hide the cursor on Linux (Raspberry Pi, Jessie).

But… If the cursor is always hidden, how do you use the UI? Do you ssh in, change it back and then reboot?

Ultimately I’d rather see the Xojo engineers fix the Linux support to correctly hide the cursor. I submitted a feedback case on this a while back titled “System.Cursors.Hide fails on Linux”: feedback://showreport?report_id=45772

Please add it to your Top Cases to help it get more points. Sounds like we’re running out of time to use unclutter now…

Yes, I’ve been using ssh to ‘undo’ this when I need to use the cursor to return (followed by a reboot). My app is a touch-screen appliance, so no cursor needed (or desired).

William,

Apparently there is an API to move the mouse pointer. When I first started looking into the contents of the /home/pi/.config/lxsession/LXDE-pi/autostart file I noticed an entry for “point-rpi”. I came across the GitHub page for it and found out that it’s purpose is to move the mouse pointer over the Start button on the taskbar at boot-up. This causes the “Click here to open applications menu” pop-up message to display. It’s a nice way to draw a new user’s attention to the Start button to get them going with the Raspbian desktop.

Here’s the GitHub page for point-rpi:

point-rpi.c

The point-rpi utility makes a call to the “XWarpPointer” function to move the mouse pointer. I wonder if calling this function after setting the mouse pointer to invisible would cause it to disappear? I’m new to Linux so I don’t know how to make such a call from Xojo (I’m more comfortable with Windows API calls).

I think I might just try to shell out to run the point-rpi program right after I set the mouse pointer to invisible to see if it does the trick. If it works, then looking into just making a call directly to “XWarpPointer” from Xojo might be worthwhile.

-Wes

Well whaddya know. It worked.

I placed this code:

Dim objShell As Shell

Self.MouseCursor = System.Cursors.InvisibleCursor

objShell = New Shell
objShell.Execute("point-rpi")
objShell = Nil

in the “Activate” event handler of my main window and whenever the main window becomes active either at startup or regaining focus after a modal dialog closes, the mouse pointer disappears.

I like that it doesn’t permanently remove the mouse pointer. The mouse pointer reappears when the application closes and so the desktop continues to function normally.

-Wes

Hero.

William Yu at Xojo updated my feedback case to suggest using Self.MouseCursor = System.Cursors.InvisibleCursor and that fixes the issue for my needs. Once my Linux (Raspbian Jessie) app starts up and the user enters a bit of data the app then runs in an unattended mode (digital signage) and the cursor is never needed again in the app.

I don’t recall how I missed setting the cursor to “System.Cursors.InvisibleCursor” unless this was added recently. I see that using this was also mentioned above by Wes.

With the introduction of the new “Raspberry Pi OS” (replacing “Raspbian”) the trick I posted for hiding the mouse pointer no longer works as it once did:

[code]
’ Let the OS know we want to change the mouse pointer.

App.MouseCursor = System.Cursors.InvisibleCursor

’ Now move mouse pointer programmatically to make it happen.

Shell_obj = New Shell
Shell_obj.Execute(“point-rpi”)
Shell_obj = Nil[/code]

With the new OS, the mouse pointer WILL become invisible but only after you move the mouse. The reason for this is that they removed the “point-rpi” program from the new Raspberry Pi OS. They felt it was no longer needed. If you need this functionality, you can re-install the “point-rpi” program thusly:

sudo apt install point-rpi

Now the mouse pointer will hide itself immediately like it did previously.

As I said in my earlier post, the point-rpi utility makes a call to the “XWarpPointer” function to move the mouse pointer. Does anyone know how to make this call from Xojo? If so, then we would no longer need to depend on the “pointer-rpi” program being installed on our system.

One further note:

If you try to restore the mouse pointer using:

App.MouseCursor = System.Cursors.StandardPointer

Raspberry Pi OS will flip the mouse pointer image. You can see it demonstrated here.

Instead, use this to restore the mouse pointer:

App.MouseCursor = Nil

-Wes

Since my last post I’ve figured out how to make an API call to hide the mouse pointer. This eliminates the need to Shell out and run the now deprecated “point-rpi” program.

Here’s what I came up with:

[code]Soft Declare Function XOpenDisplay Lib “libX11.so.6” (display As Ptr) As Ptr
Soft Declare Function XWarpPointer Lib “libX11.so.6” (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 “libX11.so.6” (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.

XCloseDisplay(Display_ptr)[/code]

Place the above code into a method and you now have a way to hide the mouse cursor reliably and without dependencies on external programs.

1 Like