# GLFW close and restore window

**URL:** <https://discourse.glfw.org/t/glfw-close-and-restore-window/253>\
**Category:** support\
**Created:** [January 20, 2012, 8:48am UTC](https://discourse.glfw.org/t/glfw-close-and-restore-window/253 "2012-01-20T08:48:04Z")\
**Posts on this page:** 13\
**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:** [January 20, 2012, 8:48am UTC](https://discourse.glfw.org/t/glfw-close-and-restore-window/253/1 "2012-01-20T08:48:04Z")

</div>

**[larsp123](https://sourceforge.net/u/larsp123/)** wrote on [Friday, January 20, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/b011c540/#5742):

I am using GLFW on Ubuntu, and I am very happy of the functionality it  
provides. Now I have an application where I want to leave full screen mode for  
a while, and then go back to full screen again. I am not sure how to best do  
this. I would prefer not to close the window at all, if not required, but I  
need to get out of the full screen mode for a while. The reason for this is  
that I pop up dialogs (using FLTK). I tried the following:

```
glfwCloseWindow();
while(glfwGetWindowParam(GLFW_OPENED)) {
	glfwPollEvents();
}

```

Immediately after this, the window is still open. How can I find out when the  
window has actually closed? I think the closing of the window is some kind of  
asynchronous process, that will be completed “after a while”.

Maybe using glfwIconifyWindow() would be better, but then I have a similar  
problem. That is, I don’t know when the window has been iconified.

Another possible solution could be to temporarily change to windowed mode,  
which I can’t find out how to do either.

---

<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 20, 2012, 6:27pm UTC](https://discourse.glfw.org/t/glfw-close-and-restore-window/253/2 "2012-01-20T18:27:50Z")

</div>

**[larsp123](https://sourceforge.net/u/larsp123/)** wrote on [Friday, January 20, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/b011c540/#96f5):

One step forward: If, instead of calling glfwCloseWindow(), I call  
glfwIconifyWindow(), and then check for  
glfwGetWindowParam(GLFW\_ICONIFIED) == GL\_TRUE in the main event loop, then  
it works for windowed mode. But it will not iconify a full screen window.

Running the demonstration program “iconify -f” doesn’t work, so I am started  
to think this is a bug in Linux. I am using GLFW version 2.7.2.

---

<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 20, 2012, 6:30pm UTC](https://discourse.glfw.org/t/glfw-close-and-restore-window/253/3 "2012-01-20T18:30:33Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Friday, January 20, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/b011c540/#3f67):

Which window manager are you using? On most modern window managers,  
glfwIconifyWindow should work for both fullscreen and regular windows.

---

<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 20, 2012, 6:34pm UTC](https://discourse.glfw.org/t/glfw-close-and-restore-window/253/4 "2012-01-20T18:34:13Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Friday, January 20, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/b011c540/#4671):

Does the iconify test program work in fullscreen mode?

---

<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 20, 2012, 6:39pm UTC](https://discourse.glfw.org/t/glfw-close-and-restore-window/253/5 "2012-01-20T18:39:40Z")

</div>

**[larsp123](https://sourceforge.net/u/larsp123/)** wrote on [Friday, January 20, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/b011c540/#d93e):

Running the test program “iconify -f”, and then pressing SPACE, will not leave  
full screen mode. The mouse pointer will return, but the screen will still  
show the original display from “iconify”. The output from the command prompt  
is:

$ ./iconify -f  
0.11 Restored Active  
1.44 Key pressed  
1.48 Key released  
1.48 Iconified Active  
^C  
$

I am using Ubuntu 11.04. I don’t know the name of the desktop manager, but it  
is the default you get when you do not use Unity. The “iconify” application  
works for windowed mode.

---

<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 20, 2012, 6:45pm UTC](https://discourse.glfw.org/t/glfw-close-and-restore-window/253/6 "2012-01-20T18:45:44Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Friday, January 20, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/b011c540/#9c74):

Metacity, then. I’m also on 11.04 and not using Unity. Most curious.

Can you check whether or not \_glfwWin.overrideRedirect in  
lib/x11/x11\_window.c is ever set to true?

---

<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 20, 2012, 7:11pm UTC](https://discourse.glfw.org/t/glfw-close-and-restore-window/253/7 "2012-01-20T19:11:03Z")

</div>

**[larsp123](https://sourceforge.net/u/larsp123/)** wrote on [Friday, January 20, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/b011c540/#f5b1):

Sorry, couldn’t find out how to find the value of \_glfwWin.overrideRedirect.  
Changing the iconify.c program to

> printf(“\_glfwWin.overrideRedirect: %d\n”, \_glfwWin.overrideRedirect);

failed to compile with _‘\_glfwWin’ undeclared_, and it is not defined in  
glfw.h.

The default glfw on Ubuntu 11.04 is 2.6, which I did not use, and installed  
2.7.2 on my own in /usr/local. Maybe I did some kind of mistake in that  
process. I don’t think so, I can’t find any signs of a 2.6 version (nothing  
in /usr/lib/GL at least.).

---

<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 20, 2012, 7:21pm UTC](https://discourse.glfw.org/t/glfw-close-and-restore-window/253/8 "2012-01-20T19:21:23Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Friday, January 20, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/b011c540/#4fa9):

If it gets set, it happens on line 846 of lib/x11/x11\_window.c.

To verify which version you are using, use glfwGetVersion. The behaviour  
you’re describing is consistent with the bugs in 2.6.

---

<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 20, 2012, 10:23pm UTC](https://discourse.glfw.org/t/glfw-close-and-restore-window/253/9 "2012-01-20T22:23:36Z")

</div>

**[larsp123](https://sourceforge.net/u/larsp123/)** wrote on [Friday, January 20, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/b011c540/#df62):

I did the following debug message:

> if( \_glfwWin.fullscreen && !\_glfwWin.hasEWMH )  
> {  
> // This is the butcher’s way of removing window decorations  
> // Setting the override-redirect attribute on a window makes the window  
> // manager ignore the window completely (ICCCM, section 4)  
> // The good thing is that this makes undecorated fullscreen windows  
> // easy to do; the bad thing is that we have to do everything manually  
> // and some things (like iconify/restore) won’t work at all, as they’re  
> // usually performed by the window manager

XSetWindowAttributes attributes;  
attributes.override\_redirect = True;  
XChangeWindowAttributes( \_glfwLibrary.display,  
\_glfwWin.window,  
CWOverrideRedirect,  
&attributes );

\_glfwWin.overrideRedirect = GL\_TRUE;

printf(“glfwWin.overrideRedirect \_glfwWin.hasEWMH: %d\n”,  
\_glfwWin.hasEWMH);  
} else {  
printf(“not glfwWin.overrideRedirect \_glfwWin.hasEWMH: %d\n”,  
\_glfwWin.hasEWMH);  
}

After “make x11”, I did

> $ tests/iconify -f  
> GLFW version: 2.7.2  
> not glfwWin.overrideRedirect \_glfwWin.hasEWMH: 1  
> 0.14 Restored Active  
> 2.19 Key pressed  
> 2.23 Key released  
> 2.23 Iconified Active  
> ^C

I had input focus on the terminal window, so I could kill the application with  
CTRL-C. But the screen only showed the application as if it was still in full  
screen mode. So it seems that it is not the case of  
\_glfwWin.overrideRedirect.

---

<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 21, 2012, 1:46pm UTC](https://discourse.glfw.org/t/glfw-close-and-restore-window/253/10 "2012-01-21T13:46:38Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Saturday, January 21, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/b011c540/#699b):

I don’t know what it could be, then. I’m unable to reproduce this.

---

<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 29, 2012, 9:06pm UTC](https://discourse.glfw.org/t/glfw-close-and-restore-window/253/11 "2012-01-29T21:06:03Z")

</div>

**[larsp123](https://sourceforge.net/u/larsp123/)** wrote on [Sunday, January 29, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/b011c540/#a88c):

Using windows 7 and Cygwin, I tried to compile the glfw library, but it fails,  
as follows (on the same machine). I am running 64 bit Windows and 64 bit  
Ubuntu, btw.

> $ make win32-cygwin  
> cd lib/win32 && make -f Makefile.win32.cygwin  
> make: Entering directory  
> `/cygdrive/c/Users/Lars/Documents/src/glfw-2.7.2/lib/win32’  
> gcc -shared -s -Wl,-kill-at,-major-image-version,2,-minor-image-version,7 -o  
> glfw.dll enable\_dll.o fullscreen\_dll.o g  
> lext\_dll.o image\_dll.o init\_dll.o input\_dll.o joystick\_dll.o  
> stream\_dll.o tga\_dll.o thread\_dll.o time\_dll.o window\_dll.o  
> win32\_dllmain\_dll.o win32\_enable\_dll.o win32\_fullscreen\_dll.o  
> win32\_glext\_dll.o win32\_init\_dll.o win32\_joystick\_dll.o w  
> in32\_thread\_dll.o win32\_time\_dll.o win32\_window\_dll.o -lglu32 -lglut32  
> -lopengl32 -lwinmm -lgdi32  
> glext\_dll.o:glext.c:(.text+0x11): undefined reference to `\_glGetString’  
> glext\_dll.o:glext.c:(.text+0x1c8): undefined reference to  
> `\_glGetIntegerv’  
> …

Any idea why linking fails for OpenGL API functions? Is there a compatibility  
problem with 32/64 bit?

---

<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 29, 2012, 9:32pm UTC](https://discourse.glfw.org/t/glfw-close-and-restore-window/253/12 "2012-01-29T21:32:08Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Sunday, January 29, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/b011c540/#a6b8):

I don’t know of any compatibility problems with GLFW on 64-bit Windows.

Have you installed the opengl Cygwin package?

Also, have you tried using mingw32-make with the win32-mingw target? I don’t  
remember if this works with GLFW 2.7.2 on Cygwin, but it may.

Note that cross-compiling GLFW using Cygwin is deprecated and has been  
replaced with updated MinGW and MSYS targets in GLFW 2.7.3, as Cygwin is  
becoming more strict about separating the Unix bits from the MinGW bits.

---

<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 29, 2012, 10:24pm UTC](https://discourse.glfw.org/t/glfw-close-and-restore-window/253/13 "2012-01-29T22:24:12Z")

</div>

**[larsp123](https://sourceforge.net/u/larsp123/)** wrote on [Sunday, January 29, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/b011c540/#3e86):

Yes, the opengl package for cygwin is installed, and the linker doesn’t  
complain that it can’t find it. It seems to be correctly installed:

> $ nm /usr/lib/w32api/libopengl32.a | grep \_glGetString  
> 00000000 I \_\_imp\_\_glGetString@4  
> 00000000 T \_glGetString@4

Doing “make win32-mingw” produces the same error messages.

I installed MinGW instead, and did (from the mingw shell):

> $ make win32-mingw  
> .\compile.bat: line 1: @echo: command not found  
> .\compile.bat: line 3: REM: command not found  
> .\compile.bat: line 4: REM: command not found  
> .\compile.bat: line 5: REM: command not found  
> .\compile.bat: line 6: REM: command not found  
> .\compile.bat: line 7: REM: command not found  
> .\compile.bat: line 8: syntax error near unexpected token `(’  
> .\compile.bat: line 8: `REM \* Windows NT, 2000 and 9x (it’s easier to make  
> a scr  
> ipt/makefile’  
> make: \*\*\* Error 2

It looks like it is trying to execute the compile.bat file.

I did the compilations (make -f Makefile.win32.mingw) myself on each sub  
directory, and now I managed to compile everything! Finally, I could test  
“iconify -f” again. This time it works. That is, I can press SPACE and get the  
desktop back.

A friend of mine also tested on Ubuntu 11.04, with no problems. Maybe there is  
something incorrect with my Ubuntu installation. Anyway, Windows is the target  
for my application, so I have what I need now.

By the way, thanks for an excellent library!
