What GLFW callback notifies me when I'm just holding the window bar (Without moving it)?

I’m using glfwSetWindowPosCallback() to get notified when a window is moved, but what if I’m just holding the window bar?

I’m asking this because the rendering stops even when just holding the window bar (My render loop waits at glfwPollEvents() until I stop holding), but this messes up with my Frame-Independent rendering, because I don’t know when I started holding the window bar, therefore I can’t offset the “non active” time.
Thanks!

I’m not sure which platform you’re on, but I’m going to assume Windows as I know this is an issue there.

The Windows operating system does not exit the Windows message loop until you stop moving the window, so if you do:

RenderAndSwap();
glfwPollEvents();

You will find your rendering is paused whilst you move the window.

To render whilst moving the window you need to create a separate thread to handle rendering.

I don’t understand your answer, I know rendering is paused while I hold the window bar, and I don’t need the rendering to continue while moving/holding, I just need a way to get notified the instant I hold the window bar, but without moving it (By the way yes, Windows 10 / Vulkan).

Ah, sorry I didn’t understand your question properly.

Currently you cannot do this with GLFW, as it does not have a callback for mouse down in the nonclient area of a window.

I see there is an open issue for this:

There are probably a few ways to get what you want without resorting to adding this functionality, for example by recording when you start glfwPollEvents() and if you receive a position callback within this you can know it starts at that time. You will likely receive multiple events during this poll, but all will have the same start time of when glfwPollEvents() was called.

1 Like

Oh, didn’t know this wasn’t implemented yet!
Thanks for your answer, I’ll see what I can do!

I’ve added a bit of pseudo-code for a potential solution to the issue:

Uhm, this is fine if window is dragged, but if it’s only held, I will never get into the if scope, so the only information I’d have is the time passed between the start and the end of glfwPoolEvents()

I’m not 100% sure what you’re trying to do, but if you simply want to ensure that you have frame time independent rendering, and you get problems when the user holds down the mouse over the non client region, you could clamp the frame time to a usable value (such as 1/20th of a second or so), or if the time spent in glfwPollEvents is greater than a certain amount you could remove that.

1 Like

or if the time spent in glfwPollEvents is greater than a certain amount you could remove that.

glfwPollEvents() takes literally microseconds, so I went with this option in the end (with a 5ms limit), until GLFW adds a callback for this particular event.