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

Unable to get/set window position on MouseMoved callback #121

Open
dark-steveneq opened this issue Oct 19, 2024 · 5 comments
Open

Unable to get/set window position on MouseMoved callback #121

dark-steveneq opened this issue Oct 19, 2024 · 5 comments

Comments

@dark-steveneq
Copy link

So for context I'm writing my own GUI framework of sorts (rendering sprites to an undecorated window with transparent framebuffer) and now that I got around to implementing window dragging its a workaround hell. Doing anything with SetPos() and GetPos() in MouseMoved freezes everything for some reason. I have *opengl.Window in my own struct if that even matters.

@bhperry
Copy link
Contributor

bhperry commented Oct 19, 2024

from MouseMoved callback?

@dark-steveneq
Copy link
Author

dark-steveneq commented Oct 19, 2024 via email

@bhperry
Copy link
Contributor

bhperry commented Oct 19, 2024

Pixel uses a package called mainthread to interact with openGL to ensure all calls come from the same thread (required by OpenGL). The callbacks are processed from within a mainthread call, and the SetPos and GetPos also use mainthread calls, so they end up getting blocked on each other. Doesn't know that it's already running in the scope of mainthread, just blindly pushes the requests onto the call queue

@dark-steveneq
Copy link
Author

dark-steveneq commented Oct 19, 2024 via email

@bhperry
Copy link
Contributor

bhperry commented Oct 19, 2024

In its current state, yes. This is a pretty good argument that the user callbacks should be run outside of the mainthread context though. Would have to collect the events as they are received and process them after. But then you could use any window function from within the callback.

In the meantime, you could do something similar. Keep track of the callbacks you received each frame, and process them after win.Update()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants