Usermode/axwin3 - Input fixes
[tpg/acess2.git] / Usermode / Applications / axwin3_src / WM / wm.c
index 89cdd06..8886af1 100644 (file)
@@ -140,6 +140,8 @@ void WM_RaiseWindow(tWindow *Window)
        Window->PrevSibling = parent->LastChild;
        Window->NextSibling = NULL;
        parent->LastChild = Window;
+       
+       _SysDebug("Raised %p", Window);
 }
 
 /*
@@ -171,6 +173,8 @@ void WM_FocusWindow(tWindow *Destination)
 {
        struct sWndMsg_Bool     _msg;
        
+       _SysDebug("WM_FocusWindow(%p)", Destination);
+
        if( gpWM_FocusedWindow == Destination )
                return ;
        if( Destination && !(Destination->Flags & WINFLAG_SHOW) )
@@ -190,8 +194,6 @@ void WM_FocusWindow(tWindow *Destination)
        WM_Invalidate(gpWM_FocusedWindow);
        WM_Invalidate(Destination);
 
-       WM_RaiseWindow(Destination);    
-
        gpWM_FocusedWindow = Destination;
 }
 
@@ -208,8 +210,10 @@ void WM_ShowWindow(tWindow *Window, int bShow)
        WM_SendMessage(NULL, Window, WNDMSG_SHOW, sizeof(_msg), &_msg);
 
        // Update the flag
-       if(bShow)
+       if(bShow) {
                Window->Flags |= WINFLAG_SHOW;
+               _SysDebug("Window %p shown", Window);
+       }
        else
        {
                Window->Flags &= ~WINFLAG_SHOW;
@@ -222,6 +226,7 @@ void WM_ShowWindow(tWindow *Window, int bShow)
                        free(Window->RenderBuffer);
                        Window->RenderBuffer = NULL;
                }
+               _SysDebug("Window %p hidden", Window);
        }
        
        WM_Invalidate(Window);
@@ -289,8 +294,9 @@ int WM_MoveWindow(tWindow *Window, int X, int Y)
        _SysDebug("WM_MoveWindow: (%i,%i)", X, Y);
        Window->X = X;  Window->Y = Y;
 
-       // TODO: Why invalidate buffer?
-       WM_Invalidate(Window);
+       // Mark up the tree that a child window has changed     
+       while( (Window = Window->Parent) )
+               Window->Flags &= ~WINFLAG_CHILDCLEAN;
 
        return 0;
 }
@@ -404,6 +410,17 @@ void WM_int_UpdateWindow(tWindow *Window)
        if( !(Window->Flags & WINFLAG_SHOW) )
                return ;
        
+       if( (Window->Flags & WINFLAG_RELATIVE) && Window->Parent )
+       {
+               Window->RealX = Window->Parent->RealX + Window->Parent->BorderL + Window->X;
+               Window->RealY = Window->Parent->RealY + Window->Parent->BorderT + Window->Y;
+       }
+       else
+       {
+               Window->RealX = Window->X;
+               Window->RealY = Window->Y;
+       }
+       
        // Render
        if( !(Window->Flags & WINFLAG_CLEAN) )
        {
@@ -425,17 +442,6 @@ void WM_int_UpdateWindow(tWindow *Window)
                        Window->RealW = Window->W;
                        Window->RealH = Window->H;
                }
-               
-               if( (Window->Flags & WINFLAG_RELATIVE) && Window->Parent )
-               {
-                       Window->RealX = Window->Parent->X + Window->Parent->BorderL + Window->X;
-                       Window->RealY = Window->Parent->Y + Window->Parent->BorderT + Window->Y;
-               }
-               else
-               {
-                       Window->RealX = Window->X;
-                       Window->RealY = Window->Y;
-               }
 
                Window->Renderer->Redraw(Window);
                Window->Flags |= WINFLAG_CLEAN;
@@ -463,6 +469,18 @@ void WM_int_BlitWindow(tWindow *Window)
        // Ignore hidden windows
        if( !(Window->Flags & WINFLAG_SHOW) )
                return ;
+       
+       // Duplicated position update to handle window moving
+       if( (Window->Flags & WINFLAG_RELATIVE) && Window->Parent )
+       {
+               Window->RealX = Window->Parent->RealX + Window->Parent->BorderL + Window->X;
+               Window->RealY = Window->Parent->RealY + Window->Parent->BorderT + Window->Y;
+       }
+       else
+       {
+               Window->RealX = Window->X;
+               Window->RealY = Window->Y;
+       }
 
 //     _SysDebug("Blit %p (%p) to (%i,%i) %ix%i", Window, Window->RenderBuffer,
 //             Window->RealX, Window->RealY, Window->RealW, Window->RealH);

UCC git Repository :: git.ucc.asn.au