libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
10.2k stars 1.86k forks source link

Passing Focus to Previous Window #8263

Closed GudBoiNero closed 9 months ago

GudBoiNero commented 1 year ago

I'm using ImGui with SDL2 and Opengl3. I'm attempting to create a top level window that allows you to press buttons to imitate macros. Getting it to stay top level was easy, but my main issue right now is making sure that the menu doesn't take up the focus of the other windows.

https://github.com/GudBoiNero/PrimedKeys/issues/8

As you can see, my focus is on VSCode yet my MacroMenu is still on top of it. That's exactly what I want. image

HOWEVER. When I click on my MacroMenu, VSCode loses focus, I want my focus to stay on VSCode whenever I press on my MacroMenu image

I can't find much documentation for this. Help appreciated.

If you want to try for yourself you should be able to simply clone master and run it on Release x86. As long as your on windows.

slouken commented 9 months ago

I'm not sure how you would keep mouse focus on another window when you're clicking on the macro window. That seems counter-intuitive to how mouse focus works?

GudBoiNero commented 9 months ago

I'm not sure how you would keep mouse focus on another window when you're clicking on the macro window. That seems counter-intuitive to how mouse focus works?

At the time I wasn't really sure what I was talking about since I'm very new to this area.

I ended up making a working solution using a windows hook and tracking each window the user opens.

The way I was describing it here was incorrect compared to what I was really trying to accomplish.

slouken commented 9 months ago

Okay, feel free to open a new issue with more details if there's something you think SDL should be doing differently here.