GLFW close and restore window

larsp123 wrote on Friday, January 20, 2012:

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.

larsp123 wrote on Friday, January 20, 2012:

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.

elmindreda wrote on Friday, January 20, 2012:

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

elmindreda wrote on Friday, January 20, 2012:

Does the iconify test program work in fullscreen mode?

larsp123 wrote on Friday, January 20, 2012:

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.

elmindreda wrote on Friday, January 20, 2012:

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?

larsp123 wrote on Friday, January 20, 2012:

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

elmindreda wrote on Friday, January 20, 2012:

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.

larsp123 wrote on Friday, January 20, 2012:

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.

elmindreda wrote on Saturday, January 21, 2012:

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

larsp123 wrote on Sunday, January 29, 2012:

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?

elmindreda wrote on Sunday, January 29, 2012:

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.

larsp123 wrote on Sunday, January 29, 2012:

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!