#include "gfx.h"
#include "shalloc.h"
+#include "winnie.h"
#define FRAMEBUFFER_SIZE(xsz, ysz, bpp) ((xsz) * (ysz) * (bpp) / CHAR_BIT)
return false;
}
+ get_subsys()->graphics_offset = (int)((char*)gfx - (char*)get_pool());
+
dev_fd = -1;
if((dev_fd = open("/dev/fb0", O_RDWR)) == -1) {
#include "keyboard.h"
#include "shalloc.h"
#include "window.h"
+#include "winnie.h"
#include "wm.h"
struct Keyboard {
return false;
}
+ get_subsys()->keyboard_offset = (int)((char*)keyboard - (char*)get_pool());
+
keyboard->ttystate = keyboard->CANONICAL;
keyboard->dev_fd = -1;
#include "mouse.h"
#include "shalloc.h"
#include "window.h"
+#include "winnie.h"
#include "wm.h"
#define BN_LEFT 1
if(!(mouse = (Mouse*)sh_malloc(sizeof *mouse))) {
return false;
}
+ get_subsys()->mouse_offset = (int)((char*)mouse - (char*)get_pool());
memset(mouse, 0, sizeof *mouse);
mouse->dev_fd = -1;
#include "gfx.h"
#include "shalloc.h"
+#include "winnie.h"
static SDL_Surface *fbsurf;
return false;
}
+ get_subsys()->graphics_offset = (int)((char*)gfx - (char*)get_pool());
+
Rect scr_rect(0, 0, 1024, 768);
gfx->screen_rect = scr_rect;
gfx->color_depth = 32;
#include "mouse.h"
#include "shalloc.h"
-#include "window.h"
#include "wm.h"
+#include "window.h"
+#include "winnie.h"
extern SDL_Event sdl_event;
if(!(mouse = (Mouse*)sh_malloc(sizeof *mouse))) {
return false;
}
+ get_subsys()->mouse_offset = (int)((char*)mouse - (char*)get_pool());
+
memset(mouse, 0, sizeof *mouse);
return true;
}
}
}
+void *get_pool()
+{
+ return (void*)pool;
+}
+
static bool is_allocated(int block_number)
{
int idx = block_number / 32;
void *sh_malloc(size_t bytes);
void sh_free(void *ptr);
+void *get_pool();
+
#endif // SHALLOC_H_
#include "gfx.h"
#include "shalloc.h"
#include "text.h"
+#include "winnie.h"
#define DPI 72
#define FONT_PATH "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf"
return false;
}
+ get_subsys()->text_offset = (int)((char*)text - (char*)get_pool());
+
if(FT_Init_FreeType(&text->ft_lib)) {
fprintf(stderr, "Failed to initialize the FreeType library!\n");
return false;
#include "shalloc.h"
#include "winnie.h"
+static Subsys *subsys;
+
bool winnie_init()
{
if(!init_shared_memory()) {
return false;
}
+ if(!(subsys = (Subsys*)sh_malloc(sizeof *subsys))) {
+ return false;
+ }
+
if(!init_gfx()) {
return false;
}
destroy_keyboard();
destroy_mouse();
destroy_text();
+ destroy_window_manager();
+
+ sh_free(subsys);
destroy_shared_memory();
}
return (tv.tv_usec - init_tv.tv_usec) / 1000 + (tv.tv_sec - init_tv.tv_sec) * 1000;
}
+
+Subsys *get_subsys()
+{
+ return subsys;
+}
#include "window.h"
#include "wm.h"
-struct subsys {
+struct Subsys {
int graphics_offset;
int keyboard_offset;
int mouse_offset;
long winnie_get_time();
+Subsys *get_subsys();
+
#endif
#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
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)
#include "geom.h"
#include "pixmap.h"
+#include "winnie.h"
class Window;