Ignore:
Timestamp:
Jun 9, 2001, 4:50:26 PM (24 years ago)
Author:
sandervl
Message:

reference count (window + class objects) rewrite

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/pmwindow.cpp

    r5805 r5935  
    1 /* $Id: pmwindow.cpp,v 1.132 2001-05-25 19:59:29 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.133 2001-06-09 14:50:19 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    214214            rc = (MRESULT)win32wnd->DispatchMsgA(pWinMsg);
    215215        }
     216        RELEASE_WNDOBJ(win32wnd);
    216217        RestoreOS2TIB();
    217218        return rc;
     
    229230        dprintf(("OS2: WM_CREATE %x", hwnd));
    230231        win32wnd = (Win32BaseWindow *)teb->o.odin.newWindow;
     232        win32wnd->addRef();
    231233        teb->o.odin.newWindow = 0;
    232234        if(win32wnd->MsgCreate(hwnd) == FALSE)
     
    302304                WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
    303305            }
     306            if(topwindow) RELEASE_WNDOBJ(topwindow);
    304307
    305308            win32wnd->setComingToTop(FALSE);
     
    319322        dprintf(("USER32: Delayed SetFocus %x %x %x call!", teb->o.odin.hwndFocus, mp1, mp2));
    320323        if(teb->o.odin.hwndFocus) {
     324            RELEASE_WNDOBJ(win32wnd);
    321325            win32wnd = Win32BaseWindow::GetWindowFromHandle(teb->o.odin.hwndFocus);
    322326            if(win32wnd) {
     
    373377    case WM_BUTTON3DBLCLK:
    374378        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     379            RELEASE_WNDOBJ(win32wnd);
    375380            win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    376381        }
     
    396401    {
    397402        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     403            RELEASE_WNDOBJ(win32wnd);
    398404            win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    399405        }
     
    525531        goto RunDefWndProc;
    526532    }
     533    if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    527534    RestoreOS2TIB();
    528535    return (MRESULT)rc;
     
    530537RunDefWndProc:
    531538//  dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
     539    if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    532540    RestoreOS2TIB();
    533541    return WinDefWindowProc( hwnd, msg, mp1, mp2 );
     
    622630    {
    623631        dprintf(("PMFRAME:WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
    624         RestoreOS2TIB();
    625         return (MRESULT)FALSE;
     632        rc = (MRESULT)FALSE;
     633        break;
    626634    }
    627635
     
    640648    case WM_BUTTON3DBLCLK:
    641649        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     650            RELEASE_WNDOBJ(win32wnd);
    642651            win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    643652        }
     
    663672    {
    664673        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     674            RELEASE_WNDOBJ(win32wnd);
    665675            win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    666676        }
     
    724734           if(wndAfter) {
    725735                wp.hwndInsertAfter = wndAfter->getWindowHandle();
     736                RELEASE_WNDOBJ(wndAfter);
    726737           }
    727738           else wp.hwndInsertAfter = HWND_TOP_W;
     
    760771            pswp->hwnd = hwnd;
    761772
    762             RestoreOS2TIB();
    763             return (MRESULT)0xf;
    764         }
    765         RestoreOS2TIB();
    766         return (MRESULT)0;
     773            rc = (MRESULT)0xf;
     774            break;
     775        }
     776        rc = 0;
     777        break;
    767778    }
    768779
     
    835846            if(wndAfter) {
    836847                 wp.hwndInsertAfter = wndAfter->getWindowHandle();
     848                 RELEASE_WNDOBJ(wndAfter);
    837849            }
    838850            else wp.hwndInsertAfter = HWND_TOP_W;
     
    959971
    960972PosChangedEnd:
    961         RestoreOS2TIB();
    962         return (MRESULT)FALSE;
     973        rc = (MRESULT)FALSE;
     974        break;
    963975    }
    964976
     
    9941006            if(wndAfter) {
    9951007                 wp.hwndInsertAfter = wndAfter->getWindowHandle();
     1008                 RELEASE_WNDOBJ(wndAfter);
    9961009            }
    9971010            else wp.hwndInsertAfter = HWND_TOP_W;
     
    10461059            newRect->yBottom += newClientRect.yBottom;
    10471060        }
    1048         RestoreOS2TIB();
    1049         return (MRESULT)res;
     1061        rc = res;
     1062        break;
    10501063    }
    10511064#else
    10521065        dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
    1053         RestoreOS2TIB();
    1054         return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
     1066        rc = (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
     1067        break;
    10551068#endif
    10561069
     
    10781091#endif
    10791092
    1080 #if 0
    1081     //is sent to both windows gaining and loosing the focus
    1082     case WM_FOCUSCHANGE:
    1083     {
    1084      HWND   hwndFocus = (HWND)mp1;
    1085      HWND   hwndLoseFocus, hwndGainFocus;
    1086      USHORT usSetFocus = SHORT1FROMMP(mp2);
    1087      USHORT fsFocusChange = SHORT2FROMMP(mp2);
    1088 
    1089         rc = 0;
    1090         dprintf(("PMFRAME:WM_FOCUSCHANGE (start) %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
    1091         if(usSetFocus) {
    1092             hwndGainFocus = hwnd;
    1093             hwndLoseFocus = hwndFocus;
    1094         }
    1095         else {
    1096             hwndGainFocus = hwndFocus;
    1097             hwndLoseFocus = hwnd;
    1098         }
    1099 
    1100         if(usSetFocus)
    1101         {
    1102           Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndLoseFocus);
    1103           if(!(fsFocusChange & FC_NOSETACTIVE))
    1104           {
    1105             if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
    1106             {
    1107               if(winfocus)
    1108                 WinSendMsg(winfocus->GetTopParent()->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    1109               else
    1110                 WinSendMsg(hwndLoseFocus, WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    1111             }
    1112           }
    1113           //SvL: Check if window is still valid
    1114           win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    1115           if(win32wnd == NULL) {
    1116             RestoreOS2TIB();
    1117             return (MRESULT)rc;
    1118           }
    1119           if(!(fsFocusChange & FC_NOSETACTIVE))
    1120           {
    1121             Win32BaseWindow *topparent = win32wnd->GetTopParent();
    1122             if(!winfocus || (winfocus->GetTopParent() != topparent))
    1123             {
    1124               if(!(fsFocusChange & FC_NOBRINGTOTOP))
    1125               {
    1126                 if(topparent) {
    1127                   //put window at the top of z order
    1128                   WinSetWindowPos(topparent->getOS2WindowHandle(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
    1129                 }
    1130               }
    1131 
    1132               // PH 2000/09/01 Netscape 4.7
    1133               // check if topparent is valid
    1134               if (topparent)
    1135                 WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    1136             }
    1137           }
    1138           //SvL: Check if window is still valid
    1139           win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    1140           if(win32wnd == NULL) {
    1141             break;
    1142           }
    1143 
    1144       //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
    1145       if(!(fsFocusChange & FC_NOSETSELECTION)) {
    1146             WinSendMsg(hwndGainFocus, WM_SETSELECTION, (MPARAM)1, (MPARAM)0);
    1147       }
    1148 
    1149       if(!(fsFocusChange & FC_NOSETFOCUS)) {
    1150             WinSendMsg(hwndGainFocus, WM_SETFOCUS, (MPARAM)hwndLoseFocus, (MPARAM)1);
    1151       }
    1152         }
    1153         else /* no usSetFocus */
    1154         {
    1155       if(!(fsFocusChange & FC_NOLOSEFOCUS)) {
    1156             WinSendMsg(hwndLoseFocus, WM_SETFOCUS, (MPARAM)hwndGainFocus, (MPARAM)0);
    1157       }
    1158       //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
    1159       if(!(fsFocusChange & FC_NOLOSESELECTION)) {
    1160             WinSendMsg(hwndLoseFocus, WM_SETSELECTION, (MPARAM)0, (MPARAM)0);
    1161       }
    1162           //SvL: Check if window is still valid
    1163           win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    1164           if(win32wnd == NULL) {
    1165             break;
    1166           }
    1167 
    1168           Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndGainFocus);
    1169           if(!(fsFocusChange & FC_NOLOSEACTIVE))
    1170           {
    1171             Win32BaseWindow *topparent = win32wnd->GetTopParent();
    1172 
    1173             if(!winfocus || (winfocus->GetTopParent() != topparent))
    1174             {
    1175               // PH 2000/09/01 Netscape 4.7
    1176               // check if topparent is valid
    1177               if (topparent)
    1178                 WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    1179             }
    1180           }
    1181           //SvL: Check if window is still valid
    1182           win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    1183           if(win32wnd == NULL)
    1184             break;
    1185 
    1186           if(!(fsFocusChange & FC_NOSETACTIVE))
    1187           {
    1188             if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
    1189             {
    1190               if(winfocus)
    1191               {
    1192                 // PH 2000/09/01 Netscape 4.7
    1193                 // check if topparent is valid
    1194                 Win32BaseWindow *topparent = winfocus->GetTopParent();
    1195                 if (topparent)
    1196                   WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    1197               }
    1198               else
    1199                 WinSendMsg(hwndGainFocus, WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    1200             }
    1201           }
    1202         }
    1203 
    1204 
    1205 #ifdef DEBUG
    1206         dprintf(("PMFRAME:WM_FOCUSCHANGE (end) %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
    1207 #endif
    1208         break;
    1209     }
    1210 #endif
    1211 
    12121093#ifdef DEBUG
    12131094    case WM_FOCUSCHANGE:
     
    12371118            if (win32wnd->IsModalDialog())
    12381119            {
    1239                 Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
    1240 
    1241                 if (topOwner) WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
     1120                if(win32wnd->getOwner()) {
     1121                    Win32BaseWindow *topOwner = Win32BaseWindow::GetWindowFromHandle(win32wnd->getOwner()->GetTopParent());
     1122 
     1123                    if (topOwner) {
     1124                        WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
     1125                        RELEASE_WNDOBJ(topOwner);
     1126                    }
     1127                }
    12421128            }
    12431129        }
     
    13561242    }
    13571243    RestoreOS2TIB();
     1244    if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    13581245    return (MRESULT)rc;
    13591246
    13601247RunDefFrameWndProc:
     1248    if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    13611249    RestoreOS2TIB();
    13621250    return pfnFrameWndProc(hwnd, msg, mp1, mp2);
    13631251
    13641252RunDefWndProc:
     1253    if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    13651254    RestoreOS2TIB();
    13661255    //calling WinDefWindowProc here breaks Opera hotlist window (WM_ADJUSTWINDOWPOS)
Note: See TracChangeset for help on using the changeset viewer.