Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input Passthrough #374

Closed
coderedart opened this issue May 11, 2021 · 5 comments
Closed

Input Passthrough #374

coderedart opened this issue May 11, 2021 · 5 comments
Labels
egui-winit porblems related to winit feature New feature or request

Comments

@coderedart
Copy link
Contributor

Is your feature request related to a problem? Please describe.
i want to make an overlay for a game. and as i will draw routes and stuff transparently over the game, i want the input to passthrough the program to the game.

Describe the solution you'd like
keyboard or mouse events should just passthrough the window as if it did not exist.

Describe alternatives you've considered
Qt::WindowTransparentForInput in qt framework is basically that. but i don't wanna use c++

Additional context
I will link my discussion as it has an example screenshots of another similar addon and other features like always_on_top etc.. which i wanted for this project.
#354

@coderedart coderedart added the feature New feature or request label May 11, 2021
@coderedart
Copy link
Contributor Author

so.. after a lot of digging through stuff, i found that there is a issue pending on winit rust-windowing/winit#1434 and rust-windowing/winit#1884 , which is trying to get input transparency working on X11. it is right now pending as there is no X11 maintainer. and will stay that way until we get a new maintainer.

i'm guessing until winit doesn't implement that, egui cannot either.

@emilk
Copy link
Owner

emilk commented Oct 2, 2021

egui is agnostic to how it gets its input. egui_glium uses winit and so depends on features landing there first. But perhaps it's worth investigating alternatives like egui-miniquad

@emilk emilk added the egui-winit porblems related to winit label Oct 2, 2021
@emilk emilk closed this as completed Oct 2, 2021
@coderedart
Copy link
Contributor Author

Oh, i actually already got this. glfw has input passthrough in the next version (which might take a long time to release), so, i forked glfw-rs and glfw-sys, copied the relevant code, and i can just do window.set_passthrough(bool) to go fully input passthrough or normal window mode. right now, i use the egui's wants_pointer_input and wants_keyboard_input functions, and if egui wants it, then i set passthrough to false and if egui doesn't need input, i set passthrough to true. its working very very well <3

winit can't get it because the x11 library that winit depends on doesn't have bindings for xshape extension yet, although there was an attempt to get it going for mac rust-windowing/winit#1884 , that pr has been abandoned for 5 months now. the x11 library that winit depends on is abandoned too atm :( and winit itself lacks X11 maintainers rust-windowing/winit#1940 .

@coderedart
Copy link
Contributor Author

coderedart commented Oct 2, 2021

https://github.com/coderedart/glfw-rs is the repo where i have input_passthrough added. if someone wants a similar thing. those wants_input functions are godsend honestly :D the only glue i need is to query the mouse position with window.get_cursor_pos() which takes like 30 micro seconds, so i can gladly do that every frame and set it. then, just ask egui if it wants input. I can also use a library like device_query or my favorite rdev which will give us global mouse position (or other global events like keypresses) which we can convert to local coordinates by offsetting them with window position, but that's for more advanced cases like global shortcut to make the window passthrough/not so that it kind works like discord overlay.

@emilk
Copy link
Owner

emilk commented Oct 2, 2021

Thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
egui-winit porblems related to winit feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants