Usermode/AxWin3 - Fixed error with relative windows and input
authorJohn Hodge (sonata) <[email protected]>
Wed, 28 Nov 2012 14:26:30 +0000 (22:26 +0800)
committerJohn Hodge (sonata) <[email protected]>
Wed, 28 Nov 2012 14:26:30 +0000 (22:26 +0800)
Usermode/Applications/axwin3_src/WM/wm.c
Usermode/Applications/axwin3_src/WM/wm_input.c
Usermode/Applications/axwin3_src/libaxwin3.so_src/r_menu.c

index 89cdd06..f039460 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);
 }
 
 /*
@@ -190,8 +192,6 @@ void WM_FocusWindow(tWindow *Destination)
        WM_Invalidate(gpWM_FocusedWindow);
        WM_Invalidate(Destination);
 
-       WM_RaiseWindow(Destination);    
-
        gpWM_FocusedWindow = Destination;
 }
 
@@ -208,8 +208,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 +224,7 @@ void WM_ShowWindow(tWindow *Window, int bShow)
                        free(Window->RenderBuffer);
                        Window->RenderBuffer = NULL;
                }
+               _SysDebug("Window %p hidden", Window);
        }
        
        WM_Invalidate(Window);
@@ -428,8 +431,8 @@ void WM_int_UpdateWindow(tWindow *Window)
                
                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;
+                       Window->RealX = Window->Parent->RealX + Window->Parent->BorderL + Window->X;
+                       Window->RealY = Window->Parent->RealY + Window->Parent->BorderT + Window->Y;
                }
                else
                {
index 5f6ef85..858862b 100644 (file)
@@ -34,8 +34,8 @@ tWindow *WM_int_GetWindowAtPos(int X, int Y)
                for(win = ret->FirstChild; win; win = win->NextSibling)
                {
                        if( !(win->Flags & WINFLAG_SHOW) )      continue ;
-                       if( X < win->X || X >= win->X + win->RealW )    continue;
-                       if( Y < win->Y || Y >= win->Y + win->RealH )    continue;
+                       if( X < win->RealX || X >= win->RealX + win->RealW )    continue;
+                       if( Y < win->RealY || Y >= win->RealY + win->RealH )    continue;
                        next_win = win; // Overwrite as we want the final rendered window
                }
        }
@@ -49,8 +49,8 @@ void WM_Input_MouseMoved(int OldX, int OldY, int NewX, int NewY)
        struct sWndMsg_MouseMove        msg;
        
        win = WM_int_GetWindowAtPos(OldX, OldY);
-       msg.X = NewX - win->X - win->BorderL;
-       msg.Y = NewY - win->Y - win->BorderT;
+       msg.X = NewX - win->RealX - win->BorderL;
+       msg.Y = NewY - win->RealY - win->BorderT;
        msg.dX = NewX - OldX;
        msg.dY = NewY - OldY;
        WM_SendMessage(NULL, win, WNDMSG_MOUSEMOVE, sizeof(msg), &msg);
@@ -64,8 +64,8 @@ void WM_Input_MouseMoved(int OldX, int OldY, int NewX, int NewY)
        // TODO: Send mouseup to match mousedown if the cursor moves out of a window?
 
        win = newWin;
-       msg.X = NewX - win->X - win->BorderL;
-       msg.Y = NewY - win->Y - win->BorderT;
+       msg.X = NewX - win->RealX - win->BorderL;
+       msg.Y = NewY - win->RealY - win->BorderT;
        msg.dX = NewX - OldX;
        msg.dY = NewY - OldY;
        WM_SendMessage(NULL, win, WNDMSG_MOUSEMOVE, sizeof(msg), &msg);
@@ -75,8 +75,8 @@ void WM_Input_int_SendBtnMsg(tWindow *Win, int X, int Y, int Index, int Pressed)
 {
        struct sWndMsg_MouseButton      msg;    
 
-       msg.X = X - Win->X - Win->BorderL;
-       msg.Y = Y - Win->Y - Win->BorderT;
+       msg.X = X - Win->RealX - Win->BorderL;
+       msg.Y = Y - Win->RealY - Win->BorderT;
        msg.Button = Index;
        msg.bPressed = !!Pressed;
        
@@ -94,7 +94,12 @@ void WM_Input_MouseButton(int X, int Y, int ButtonIndex, int Pressed)
        {
 //             _SysDebug("Gave focus to %p", win);
                WM_FocusWindow(win);
-               WM_RaiseWindow(win);
+               tWindow *tmpwin = win;
+               while( tmpwin )
+               {
+                       WM_RaiseWindow(tmpwin);
+                       tmpwin = tmpwin->Parent;
+               }
        }
 
        // Make sure that even if the mouse has moved out of the original window,
index 4b7bb56..65525b9 100644 (file)
@@ -43,9 +43,9 @@ int AxWin3_Menu_int_Callback(tHWND Window, int Message, int Length, void *Data)
                if(msg->ID >= info->nItems)     return -1;
                item = &info->Items[msg->ID];
                if(item->Callback)      item->Callback(item->CbPtr);
-               return 0; }
+               return 1; }
        }
-       return 1;
+       return 0;
 }
 
 tHWND AxWin3_Menu_Create(tHWND Parent)

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