From 6c5c7786ca36ec5bc60559a8125d6147e53a976a Mon Sep 17 00:00:00 2001 From: Josh Simmons Date: Sat, 5 Oct 2013 14:41:22 +1000 Subject: [PATCH] Handle exit message from window manager on Linux --- examples/common/entry/entry_linux.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/examples/common/entry/entry_linux.cpp b/examples/common/entry/entry_linux.cpp index d4274df5..1c3c13ce 100644 --- a/examples/common/entry/entry_linux.cpp +++ b/examples/common/entry/entry_linux.cpp @@ -160,6 +160,11 @@ namespace entry , &windowAttrs ); + const char *wmDeleteWindowName = "WM_DELETE_WINDOW"; + Atom wmDeleteWindow; + XInternAtoms(m_display, (char **)&wmDeleteWindowName, 1, False, &wmDeleteWindow); + XSetWMProtocols(m_display, m_window, &wmDeleteWindow, 1); + XMapWindow(m_display, m_window); XStoreName(m_display, m_window, "BGFX"); @@ -187,6 +192,13 @@ namespace entry case ConfigureNotify: break; + case ClientMessage: + if((Atom)event.xclient.data.l[0] == wmDeleteWindow) + { + m_eventQueue.postExitEvent(); + } + break; + case ButtonPress: case ButtonRelease: {