Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Draft
AQtun81 wants to merge1 commit intolibsdl-org:main
base:main
Choose a base branch
Loading
fromAQtun81:main

Conversation

@AQtun81
Copy link

Description

This PR adds aSDL_SetWindowMousePassthrough function 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'sHWND with contents ofWIN_SetWindowMousePassthrough directly)

TODO:
SDL_video.h is missing docummentation comment explaining the functionality
DYNAPI is possibly misconfigured/missing information (the new function is not present in build)

Existing Issue(s)

#12683

@slouken
Copy link
Collaborator

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 reacted with thumbs up emoji

@sloukenslouken added this to the3.x milestoneDec 2, 2025
@AQtun81
Copy link
Author

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, shouldSDL_SetWindowMousePassthrough return a bool? Since as far as I know some platforms don't allow for mouse passthrough for bordered windows, this function could enforce that it can only be used on borderless windows ensuring consistent cross-platform behavior. On the other hand not everyone might care about cross-platform as long as their platform/s supports it.

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
Copy link
Collaborator

Yes, it should return a bool.

@sloukenslouken modified the milestones:3.x,3.6.0Dec 17, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

3.6.0

Development

Successfully merging this pull request may close these issues.

2 participants

@AQtun81@slouken

[8]ページ先頭

©2009-2025 Movatter.jp