2.5
[blender.git] / source / blender / windowmanager / intern / wm_init_exit.c
index c196f7a4fff8389dbb0da7c2c5de9c5c64c7436c..4d170ceeb46478e105d65ab377fea6ed0d81ddb7 100644 (file)
@@ -74,6 +74,9 @@
 
 #include "WM_api.h"
 #include "WM_types.h"
+
+#include "wm_cursors.h"
+#include "wm_event_system.h"
 #include "wm.h"
 #include "wm_files.h"
 #include "wm_window.h"
@@ -109,6 +112,7 @@ void WM_init(bContext *C)
 {
        
        wm_ghost_init(C);       /* note: it assigns C to ghost! */
+       wm_init_cursor_data();
        wm_operatortype_init();
        
        set_free_windowmanager_cb(wm_close_and_free);   /* library.c */
@@ -157,6 +161,23 @@ extern wchar_t *copybufinfo;
 /* called in creator.c even... tsk, split this! */
 void WM_exit(bContext *C)
 {
+       wmWindow *win;
+       
+       /* first wrap up running stuff, we assume only the active WM is running */
+       /* modal handlers are on window level freed, others too? */
+       if(C && C->wm) {
+               for(win= C->wm->windows.first; win; win= win->next) {
+                       ARegion *ar;
+                       
+                       C->window= win; /* needed by operator close callbacks */
+                       WM_event_remove_handlers(C, &win->handlers);
+                       
+                       for(ar= win->screen->regionbase.first; ar; ar= ar->next)
+                               WM_event_remove_handlers(C, &ar->handlers);
+                       
+                       ED_screen_exit(C, win, win->screen);
+               }
+       }
        wm_operatortype_free();
        
        free_ttfont(); /* bke_font.h */