Skip to content
This repository has been archived by the owner on Feb 10, 2024. It is now read-only.

[SDL2]: Possibility to reveal mouse pointer outside an SDL window? #159

Open
raziel- opened this issue Sep 2, 2020 · 13 comments
Open

[SDL2]: Possibility to reveal mouse pointer outside an SDL window? #159

raziel- opened this issue Sep 2, 2020 · 13 comments

Comments

@raziel-
Copy link

raziel- commented Sep 2, 2020

So, i have an SDL app running in window mode.
It has it´s own mouse pointer which moves around just fine inside the window borders.
Though, once you happen to move the pointer outside the window borders the SDL apps pointer is stuck at where you left the window.
While i understand that the SDL apps pointer won´t move along the window borders according to where the (now hidden) pointer is outside the window, it would still be nice to see where it is.

Right now, moving the pointer out of the window makes it vanish completely (on the rest of the Workbench screen that is).
The pointer itself is still tracked by the system though, because if i move it anywhere on the WB and click, it will pop up at the correct spot.
The problem is to find the "correct" spot to click, because the pointer could be anywhere, e.g. over a docky icon and clicking now to reveal the pointer also clicks on the docky icon and starts the program bound to it (which is not wanted in that case).

My question is:
Would it be possible to reveal the pointer on WB, once it leaves the borders of an SDL window?
It wouldn´t have to be the original WB pointer, i´d be happy with anything i could track with my eyes, like a bright red dot or something.

Thank you

AmigaOS4
SDL 2.0.12
SDL 1.0.15

@capehill
Copy link
Collaborator

Can you share the link to sources, please? It seems like app is hiding the mouse pointer but not grabbing the input.

I think it should be technically possible to do what you describe, by tracking the mouse coordinates and comparing against the window box. However there is one big problem potentially: if application uses different "mouse sensitivity" parameters, then system pointer and application pointer are never in sync and it probably ends in strange result (2 mouse pointers with different speeds).

@raziel-
Copy link
Author

raziel- commented Oct 11, 2020

Sure, it's ScummVM.

I remember having a vice-versa issue when switching to SDL2 in ScummVM.

A remaining red or black dot was still visibly drawn OVER the ScummVM pointer.

But the pointer itself was invisible outside the SDL window from day one, iirc.

I can provide a minimal test build, if necessary, will take some time, though

@capehill
Copy link
Collaborator

If I remember correctly, clearing the mouse pointer was done wrongly and that caused extra dot. Ok, no need to make test build, I should be able to build ScummVM locally if needed.

@raziel-
Copy link
Author

raziel- commented Oct 11, 2020

Thank you very much for taking a look.

@capehill
Copy link
Collaborator

Maybe you could try comment out the next line for the science: https://github.com/scummvm/scummvm/blob/bb388295a465ef2443a419bc399ae52e71c39df5/backends/platform/sdl/sdl.cpp#L167 (or change it to SDL_ENABLE)

The idea is to observe system pointer behaviour related to ScummVM's one. Of course, there is mouse code all over ScummVM so that line may not be sufficient.

@raziel-
Copy link
Author

raziel- commented Nov 14, 2020

There are four instances of SDL_ShowCursor(SDL_ENABLE) in the code.
Setting all of them to "forced" diable changes nothing.

That is as far as my limited knowledge will take me.
I'm not sure if ScummVM is preventing the cursor to be drawn outside a window or our SDL implementantion, but if my (again, limited) memory serves me right i have never had an SDL app show the system cursor outside it's window, so it might as well be a limitation of SDL itself?

@capehill
Copy link
Collaborator

@raziel- IIRC I changed locally this file also https://github.com/scummvm/scummvm/blob/d968d22eb124a9f422d5c5ebd401135cdd41033f/backends/graphics/sdl/sdl-graphics.cpp

And then I could see 2 cursors at the same time, and they were actually in sync within the window area.

@raziel-
Copy link
Author

raziel- commented Nov 15, 2020

@capehill

Thanks for the tests.

That is not the intended behaviour i was looking for though.
I don't want to have two mouse pointers visible simultaneously, rather i'd like to reveal the system pointer only when the mouse is moved outside the sdl apps window.

I guess ScummVM is not capable of doing that, but is SDL?

@capehill
Copy link
Collaborator

@raziel- it was merely a debugging test, not a solution. I don't know yet how to deal with this request, it's kind of multidimensional :) There is SDL 1 and 2. Then there is possibility to capture (grab) pointer inside the window (so cannot move pointer out of window). And probably loads of more things that I cannot even think right now.

@raziel-
Copy link
Author

raziel- commented Nov 17, 2020

Don't feel pushed.
Take your time and if it isn't possible than that's ok too...no life depending on this FR.

@raziel-
Copy link
Author

raziel- commented Apr 10, 2022

@capehill

I'm not sure if it will help the effort in any way, but you could probably drop the SDL1 part from this request?

@capehill capehill changed the title [SDL1/2]: Possibility to reveal mouse pointer outside an SDL window? [SDL2]: Possibility to reveal mouse pointer outside an SDL window? Apr 23, 2022
@capehill
Copy link
Collaborator

@raziel- done, sorry, I haven't been investigating this much.

@raziel-
Copy link
Author

raziel- commented Apr 23, 2022

No problem.
Would be nice to have, but not essential.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants