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

**URL:** <https://discourse.glfw.org/t/what-glfw-callback-notifies-me-when-im-just-holding-the-window-bar-without-moving-it/1456>\
**Category:** support\
**Created:** [December 16, 2019, 2:16pm UTC](https://discourse.glfw.org/t/what-glfw-callback-notifies-me-when-im-just-holding-the-window-bar-without-moving-it/1456 "2019-12-16T14:16:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShockCoding](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/shockcoding/32/291_2.png) [@ShockCoding](https://discourse.glfw.org/u/ShockCoding)\
**Post date:** [December 16, 2019, 2:16pm UTC](https://discourse.glfw.org/t/what-glfw-callback-notifies-me-when-im-just-holding-the-window-bar-without-moving-it/1456/1 "2019-12-16T14:16:06Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [December 16, 2019, 3:18pm UTC](https://discourse.glfw.org/t/what-glfw-callback-notifies-me-when-im-just-holding-the-window-bar-without-moving-it/1456/2 "2019-12-16T15:18:46Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![ShockCoding](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/shockcoding/32/291_2.png) [@ShockCoding](https://discourse.glfw.org/u/ShockCoding)\
**Post date:** [December 16, 2019, 3:28pm UTC](https://discourse.glfw.org/t/what-glfw-callback-notifies-me-when-im-just-holding-the-window-bar-without-moving-it/1456/3 "2019-12-16T15:28:18Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [December 16, 2019, 4:12pm UTC](https://discourse.glfw.org/t/what-glfw-callback-notifies-me-when-im-just-holding-the-window-bar-without-moving-it/1456/4 "2019-12-16T16:12:34Z")

</div>

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](https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-nclbuttondown).

I see there is an open issue for this:

> <https://github.com/glfw/glfw/issues/1611>
>
> I currently am trying to write a small engine using GLFW, and encountered this problem: Whenever the window gets dragged, all...

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.

---

<div class="post-metadata">

**Author:** ![ShockCoding](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/shockcoding/32/291_2.png) [@ShockCoding](https://discourse.glfw.org/u/ShockCoding)\
**Post date:** [December 16, 2019, 4:20pm UTC](https://discourse.glfw.org/t/what-glfw-callback-notifies-me-when-im-just-holding-the-window-bar-without-moving-it/1456/5 "2019-12-16T16:20:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [December 16, 2019, 4:30pm UTC](https://discourse.glfw.org/t/what-glfw-callback-notifies-me-when-im-just-holding-the-window-bar-without-moving-it/1456/6 "2019-12-16T16:30:55Z")

</div>

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

> <https://github.com/glfw/glfw/issues/1611#issuecomment-566136558>
>
> I currently am trying to write a small engine using GLFW, and encountered this problem: Whenever the window gets dragged, all...

---

<div class="post-metadata">

**Author:** ![ShockCoding](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/shockcoding/32/291_2.png) [@ShockCoding](https://discourse.glfw.org/u/ShockCoding)\
**Post date:** [December 16, 2019, 4:35pm UTC](https://discourse.glfw.org/t/what-glfw-callback-notifies-me-when-im-just-holding-the-window-bar-without-moving-it/1456/7 "2019-12-16T16:35:36Z")

</div>

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()

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [December 16, 2019, 5:49pm UTC](https://discourse.glfw.org/t/what-glfw-callback-notifies-me-when-im-just-holding-the-window-bar-without-moving-it/1456/8 "2019-12-16T17:49:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ShockCoding](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/shockcoding/32/291_2.png) [@ShockCoding](https://discourse.glfw.org/u/ShockCoding)\
**Post date:** [December 16, 2019, 5:56pm UTC](https://discourse.glfw.org/t/what-glfw-callback-notifies-me-when-im-just-holding-the-window-bar-without-moving-it/1456/9 "2019-12-16T17:56:38Z")

</div>

> 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.
