Index: salframe.cxx =================================================================== RCS file: /cvs/oo/gsl/vcl/unx/source/window/salframe.cxx,v retrieving revision 1.114.2.4 diff -u -B -r1.114.2.4 salframe.cxx --- salframe.cxx 2002/06/21 13:34:23 1.114.2.4 +++ salframe.cxx 2002/08/30 10:18:39 @@ -180,6 +180,7 @@ static ::std::list< XLIB_Window > aPresentationReparentList; static SalFrame* pIntroBitmap = NULL; static bool bWasIntroBitmap = false; +static SalFrame* pSaveYourselfFrame = NULL; static int nVisibleFloats = 0; // -=-= C++ statics =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= @@ -452,21 +453,21 @@ if( ! pParentData ) { - XSizeHints* pHints = XAllocSizeHints(); - pHints->flags = PWinGravity | PPosition | PSize; - pHints->x = x; - pHints->y = y; - pHints->width = w; - pHints->height = h; - pHints->win_gravity = NorthWestGravity; - XFree( pHints ); - XSetWMHints( GetXDisplay(), mhWindow, &Hints ); // WM Protocols && internals + // All of our top level windows implement the WM_DELETE_WINDOW protocol, + // and the whole application should have exactly one window that implements + // the WM_SAVE_YOURSELF protocol. Atom a[4]; int n = 0; a[n++] = pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::WM_DELETE_WINDOW ); - a[n++] = pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::WM_SAVE_YOURSELF ); + if ( ! pSaveYourselfFrame ) { + a[n++] = pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::WM_SAVE_YOURSELF ); + pSaveYourselfFrame = pFrame_; +#ifdef DEBUG + printf( "WM_SAVE_YOURSELF window set to XID %#x\n", mhWindow ); +#endif + } XSetWMProtocols( GetXDisplay(), mhWindow, a, n ); XClassHint* pClass = XAllocClassHint(); @@ -643,6 +644,42 @@ pTemp->pNextFrame_ = GetNextFrame(); } + + /* + * In case we just deleted the frame that contained the WM_SAVE_YOURSELF + * WM_PROTOCOLS atom for the application, we try to find another + * top level window that gets the WM_SAVE_YOURSELF atom. + */ + if ( pFrame_ == pSaveYourselfFrame ) + { + pSaveYourselfFrame = NULL; + + SalFrame *pFrameTemp = pSalData->pFirstFrame_; + while ( pFrameTemp && pFrameTemp->maFrameData.mpParent != NULL ) + pFrameTemp = pFrameTemp->maFrameData.pNextFrame_; + + if ( pFrameTemp ) + { + pSaveYourselfFrame = pFrameTemp; + + Atom a[4]; + int n = 0; + a[n++] = pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::WM_DELETE_WINDOW ); + a[n++] = pDisplay_->getWMAdaptor()->getAtom( WMAdaptor::WM_SAVE_YOURSELF ); + XSetWMProtocols( GetXDisplay(), pFrameTemp->maFrameData.mhWindow, a, n ); + +#ifdef DEBUG + printf( "WM_SAVE_YOURSELF window moved to XID %#x\n", pFrameTemp->maFrameData.mhWindow ); +#endif + } + else + { +#ifdef DEBUG + printf( "WM_SAVE_YOURSELF window was deleted\n" ); +#endif + } + } + /* * check if there is only the status frame is left * if so, free it @@ -3051,10 +3115,7 @@ } else if( pEvent->data.l[0] == rWMAdaptor.getAtom( WMAdaptor::WM_SAVE_YOURSELF ) ) { - SalFrame* pLast = GetSalData()->pFirstFrame_; - while( pLast->maFrameData.pNextFrame_ ) - pLast = pLast->maFrameData.pNextFrame_; - if( pLast == pFrame_ ) + if( pFrame_ == pSaveYourselfFrame ) { ByteString aExec( SessionManagerClient::getExecName(), osl_getThreadTextEncoding() ); char* argv[2];