go-gl / glfw

Go bindings for GLFW 3
BSD 3-Clause "New" or "Revised" License
1.58k stars 181 forks source link

v3.4 and supporting GLFW_MOUSE_PASSTHROUGH #375

Open J7mbo opened 1 year ago

J7mbo commented 1 year ago

Hi folks! I'm displaying a transparent window overlay to highlight things on the screen (a red rectangle) and I'd really like to be able to "still click through" to things underneath this rectangle. I found that glfw itself has: GLFW_MOUSE_PASSTHROUGH from 2020 I think. I couldn't find this in the code in here, so I assume it's not implemented yet.

Would it be possible to add this without too much effort? If it's just a redirect from to a C function or something, I'd be happy to learn and follow the pattern you do for other calls, but I may need support on knowing exactly what to do.

Please let me know what you think and if you'd be willing to support this?

J7mbo commented 1 year ago

It looks like this is only for v3.4. So I guess my request is actually about supporting version v3.4. I'll change the title of the issue.

J7mbo commented 1 year ago

Additionally, it's probable that supporting an entirely new version would be a tonne of work and it's not fair for me to request this just for a single window hint.

However would a maintainer / supporter be willing to suggest or advise here were I to attempt to do this myself, just for a single window hint, by following the patterns set by this library for the other versions?

Maybe the PR could even begin the work for supporting v3.4 and if it's not complicated I could contribute with the rest if it's just "passthrough" function calls. :)

J7mbo commented 1 year ago

Closing as it looks like this isn't interesting for anyone. I'll figure out another way.

J7mbo commented 6 months ago

Looks this this issue will solve this.

DownloadableFox commented 6 months ago

Sorry if I shouldn't be typing here considering it's closed, I tried to reach you out on Twitter but it seems you don't have DMs enabled. I have been experiencing the same issue with a personal project that I have pause whilst waiting for the release of GLFW 3.4. I was looking to use the GLFW_MOUSE_PASSTHROUGH but of course, it is not yet available.

I was wondering if you have found any alternative to this so far?

J7mbo commented 6 months ago

Hey @DownloadableFox, nope not found anything else yet. Just waiting for this MR. There's no instructions there that I can see yet as I'm on a Mac.

I'll re-open as it's being actively worked on.

J7mbo commented 6 months ago

Okay I got this working.

I checked out Geo25ray's master branch which has 3.4 changes in.

Then in testdata/customcursor/main.go I commented out the line window.SetIcon(), because this wasn't working on Mac. Maybe it works for you if you're not using a Mac.

Then in the Hints area at the top of window.go, directly under floating, I added the new hint:

MousePassthrough Hint = C.GLFW_MOUSE_PASSTHROUGH

Finally in customcursor/main.go I added:

window.SetAttrib(glfw.MousePassthrough, 1) window.SetAttrib(glfw.Floating, 1)

And mouse pass through worked! :)