added struct subsys so that we know each
[winnie] / src / wm.cc
index dd47d30..621a23f 100644 (file)
--- a/src/wm.cc
+++ b/src/wm.cc
@@ -1,3 +1,24 @@
+/*
+winnie - an experimental window system
+
+Copyright (C) 2013 Eleni Maria Stea
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Author: Eleni Maria Stea <elene.mst@gmail.com>
+*/
+
 #include <algorithm>
 #include <limits.h>
 #include <stdexcept>
 #include "gfx.h"
 #include "mouse.h"
 #include "mouse_cursor.h"
+#include "shalloc.h"
 #include "text.h"
-#include "wm.h"
 #include "window.h"
 #include "winnie.h"
+#include "wm.h"
 
 #define DCLICK_INTERVAL 400
 
@@ -21,16 +43,22 @@ static void motion(Window *win, int x, int y);
 
 bool init_window_manager()
 {
-       if(!(wm = new WindowManager)) {
+       void *wm_mem;
+       if(!(wm_mem = sh_malloc(sizeof *wm))) {
                return false;
        }
 
+       wm = new (wm_mem) WindowManager; 
+
+       get_subsys()->wm_offset = (int)((char*)wm - (char*)get_pool());
+
        return true;
 }
 
 void destroy_window_manager()
 {
-       delete wm;
+       wm->~WindowManager();
+       sh_free(wm);
 }
 
 void WindowManager::create_frame(Window *win)