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ā€: <https://xojo.com/issue/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