Back to index

lightning-sunbird  0.9+nobinonly
nsWindow.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Jerry.Kirk@Nexwarecorp.com
00024  *   Dale.Stansberry@Nexwarecorop.com
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 
00041 #include <Pt.h>
00042 #include <photon/PtServer.h>
00043 #include "PtRawDrawContainer.h"
00044 #include "nsCRT.h"
00045 
00046 #include "nsWindow.h"
00047 #include "nsWidgetsCID.h"
00048 #include "nsIFontMetrics.h"
00049 #include "nsFont.h"
00050 #include "nsGUIEvent.h"
00051 #include "nsIRenderingContext.h"
00052 #include "nsIRegion.h"
00053 #include "nsRect.h"
00054 #include "nsTransform2D.h"
00055 #include "nsGfxCIID.h"
00056 #include "nsIMenuBar.h"
00057 #include "nsToolkit.h"
00058 #include "nsIPref.h"
00059 
00060 #include "nsClipboard.h"
00061 #include "nsIRollupListener.h"
00062 
00063 #include "nsIServiceManager.h"
00064 #include "nsIAppShell.h"
00065 #include "nsIDocShell.h"
00066 
00067 #include "nsIViewManager.h"
00068 #include "nsIXULWindow.h"
00069 #include "nsIDocShellTreeItem.h"
00070 #include "nsIWindowMediator.h"
00071 #include "nsIPresShell.h"
00072 #include "nsReadableUtils.h"
00073 
00074 static PhTile_t *GetWindowClipping( PtWidget_t *aWidget );
00075 
00076 nsIRollupListener *nsWindow::gRollupListener = nsnull;
00077 nsIWidget         *nsWindow::gRollupWidget = nsnull;
00078 static PtWidget_t    *gMenuRegion;
00079 
00080 /* avoid making a costly PhWindowQueryVisible call */
00081 static PhRect_t gConsoleRect;
00082 static PRBool gConsoleRectValid = PR_FALSE;
00083 #define QueryVisible( )     {\
00084                                                                                            if( gConsoleRectValid == PR_FALSE ) { \
00085                                                                                                          PhWindowQueryVisible( Ph_QUERY_IG_POINTER, 0, 1, &gConsoleRect ); \
00086                                                                                                          gConsoleRectValid = PR_TRUE;\
00087                                                                                                          } \
00088                                                                                            }
00089 
00090 //-------------------------------------------------------------------------
00091 //
00092 // nsWindow constructor
00093 //
00094 //-------------------------------------------------------------------------
00095 nsWindow::nsWindow() 
00096 {
00097   mClientWidget    = nsnull;
00098   mIsTooSmall      = PR_FALSE;
00099   mBorderStyle     = eBorderStyle_default;
00100   mWindowType      = eWindowType_child;
00101        mLastMenu                           = nsnull;
00102 }
00103 
00104 //-------------------------------------------------------------------------
00105 //
00106 // nsWindow destructor
00107 //
00108 //-------------------------------------------------------------------------
00109 nsWindow::~nsWindow()
00110 {
00111        nsWindow *p = (nsWindow*)mParent;
00112        if( p && p->mLastMenu == mWidget ) p->mLastMenu = nsnull;
00113 
00114   // always call destroy.  if it's already been called, there's no harm
00115   // since it keeps track of when it's already been called.
00116   Destroy();
00117 }
00118 
00119 PRBool nsWindow::IsChild() const
00120 {
00121   return PR_FALSE;
00122 }
00123 
00124 NS_IMETHODIMP nsWindow::WidgetToScreen( const nsRect& aOldRect, nsRect& aNewRect ) {
00125 
00126        PhPoint_t pos, offset;
00127        PtWidget_t *disjoint = PtFindDisjoint( mWidget );
00128 
00129        QueryVisible( );
00130 
00131        PtGetAbsPosition( disjoint, &pos.x, &pos.y );
00132        PtWidgetOffset( mWidget, &offset );
00133        aNewRect.x = pos.x + offset.x + aOldRect.x - gConsoleRect.ul.x;
00134        aNewRect.y = pos.y + offset.y + aOldRect.y - gConsoleRect.ul.y;
00135 
00136        aNewRect.width = aOldRect.width;
00137        aNewRect.height = aOldRect.height;
00138 
00139   return NS_OK;
00140        }
00141 
00142 void nsWindow::DestroyNative(void)
00143 {
00144   if ( mClientWidget )
00145   {
00146     PtDestroyWidget(mClientWidget );  
00147     mClientWidget = nsnull;
00148   }
00149   // destroy all of the children that are nsWindow() classes
00150   // preempting the gdk destroy system.
00151   if( mWidget ) DestroyNativeChildren();
00152 
00153   // Call the base class to actually PtDestroy mWidget.
00154   nsWidget::DestroyNative();
00155 }
00156 
00157 // this function will walk the list of children and destroy them.
00158 // the reason why this is here is that because of the superwin code
00159 // it's very likely that we will never get notification of the
00160 // the destruction of the child windows.  so, we have to beat the
00161 // layout engine to the punch.  CB 
00162 
00163 void nsWindow::DestroyNativeChildren(void)
00164 {
00165   for(PtWidget_t *w=PtWidgetChildFront( mWidget ); w; w=PtWidgetBrotherBehind( w )) 
00166   {
00167          if( w->flags & Pt_DESTROYED ) continue;
00168          nsWindow *childWindow = NS_STATIC_CAST(nsWindow *, GetInstance(w) );
00169               if( childWindow && !childWindow->mIsDestroying) childWindow->Destroy();
00170   }
00171 }
00172 
00173 NS_IMETHODIMP nsWindow::CaptureRollupEvents( nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent ) {
00174   PtWidget_t *grabWidget;
00175   grabWidget = mWidget;
00176 
00177   if (aDoCapture) {
00178     NS_IF_RELEASE(gRollupListener);
00179     NS_IF_RELEASE(gRollupWidget);
00180     gRollupListener = aListener;
00181     NS_ADDREF(aListener);
00182     gRollupWidget = this;
00183     NS_ADDREF(this);
00184        
00185               /* Realize the gMenuRegion to capture events outside of the application's canvas when menus are displayed */
00186               /* Menus+submenus have the same parent. If the parent has mLastMenu set and realized, then use its region as "infront" */
00187               /* If not, then this widget ( mWidget ) becomes the mLastMenu and gets recorded into the parent */
00188               /* Different windows have different mLastMenu's */
00189               if( mWindowType == eWindowType_popup && !( PtWidgetFlags( gMenuRegion ) & Pt_REALIZED ) ) {
00190 
00191                      PtWidget_t *pw = mParent ? ((nsWindow*)mParent)->mLastMenu : NULL;
00192 
00193                      if( pw && ( PtWidgetFlags( pw ) & Pt_REALIZED ) && PtWidgetRid( pw ) > 0 )
00194                             PtSetResource( gMenuRegion, Pt_ARG_REGION_INFRONT, PtWidgetRid( pw ), 0 );
00195                      else {
00196                             if( !PtWidgetIsRealized( mWidget ) ) PtRealizeWidget( mWidget );
00197                             PtSetResource( gMenuRegion, Pt_ARG_REGION_INFRONT, PtWidgetRid( mWidget ), 0 );
00198                             if ( mParent )
00199                                    ((nsWindow*)mParent)->mLastMenu = mWidget;
00200                             }
00201 
00202                      PtRealizeWidget( gMenuRegion );
00203                      }
00204        }
00205        else {
00206     NS_IF_RELEASE(gRollupListener);
00207     gRollupListener = nsnull;
00208     NS_IF_RELEASE(gRollupWidget);
00209               gRollupWidget = nsnull;
00210 
00211               if( mWindowType == eWindowType_popup && ( PtWidgetFlags( gMenuRegion ) & Pt_REALIZED ) )
00212                      PtUnrealizeWidget( gMenuRegion );
00213        }
00214   
00215   return NS_OK;
00216 }
00217 
00218 NS_METHOD nsWindow::PreCreateWidget( nsWidgetInitData *aInitData ) {
00219   if (nsnull != aInitData) {
00220     SetWindowType( aInitData->mWindowType );
00221     SetBorderStyle( aInitData->mBorderStyle );
00222     return NS_OK;
00223        }
00224   return NS_ERROR_FAILURE;
00225        }
00226 
00227 
00228 //-------------------------------------------------------------------------
00229 //
00230 // Create the native widget
00231 //
00232 //-------------------------------------------------------------------------
00233 NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) {
00234   PtArg_t   arg[25];
00235   int       arg_count = 0;
00236   PhPoint_t pos;
00237   PhDim_t   dim;
00238   unsigned  long render_flags;
00239   nsresult  result = NS_ERROR_FAILURE;
00240 
00241   pos.x = mBounds.x;
00242   pos.y = mBounds.y;
00243   dim.w = mBounds.width;
00244   dim.h = mBounds.height;
00245 
00246   switch( mWindowType )
00247   {
00248   case eWindowType_popup :
00249     mIsToplevel = PR_TRUE;
00250     break;
00251   case eWindowType_toplevel :
00252   case eWindowType_invisible :
00253     mIsToplevel = PR_TRUE;
00254     break;
00255   case eWindowType_dialog :
00256     mIsToplevel = PR_TRUE;
00257     break;
00258   case eWindowType_child :
00259     mIsToplevel = PR_FALSE;
00260     break;
00261   }
00262        
00263   if ( mWindowType == eWindowType_child )
00264   {
00265        arg_count = 0;
00266     PtSetArg( &arg[arg_count++], Pt_ARG_POS, &pos, 0 );
00267     PtSetArg( &arg[arg_count++], Pt_ARG_DIM, &dim, 0 );
00268     PtSetArg( &arg[arg_count++], Pt_ARG_RESIZE_FLAGS, 0, Pt_RESIZE_XY_BITS );
00269     PtSetArg( &arg[arg_count++], Pt_ARG_FLAGS, 0 , Pt_HIGHLIGHTED|Pt_GETS_FOCUS );
00270     PtSetArg( &arg[arg_count++], Pt_ARG_BORDER_WIDTH, 0, 0 );
00271     PtSetArg( &arg[arg_count++], Pt_ARG_FILL_COLOR, Pg_RED, 0 );
00272     PtSetArg( &arg[arg_count++], RDC_DRAW_FUNC, RawDrawFunc, 0 );
00273     mWidget = PtCreateWidget( PtRawDrawContainer, parentWidget, arg_count, arg );
00274   }
00275   else
00276   {
00277     // No border or decorations is the default
00278     render_flags = 0; // Ph_WM_RENDER_RESIZE;
00279 
00280     if( mWindowType != eWindowType_popup ) {
00281 
00282       #define PH_BORDER_STYLE_ALL  \
00283         Ph_WM_RENDER_TITLE | \
00284         Ph_WM_RENDER_CLOSE | \
00285         Ph_WM_RENDER_BORDER | \
00286         Ph_WM_RENDER_RESIZE | \
00287         Ph_WM_RENDER_MAX | \
00288         Ph_WM_RENDER_MIN | \
00289         Ph_WM_RENDER_MENU
00290 
00291 
00292       if( mBorderStyle & eBorderStyle_all )      render_flags |= PH_BORDER_STYLE_ALL;
00293       else
00294       {
00295         if( mBorderStyle & eBorderStyle_border )        render_flags |= Ph_WM_RENDER_BORDER;
00296         if( mBorderStyle & eBorderStyle_title )                render_flags |= ( Ph_WM_RENDER_TITLE | Ph_WM_RENDER_BORDER );
00297         if( mBorderStyle & eBorderStyle_close )                render_flags |= Ph_WM_RENDER_CLOSE;
00298         if( mBorderStyle & eBorderStyle_menu )                 render_flags |= Ph_WM_RENDER_MENU;
00299         if( mBorderStyle & eBorderStyle_resizeh )              render_flags |= Ph_WM_RENDER_RESIZE;
00300         if( mBorderStyle & eBorderStyle_minimize )             render_flags |= Ph_WM_RENDER_MIN;
00301         if( mBorderStyle & eBorderStyle_maximize )             render_flags |= Ph_WM_RENDER_MAX;
00302       }
00303     }
00304        arg_count = 0;
00305     if (mWindowType == eWindowType_dialog)
00306     {
00307        // center on parent
00308        if (parentWidget)
00309        {
00310               PtCalcAbsPosition(parentWidget, NULL, &dim, &pos);
00311               PtSetArg( &arg[arg_count++], Pt_ARG_POS, &pos, 0 );
00312        }
00313        }
00314     else if ((mWindowType == eWindowType_toplevel) && parentWidget)
00315     {
00316                      QueryVisible( );
00317       pos.x += gConsoleRect.ul.x;
00318       pos.y += gConsoleRect.ul.y;
00319        PtSetArg( &arg[arg_count++], Pt_ARG_POS, &pos, 0 );
00320     }
00321 
00322     PtSetArg( &arg[arg_count++], Pt_ARG_DIM, &dim, 0 );
00323     PtSetArg( &arg[arg_count++], Pt_ARG_RESIZE_FLAGS, 0, Pt_RESIZE_XY_BITS );
00324 
00325     /* Create Pop-up Menus as a PtRegion */
00326 
00327     if (!parentWidget)
00328       PtSetParentWidget( nsnull );
00329               
00330     if( mWindowType == eWindowType_popup ) {
00331 
00332                      /* the gMenuRegion is used to capture events outside of the application's canvas when menus are displayed */
00333                      if( !gMenuRegion ) {
00334                             PtArg_t args[10];
00335                             PtSetParentWidget( NULL );
00336                             PtSetArg( &args[0], Pt_ARG_REGION_PARENT, 0, 0 );
00337                      PtSetArg( &args[1], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0);
00338                             PhArea_t area = { { 0, 0 }, { SHRT_MAX, SHRT_MAX } };
00339                             PtSetArg( &args[2], Pt_ARG_AREA, &area, 0 );
00340                             PtSetArg( &args[3], Pt_ARG_REGION_SENSE, Ph_EV_BUT_PRESS, Ph_EV_BUT_PRESS );
00341                             PtSetArg( &args[4], Pt_ARG_REGION_FLAGS, Ph_FORCE_BOUNDARY, Ph_FORCE_BOUNDARY );
00342                             PtSetArg( &args[5], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_POINTER, 0 );
00343                             gMenuRegion = PtCreateWidget( PtRegion, NULL, 6, args );
00344                             PtAddEventHandler( gMenuRegion, Ph_EV_BUT_PRESS, MenuRegionCallback, this );
00345                             }
00346 
00347               int    fields = Ph_REGION_PARENT|Ph_REGION_HANDLE| Ph_REGION_FLAGS|Ph_REGION_ORIGIN|Ph_REGION_EV_SENSE|Ph_REGION_EV_OPAQUE|Ph_REGION_RECT;
00348               int sense =  Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_BUT_REPEAT;
00349                      PtCallback_t cb_destroyed = { MenuRegionDestroyed, NULL };
00350 
00351       PtSetArg( &arg[arg_count++], Pt_ARG_REGION_FIELDS,   fields, fields );
00352       PtSetArg( &arg[arg_count++], Pt_ARG_REGION_PARENT,   Ph_ROOT_RID, 0 );
00353       PtSetArg( &arg[arg_count++], Pt_ARG_REGION_SENSE,    sense | Ph_EV_DRAG|Ph_EV_EXPOSE, sense | Ph_EV_DRAG|Ph_EV_EXPOSE);
00354       PtSetArg( &arg[arg_count++], Pt_ARG_REGION_OPAQUE,   sense | Ph_EV_DRAG|Ph_EV_EXPOSE|Ph_EV_DRAW|Ph_EV_BLIT, sense |Ph_EV_DRAG|Ph_EV_EXPOSE|Ph_EV_DRAW|Ph_EV_BLIT);
00355       PtSetArg( &arg[arg_count++], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, Pt_GETS_FOCUS | Pt_DELAY_REALIZE);
00356                      PtSetArg( &arg[arg_count++], Pt_CB_DESTROYED, &cb_destroyed, 0 );
00357       mWidget = PtCreateWidget( PtRegion, parentWidget, arg_count, arg);
00358 
00359        // Must also create the client-area widget
00360       arg_count = 0;
00361       PtSetArg( &arg[arg_count++], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_ALL, ~0 );
00362       PtSetArg( &arg[arg_count++], Pt_ARG_BORDER_WIDTH, 0 , 0 );
00363       PtSetArg( &arg[arg_count++], Pt_ARG_MARGIN_WIDTH, 0 , 0 );
00364       PhRect_t anch_offset = {{0, 0},{0, 0}};
00365       PtSetArg( &arg[arg_count++], Pt_ARG_ANCHOR_OFFSETS, &anch_offset, 0 );
00366 
00367       PtSetArg( &arg[arg_count++], RDC_DRAW_FUNC, RawDrawFunc, 0 );
00368       PtSetArg( &arg[arg_count++], Pt_ARG_FLAGS, 0, (Pt_HIGHLIGHTED | Pt_GETS_FOCUS));
00369       mClientWidget = PtCreateWidget( PtRawDrawContainer, mWidget, arg_count, arg );
00370      }
00371        else {
00372               /* Dialog and TopLevel Windows */
00373               PtSetArg( &arg[arg_count++], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, Pt_DELAY_REALIZE);
00374               PtSetArg( &arg[arg_count++], Pt_ARG_WINDOW_RENDER_FLAGS, render_flags, -1 );
00375               PtSetArg( &arg[arg_count++], Pt_ARG_WINDOW_MANAGED_FLAGS, 0, Ph_WM_CLOSE );
00376               PtSetArg( &arg[arg_count++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Ph_WM_CLOSE|Ph_WM_CONSWITCH|Ph_WM_FOCUS, ~0 );
00377               PtSetArg( &arg[arg_count++], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0 );
00378 
00379               PtRawCallback_t cb_raw = { Ph_EV_INFO, EvInfo, NULL };
00380               PtCallback_t cb_resize = { ResizeHandler, NULL };
00381               PtCallback_t cb_window = { WindowWMHandler, this };
00382 
00383               PtSetArg( &arg[arg_count++], Pt_CB_RESIZE, &cb_resize, NULL );
00384               PtSetArg( &arg[arg_count++], Pt_CB_RAW, &cb_raw, NULL );
00385               PtSetArg( &arg[arg_count++], Pt_CB_WINDOW, &cb_window, 0 );
00386               mWidget = PtCreateWidget( PtWindow, parentWidget, arg_count, arg );
00387               }
00388   }
00389 
00390   if( mWidget ) {
00391          SetInstance( mWidget, this );
00392          if( mClientWidget ) SetInstance( mClientWidget, this );
00393          if( mWindowType == eWindowType_child ) {
00394        PtAddCallback(mWidget, Pt_CB_RESIZE, ResizeHandler, nsnull ); 
00395        PtAddEventHandler( mWidget,
00396          Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON |
00397          Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE |Ph_EV_BOUNDARY|Ph_EV_DRAG
00398          , RawEventHandler, this );
00399        
00400               PtArg_t arg;
00401               PtRawCallback_t callback;
00402               
00403                             callback.event_mask = ( Ph_EV_KEY ) ;
00404                             callback.event_f = RawEventHandler;
00405                             callback.data = this;
00406                             PtSetArg( &arg, Pt_CB_FILTER, &callback, 0 );
00407                             PtSetResources( mWidget, 1, &arg );
00408               }
00409     else if( mWindowType == eWindowType_popup ) {
00410               PtAddEventHandler( mClientWidget,
00411                             Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON | 
00412                      Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE |Ph_EV_BOUNDARY,
00413                        RawEventHandler, this );
00414 
00415               PtAddEventHandler( mWidget, Ph_EV_DRAG, RawEventHandler, this );
00416 
00417               PtArg_t arg;
00418               PtRawCallback_t callback;
00419               
00420                                    callback.event_mask = ( Ph_EV_KEY ) ;
00421                                    callback.event_f = RawEventHandler;
00422                                    callback.data = this;
00423                                    PtSetArg( &arg, Pt_CB_FILTER, &callback, 0 );
00424                                    PtSetResources( mClientWidget, 1, &arg );
00425                      
00426                 PtAddCallback(mClientWidget, Pt_CB_RESIZE, ResizeHandler, nsnull ); 
00427                                    }
00428     else if( !parentWidget ) {
00429        if( mClientWidget ) PtAddCallback(mClientWidget, Pt_CB_RESIZE, ResizeHandler, nsnull );
00430        }
00431 
00432     // call the event callback to notify about creation
00433     DispatchStandardEvent( NS_CREATE );
00434 
00435     result = NS_OK;
00436        }
00437 
00438   /* force SetCursor to actually set the cursor, even though our internal state indicates that we already
00439      have the standard cursor */
00440   mCursor = eCursor_wait;
00441   SetCursor( mCursor );
00442 
00443   return result;
00444        }
00445 
00446 
00447 //-------------------------------------------------------------------------
00448 //
00449 // Return some native data according to aDataType
00450 //
00451 //-------------------------------------------------------------------------
00452 void *nsWindow::GetNativeData(PRUint32 aDataType)
00453 {
00454   switch(aDataType)
00455   {
00456   case NS_NATIVE_WINDOW:
00457     if( !mWidget )   return (void *)mWidget;
00458 
00459   case NS_NATIVE_WIDGET:
00460               if (mClientWidget)   return (void *) mClientWidget;
00461               else   return (void *) mWidget;
00462   }
00463               
00464   return nsWidget::GetNativeData(aDataType);
00465 }
00466 
00467 //-------------------------------------------------------------------------
00468 //
00469 // Scroll the bits of a window
00470 //
00471 //-------------------------------------------------------------------------
00472 NS_METHOD nsWindow::Scroll( PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect ) {
00473        PtWidget_t  *widget = (PtWidget_t *)GetNativeData(NS_NATIVE_WIDGET);
00474 
00475        /* If aDx and aDy are 0 then skip it or if widget == null */
00476        if( ( !aDx && !aDy ) || (!widget )) return NS_OK;
00477 
00478        PtStartFlux( widget );
00479 
00480        PtWidget_t *w;
00481        for( w=PtWidgetChildFront( widget ); w; w=PtWidgetBrotherBehind( w )) {
00482               PtArg_t arg;
00483               PhPoint_t  p;
00484               p.x = w->area.pos.x + aDx;
00485               p.y = w->area.pos.y + aDy;
00486 
00487               PtSetArg( &arg, Pt_ARG_POS, &p, 0 );
00488               PtSetResources( w, 1, &arg ) ;
00489 
00490               nsWindow *pWin = (nsWindow *) GetInstance(w);
00491               if (pWin) {
00492                      pWin->mBounds.x += aDx;
00493                      pWin->mBounds.y += aDy;
00494                      }
00495               }
00496 
00497        PtEndFlux( widget);
00498 
00499        PhRect_t source = {{widget->area.pos.x, widget->area.pos.y},{widget->area.pos.x+ widget->area.size.w-1, widget->area.pos.y + widget->area.size.h-1}};
00500        PhPoint_t point = { aDx, aDy };
00501 
00502        if( !widget->damage_list ) {
00503               static int count;
00504               PtBlit( widget, &source, &point );
00505        } else {
00506               /* first noticed as a scrolling problem in netscape email */
00507               /* the scrolling should be clipped out by the rectangles given by Invalidate(). These are accumulated in widget->damage_list */
00508               PhTile_t original = { source, NULL }, *clip;
00509 
00510               clip = PhGetTile();
00511               clip->rect = source;
00512               clip->next = NULL;
00513               clip = PhClipTilings( clip, widget->damage_list, NULL );
00514 
00515               if( clip ) {
00516                      PtClippedBlit( widget, &original, &point, clip );
00517                      PhFreeTiles( clip );
00518                      }
00519               }
00520   
00521        return NS_OK;
00522        }
00523 
00524 NS_METHOD nsWindow::ScrollWidgets( PRInt32 aDx, PRInt32 aDy ) {
00525        PtWidget_t  *widget = (PtWidget_t *)GetNativeData(NS_NATIVE_WIDGET);
00526 
00527        if( ( !aDx && !aDy ) || (!widget )) return NS_OK;
00528 
00529        PtStartFlux( widget );
00530 
00531        PtWidget_t *w;
00532        for( w=PtWidgetChildFront( widget ); w; w=PtWidgetBrotherBehind( w )) {
00533               PtArg_t arg;
00534               PhPoint_t  p;
00535               p.x = w->area.pos.x + aDx;
00536               p.y = w->area.pos.y + aDy;
00537               PtSetArg( &arg, Pt_ARG_POS, &p, 0 );
00538               PtSetResources( w, 1, &arg ) ;
00539 
00540               nsWindow *pWin = (nsWindow *) GetInstance(w);
00541               if (pWin) {
00542                      pWin->mBounds.x += aDx;
00543                      pWin->mBounds.y += aDy;
00544                      }
00545               }
00546 
00547        PtEndFlux( widget);
00548        return NS_OK;    
00549        }
00550 
00551 NS_METHOD nsWindow::SetTitle( const nsAString& aTitle ) {
00552   if( mWidget ) {
00553        char * title = ToNewUTF8String(aTitle);
00554     PtSetResource( mWidget, Pt_ARG_WINDOW_TITLE, title, 0 );
00555        if (title) nsCRT::free(title);
00556               }
00557   return NS_OK;
00558 }
00559 
00560 
00561 NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
00562 {
00563        PRBool nNeedToShow = PR_FALSE;
00564        
00565        if (mWidget) {
00566               PtWidget_t *parent;
00567               int n = 1;
00568               for (parent = mWidget; parent && n <= 3; parent = parent->parent, n++) {
00569                      char *description = parent->class_rec->description;
00570 
00571                      if (description && strcmp(description, "PtMozilla") == 0) {
00572                             //
00573                             // For embedding, make sure the browser does not try to 
00574                             // resize itself bigger than the PtMozilla widget or else our
00575                             // scroll bars will be clipped. We don't go more than 3 levels
00576                             // deep or else we get into iframes, which we don't want to 
00577                             // cut off.
00578                             //
00579                             if (aWidth > parent->area.size.w)
00580                                    aWidth = parent->area.size.w;
00581                             if (aHeight > parent->area.size.h)
00582                                    aHeight = parent->area.size.h;
00583                             break; //for
00584                             }
00585                      }
00586               }
00587 
00588        if( aWidth == mBounds.width && aHeight == mBounds.height ) return NS_OK;
00589        
00590        mBounds.width  = aWidth;
00591        mBounds.height = aHeight;
00592        
00593        // code to keep the window from showing before it has been moved or resized
00594        // if we are resized to 1x1 or less, we will hide the window.  Show(TRUE) will be ignored until a larger resize has happened
00595        if( aWidth <= 1 || aHeight <= 1 ) {
00596               aWidth = aHeight = 1;
00597               mIsTooSmall = PR_TRUE;
00598               }
00599        else {
00600               if( mIsTooSmall ) {
00601                      // if we are not shown, we don't want to force a show here, so check and see if Show(TRUE) has been called
00602                      nNeedToShow = mShown;
00603                      mIsTooSmall = PR_FALSE;
00604                      }
00605               }
00606        
00607        PhDim_t  dim = { aWidth, aHeight };
00608        
00609        if( mWidget ) {
00610               // center the dialog
00611               if( mWindowType == eWindowType_dialog ) {
00612                      PhPoint_t p;
00613                      QueryVisible( );
00614                      PtCalcAbsPosition( NULL, NULL, &dim, &p );
00615                      p.x -= gConsoleRect.ul.x;
00616                      p.y -= gConsoleRect.ul.y;
00617                      Move(p.x, p.y); // the move should be in coordinates assuming the console is 0, 0
00618                      }
00619               if( aRepaint == PR_FALSE )  PtStartFlux(mWidget);
00620               PtSetResource( mWidget, Pt_ARG_DIM, &dim, 0 );
00621               if( aRepaint == PR_FALSE ) PtEndFlux(mWidget);
00622 
00623               /* ATENTIE Remove when wojtek fixes PR:22930 in the photon library */
00624               if( PtWidgetClass( mWidget ) == PtRegion ) PtSetResource( mWidget, Pt_ARG_REGION_OPAQUE, 0, Ph_EV_KEY );
00625               }
00626 
00627        if( mIsToplevel || mListenForResizes ) {
00628               nsSizeEvent sevent(PR_TRUE, 0, nsnull);
00629               sevent.message = NS_SIZE;
00630               sevent.widget = this;
00631               
00632               sevent.windowSize = new nsRect (0, 0, aWidth, aHeight);        
00633               
00634               sevent.point.x = 0;
00635               sevent.point.y = 0;
00636               sevent.mWinWidth = aWidth;
00637               sevent.mWinHeight = aHeight;
00638               // XXX fix this
00639               sevent.time = 0;
00640               AddRef();
00641               DispatchWindowEvent(&sevent);
00642               Release();
00643               delete sevent.windowSize;
00644               }
00645        if( nNeedToShow ) Show(PR_TRUE);
00646        return NS_OK;
00647 }
00648 
00649 int nsWindow::WindowWMHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) 
00650 {
00651        PhWindowEvent_t *we = (PhWindowEvent_t *) cbinfo->cbdata;
00652        switch( we->event_f ) {
00653               case Ph_WM_CLOSE:
00654                 {
00655                             nsWindow * win = (nsWindow*) data;
00656                        NS_ADDREF(win);
00657                        
00658                        // dispatch an "onclose" event. to delete immediately, call win->Destroy()
00659                        nsGUIEvent event(PR_TRUE, 0, nsnull);
00660                        nsEventStatus status;
00661                        
00662                        event.message = NS_XUL_CLOSE;
00663                        event.widget  = win;
00664                        
00665                        event.time = 0;
00666                        event.point.x = 0;
00667                        event.point.y = 0;
00668                        
00669                        win->DispatchEvent(&event, status);
00670                        
00671                        NS_RELEASE(win);
00672                 }
00673               break;
00674 
00675               case Ph_WM_CONSWITCH:
00676                      gConsoleRectValid = PR_FALSE; /* force a call tp PhWindowQueryVisible() next time, since we might have moved this window into a different console */
00677       /* rollup the menus */
00678       if( gRollupWidget && gRollupListener ) gRollupListener->Rollup();
00679                      break;
00680 
00681               case Ph_WM_FOCUS:
00682                      if( we->event_state == Ph_WM_EVSTATE_FOCUSLOST ) {
00683        /* rollup the menus */
00684        if( gRollupWidget && gRollupListener ) gRollupListener->Rollup();
00685 
00686                             if( sFocusWidget ) sFocusWidget->DispatchStandardEvent(NS_DEACTIVATE);
00687                             }
00688                      break;
00689        }
00690        
00691        return Pt_CONTINUE;
00692 }
00693 
00694 void nsWindow::RawDrawFunc( PtWidget_t * pWidget, PhTile_t * damage )
00695 {
00696   nsWindow  * pWin = (nsWindow*) GetInstance( pWidget );
00697   nsresult    result;
00698   PhTile_t  * dmg = NULL;
00699   nsPaintEvent pev(PR_TRUE, 0, nsnull);
00700   PhRect_t   extent;
00701 
00702   if( !pWin || !pWin->mContext ) return;
00703 
00704        if ( pWin->mEventCallback ) {
00705               PhPoint_t  offset;
00706               nsRect     nsDmg;
00707 
00708               // Ok...  The damage rect is in window coordinates and is not neccessarily clipped to
00709               // the widgets canvas. Mozilla wants the paint coords relative to the parent widget, not the window.
00710               PtWidgetExtent(pWidget, &extent);
00711               PtWidgetOffset(pWidget, &offset);
00712               /* Build a List of Tiles that might be in front of me.... */
00713               PhTile_t *new_damage, *clip_tiles, *intersect;
00714               /* Intersect the Damage tile list w/ the clipped out list and see whats left! */
00715 #if 0
00716               int count = 0;
00717               for (new_damage = damage->next; new_damage; new_damage = new_damage->next)
00718                      count++;
00719               printf("*** nsWindow::RawDrawFunc got %d damage tiles\n", count);
00720 #endif
00721               new_damage = PhCopyTiles(damage->next);
00722               PhDeTranslateTiles(new_damage, &offset);
00723               clip_tiles = GetWindowClipping( pWidget );
00724               if (clip_tiles) {
00725                      new_damage = PhClipTilings( new_damage, clip_tiles, NULL);
00726                      PhFreeTiles(clip_tiles);
00727               }
00728               clip_tiles = PhRectsToTiles(&extent, 1);
00729               intersect = PhIntersectTilings( new_damage, clip_tiles, NULL);
00730               if ( intersect == NULL ) return;
00731               PhDeTranslateTiles(intersect, &extent.ul);
00732               PhFreeTiles(clip_tiles);
00733               PhFreeTiles(new_damage);
00734               new_damage = intersect;
00735               
00736               pWin->InitEvent(pev, NS_PAINT);
00737               pev.region = nsnull;
00738               pev.renderingContext = nsnull;
00739               pev.renderingContext = pWin->GetRenderingContext();
00740               for( dmg = new_damage; dmg; dmg = dmg->next ) {
00741                      nsDmg.x = dmg->rect.ul.x;
00742                      nsDmg.y = dmg->rect.ul.y;
00743                      nsDmg.width = dmg->rect.lr.x - dmg->rect.ul.x + 1;
00744                      nsDmg.height = dmg->rect.lr.y - dmg->rect.ul.y + 1;
00745 
00746                      if( (nsDmg.width <= 0 ) || (nsDmg.height <= 0 ) ) /* Move to the next Damage Tile */
00747                             continue;
00748 
00749                      /* Re-Setup Paint Event */
00750                      pWin->InitEvent(pev, NS_PAINT);
00751                      pev.point.x = nsDmg.x;
00752                      pev.point.y = nsDmg.y;
00753                      pev.rect = &nsDmg;
00754                      pev.region = nsnull;
00755 
00756                      if( pev.renderingContext ) {
00757                             nsIRegion *ClipRegion = pWin->GetRegion( );
00758                             ClipRegion->SetTo( nsDmg.x, nsDmg.y, nsDmg.width, nsDmg.height );
00759                             pev.renderingContext->SetClipRegion( NS_STATIC_CAST(const nsIRegion &, *(ClipRegion)), nsClipCombine_kReplace );
00760 
00761                             NS_RELEASE( ClipRegion );
00762                             
00763                             /* You can turn off most drawing if you take this out */
00764                             result = pWin->DispatchWindowEvent(&pev);
00765                      }
00766               }
00767               NS_RELEASE(pev.renderingContext);
00768               PhFreeTiles( new_damage );
00769        }
00770 }
00771 
00772 static PhTile_t *GetWindowClipping( PtWidget_t *aWidget ) {
00773        PtWidget_t *w;
00774        PhTile_t *clip_tiles = NULL, *last = NULL;
00775        PhRect_t w_extent;
00776 
00777        PtWidgetExtent( aWidget, &w_extent);
00778        
00779        for( w = PtWidgetChildFront( aWidget ); w; w=PtWidgetBrotherBehind( w ) ) {
00780               long flags = PtWidgetFlags( w );
00781               if( (flags & Pt_REALIZED) && (flags & Pt_OPAQUE) && !PtIsDisjoint(w) ) {
00782                      PhTile_t *tile = PhGetTile( );
00783                      if( !tile ) return NULL;
00784 
00785                      tile->rect.ul.x = w->area.pos.x + w_extent.ul.x;
00786                      tile->rect.ul.y = w->area.pos.y + w_extent.ul.y;
00787                      tile->rect.lr.x = tile->rect.ul.x + w->area.size.w - 1;
00788                      tile->rect.lr.y = tile->rect.ul.y + w->area.size.h - 1;
00789 
00790                      tile->next = NULL;
00791                      if( !clip_tiles ) clip_tiles = tile;
00792                      if( last ) last->next = tile;
00793                      last = tile;
00794                      }
00795               }
00796        return clip_tiles;
00797        }
00798 
00799 int nsWindow::ResizeHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo )
00800 {
00801   nsWindow *someWindow = (nsWindow *) GetInstance(widget);
00802   if( someWindow ) {
00803        PtContainerCallback_t *cb = (PtContainerCallback_t *) cbinfo->cbdata;
00804        PhRect_t *extents = &cb->new_size;
00805        nsRect rect;
00806               rect.x = extents->ul.x;
00807     rect.y = extents->ul.y;
00808     rect.width = extents->lr.x - rect.x + 1;
00809     rect.height = extents->lr.y - rect.y + 1;
00810 
00811     if( someWindow->mBounds.width == rect.width && someWindow->mBounds.height == rect.height )
00812                 return Pt_CONTINUE;
00813 
00814     someWindow->mBounds.width  = rect.width;
00815     someWindow->mBounds.height = rect.height;
00816 
00817     /* This enables the resize holdoff */
00818     if( PtWidgetIsRealized( widget ) ) someWindow->OnResize( rect );
00819        }
00820        return Pt_CONTINUE;
00821 }
00822 
00823 
00824 static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
00825 
00826 /* catch an Ph_EV_INFO event when the graphics mode has changed */
00827 int nsWindow::EvInfo( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) {
00828 
00829        if( cbinfo->event && cbinfo->event->type == Ph_EV_INFO && cbinfo->event->subtype == Ph_OFFSCREEN_INVALID ) {
00830               nsresult rv;
00831               
00832               nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
00833               if (NS_SUCCEEDED(rv)) {
00834                       PRBool displayInternalChange = PR_FALSE;
00835                       pPrefs->GetBoolPref("browser.display.internaluse.graphics_changed", &displayInternalChange);
00836                       pPrefs->SetBoolPref("browser.display.internaluse.graphics_changed", !displayInternalChange);
00837                }
00838               nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID));
00839               NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE);
00840 
00841               nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
00842               NS_ENSURE_SUCCESS(windowMediator->GetXULWindowEnumerator(nsnull, getter_AddRefs(windowEnumerator)), NS_ERROR_FAILURE);
00843 
00844               PRBool more;
00845               windowEnumerator->HasMoreElements(&more);
00846               while(more) {
00847                      nsCOMPtr<nsISupports> nextWindow = nsnull;
00848                      windowEnumerator->GetNext(getter_AddRefs(nextWindow));
00849                      nsCOMPtr<nsIXULWindow> xulWindow(do_QueryInterface(nextWindow));
00850                      NS_ENSURE_TRUE(xulWindow, NS_ERROR_FAILURE);
00851        
00852                      nsCOMPtr<nsIDocShell> docShell;
00853                      xulWindow->GetDocShell(getter_AddRefs(docShell));
00854 
00855                      nsCOMPtr<nsIPresShell> presShell;
00856                      docShell->GetPresShell( getter_AddRefs(presShell) );
00857 
00858                      nsIViewManager* viewManager = presShell->GetViewManager();
00859                      NS_ENSURE_TRUE(viewManager, NS_ERROR_FAILURE);
00860 
00861                      windowEnumerator->HasMoreElements(&more);
00862                      }
00863 
00864               PtDamageWidget( widget );
00865               }
00866        return Pt_CONTINUE;
00867        }
00868 
00869 //-------------------------------------------------------------------------
00870 //
00871 // Move this component
00872 //
00873 //-------------------------------------------------------------------------
00874 NS_METHOD nsWindow::Move( PRInt32 aX, PRInt32 aY ) {
00875 
00876        if( mWindowType != eWindowType_popup && (mBounds.x == aX) && (mBounds.y == aY) )
00877               return NS_OK;
00878 
00879        mBounds.x = aX;
00880        mBounds.y = aY;
00881 
00882        switch( mWindowType ) {
00883               case eWindowType_popup:
00884                      {
00885                      //
00886                      // Previously we looped through the disjoint parents to add up
00887                      // all the offsets, but now the menu offset gets passed in,
00888                      // so we just need to account for the worldview window.
00889                      //
00890                      QueryVisible( );
00891                      aX += gConsoleRect.ul.x;
00892                      aY += gConsoleRect.ul.y;
00893                      }
00894                      break;
00895 
00896               case eWindowType_dialog:
00897               case eWindowType_toplevel:
00898                      /* Offset to the current virtual console */
00899                      QueryVisible( );
00900                      aX += gConsoleRect.ul.x;
00901                      aY += gConsoleRect.ul.y;
00902                      break;
00903               }
00904 
00905   if( mWidget ) {
00906     if(( mWidget->area.pos.x != aX ) || ( mWidget->area.pos.y != aY )) {
00907       PhPoint_t pos = { aX, aY };
00908       PtSetResource( mWidget, Pt_ARG_POS, &pos, 0 );
00909 
00910                      /* ATENTIE Remove when wojtek fixes PR:22930 in the photon library */
00911                      if( PtWidgetClass( mWidget ) == PtRegion ) PtSetResource( mWidget, Pt_ARG_REGION_OPAQUE, 0, Ph_EV_KEY );
00912        }
00913        }
00914 
00915        return NS_OK;
00916        }
00917 
00918 int nsWindow::MenuRegionCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) {
00919        if( gRollupWidget && gRollupListener ) {
00920               /* rollup the menu */
00921               gRollupListener->Rollup();
00922               }
00923        return Pt_CONTINUE;
00924        }
00925 
00926 NS_IMETHODIMP nsWindow::SetModal( PRBool aModal ) {
00927   nsresult res = NS_ERROR_FAILURE;
00928  
00929   if (!mWidget)
00930        return NS_ERROR_FAILURE;
00931 
00932   PtWidget_t *toplevel = PtFindDisjoint(mWidget);
00933   if( !toplevel ) return NS_ERROR_FAILURE;
00934 
00935   if( aModal ) {
00936          PtModalStart();
00937          res = NS_OK;
00938        }
00939   else {
00940               PtModalEnd();
00941     res = NS_OK;
00942        }
00943 
00944   return res;
00945        }
00946 
00947 
00948 inline nsIRegion *nsWindow::GetRegion()
00949 {
00950   nsIRegion *region = NULL;
00951   nsresult res;
00952 
00953   static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
00954 
00955   res = CallCreateInstance( kRegionCID, &region );
00956   if (NS_SUCCEEDED(res)) region->Init();
00957 
00958   NS_ASSERTION(NULL != region, "Null region context");
00959   
00960   return region;  
00961 }
00962 
00963 /*
00964        widget is a PtRegion representing the native widget for a menu - reset the mParent->mLastMenu
00965        since it points to an widget being destroyed
00966 */
00967 int nsWindow::MenuRegionDestroyed( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo )
00968 {
00969        nsWindow *pWin = (nsWindow *) GetInstance( widget );
00970        if( pWin ) {
00971               nsWindow *parent = ( nsWindow * ) pWin->mParent;
00972               if( parent && parent->mLastMenu == widget )
00973                      parent->mLastMenu = nsnull;
00974               }
00975        return Pt_CONTINUE;
00976 }
00977 
00978 NS_IMETHODIMP nsWindow::SetFocus(PRBool aRaise)
00979 {
00980        sFocusWidget = this;
00981 
00982        if( PtIsFocused( mWidget ) == 2 ) return NS_OK;
00983 
00984        if( mWidget ) {
00985 #if 0
00986               PtWidget_t *disjoint;
00987               disjoint = PtFindDisjoint( mWidget );
00988               if( PtWidgetIsClass( disjoint, PtWindow ) ) {
00989                      printf("    disjoint is a PtWindow\n");
00990                      if( !( PtWindowGetState( disjoint ) & Ph_WM_STATE_ISFOCUS ) ) {
00991                             printf("    disjoint is not in focus, bringing it to front\n");
00992                             nsWindow *pWin = (nsWindow *) GetInstance( disjoint );
00993                             //
00994                             // The following line was causing TestPhEmbed (and therefore
00995                             // kwww) to crash. Mozserver was unaffected because the disjoint
00996                             // widget is a PtServer. So it seems like we don't need to bring
00997                             // the disjoint widget to front anyways. Standalone Firefox
00998                             // does have a disjoint widget that is a PtWindow, but we never
00999                             // seem to get in here because it's always in focus for some
01000                             // reason. So I am commenting out this whole section of 
01001                             // seemingly unnecessary code. This following call is through
01002                             // an overloaded "->" operator through a templated class.
01003                             //
01004                             pWin->GetAttention( -1 );
01005                             }
01006                      }
01007               printf("    Giving container focus\n");
01008 #endif
01009               PtContainerGiveFocus( mWidget, NULL );
01010               }
01011        return NS_OK;
01012 }
01013 
01014 NS_IMETHODIMP nsWindow::MakeFullScreen(PRBool aFullScreen)
01015 {
01016        /* we can use static data here because there can be only one full-screen window at a time */
01017        static unsigned short old_render_flags;
01018        static PhPoint_t old_pos;
01019 
01020        PtArg_t args[3];
01021 
01022        if( aFullScreen ) {
01023               unsigned short p, *pflags;
01024               PhArea_t area;
01025 
01026               PtSetArg( &args[0], Pt_ARG_WINDOW_RENDER_FLAGS, &pflags, 0 );
01027               PtGetResources( mWidget, 1, args );
01028               p = old_render_flags = *pflags; // save the render flags
01029               p &= ~(Ph_WM_RENDER_TITLE|Ph_WM_RENDER_BORDER);
01030 
01031               PtWidgetArea( mWidget, &area );
01032               old_pos = area.pos;
01033 
01034               QueryVisible( );
01035               PtSetArg( &args[0], Pt_ARG_POS, &gConsoleRect.ul, 0 );
01036               PtSetArg( &args[1], Pt_ARG_WINDOW_RENDER_FLAGS, p, -1 );
01037               PtSetArg( &args[2], Pt_ARG_WINDOW_STATE, Ph_WM_STATE_ISFRONT, Ph_WM_STATE_ISFRONT );
01038               PtSetResources( mWidget, 3, args );
01039               }
01040        else {
01041               PtSetArg( &args[0], Pt_ARG_POS, &old_pos, 0 );
01042               PtSetArg( &args[1], Pt_ARG_WINDOW_RENDER_FLAGS, old_render_flags, -1 ); /* restore the render flags to the previous value */
01043               PtSetArg( &args[2], Pt_ARG_WINDOW_STATE, Ph_WM_STATE_ISNORMAL, Ph_WM_STATE_ISFRONT|Ph_WM_STATE_ISNORMAL );
01044               PtSetResources( mWidget, 3, args );
01045               }
01046 
01047        return nsBaseWidget::MakeFullScreen( aFullScreen );
01048 }