diff --git a/mozilla/widget/src/photon/Makefile.in b/mozilla/widget/src/photon/Makefile.in index 6fa011404ba..087f529c334 100644 --- a/mozilla/widget/src/photon/Makefile.in +++ b/mozilla/widget/src/photon/Makefile.in @@ -43,6 +43,7 @@ CPPSRCS = \ nsWidgetFactory.cpp \ nsWindow.cpp \ nsBidiKeyboard.cpp \ + nsSound.cpp \ $(NULL) SHARED_LIBRARY_LIBS = $(DIST)/lib/libxpwidgets_s.a diff --git a/mozilla/widget/src/photon/nsAppShell.cpp b/mozilla/widget/src/photon/nsAppShell.cpp index 5041d206aa8..6951f3983a8 100644 --- a/mozilla/widget/src/photon/nsAppShell.cpp +++ b/mozilla/widget/src/photon/nsAppShell.cpp @@ -58,8 +58,7 @@ our_photon_input_add (int fd, PtFdProc_t event_processor_callback, void *data) { - int err = PtAppAddFd(NULL, fd, (Pt_FD_READ | Pt_FD_NOPOLL | Pt_FD_DRAIN ), - event_processor_callback,data); + int err = PtAppAddFdPri( NULL, fd, (Pt_FD_READ | Pt_FD_NOPOLL | Pt_FD_DRAIN ), event_processor_callback, data, getprio( 0 ) + 1 ); if (err != 0) { NS_ASSERTION(0,"nsAppShell::our_photon_input_add Error calling PtAppAddFD\n"); diff --git a/mozilla/widget/src/photon/nsFontRetrieverService.cpp b/mozilla/widget/src/photon/nsFontRetrieverService.cpp index 954f86824ed..131da31eb75 100644 --- a/mozilla/widget/src/photon/nsFontRetrieverService.cpp +++ b/mozilla/widget/src/photon/nsFontRetrieverService.cpp @@ -162,7 +162,7 @@ static FontInfo * GetFontInfo(nsVoidArray * aFontList, char * aName) FontInfo * fontInfo = new FontInfo(); fontInfo->mName = nsString( (const PRUnichar *) aName, strlen(aName)); - printf("nsFontRetrieverService::GetFontInfo Adding [%s]\n", aName);fflush(stdout); + //printf("nsFontRetrieverService::GetFontInfo Adding [%s]\n", aName);fflush(stdout); fontInfo->mIsScalable = PR_FALSE; // X fonts aren't scalable right?? fontInfo->mSizes = nsnull; aFontList->AppendElement(fontInfo); diff --git a/mozilla/widget/src/photon/nsScrollbar.cpp b/mozilla/widget/src/photon/nsScrollbar.cpp index 5e981d836c0..d19f8aa3016 100644 --- a/mozilla/widget/src/photon/nsScrollbar.cpp +++ b/mozilla/widget/src/photon/nsScrollbar.cpp @@ -61,30 +61,35 @@ nsScrollbar::~nsScrollbar () //------------------------------------------------------------------------- NS_METHOD nsScrollbar::CreateNative (PtWidget_t * parentWindow) { - nsresult res = NS_ERROR_FAILURE; - PhPoint_t pos; - PhDim_t dim; - PtArg_t arg[4]; - - pos.x = mBounds.x; - pos.y = mBounds.y; - dim.w = mBounds.width; - dim.h = mBounds.height; - - PtSetArg( &arg[0], Pt_ARG_ORIENTATION, mOrientation, 0 ); - PtSetArg( &arg[1], Pt_ARG_POS, &pos, 0 ); - PtSetArg( &arg[2], Pt_ARG_DIM, &dim, 0 ); - PtSetArg( &arg[3], Pt_ARG_FLAGS, 0, Pt_GETS_FOCUS); - mWidget = PtCreateWidget( PtScrollbar, parentWindow, 4, arg ); - if( mWidget ) { - res = NS_OK; - - /* Add an Activate Callback */ - PtAddCallback(mWidget, Pt_CB_SCROLL_MOVE, handle_scroll_move_event, this); - } - return res; + nsresult res = NS_ERROR_FAILURE; + PhPoint_t pos; + PhDim_t dim; + PtArg_t arg[5]; + + pos.x = mBounds.x; + pos.y = mBounds.y; + dim.w = mBounds.width; + dim.h = mBounds.height; + + PtSetArg( &arg[0], Pt_ARG_ORIENTATION, mOrientation, 0 ); + PtSetArg( &arg[1], Pt_ARG_POS, &pos, 0 ); + PtSetArg( &arg[2], Pt_ARG_DIM, &dim, 0 ); + PtSetArg( &arg[3], Pt_ARG_FLAGS, 0, Pt_GETS_FOCUS); + PtSetArg( &arg[4], Pt_ARG_BASIC_FLAGS, Pt_ALL_INLINES, -1 ); + mWidget = PtCreateWidget( PtScrollbar, parentWindow, 5, arg ); + if( mWidget ) + { + res = NS_OK; + + /* Add an Activate Callback */ + PtAddCallback(mWidget, Pt_CB_SCROLL_MOVE, handle_scroll_move_event, this); + } + + return res; } + + //------------------------------------------------------------------------- // // Define the range settings diff --git a/mozilla/widget/src/photon/nsWidget.cpp b/mozilla/widget/src/photon/nsWidget.cpp index a1f0d3a379e..ab79c3b1d4f 100644 --- a/mozilla/widget/src/photon/nsWidget.cpp +++ b/mozilla/widget/src/photon/nsWidget.cpp @@ -65,8 +65,6 @@ nsIWidget *nsWidget::gRollupWidget = nsnull; /* These are used to keep Popup Menus from drawing twice when they are put away */ /* because of extra EXPOSE events from Photon */ -PhRid_t nsWidget::gLastUnrealizedRegion = -1; -PhRid_t nsWidget::gLastUnrealizedRegionsParent = -1; // // Keep track of the last widget being "dragged" @@ -79,7 +77,7 @@ PRBool nsWidget::mDmgQueueInited = PR_FALSE; nsILookAndFeel *nsWidget::sLookAndFeel = nsnull; PRUint32 nsWidget::sWidgetCount = 0; nsWidget *nsWidget::sFocusWidget = nsnull; -PRBool nsWidget::sWidgetCreating = PR_FALSE; +PRBool nsWidget::sJustGotActivated = PR_FALSE; PRBool nsWidget::sJustGotDeactivated = PR_TRUE; /* Enable this to queue widget damage, this should be ON by default */ @@ -266,66 +264,61 @@ NS_METHOD nsWidget::Show( PRBool bState ) { if( !mWidget ) return NS_OK; // Will be null durring printing -/* Note: Calling PtWidgetIsRealized(mWidget) is not valid because usually -the parent window has not been realized yet when we get into this code. Also -calling PtRealizeWidget() returns an error when the parent has not been -realized. So you must just blindly bash on both the DELAY_REALIZE flags and -the PtRealizeWidget functions */ - PtArg_t arg; if( bState ) { - if (PtWidgetIsRealized(mWidget)) { - mShown = PR_TRUE; - return NS_OK; - } - EnableDamage( mWidget, PR_FALSE ); - PtRealizeWidget(mWidget); - if( mWidget->rid == -1 ) { + if( mWindowType != eWindowType_child ) { + if (PtWidgetIsRealized(mWidget)) { + mShown = PR_TRUE; + return NS_OK; + } + EnableDamage( mWidget, PR_FALSE ); + PtRealizeWidget(mWidget); + + + if( mWidget->rid == -1 ) { + EnableDamage( mWidget, PR_TRUE ); + NS_ASSERTION(0,"nsWidget::Show mWidget's rid == -1\n"); + mShown = PR_FALSE; + return NS_ERROR_FAILURE; + } + PtSetArg(&arg, Pt_ARG_FLAGS, 0, Pt_DELAY_REALIZE); + PtSetResources(mWidget, 1, &arg); EnableDamage( mWidget, PR_TRUE ); - NS_ASSERTION(0,"nsWidget::Show mWidget's rid == -1\n"); - mShown = PR_FALSE; - return NS_ERROR_FAILURE; - } - PtSetArg(&arg, Pt_ARG_FLAGS, 0, Pt_DELAY_REALIZE); - PtSetResources(mWidget, 1, &arg); - EnableDamage( mWidget, PR_TRUE ); - /* Always add it to the Widget Damage Queue when it gets realized */ - PtDamageWidget(mWidget); -#if 0 - QueueWidgetDamage(); -#endif - } + PtDamageWidget(mWidget); + } + else { + EnableDamage( mWidget, PR_FALSE ); + PtWidgetToFront( mWidget ); + if( !mShown || !( mWidget->flags & Pt_REALIZED ) ) PtRealizeWidget( mWidget ); + EnableDamage( mWidget, PR_TRUE ); + } + } else { + if( mWindowType != eWindowType_child ) { EnableDamage( mWidget, PR_FALSE ); - - if( PtWidgetIsClass( mWidget, PtRegion ) ) { - PtWidget_t *w=nsnull, *w1=nsnull; - - gLastUnrealizedRegion = PtWidgetRid(mWidget); - w = mWidget; - while( 1 ) { - w1 = PtWidgetParent(w); - if( w1 == 0 ) { - gLastUnrealizedRegionsParent = PtWidgetRid(w); - break; - } - w = w1; - } - } - PtUnrealizeWidget(mWidget); + + EnableDamage( mWidget, PR_TRUE ); PtSetArg(&arg, Pt_ARG_FLAGS, Pt_DELAY_REALIZE, Pt_DELAY_REALIZE); PtSetResources(mWidget, 1, &arg); + } + else { + EnableDamage( mWidget, PR_FALSE ); + PtWidgetToBack( mWidget ); + if( mShown ) PtUnrealizeWidget( mWidget ); + EnableDamage( mWidget, PR_TRUE ); + } } mShown = bState; return NS_OK; } + /* This got moved to nsWindow.cpp */ NS_IMETHODIMP nsWidget::CaptureRollupEvents( nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent ) { return NS_OK; @@ -399,24 +392,22 @@ NS_METHOD nsWidget::Resize( PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint ) { if( mWidget ) { PtArg_t arg; - int *border; - - PtSetArg( &arg, Pt_ARG_BORDER_WIDTH, &border, 0 ); - PtGetResources( mWidget, 1, &arg ); /* Add the border to the size of the widget */ - PhDim_t dim = {aWidth - 2*(*border), aHeight - 2*(*border)}; -// EnableDamage( mWidget, PR_FALSE ); + PhDim_t dim = { aWidth, aHeight }; + + EnableDamage( mWidget, PR_FALSE ); PtSetArg( &arg, Pt_ARG_DIM, &dim, 0 ); PtSetResources( mWidget, 1, &arg ); -// EnableDamage( mWidget, PR_TRUE ); + EnableDamage( mWidget, PR_TRUE ); } return NS_OK; } + NS_METHOD nsWidget::Resize( PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint ) { Move(aX,aY); Resize(aWidth,aHeight,aRepaint); @@ -733,54 +724,26 @@ NS_METHOD nsWidget::Invalidate( const nsRect & aRect, PRBool aIsSynchronous ) { if( !mWidget ) return NS_OK; // mWidget will be null during printing if( !PtWidgetIsRealized( mWidget ) ) return NS_OK; - nsRect rect = aRect; - - /* convert to parent coords */ - rect.x += mBounds.x; - rect.y += mBounds.y; - - if( GetParentClippedArea( rect ) == PR_TRUE ) { - /* convert back widget coords */ - rect.x -= mBounds.x; - rect.y -= mBounds.y; -#if 0 - mUpdateArea->Union(aRect.x, aRect.y, aRect.width, aRect.height); - if( PtWidgetIsRealized( mWidget ) ) QueueWidgetDamage( ); -#else - PhRect_t prect; - prect.ul.x = rect.x + mWidget->extent.ul.x; - prect.ul.y = rect.y + mWidget->extent.ul.y; - prect.lr.x = prect.ul.x + rect.width - 1; - prect.lr.y = prect.ul.y + rect.height - 1; - PtDamageExtent(mWidget, &prect); - if (aIsSynchronous) - PtFlush(); -#endif - } + PhRect_t prect; + prect.ul.x = aRect.x; + prect.ul.y = aRect.y; + prect.lr.x = prect.ul.x + aRect.width - 1; + prect.lr.y = prect.ul.y + aRect.height - 1; + if( ! ( mWidget->class_rec->flags & Pt_DISJOINT ) ) + PhTranslateRect( &prect, &mWidget->area.pos ); + PtDamageExtent( mWidget, &prect ); + if( aIsSynchronous ) PtFlush( ); return NS_OK; } NS_IMETHODIMP nsWidget::InvalidateRegion( const nsIRegion *aRegion, PRBool aIsSynchronous ) { - -#if 0 - mUpdateArea->Union( *aRegion ); - if( aIsSynchronous ) UpdateWidgetDamage(); - else QueueWidgetDamage(); -#else - nsresult rv = NS_OK; PhTile_t *tiles = NULL; - rv = aRegion->GetNativeRegion( ( void*& ) tiles ); - if (tiles) { - if (NS_SUCCEEDED(rv)) { - tiles = PhCopyTiles(tiles); - PhTranslateTiles(tiles, &mWidget->extent.ul); - PtDamageTiles(mWidget, tiles); - if (aIsSynchronous) - PtFlush(); - PhFreeTiles(tiles); + aRegion->GetNativeRegion( ( void*& ) tiles ); + if( tiles ) { + PhTranslateTiles( tiles, &mWidget->area.pos ); + PtDamageTiles( mWidget, tiles ); + if( aIsSynchronous ) PtFlush( ); } - } -#endif return NS_OK; } @@ -963,8 +926,8 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent, PtWidget_t *parentWidget = nsnull; - sWidgetCreating = PR_TRUE; - + sJustGotActivated = PR_TRUE; + nsIWidget *baseParent = aInitData && (aInitData->mWindowType == eWindowType_dialog || aInitData->mWindowType == eWindowType_toplevel ) ? nsnull : aParent; @@ -1561,6 +1524,12 @@ PRBool nsWidget::HandleEvent( PtCallbackInfo_t* aCbInfo ) { InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MIDDLE_BUTTON_DOWN ); result = DispatchMouseEvent(theMouseEvent); + + // if we're a right-button-up we're trying to popup a context menu. send that event to gecko also + if( ptrev->buttons & Ph_BUTTON_MENU ) { + InitMouseEvent( ptrev, this, theMouseEvent, NS_CONTEXTMENU ); + result = DispatchMouseEvent( theMouseEvent ); + } } } break; @@ -1640,14 +1609,10 @@ PRBool nsWidget::HandleEvent( PtCallbackInfo_t* aCbInfo ) { case Ph_EV_BOUNDARY: switch( event->subtype ) { - case Ph_EV_PTR_ENTER: { - PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event ); - nsMouseEvent MouseEvent; - ScreenToWidget( ptrev->pos ); - InitMouseEvent( ptrev, this, MouseEvent, NS_MOUSE_MOVE ); - DispatchMouseEvent( MouseEvent ); - } + case Ph_EV_PTR_ENTER: + result = DispatchStandardEvent( NS_MOUSE_ENTER ); break; + case Ph_EV_PTR_LEAVE_TO_CHILD: case Ph_EV_PTR_LEAVE: result = DispatchStandardEvent( NS_MOUSE_EXIT ); break; @@ -1655,19 +1620,6 @@ PRBool nsWidget::HandleEvent( PtCallbackInfo_t* aCbInfo ) { break; } break; - - case Ph_EV_EXPOSE: - { - int reg; - int parreg; - - reg = event->emitter.rid; - parreg = PtWidgetRid(mWidget); - - if (reg == gLastUnrealizedRegion && parreg == gLastUnrealizedRegionsParent) result = PR_TRUE; - else result = PR_FALSE; - } - break; } return result; @@ -1845,8 +1797,6 @@ int nsWidget::WorkProc( void *data ) { DamageQueueEntry **dq = (DamageQueueEntry **) data; - sWidgetCreating = PR_FALSE; - if( dq && (*dq) ) { DamageQueueEntry *dqe = *dq; DamageQueueEntry *last_dqe; @@ -1931,11 +1881,13 @@ int nsWidget::GotFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t pWidget->DispatchStandardEvent(NS_GOTFOCUS); - if(!sWidgetCreating) + if( !sJustGotActivated ) { - pWidget->DispatchStandardEvent(NS_ACTIVATE); + sJustGotActivated = PR_TRUE; sJustGotDeactivated = PR_FALSE; + pWidget->DispatchStandardEvent(NS_ACTIVATE); } + else sJustGotActivated = PR_FALSE; return Pt_CONTINUE; } @@ -1960,6 +1912,8 @@ int nsWidget::LostFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_ // pWidget->DispatchStandardEvent(NS_LOSTFOCUS); + sJustGotActivated = PR_FALSE; + return Pt_CONTINUE; } diff --git a/mozilla/widget/src/photon/nsWidget.h b/mozilla/widget/src/photon/nsWidget.h index 2b39e627aa1..8cc07666e97 100644 --- a/mozilla/widget/src/photon/nsWidget.h +++ b/mozilla/widget/src/photon/nsWidget.h @@ -263,7 +263,7 @@ protected: // Focus used global variable static nsWidget* sFocusWidget; //Current Focus Widget static PRBool sJustGotDeactivated; - static PRBool sWidgetCreating; //For getting rid of the ASSERT ERROR due to reducing suppressing of focus. + static PRBool sJustGotActivated; //For getting rid of the ASSERT ERROR due to reducing suppressing of focus. /* this is the rollup listener variables */ /* These variables help us close the Menu when the clicks outside the application */ @@ -272,9 +272,6 @@ protected: static nsILookAndFeel *sLookAndFeel; static PRUint32 sWidgetCount; - - static PhRid_t gLastUnrealizedRegion; - static PhRid_t gLastUnrealizedRegionsParent; }; #endif /* nsWidget_h__ */ diff --git a/mozilla/widget/src/photon/nsWidgetFactory.cpp b/mozilla/widget/src/photon/nsWidgetFactory.cpp index 8aeb750e7fd..0f7256c1425 100644 --- a/mozilla/widget/src/photon/nsWidgetFactory.cpp +++ b/mozilla/widget/src/photon/nsWidgetFactory.cpp @@ -36,6 +36,7 @@ #include "nsDragService.h" #include "nsFileSpecWithUIImpl.h" #include "nsScrollbar.h" +#include "nsSound.h" #ifdef IBMBIDI #include "nsBidiKeyboard.h" #endif @@ -54,6 +55,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileSpecWithUIImpl) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) #ifdef IBMBIDI NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) #endif @@ -165,6 +167,10 @@ static nsModuleComponentInfo components[] = // "@mozilla.org/widget/dragservice/ph;1", "@mozilla.org/widget/dragservice;1", nsDragServiceConstructor }, +{ "Ph Sound", + NS_SOUND_CID, + "@mozilla.org/sound;1", + nsSoundConstructor }, #ifdef IBMBIDI { "Gtk Bidi Keyboard", NS_BIDIKEYBOARD_CID, @@ -179,6 +185,4 @@ static nsModuleComponentInfo components[] = nsFileSpecWithUIImplConstructor } }; - NS_IMPL_NSGETMODULE("nsWidgetPhModule", components) -