Browse Source

EglContext: Handle window closing.

This is the most fucked up way to so fucking simple thing.
vectorfields
Vladimír Vondruš 14 years ago
parent
commit
9ea8efe73b
  1. 11
      src/Contexts/EglContext.cpp
  2. 1
      src/Contexts/EglContext.h

11
src/Contexts/EglContext.cpp

@ -83,6 +83,10 @@ EglContext::EglContext(int&, char**, const string& title, const Math::Vector2<GL
XSetStandardProperties(xDisplay, xWindow, title.c_str(), 0, None, 0, 0, 0);
XFree(visInfo);
/* Be notified about closing the window */
deleteWindow = XInternAtom(xDisplay, "WM_DELETE_WINDOW", True);
XSetWMProtocols(xDisplay, xWindow, &deleteWindow, 1);
/* Create context and window surface */
static const EGLint contextAttributes[] = {
#ifdef MAGNUM_TARGET_GLES
@ -138,6 +142,13 @@ int EglContext::exec() {
while(true) {
XEvent event;
/* Closed window */
if(XCheckTypedWindowEvent(xDisplay, xWindow, ClientMessage, &event) &&
Atom(event.xclient.data.l[0]) == deleteWindow) {
return 0;
}
while(XCheckWindowEvent(xDisplay, xWindow, INPUT_MASK, &event)) {
switch(event.type) {
/* Window resizing */

1
src/Contexts/EglContext.h

@ -155,6 +155,7 @@ class EglContext: public AbstractContext {
private:
Display* xDisplay;
Window xWindow;
Atom deleteWindow;
EGLDisplay display;
EGLSurface surface;

Loading…
Cancel
Save