AmigaPorts / SDL_old

Automated mirror of https://hg.libsdl.org/SDL/
Other
9 stars 5 forks source link

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

Open raziel- opened 4 years ago

raziel- commented 4 years ago

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 commented 3 years ago

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- commented 3 years ago

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 commented 3 years ago

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- commented 3 years ago

Thank you very much for taking a look.

capehill commented 3 years ago

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- commented 3 years ago

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 commented 3 years ago

@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- commented 3 years ago

@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 commented 3 years ago

@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- commented 3 years ago

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- commented 2 years ago

@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 commented 2 years ago

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

raziel- commented 2 years ago

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