# Set window focus

**URL:** <https://discourse.glfw.org/t/set-window-focus/40>\
**Category:** support\
**Created:** [February 16, 2014, 8:35pm UTC](https://discourse.glfw.org/t/set-window-focus/40 "2014-02-16T20:35:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [February 16, 2014, 8:35pm UTC](https://discourse.glfw.org/t/set-window-focus/40/1 "2014-02-16T20:35:12Z")

</div>

**[afalkenhahn](https://sourceforge.net/u/afalkenhahn/)** wrote on [Sunday, February 16, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/c0980c99/#6616):

Hi,

is it possible to programmatically activate a GLFW window? Suppose I have four different GLFW windows and now I’d like to make one of them the active window… is that possible somehow? I can listen to focus changes but I don’t seem to be able to set focus programmatically. Maybe we’d need something like glfwSetWindowFocus()…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [March 6, 2014, 10:31pm UTC](https://discourse.glfw.org/t/set-window-focus/40/2 "2014-03-06T22:31:18Z")

</div>

**[xdread](https://sourceforge.net/u/xdread/)** wrote on [Thursday, March 06, 2014](https://sourceforge.net/p/glfw/discussion/247562/thread/c0980c99/#7227):

I think you can use glfw3native and then one of these functions to obtain a window handle to set focus:

[http://www.glfw.org/docs/latest/glfw3native\_8h.html](http://www.glfw.org/docs/latest/glfw3native_8h.html)

Just define two macros like described in this document before including the header file:

[http://www.glfw.org/docs/latest/group\_\_native.html](http://www.glfw.org/docs/latest/group__native.html)

EDIT: It is worth mentioning that this is platform specific, so you need to make the platform independence yourself in this case.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [January 2, 2015, 5:23pm UTC](https://discourse.glfw.org/t/set-window-focus/40/3 "2015-01-02T17:23:03Z")

</div>

**[divxdede](https://sourceforge.net/u/divxdede/)** wrote on [Friday, January 02, 2015](https://sourceforge.net/p/glfw/discussion/247562/thread/c0980c99/#aee2):

It would be nice to have a glfwFocusWindow like we have with glfwIconifyWindow  
I can’t use native since i use a wrapper that don’t expose it to me…

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [March 8, 2016, 12:19pm UTC](https://discourse.glfw.org/t/set-window-focus/40/4 "2016-03-08T12:19:31Z")

</div>

Window focusing has been added and will be included in 3.2.

> <https://github.com/glfw/glfw/commit/baf574494da1f1b6a07ff426c62670090e67b445>
