question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

missing new hint "GLFW_MOUSE_PASSTHROUGH" in current version

See original GitHub issue

Hello, thank you for creating this awesome library.

it was added/released in glfw hours before the last release of pyGLFW!

I tried glfw.window_hint(0x0002000D, glfw.TRUE) instead of glfw.window_hint(glfw.MOUSE_PASSTHROUGH, glfw.TRUE) but found out the compiled library needs updating.

Traceback (most recent call last):
  File "./test-clickthrough.py", line 37, in <module>
    glfw.window_hint(0x0002000D, 1)
  File "glfw/__init__.py", line 1138, in window_hint
    _glfw.glfwWindowHint(hint, value)
  File "glfw/__init__.py", line 628, in errcheck
    _reraise(exc[1], exc[2])
  File "glfw/__init__.py", line 52, in _reraise
    raise exception.with_traceback(traceback)
  File "glfw/__init__.py", line 607, in callback_wrapper
    return func(*args, **kwargs)
  File "glfw/__init__.py", line 820, in _handle_glfw_errors
    raise GLFWError(message)
glfw.GLFWError: (65539) b'Invalid window hint 0x0002000D'

can you please release an update?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
aSemycommented, Feb 27, 2021

I know this issue is closed and the flag won’t be added until the 3.4 release, but it’s a good solution for me at the moment and so I hacked together a solution. I wanted to write it up for anyone else who comes across this issue and would like to set the 3.4 dll up, but (like me) finds cmake an absolute nightmare.

Caveat: it’s not working locally for me. I get this error from the ctypes.CDLL(...) call in library.py, no matter what I seem to do. But I HAVE had it working! And it works on a VM I created! I think it’s something to do with Poetry? PyCharm? Or Windows 10 security? Or I installed Windows updates which screwed something up? Or caching? Or uninstalled Visual Studio Code? Or it’s something with Python 3.9 and ctypes? I have no idea. I’ll figure it out - I know it’s something weird locally on my machine.

FileNotFoundError: Could not find module 'D:/Users/Yreh/Projects/python/proj/Overlay/glfw3.dll' (or one of its dependencies). Try using the full path with constructor syntax.


Anyway, enough about my problems. Here’s how you (the search engine engine user who came across this ticket) can (hopefully) use the 3.4 glfw dll.

  1. Get 3.4 glfw3.dll https://github.com/aSemy/glfw/releases

    I forked glfw/glfw and set up a build job to do this, based off the .appveyor.yml in glfw/glfw. If you want to fork glfw/glfw yourself, and copy the .github/workflows/cmakesimple.yml I made - go ahead.

  2. Windows: You might need to right click on the downloaded archive and uncheck the security warning? I used 7zip to extract it.

  3. I found the pyGLFW folder virtualenvs\asdja-py3.9\Lib\site-packages\glfw and replaced the existing glfw3.dl with the downloaded one.

  4. I found the ‘id code’ for the GLFW_MOUSE_PASSTHROUGH by searching in the glfw/glfw project (it’s in file include/GLFW/glfw3.h) - it turns out it’s 0x0002000D

  5. I edited 2 pyGLFW files, in it’s module folder.

    • __init__.py > insert this value
         FOCUS_ON_SHOW = 0x0002000C
         MOUSE_PASSTHROUGH = 0x0002000D # < add this line
         RED_BITS = 0x00021001
     
    • GLFW.py > Between 'FOCUS_ON_SHOW ’ (line 530) and RED_BITS (line 531) I added…
     FOCUS_ON_SHOW as GLFW_FOCUS_ON_SHOW,
     MOUSE_PASSTHROUGH as GLFW_MOUSE_PASSTHROUGH, # < add this line 
     FORMAT_UNAVAILABLE as GLFW_FORMAT_UNAVAILABLE,
     
  6. I added a print statement after the import to check it was working.

    import glfw
    print(glfw.get_version())
    

output: (3, 4, 0)

Ta da!

Click here to have a look at an Example
import glfw
print(glfw.get_version())

def main():
    # Initialize the library
    if not glfw.init():
        return
    glfw.window_hint(glfw.MOUSE_PASSTHROUGH, glfw.TRUE)
    glfw.window_hint(glfw.RESIZABLE, glfw.FALSE)
    glfw.window_hint(glfw.DECORATED, glfw.FALSE)
    glfw.window_hint(glfw.FLOATING, glfw.TRUE)
    # Create a windowed mode window and its OpenGL context
    window = glfw.create_window(640, 480, "Hello World", None, None)
    if not window:
        glfw.terminate()
        return

    glfw.set_window_opacity(window, 0.5)

    # Make the window's context current
    glfw.make_context_current(window)

    # Loop until the user closes the window
    while not glfw.window_should_close(window):
        # Render here, e.g. using pyOpenGL
        # Swap front and back buffers
        glfw.swap_buffers(window)
        # Poll for and process events
        glfw.poll_events()

    glfw.terminate()

if __name__ == "__main__":
    main()

And check out the docs - they say that this new flag is “only supported for undecorated windows” https://www.glfw.org/docs/3.4/group__window.html#ga88981797d29800808ec242274ab5c03a

1reaction
FlorianRhiemcommented, Nov 7, 2021

I’ve just released version 2.4.0, along with a helper package glfw_preview.

With this new version, if you:

  • pip install glfw[preview], or
  • pip install glfw_preview after upgrading glfw, or
  • set the environment variable PYGLFW_PREVIEW to a non-empty value

the glfw package will include wrappers for unreleased functions and macros. There will still be a delay between them being introduced to the GLFW master and them being wrapped, as there’s still manual work involved with that, but I’ve setup a CI script that should inform me of any unwrapped macros or functions every saturday morning, so the delay shouldn’t be that long.

Please try it and let me know if there are any issues with the preview mechanism or with the newly-wrapped functions and macros.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GLFW Mouse Passthrough Broken in Docking Branch #4635
If you set up a GLFW window and enable the mouse passthrough hint, the actual mouse passthrough does not happen and instead mouse...
Read more >
Release notes - GLFW
GLFW now provides the GLFW_MOUSE_PASSTHROUGH window hint for making a window transparent to mouse input, lettings events pass to whatever window ...
Read more >
window.dox - Google Git
such a window, request the current video mode. @code. const GLFWvidmode* mode = glfwGetVideoMode(monitor);. glfwWindowHint(GLFW_RED_BITS, mode->redBits);.
Read more >
GLFW (LWJGL 3.3.2-snapshot)
Returns the compile-time generated version string of the GLFW library binary. static GLFWVidMode. glfwGetVideoMode(long monitor). Returns the current video mode ...
Read more >
mouse passthrough in a transparent window in glfw? - Reddit
Looks like there's a window hint for it https://www.glfw.org/docs/3.4/window_guide.html#GLFW_MOUSE_PASSTHROUGH_hint.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found