2 * Acess2 Window Manager v3
3 * - By John Hodge (thePowersGang)
6 * - Window manager core
9 #include <wm_renderer.h>
14 tWMRenderer *gpWM_Renderers;
15 // - Render order list (gpWM_FirstWindow is rendered first)
16 tWindow *gpWM_RootWindow;
19 void WM_Initialise(void)
21 WM_CreateWindow(NULL, 0x8888FF, "Background");
24 void WM_RegisterRenderer(tWMRenderer *Renderer)
26 // TODO: Catch out duplicates
27 Renderer->Next = gpWM_Renderers;
28 gpWM_Renderers = Renderer;
31 tWindow *WM_CreateWindow(tWindow *Parent, int RendererArg, const char *RendererName)
33 tWMRenderer *renderer;
37 for( renderer = gpWM_Renderers; renderer; renderer = renderer->Next )
39 if(strcmp(RendererName, renderer->Name) == 0)
45 // - Call create window function
46 ret = renderer->CreateWindow(RendererArg);
50 Parent = gpWM_RootWindow;
56 Parent->LastChild->NextSibling = ret;
58 Parent->FirstChild = ret;
59 ret->PrevSibling = Parent->LastChild;
60 Parent->LastChild = ret;
64 gpWM_RootWindow = ret;
71 tWindow *WM_CreateWindowStruct(size_t ExtraSize)
73 return calloc( sizeof(tWindow) + ExtraSize, 1 );
76 void WM_int_UpdateWindow(tWindow *Window)
80 // Ignore hidden windows
81 if( !(Window->Flags & WINFLAG_SHOW) )
83 // Ignore unchanged windows
84 if( Window->Flags & WINFLAG_CLEAN )
88 Window->Renderer->Redraw(Window);
91 for( child = Window->FirstChild; child; child = child->NextSibling )
93 WM_int_UpdateWindow(child);
96 Window->Flags |= WINFLAG_CLEAN;
101 // - Iterate through visible windows, updating them as needed
103 // - Draw windows from back to front to the render buffer
105 // - Blit the buffer to the screen
108 void WM_Render_FilledRect(tWindow *Window, tColour Colour, int X, int Y, int W, int H)
110 // Clip to window dimensions
111 if(X < 0) { W += X; X = 0; }
112 if(Y < 0) { H += Y; Y = 0; }
113 if(X >= Window->W) return;
114 if(Y >= Window->H) return;
115 if(X + W > Window->W) W = Window->W - X;
116 if(Y + H > Window->H) H = Window->H - Y;