if(renderer == NULL)
return NULL;
+ if(!Parent)
+ Parent = gpWM_RootWindow;
+
// - Call create window function
ret = renderer->CreateWindow(RendererArg);
ret->Parent = Parent;
ret->Renderer = renderer;
-
- if(!Parent)
- Parent = gpWM_RootWindow;
+ ret->Flags = WINFLAG_CLEAN; // Note, not acutally clean, but it makes invaidate work
// Append to parent
if(Parent)
Window->Flags |= WINFLAG_SHOW;
else
Window->Flags &= ~WINFLAG_SHOW;
+ WM_Invalidate(Window);
}
int WM_MoveWindow(tWindow *Window, int X, int Y)
if(Y >= giScreenHeight) Y = giScreenHeight - 1;
Window->X = X; Window->Y = Y;
-
+
+ WM_Invalidate(Window);
+
return 0;
}
if(Window->Y + H < 0) Window->Y = -H + 1;
Window->W = W; Window->H = H;
+
+ WM_Invalidate(Window);
return 0;
}
+void WM_Invalidate(tWindow *Window)
+{
+ // Don't invalidate twice (speedup)
+ if( !(Window->Flags & WINFLAG_CLEAN) ) return;
+
+ _SysDebug("Invalidating %p");
+
+ // Mark for re-render
+ Window->Flags &= ~WINFLAG_CLEAN;
+
+ // Mark up the tree that a child window has changed
+ while( (Window = Window->Parent) )
+ {
+ _SysDebug("Childclean removed from %p", Window);
+ Window->Flags &= ~WINFLAG_CHILDCLEAN;
+ }
+}
+
// --- Rendering / Update
void WM_int_UpdateWindow(tWindow *Window)
{
// Ignore hidden windows
if( !(Window->Flags & WINFLAG_SHOW) )
return ;
- // Ignore unchanged windows
- if( Window->Flags & WINFLAG_CLEAN )
- return;
-
+
// Render
- Window->Renderer->Redraw(Window);
+ if( !(Window->Flags & WINFLAG_CLEAN) )
+ {
+ Window->Renderer->Redraw(Window);
+ Window->Flags |= WINFLAG_CLEAN;
+ }
// Process children
- for( child = Window->FirstChild; child; child = child->NextSibling )
+ if( !(Window->Flags & WINFLAG_CHILDCLEAN) )
{
- WM_int_UpdateWindow(child);
+ for( child = Window->FirstChild; child; child = child->NextSibling )
+ {
+ WM_int_UpdateWindow(child);
+ }
+ Window->Flags |= WINFLAG_CHILDCLEAN;
}
- Window->Flags |= WINFLAG_CLEAN;
}
void WM_int_BlitWindow(tWindow *Window)
void WM_Update(void)
{
// Don't redraw if nothing has changed
- if( gpWM_RootWindow->Flags & WINFLAG_CLEAN )
+ if( (gpWM_RootWindow->Flags & WINFLAG_CHILDCLEAN) )
return ;
// - Iterate through visible windows, updating them as needed