coderedart / egui_overlay

An Overlay Window that allows input to passthrough
MIT License
148 stars 17 forks source link

Focus not passed through on click (Wayland) #11

Closed kandayin closed 1 year ago

kandayin commented 1 year ago

Using the triangle example, the triangle overlay takes focus on click rather than the window behind it. Mouse clicks properly propagate to the app behind the overlay, however keyboard entry doesn't work because the triangle overlay has focus.

How to reproduce:

The problem does not occur in Gnome42.9 + X11. Clicks send the focus to the app behind the triangle.

coderedart commented 1 year ago

just checked on plasma wayland. It worked as expected for me.

And i did face the same bug in gnome before. Gnome sends the keyboard events to the topmost app (which is our overlay) instead of the app in focus. https://github.com/coderedart/egui_overlay/issues/6 is a good example of a similar issue with keyboard and overlay.

Try checking if you can reproduce this on any other DE/WM. If other WMs work fine, then we will mark this as a gnome bug :)

kandayin commented 1 year ago

Thank you for the pointer about the gnome bug! I upgraded to Gnome 44.3 (by upgrading Ubuntu from 22.04 to 23.04) and the Wayland problem does not happen!

coderedart commented 1 year ago

great. i hope coderedart/jokolay#6 will be resolved soon too :)

dphaldes commented 5 months ago

I can somewhat recreate this on KDE wayland. It happens after the window size becomes big enough (maximized and fullscreen are block focus) The window blocks all focus

coderedart commented 5 months ago

kde wayland works fine for me. On latest KDE + Endeavour (Archlinux) with Nvidia

can you try running the basic example and check the passthrough value displayed?

https://github.com/coderedart/egui_overlay/assets/24411704/0b7428c8-04a9-465d-9854-49aa537873f4

dphaldes commented 5 months ago

the basic example is also not working. The pass-through field in the app changes, but it doesn't let me click through. maybe because it runs through xwayland, I am not sure

I am also on arch and Kde wayland and an up to date system

coderedart commented 5 months ago

@mystchonky This would be hard to debug on my side as I can't reproduce it.

If you want to figure out the problem, you can first try running the passthrough example at https://github.com/coderedart/glfw-sys-passthrough/blob/master/examples/passthrough.c

cmake -S path/to/glfw -B path/to/build -D GLFW_BUILD_EXAMPLES=ON

If that doesn't work, you will have to deal with master glfw version 3.4 directly.

dphaldes commented 5 months ago

passthrough example doesn't work either. Is there a way to create a wayland window and not x11 ? Could that be the problem ?

If that doesn't work, you will have to deal with master glfw version 3.4 directly.

what does this mean?

dphaldes commented 5 months ago

I figured out how to build it using wayland and now it correctly passes through. not sure what is going on

coderedart commented 5 months ago

Is there a way to create a wayland window and not x11 ?

https://www.glfw.org/docs/latest/compile_guide.html#GLFW_BUILD_X11 probably something like

cmake -S path/to/glfw -B path/to/build -D GLFW_BUILD_EXAMPLES=ON -D GLFW_BUILD_X11=OFF -D GLFW_BUILD_WAYLAND=ON

The glfw-sys-passthrough repo is my fork of 3.3.* version of glfw source with just passthrough patches (and a vulkan transparency patch for X11) because passthrough was a feature of glfw 3.4 (which only released recently).

https://github.com/glfw/glfw could have had some more improvements recently which I haven't patched back into my fork.

  1. clone the official glfw repo
  2. copy the passthrough.c example from my fork into examples/ directory
  3. edit the CMakeLists.txt with this diff image
  4. build the example as usual without wayland support and check if its working.

If it does work, then its just my fork not having the recent fixes for passthrough. I will just fix that. If it still doesn't work, it could be an issue with your xwayland somehow.

coderedart commented 5 months ago

I figured out how to build it using wayland and now it correctly passes through. not sure what is going on

The problem with using pure wayland is that it won't allow us to get global cursor position. So, when our window is not in focus, we can't check if the cursor is on any of our "egui areas" to disable passthrough.

https://github.com/coderedart/egui_overlay/issues/38

dphaldes commented 5 months ago

The glfw-sys-passthrough repo is my fork of 3.3.* version of glfw source with just passthrough patches (and a vulkan transparency patch for X11) because passthrough was a feature of glfw 3.4 (which only released recently).

https://github.com/glfw/glfw could have had some more improvements recently which I haven't patched back into my fork.

1. clone the official glfw repo

2. copy the `passthrough.c` example from my fork into `examples/` directory

3. edit the CMakeLists.txt with this diff ![image](https://private-user-images.githubusercontent.com/24411704/327850476-cf1d7735-cca8-46a0-831b-6d0b013241af.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTQ3NjIwMzYsIm5iZiI6MTcxNDc2MTczNiwicGF0aCI6Ii8yNDQxMTcwNC8zMjc4NTA0NzYtY2YxZDc3MzUtY2NhOC00NmEwLTgzMWItNmQwYjAxMzI0MWFmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA1MDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNTAzVDE4NDIxNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI1MWE1OTZjZThkMWE2ZGQ0ZWRlNGMxMzY3MDg2ODI2MWFlNjNmOWZjOTY2NjMyZTAzNDcwZmRkZjNiMWQ4ZjYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.WWwOXVbYk2llH2Of2kcnS3CTztQ2Uk30oCGq4Wh8594)

4. build the example as usual without wayland support and check if its working.

If it does work, then its just my fork not having the recent fixes for passthrough. I will just fix that. If it still doesn't work, it could be an issue with your xwayland somehow.

I tried this. Had to make a small adjustment and add a #define right above glad include to fix a linking issue. With wayland it works as expected and passthrough works correctly. On X11/Xwayland it does not

coderedart commented 5 months ago

Then, the issue is probably with your xwayland. maybe reinstall xorg-xwayland package and reboot your system? This is beyond my knowledge tbh.

I just installed hyprland window manager and running egui_overlay with xwayland works fine for me. I updated my system and rebooted, just to see if there's any new bugs. But everything is still working fine under both plasma wayland and hyprland.

I will answer any questions you might have, but you will probably need to debug this yourself as I can't reproduce it at all.

dphaldes commented 5 months ago

Apparently it is a bug with XWayland itself and a fix has already been merged in 24.1. This isn't an issue related to this project, GLFW or KDE plasma either. I will post an update here once I test the fix :)