Implement window.onclose event, which happens just before window close.
authorGuo Rui <firemeteor@Adam.(none)>
Sun, 26 Jul 2009 15:43:33 +0000 (26 23:43 +0800)
committerGuo Rui <firemeteor@Adam.(none)>
Sun, 26 Jul 2009 15:43:33 +0000 (26 23:43 +0800)
src/script.c
src/window.c
src/window.h

index 87aefe1..2717a97 100644 (file)
@@ -205,6 +205,7 @@ struct sev_description {
 
       /* Window events */
       {"window_can_resize", "", offsetof(struct win, w_sev.canresize)},
+      {"window_onclose", "w", offsetof(struct win, w_sev.onclose)},
       {"window_onfocus", "dw", offsetof(struct win, w_sev.onfocus)},
       /* last view of window w disappeared on display d. */
       {"window_onhide", "dw", offsetof(struct win, w_sev.onhide)},
index 4754a98..fa4500f 100644 (file)
@@ -950,6 +950,11 @@ struct win *wp;
   struct layer *l;
 
   debug1("FreeWindow %d\n", wp ? wp->w_number: -1);
+
+#ifdef SCRIPT
+  trigger_sevent(&wp->w_sev.onclose, wp);
+#endif
+
 #ifdef PSEUDOS
   if (wp->w_pwin)
     FreePseudowin(wp);
index b79adfa..2183bb9 100644 (file)
@@ -289,6 +289,7 @@ struct win
       struct script_event onleave;
       struct script_event onhide;
       struct script_event onshow;
+      struct script_event onclose;
     } w_sev; /*For Script events. */
 #endif
 };