I have done some X11 updates today, having just tried glfw for the first time …
I have added …
glfwSetWMCloseCallback( shut );
glfwSetIconCallback( icon );
glfwSetVisibilityCallback( viz );
where “shut,icon and viz” were my user supplied callback functions. You provide whatever you want!
So that you can trap a Window Manager close and terminate gracefully. (Default handler action is to glfwTerminate();exit(0); )
You can detect when iconised and call a handler e.g. to switch off updates etc and conserve cpu cycles! (Default action is to do nothing)
You can detect 3 visibility states …
0 = fully visible
1 = partially visible (either covered
by another or part off screen)
2 = fully obscured (also set when iconised)
(Default action is to do nothing)
Marcus, if you want the code additions, email
I will attempt to hack the win32 stuff, but maybe someone else would like to incorporate my offerings into the win32 codebase??
Thanks Rob! (you know by mail that I am integrating your work into the next release of GLFW)
I will make the necessary modifications to the Win32 code once the callback functionality is official.
No problem. Hope the code makes sense!
Not any huge effort to add useful functionality eh?
Did you get the key repeat stuff in X11 sorted out? Nasty nasty stuff eh?
> No problem. Hope the code makes sense!
Yes, it does! I just had to rearrange some stuff to fit my current code layout (which is slightly different from the 2.0.3 version you patched).
> Not any huge effort to add useful functionality eh?
No, not at all. It’s just that I am not a very experienced X11 programmer, so finding these little bits and pieces that do what you want is not always trivial.
> Did you get the key repeat stuff in X11 sorted out? Nasty nasty stuff eh?
I think so. I actually have not had time to test the code (not to code at all actually). On thing I was wondering about was the visibility thing. Wouldn’t it be more useful with a redraw event (when part of a window is revealed, not hidden)? I’m planning to add a redraw callback in the future - wouldn’t that replace the visibility functionality?
I think visibility is a different thing.
You do need to know when an app is iconised,
or another window is obsuring it (I think
on win32 you can’t detect the partial obscure?).
The main reason for doing this would be to possibly suspend the program and conserve cpu, so the user can go about doing other things.
In the games world, not so much an issue, but if the toolkit is to become more “generic” and used by “non-gamers”, then this would indeed be what people would want to do.
A redraw callback (expose) should be a separate callback event.