Index: src/views/unix/SkOSWindow_Unix.cpp |
diff --git a/src/views/unix/SkOSWindow_Unix.cpp b/src/views/unix/SkOSWindow_Unix.cpp |
index 078a9f9d56c6a15e79c78a2acd2e7f4d1cec8e6e..fad59225177763caa44d0bfd398da9ab9a069bcb 100644 |
--- a/src/views/unix/SkOSWindow_Unix.cpp |
+++ b/src/views/unix/SkOSWindow_Unix.cpp |
@@ -200,11 +200,13 @@ static bool MyXNextEventWithDelay(Display* dsp, XEvent* evt) { |
return true; |
} |
+static Atom wm_delete_window_message; |
+ |
SkOSWindow::NextXEventResult SkOSWindow::nextXEvent() { |
XEvent evt; |
Display* dsp = fUnixWindow.fDisplay; |
- if (!MyXNextEventWithDelay(fUnixWindow.fDisplay, &evt)) { |
+ if (!MyXNextEventWithDelay(dsp, &evt)) { |
return kContinue_NextXEventResult; |
} |
@@ -248,6 +250,11 @@ SkOSWindow::NextXEventResult SkOSWindow::nextXEvent() { |
case KeyRelease: |
this->handleKeyUp(XKeyToSkKey(XkbKeycodeToKeysym(dsp, evt.xkey.keycode, 0, 0))); |
break; |
+ case ClientMessage: |
+ if ((Atom)evt.xclient.data.l[0] == wm_delete_window_message) { |
+ return kQuitRequest_NextXEventResult; |
+ } |
+ // fallthrough |
default: |
// Do nothing for other events |
break; |
@@ -262,6 +269,9 @@ void SkOSWindow::loop() { |
} |
Window win = fUnixWindow.fWin; |
+ wm_delete_window_message = XInternAtom(dsp, "WM_DELETE_WINDOW", False); |
+ XSetWMProtocols(dsp, win, &wm_delete_window_message, 1); |
+ |
XSelectInput(dsp, win, EVENT_MASK); |
bool sentExposeEvent = false; |