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

Found a bug? Post information about it here so we can fix it!

Moderator: Moderators

Post Reply
User avatar
Ats
Posts: 704
Joined: Fri Sep 28, 2012 10:05 am
Contact:

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

Post 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.
Last edited by Ats on Mon May 03, 2021 2:27 pm, edited 1 time in total.
User avatar
Ats
Posts: 704
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Mouse cursor isn't showing up on Linux

Post 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.
Last edited by Ats on Fri Apr 30, 2021 5:02 pm, edited 1 time in total.
User avatar
Ats
Posts: 704
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Mouse cursor isn't showing up on Linux

Post 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...)
User avatar
Ats
Posts: 704
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Mouse cursor isn't showing up on Linux

Post 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.
User avatar
VilleK
Site Admin
Posts: 2316
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Mouse cursor isn't showing up on Linux

Post by VilleK »

Maybe change it like this:

Code: Select all

if Visible then 
  SDL_ShowCursor(1)
else
  SDL_ShowCursor(0);
User avatar
Ats
Posts: 704
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Mouse cursor isn't showing up on Linux

Post 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;
Post Reply