Page 1 of 1

[FIXED] Mouse cursor isn't showing up on Linux

Posted: Tue Apr 27, 2021 6:09 pm
by Ats
I hope this is the last remaining bug (or missing feature?) for a perfect Linux build of ZGE projects: the mouse cursor doesn't show up.
I already tried to play with option App.MouseVisible.

Maybe it is something related to SDL2? I'm going to dig that later.

Re: Mouse cursor isn't showing up on Linux

Posted: Fri Apr 30, 2021 1:19 pm
by Ats
Bug happens in windowed mode and full-screen.
writeln(SDL_ShowCursor(vals[Visible])); returns 1

Is it possible that the mouse is showing before (and behind) the viewport?
I already tried toying with the order of initialization inside procedure TZApplication.CreateWindow;

Or maybe we need to create the cursor with SDL_CreateCursor on Linux? I remember needed to do that years ago for a PSP homebrew relying on SDL and OpenGL.

Re: Mouse cursor isn't showing up on Linux

Posted: Fri Apr 30, 2021 2:49 pm
by Ats
SDL_CreateCursor doesn't solve the problem:

Code: Select all

procedure Platform_ShowMouse(Visible : boolean);
const vals : array[boolean] of integer = (0,1);
var
  data: UInt8 = 150;
  p: ^UInt8;
begin
  p := @data;
  SDL_CreateCursor(p, p, 4, 4, 0, 0);
  SDL_ShowCursor(vals[Visible]);
  writeln(SDL_GetError());
end;
(but maybe I messed up with the UInt8 and pointer...)

Re: Mouse cursor isn't showing up on Linux

Posted: Fri Apr 30, 2021 5:12 pm
by Ats
I got the cursor to show up with "SDL_ShowCursor(1);" instead of "SDL_ShowCursor(vals[Visible])".

The problem is that "writeln(vals[Visible]);" returns 0, either App.MouseVisible is ticked or not.

Re: Mouse cursor isn't showing up on Linux

Posted: Mon May 03, 2021 8:04 am
by VilleK
Maybe change it like this:

Code: Select all

if Visible then 
  SDL_ShowCursor(1)
else
  SDL_ShowCursor(0);

Re: Mouse cursor isn't showing up on Linux

Posted: Mon May 03, 2021 8:28 am
by Ats
Yep. As simple as that. It's working :)

ZPlatform_SDL.inc

Code: Select all

procedure Platform_ShowMouse(Visible : boolean);
begin
  if Visible then
  	SDL_ShowCursor(1)
  else
  	SDL_ShowCursor(0);
end;