void Video_Blit(uint32_t *Source, short DstX, short DstY, short W, short H)
{
uint32_t *buf;
+ short drawW = W;
if( DstX >= giScreenWidth) return ;
if( DstY >= giScreenHeight) return ;
// TODO: Handle -ve X/Y by clipping
if( DstX < 0 || DstY < 0 ) return ;
// TODO: Handle out of bounds by clipping too
- if( DstX + W > giScreenWidth ) return;
+ if( DstX + drawW > giScreenWidth ) {
+ int oldw = drawW;
+ drawW = giScreenWidth - DstX;
+ _SysDebug("Video_Blit: Clipped width from %i to %i", oldw, drawW);
+ }
if( DstY + H > giScreenHeight )
H = giScreenHeight - DstY;
if( W <= 0 || H <= 0 ) return;
- if( DstX < giVideo_FirstDirtyLine )
+ if( DstY < giVideo_FirstDirtyLine )
giVideo_FirstDirtyLine = DstY;
if( DstY + H > giVideo_LastDirtyLine )
giVideo_LastDirtyLine = DstY + H;
buf = gpScreenBuffer + DstY*giScreenWidth + DstX;
- if(W != giScreenWidth)
+ if(drawW != giScreenWidth)
{
while( H -- )
{
- memcpy(buf, Source, W*4);
+ memcpy(buf, Source, drawW*4);
Source += W;
buf += giScreenWidth;
}
parent->LastChild = Window;
}
+/*
+void WM_RaiseWindow(tWindow *Window)
+{
+ // Move to the last render position (move to top)
+ while(Window && Window->Parent)
+ {
+ if( Window->NextSibling )
+ {
+ // remove
+ if( Window->PrevSibling )
+ Window->PrevSibling->NextSibling = Window->NextSibling;
+ Window->NextSibling->PrevSibling = Window->PrevSibling;
+ // Mutate self
+ Window->PrevSibling = Window->Parent->LastChild;
+ Window->NextSibling = NULL;
+ // re-add
+ Window->PrevSibling->NextSibling = Window;
+ Window->Parent->LastChild = Window;
+ }
+ _SysDebug("WM_RaiseWindow: Raised %p", Window);
+ Window = Window->Parent;
+ }
+}
+*/
+
void WM_FocusWindow(tWindow *Destination)
{
struct sWndMsg_Bool _msg;
WM_Invalidate(gpWM_FocusedWindow);
WM_Invalidate(Destination);
- gpWM_FocusedWindow = Destination;
+ WM_RaiseWindow(Destination);
- // Get the owner of the focused window
-// while(Destination && Destination->Owner) Destination = Destination->Owner;
-// gpWM_HilightedWindow = Destination;
+ gpWM_FocusedWindow = Destination;
}
}
// TODO: Re-sanitise
+ _SysDebug("WM_MoveWindow: (%i,%i)", X, Y);
Window->X = X; Window->Y = Y;
// TODO: Why invalidate buffer?
if( Window->W == W && Window->H == H )
return 0;
+ _SysDebug("WM_Resizeindow: %ix%i", W, H);
Window->W = W; Window->H = H;
if(Window->RenderBuffer) {