- Notifications
You must be signed in to change notification settings - Fork2.5k
Add click-through functionality for windows#14561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
slouken commentedDec 1, 2025
For dynapi, go ahead and revert your changes in that directory and run src/dynapi/gendynapi.py instead. Also, in general, please use the SDL coding style, e.g. if (x) {}else {} |
AQtun81 commentedDec 3, 2025
I have made so many small errors and commits fixing them, so I went ahead and squashed the commits, it should make the changes more readable. Regarding the API, should This is the program I'm using to test the feature, it renders a red square on a transparent window and toggles mouse passthrough when mouse cursor hovers over it or leaves the area. #include<SDL3/SDL.h>intmain(){constSDL_FRecttestRect= {100,100,200,200};boolrunning= true;boolmousePassthrough= false;SDL_Eventevent;if (!SDL_Init(SDL_INIT_VIDEO)) {SDL_Log("SDL_Init failed: %s",SDL_GetError());return1; }SDL_Window*window=SDL_CreateWindow("Mouse Passthrough",800,600,SDL_WINDOW_TRANSPARENT |SDL_WINDOW_BORDERLESS |SDL_WINDOW_ALWAYS_ON_TOP);if (!window) {SDL_Log("SDL_CreateWindow failed: %s",SDL_GetError());SDL_Quit();return1; }SDL_Renderer*renderer=SDL_CreateRenderer(window,NULL);if (!renderer) {SDL_Log("SDL_CreateRenderer failed: %s",SDL_GetError());SDL_DestroyWindow(window);SDL_Quit();return1; }SDL_SetRenderVSync(renderer,1);SDL_SetRenderDrawBlendMode(renderer,SDL_BLENDMODE_BLEND);while (running) {while (SDL_PollEvent(&event)) {if (event.type==SDL_EVENT_QUIT) {running= false; }if (event.type==SDL_EVENT_KEY_DOWN) {if (event.key.key==SDLK_ESCAPE) {running= false; } } }// toggle mouse passthroughfloatx,y;intxOffset,yOffset;SDL_GetGlobalMouseState(&x,&y);SDL_GetWindowPosition(window,&xOffset,&yOffset);x-= (float)xOffset;y-= (float)yOffset;boolhovered=x >=testRect.x&&x<testRect.x+testRect.w&&y >=testRect.y&&y<testRect.y+testRect.h;if (!hovered!=mousePassthrough) {mousePassthrough= !hovered;SDL_SetWindowMousePassthrough(window,mousePassthrough);SDL_Log(mousePassthrough ?"passthrough enabled\n" :"passthrough disabled\n"); }// renderSDL_SetRenderDrawColor(renderer,0,0,0,0);SDL_RenderClear(renderer);SDL_SetRenderDrawColor(renderer,255,0,0,128);SDL_RenderFillRect(renderer,&testRect);SDL_RenderPresent(renderer); }SDL_DestroyRenderer(renderer);SDL_DestroyWindow(window);SDL_Quit();return0;} |
slouken commentedDec 17, 2025
Yes, it should return a bool. |
Description
This PR adds a
SDL_SetWindowMousePassthroughfunction which allows users to create windows that don't capture input allowing them to create overlay-style apps.This implementation has only been tested on Windows 11, other platforms require validation.
(testing used SDL window's
HWNDwith contents ofWIN_SetWindowMousePassthroughdirectly)TODO:
SDL_video.his missing docummentation comment explaining the functionalityDYNAPI is possibly misconfigured/missing information (the new function is not present in build)
Existing Issue(s)
#12683