NOT PART OF BUILD (Photon Only)

- many fixes (rendering speedup, focus problems, fixed up colors)
This commit is contained in:
dinglis%qnx.com 2001-07-04 18:02:00 +00:00
parent b383ee444c
commit bfdf148c6f
8 changed files with 266 additions and 247 deletions

View File

@ -16,8 +16,6 @@ PtWidgetClassRef_t *PtRawDrawContainer = &WRawDrawContainer;
static void raw_draw_container_dflts( PtWidget_t *widget )
{
RawDrawContainerWidget *rdc = ( RawDrawContainerWidget * ) widget;
PtContainerWidget_t *container = ( PtContainerWidget_t * ) widget;
PtBasicWidget_t *basic = ( PtBasicWidget_t * ) widget;
widget->flags |= ( Pt_OPAQUE );
rdc->draw_f = NULL;
}
@ -35,7 +33,6 @@ static void raw_draw_container_draw( PtWidget_t *widget, PhTile_t *damage )
printf("raw_draw_container_draw NULL widget!\n");
return;
}
if( rdc->draw_f )
rdc->draw_f( widget, damage );
}
@ -47,8 +44,8 @@ PtWidgetClass_t *CreateRawDrawContainerClass( void )
{
// define our resources
static PtResourceRec_t resources[] = {
RDC_DRAW_FUNC, Pt_CHANGE_INVISIBLE, 0,
Pt_ARG_IS_POINTER( RawDrawContainerWidget, draw_f ), 0,
{ RDC_DRAW_FUNC, Pt_CHANGE_INVISIBLE, 0,
Pt_ARG_IS_POINTER( RawDrawContainerWidget, draw_f ), 0 }
};
// set up our class member values

View File

@ -58,7 +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),
int err = PtAppAddFd(NULL, fd, (Pt_FD_READ | Pt_FD_NOPOLL | Pt_FD_DRAIN ),
event_processor_callback,data);
if (err != 0)
{
@ -137,13 +137,8 @@ static int event_processor_callback(int fd, void *data, unsigned mode)
NS_IMETHODIMP nsAppShell::Create(int *bac, char **bav)
{
char *home=nsnull;
char *path=nsnull;
if (!PhWidLog)
{
PhWidLog = PR_NewLogModule("PhWidLog");
}
int argc = bac ? *bac : 0;
char **argv = bav;

View File

@ -91,7 +91,6 @@ NS_IMETHODIMP nsClipboard::SetNativeClipboardData(PRInt32 aWhichClipboard)
if( cliphdr ) {
PRUint32 i=0, index=0;
nsString *df;
void *data = nsnull;
PRUint32 dataLen;
@ -167,8 +166,10 @@ nsClipboard::GetNativeClipboardData( nsITransferable * aTransferable, PRInt32 aW
PRUint32 dataLen;
clipPtr = PhClipboardPasteStart( 1 );
if(!clipPtr)
return NS_ERROR_FAILURE;
for ( PRUint32 i = 0; i < cnt; ++i ) {
for ( PRUint32 i = 0; i < cnt; ++i ) {
nsCOMPtr<nsISupports> genericFlavor;
flavorList->GetElementAt ( i, getter_AddRefs(genericFlavor) );
nsCOMPtr<nsISupportsString> currentFlavor ( do_QueryInterface(genericFlavor) );
@ -189,6 +190,7 @@ nsClipboard::GetNativeClipboardData( nsITransferable * aTransferable, PRInt32 aW
int len_unicode;
PRUnichar *unicode;
nsPrimitiveHelpers::ConvertPlatformPlainTextToUnicode( (char*) data, dataLen, &unicode, &len_unicode );
len_unicode--;
len_unicode *= 2;
#if 0
@ -224,7 +226,7 @@ nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList,
PRInt32 aWhichClipboard,
PRBool * outResult) {
nsresult res = NS_ERROR_FAILURE;
nsresult res = NS_OK;
* outResult = PR_FALSE;
// Walk through flavors and see which flavor matches the one being pasted:
@ -236,8 +238,6 @@ nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList,
void *clipPtr;
PhClipHeader cliptype;
PhClipHeader *cliphdr;
void *data = nsnull;
PRUint32 dataLen;
clipPtr = PhClipboardPasteStart( 1 );
if(nsnull == clipPtr)

View File

@ -57,22 +57,22 @@ NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor)
switch (aID)
{
case eColor_WindowBackground:
aColor = PH_TO_NS_RGB(Pg_WHITE);
aColor = PH_TO_NS_RGB(Pg_LGREY);
break;
case eColor_WindowForeground:
aColor = PH_TO_NS_RGB(Pg_BLACK);
aColor = PH_TO_NS_RGB(Pg_DGREY);
break;
case eColor_WidgetBackground:
aColor = PH_TO_NS_RGB(Pg_GREY);
aColor = PH_TO_NS_RGB(Pg_LGREY);
break;
case eColor_WidgetForeground:
aColor = PH_TO_NS_RGB(Pg_BLACK);
aColor = PH_TO_NS_RGB(Pg_DGREY);
break;
case eColor_WidgetSelectBackground:
aColor = PH_TO_NS_RGB(Pg_DGREY);
break;
case eColor_WidgetSelectForeground:
aColor = PH_TO_NS_RGB(Pg_BLACK);
aColor = PH_TO_NS_RGB(Pg_DGREY);
break;
case eColor_Widget3DHighlight:
aColor = PH_TO_NS_RGB(Pg_WHITE);
@ -101,10 +101,10 @@ NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor)
aColor = PH_TO_NS_RGB(Pg_YELLOW);
break;
case eColor_appworkspace:
aColor = PH_TO_NS_RGB(Pg_BLACK);
aColor = PH_TO_NS_RGB(Pg_LGREY);
break;
case eColor_background:
aColor = PH_TO_NS_RGB(Pg_GREY);
aColor = PH_TO_NS_RGB(Pg_LGREY);
break;
case eColor_captiontext:
aColor = PH_TO_NS_RGB(Pg_BLACK);
@ -128,23 +128,23 @@ NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor)
aColor = PH_TO_NS_RGB(Pg_DGREY);
break;
case eColor_infobackground:
aColor = PH_TO_NS_RGB(0xfeffb1); // popup yellow
aColor = PH_TO_NS_RGB(Pg_BALLOONCOLOR); // popup yellow
break;
case eColor_infotext:
aColor = PH_TO_NS_RGB(Pg_BLACK);
break;
case eColor_menu:
aColor = PH_TO_NS_RGB(Pg_GREY);
aColor = PH_TO_NS_RGB(Pg_LGREY);
break;
case eColor_menutext:
aColor = PH_TO_NS_RGB(Pg_BLACK);
break;
case eColor_scrollbar:
aColor = PH_TO_NS_RGB(Pg_GREY);
aColor = PH_TO_NS_RGB(Pg_LGREY);
break;
case eColor_threedface:
case eColor_buttonface:
aColor = PH_TO_NS_RGB(Pg_GREY);
aColor = PH_TO_NS_RGB(Pg_LGREY);
break;
case eColor_buttonhighlight:
@ -166,16 +166,15 @@ NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor)
break;
case eColor_threedlightshadow:
aColor = PH_TO_NS_RGB(Pg_GREY);
aColor = PH_TO_NS_RGB(Pg_LGREY);
break;
case eColor_window:
aColor = PH_TO_NS_RGB(Pg_WHITE);
break;
case eColor_windowframe:
aColor = PH_TO_NS_RGB(Pg_GREY);
aColor = PH_TO_NS_RGB(Pg_LGREY);
break;
case eColor_windowtext:
@ -194,7 +193,7 @@ NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor)
break;
case eColor__moz_dialog:
aColor = PH_TO_NS_RGB(Pg_GREY);
aColor = PH_TO_NS_RGB(Pg_LGREY);
break;
case eColor__moz_dialogtext:
@ -202,7 +201,7 @@ NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor)
break;
case eColor__moz_dragtargetzone:
aColor = PH_TO_NS_RGB(Pg_GREY);
aColor = PH_TO_NS_RGB(Pg_LGREY);
break;
default:

View File

@ -145,15 +145,6 @@ NS_METHOD nsScrollbar::SetPosition (PRUint32 aPos)
if( mWidget )
{
PtArg_t arg;
#ifdef PHOTON1_ONLY
PtSetArg( &arg, Pt_ARG_SCROLL_POSITION, aPos, 0 );
if( PtSetResources( mWidget, 1, &arg ) == 0 )
{
res = NS_OK;
}
#endif
}
@ -172,16 +163,6 @@ NS_METHOD nsScrollbar::GetPosition (PRUint32 & aPos)
if( mWidget )
{
PtArg_t arg;
int *pos;
#ifdef PHOTON1_ONLY
PtSetArg( &arg, Pt_ARG_SCROLL_POSITION, &pos, 0 );
if( PtGetResources( mWidget, 1, &arg ) == 0 )
{
aPos = *pos;
res = NS_OK;
}
#endif
}
return res;
@ -300,16 +281,13 @@ NS_METHOD nsScrollbar::SetParameters (PRUint32 aMaxRange, PRUint32 aThumbSize,
if( mWidget )
{
PtArg_t arg[5];
PtArg_t arg[3];
PtSetArg( &arg[0], Pt_ARG_MAXIMUM , aMaxRange, 0 );
PtSetArg( &arg[1], Pt_ARG_SLIDER_SIZE , aThumbSize, 0 );
#ifdef PHOTON1_ONLY
PtSetArg( &arg[2], Pt_ARG_SCROLL_POSITION , aPosition, 0 );
#endif
PtSetArg( &arg[3], Pt_ARG_INCREMENT, aLineIncrement, 0 );
PtSetArg( &arg[2], Pt_ARG_INCREMENT, aLineIncrement, 0 );
if( PtSetResources( mWidget, 4, arg ) == 0 )
if( PtSetResources( mWidget, 3, arg ) == 0 )
{
res = NS_OK;
}

View File

@ -71,14 +71,16 @@ PhRid_t nsWidget::gLastUnrealizedRegionsParent = -1;
//
// Keep track of the last widget being "dragged"
//
#if 0
DamageQueueEntry *nsWidget::mDmgQueue = nsnull;
PtWorkProcId_t *nsWidget::mWorkProcID = nsnull;
PRBool nsWidget::mDmgQueueInited = PR_FALSE;
#endif
nsILookAndFeel *nsWidget::sLookAndFeel = nsnull;
PRUint32 nsWidget::sWidgetCount = 0;
nsWidget *nsWidget::gFocusWidget = nsnull;
PRBool gJustGotDeactivate = PR_TRUE;
nsWidget *nsWidget::sFocusWidget = nsnull;
PRBool nsWidget::sWidgetCreating = PR_FALSE;
PRBool nsWidget::sJustGotDeactivated = PR_TRUE;
/* Enable this to queue widget damage, this should be ON by default */
#define ENABLE_DAMAGE_QUEUE
@ -192,7 +194,7 @@ NS_IMETHODIMP nsWidget::Destroy( void ) {
// make sure no callbacks happen
mEventCallback = nsnull;
if( gFocusWidget == this ) gFocusWidget = nsnull;
if( sFocusWidget == this ) sFocusWidget = nsnull;
return NS_OK;
}
@ -204,8 +206,10 @@ void nsWidget::DestroyNative( void ) {
if( mWidget ) {
// prevent the widget from causing additional events
mEventCallback = nsnull;
RemoveDamagedWidget(mWidget);
PtDestroyWidget( mWidget );
#if 0
RemoveDamagedWidget(mWidget);
#endif
PtDestroyWidget( mWidget );
mWidget = nsnull;
}
@ -272,25 +276,22 @@ the PtRealizeWidget functions */
PtArg_t arg;
if( bState ) {
EnableDamage( mWidget, PR_FALSE );
PtRealizeWidget(mWidget);
if( mWidget->rid == -1 ) {
PtRegionWidget_t *region = (PtRegionWidget_t *) mWidget;
NS_ASSERTION(0,"nsWidget::Show mWidget's rid == -1\n");
mShown = PR_FALSE;
return NS_ERROR_FAILURE;
}
EnableDamage( mWidget, PR_TRUE );
PtSetArg(&arg, Pt_ARG_FLAGS, 0, Pt_DELAY_REALIZE);
PtSetResources(mWidget, 1, &arg);
/* Always add it to the Widget Damage Queue when it gets realized */
QueueWidgetDamage();
}
#if 0
QueueWidgetDamage();
#endif
}
else {
EnableDamage( mWidget, PR_FALSE );
@ -352,63 +353,63 @@ NS_METHOD nsWidget::ConstrainPosition( PRInt32 *aX, PRInt32 *aY ) {
//-------------------------------------------------------------------------
NS_METHOD nsWidget::Move( PRInt32 aX, PRInt32 aY ) {
if( ( mBounds.x == aX ) && ( mBounds.y == aY ) ) return NS_OK;
mBounds.x = aX;
mBounds.y = aY;
if( ( mBounds.x == aX ) && ( mBounds.y == aY ) )
return NS_OK;
mBounds.x = aX;
mBounds.y = aY;
if(mWidget) {
PtArg_t arg;
PhPoint_t *oldpos;
PhPoint_t pos;
pos.x = aX;
pos.y = aY;
// EnableDamage( mWidget, PR_FALSE );
PtSetArg( &arg, Pt_ARG_POS, &oldpos, 0 );
PtGetResources( mWidget, 1, &arg );
if(( oldpos->x != pos.x ) || ( oldpos->y != pos.y )) {
PtSetArg( &arg, Pt_ARG_POS, &pos, 0 );
PtSetResources( mWidget, 1, &arg );
}
// EnableDamage( mWidget, PR_TRUE );
}
// EnableDamage( mWidget, PR_FALSE );
PtSetArg( &arg, Pt_ARG_POS, &oldpos, 0 );
PtGetResources( mWidget, 1, &arg );
if(( oldpos->x != pos.x ) || ( oldpos->y != pos.y )) {
PtSetArg( &arg, Pt_ARG_POS, &pos, 0 );
PtSetResources( mWidget, 1, &arg );
}
// EnableDamage( mWidget, PR_TRUE );
}
return NS_OK;
}
NS_METHOD nsWidget::Resize( PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint ) {
if( ( mBounds.width != aWidth ) || ( mBounds.height != aHeight ) ) {
if( ( mBounds.width == aWidth ) && ( mBounds.height == aHeight ) )
return NS_OK;
mBounds.width = aWidth;
mBounds.height = aHeight;
if( mWidget ) {
PtArg_t arg;
int *border;
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 );
PtSetArg( &arg, Pt_ARG_DIM, &dim, 0 );
PtSetResources( mWidget, 1, &arg );
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 );
PtSetArg( &arg, Pt_ARG_DIM, &dim, 0 );
PtSetResources( mWidget, 1, &arg );
EnableDamage( mWidget, PR_TRUE );
}
}
return NS_OK;
EnableDamage( mWidget, PR_TRUE );
}
return NS_OK;
}
NS_METHOD nsWidget::Resize( PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint ) {
@ -431,7 +432,7 @@ PRBool nsWidget::OnResize( nsRect &aRect ) {
nsSizeEvent event;
/* Stole this from GTK */
InitEvent(event, NS_SIZE);
InitEvent(event, NS_SIZE);
event.eventStructType = NS_SIZE_EVENT;
nsRect *foo = new nsRect(0, 0, aRect.width, aRect.height);
@ -472,13 +473,15 @@ PRBool nsWidget::OnMove( PRInt32 aX, PRInt32 aY ) {
//
//-------------------------------------------------------------------------
NS_METHOD nsWidget::Enable( PRBool bState ) {
if( mWidget ) {
PtArg_t arg;
if( bState ) PtSetArg( &arg, Pt_ARG_FLAGS, 0, Pt_BLOCKED );
else PtSetArg( &arg, Pt_ARG_FLAGS, Pt_BLOCKED, Pt_BLOCKED );
PtSetResources( mWidget, 1, &arg );
}
return NS_OK;
if( mWidget ) {
PtArg_t arg;
if( bState )
PtSetArg( &arg, Pt_ARG_FLAGS, 0, Pt_BLOCKED );
else
PtSetArg( &arg, Pt_ARG_FLAGS, Pt_BLOCKED, Pt_BLOCKED );
PtSetResources( mWidget, 1, &arg );
}
return NS_OK;
}
@ -489,17 +492,17 @@ NS_METHOD nsWidget::Enable( PRBool bState ) {
//-------------------------------------------------------------------------
NS_METHOD nsWidget::SetFocus( PRBool aRaise ) {
if(gFocusWidget == this)
if(sFocusWidget == this)
return NS_OK;
// call this so that any cleanup will happen that needs to...
if(gFocusWidget && mWidget->parent)
gFocusWidget->LoseFocus();
if(sFocusWidget && mWidget->parent)
sFocusWidget->LoseFocus();
if(!mWidget->parent)
return NS_OK;
gFocusWidget = this;
sFocusWidget = this;
if( mWidget && mWidget->parent) {
PtContainerGiveFocus( mWidget, NULL );
@ -518,7 +521,7 @@ void nsWidget::LoseFocus( void )
if( mHasFocus == PR_FALSE ) return;
mHasFocus = PR_FALSE;
gFocusWidget = nsnull;
sFocusWidget = nsnull;
}
@ -564,14 +567,13 @@ NS_METHOD nsWidget::SetFont( const nsFont &aFont ) {
NS_METHOD nsWidget::SetBackgroundColor( const nscolor &aColor ) {
nsBaseWidget::SetBackgroundColor( aColor );
if( mWidget ) {
PtArg_t arg;
PgColor_t color = NS_TO_PH_RGB( aColor );
PtSetArg( &arg, Pt_ARG_FILL_COLOR, color, 0 );
PtSetResources( mWidget, 1, &arg );
if( mWidget ) {
PtArg_t arg;
PgColor_t color = NS_TO_PH_RGB( aColor );
PtSetArg( &arg, Pt_ARG_FILL_COLOR, color, 0 );
PtSetResources( mWidget, 1, &arg );
}
return NS_OK;
}
@ -700,19 +702,24 @@ NS_METHOD nsWidget::SetCursor( nsCursor aCursor ) {
NS_METHOD nsWidget::Invalidate( PRBool aIsSynchronous ) {
if( !mWidget ) return NS_OK; // mWidget will be null during printing
if( !PtWidgetIsRealized( mWidget ) ) return NS_OK;
if( !mWidget ) return NS_OK; // mWidget will be null during printing
if( !PtWidgetIsRealized( mWidget ) ) return NS_OK;
nsRect rect = mBounds;
PtWidget_t *aWidget = (PtWidget_t *)GetNativeData(NS_NATIVE_WIDGET);
long widgetFlags = PtWidgetFlags(aWidget);
#if 0
nsRect rect = mBounds;
/* Damage has to be relative Widget coords */
mUpdateArea->SetTo( rect.x - mBounds.x, rect.y - mBounds.y, rect.width, rect.height );
if( aIsSynchronous ) UpdateWidgetDamage();
else QueueWidgetDamage();
#else
PtDamageWidget(aWidget);
if (aIsSynchronous)
PtFlush();
#endif
return NS_OK;
}
@ -731,20 +738,41 @@ NS_METHOD nsWidget::Invalidate( const nsRect & aRect, PRBool aIsSynchronous ) {
/* 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;
prect.ul.y = rect.y;
prect.lr.x = rect.x + rect.width - 1;
prect.lr.y = rect.y + rect.height - 1;
PtDamageExtent(mWidget, &prect);
if (aIsSynchronous)
PtFlush();
#endif
}
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)) {
PtDamageTiles(mWidget, tiles);
if (aIsSynchronous)
PtFlush();
}
}
#endif
return NS_OK;
}
@ -828,8 +856,8 @@ PRBool nsWidget::GetParentClippedArea( nsRect &rect ) {
NS_METHOD nsWidget::Update( void ) {
/* if the widget has been invalidated or damaged then re-draw it */
UpdateWidgetDamage();
// UpdateWidgetDamage();
PtFlush();
return NS_OK;
}
@ -923,6 +951,8 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent,
PtWidget_t *parentWidget = nsnull;
sWidgetCreating = PR_TRUE;
nsIWidget *baseParent = aInitData && (aInitData->mWindowType == eWindowType_dialog ||
aInitData->mWindowType == eWindowType_toplevel ) ? nsnull : aParent;
@ -1470,7 +1500,6 @@ int nsWidget::RawEventHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t
PRBool nsWidget::HandleEvent( PtCallbackInfo_t* aCbInfo ) {
PRBool result = PR_TRUE; // call the default nsWindow proc
int err;
PhEvent_t* event = aCbInfo->event;
/* Photon 2 added a Consumed flag which indicates a previous receiver of the */
@ -1522,32 +1551,32 @@ PRBool nsWidget::HandleEvent( PtCallbackInfo_t* aCbInfo ) {
result = DispatchMouseEvent(theMouseEvent);
}
}
break;
case Ph_EV_BUT_RELEASE:
{
PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event );
nsMouseEvent theMouseEvent;
if (event->subtype==Ph_EV_RELEASE_REAL || event->subtype==Ph_EV_RELEASE_PHANTOM) {
if (ptrev) {
ScreenToWidget( ptrev->pos );
if ( ptrev->buttons & Ph_BUTTON_SELECT ) // Normally the left mouse button
InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_UP );
else if( ptrev->buttons & Ph_BUTTON_MENU ) // the right button
InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_RIGHT_BUTTON_UP );
else // middle button
InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MIDDLE_BUTTON_UP );
result = DispatchMouseEvent(theMouseEvent);
}
}
else if (event->subtype==Ph_EV_RELEASE_OUTBOUND) {
PhRect_t rect = {0,0,0,0};
PhRect_t boundary = {-10000,-10000,10000,10000};
PhInitDrag( PtWidgetRid(mWidget), ( Ph_DRAG_KEY_MOTION | Ph_DRAG_TRACK ),&rect, &boundary, aCbInfo->event->input_group , NULL, NULL, NULL, NULL, NULL);
}
}
break;
case Ph_EV_BUT_RELEASE:
{
PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event );
nsMouseEvent theMouseEvent;
if (event->subtype==Ph_EV_RELEASE_REAL || event->subtype==Ph_EV_RELEASE_PHANTOM) {
if (ptrev) {
ScreenToWidget( ptrev->pos );
if ( ptrev->buttons & Ph_BUTTON_SELECT ) // Normally the left mouse button
InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_UP );
else if( ptrev->buttons & Ph_BUTTON_MENU ) // the right button
InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_RIGHT_BUTTON_UP );
else // middle button
InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MIDDLE_BUTTON_UP );
result = DispatchMouseEvent(theMouseEvent);
}
}
else if (event->subtype==Ph_EV_RELEASE_OUTBOUND) {
PhRect_t rect = {{0,0},{0,0}};
PhRect_t boundary = {{-10000,-10000},{10000,10000}};
PhInitDrag( PtWidgetRid(mWidget), ( Ph_DRAG_KEY_MOTION | Ph_DRAG_TRACK ),&rect, &boundary, aCbInfo->event->input_group , NULL, NULL, NULL, NULL, NULL);
}
}
break;
case Ph_EV_PTR_MOTION_BUTTON:
@ -1573,7 +1602,6 @@ PRBool nsWidget::HandleEvent( PtCallbackInfo_t* aCbInfo ) {
case Ph_EV_DRAG:
{
PhDragEvent_t* ptrev = (PhDragEvent_t*) PhGetData( event );
nsMouseEvent theMouseEvent;
switch(event->subtype) {
@ -1652,6 +1680,7 @@ void nsWidget::ScreenToWidget( PhPoint_t &pt ) {
// Starts a Photon background task that will flush widget damage when the
// app goes idle.
//---------------------------------------------------------------------------
#if 0
void nsWidget::InitDamageQueue( ) {
mDmgQueue = nsnull;
@ -1667,7 +1696,6 @@ void nsWidget::InitDamageQueue( ) {
}
}
//---------------------------------------------------------------------------
// nsWidget::QueueWidgetDamage()
//
@ -1723,9 +1751,9 @@ void nsWidget::UpdateWidgetDamage( ) {
if( mWidget == NULL ) return;
if( !PtWidgetIsRealized( mWidget ) ) return;
#if 0
RemoveDamagedWidget( mWidget );
#endif
if( mUpdateArea->IsEmpty( ) ) return;
@ -1734,37 +1762,36 @@ void nsWidget::UpdateWidgetDamage( ) {
if( PtWidgetIsClass(mWidget, PtWindow ) || PtWidgetIsClass( mWidget, PtRegion ) ) {
area.pos.x = area.pos.y = 0;
}
}
if (NS_FAILED(mUpdateArea->GetRects(&regionRectSet))) {
NS_ASSERTION(0,"nsWidget::UpdateWidgetDamaged Error mUpdateArea->GetRects returned NULL");
return;
}
}
len = regionRectSet->mRectsLen;
for( i=0; i<len; ++i ) {
nsRegionRect *r = &(regionRectSet->mRects[i]);
temp_rect.SetRect(r->x, r->y, r->width, r->height);
if( GetParentClippedArea( temp_rect ) ) {
extent.ul.x = temp_rect.x + area.pos.x;
extent.ul.y = temp_rect.y + area.pos.y;
extent.lr.x = extent.ul.x + temp_rect.width - 1;
extent.lr.y = extent.ul.y + temp_rect.height - 1;
PtDamageExtent( mWidget, &extent );
}
}
nsRegionRect *r = &(regionRectSet->mRects[i]);
temp_rect.SetRect(r->x, r->y, r->width, r->height);
if( GetParentClippedArea( temp_rect ) ) {
extent.ul.x = temp_rect.x + area.pos.x;
extent.ul.y = temp_rect.y + area.pos.y;
extent.lr.x = extent.ul.x + temp_rect.width - 1;
extent.lr.y = extent.ul.y + temp_rect.height - 1;
PtDamageExtent( mWidget, &extent );
}
}
// drop the const.. whats the right thing to do here?
mUpdateArea->FreeRects(regionRectSet);
//PtFlush(); //HOLD_HACK
//PtFlush();
mUpdateArea->SetTo(0,0,0,0);
}
}
void nsWidget::RemoveDamagedWidget( PtWidget_t *aWidget ) {
@ -1805,7 +1832,9 @@ void nsWidget::RemoveDamagedWidget( PtWidget_t *aWidget ) {
int nsWidget::WorkProc( void *data )
{
DamageQueueEntry **dq = (DamageQueueEntry **) data;
sWidgetCreating = PR_FALSE;
if( dq && (*dq) ) {
DamageQueueEntry *dqe = *dq;
DamageQueueEntry *last_dqe;
@ -1876,7 +1905,7 @@ int nsWidget::WorkProc( void *data )
return Pt_END;
}
#endif
int nsWidget::GotFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo )
{
nsWidget *pWidget = (nsWidget *) data;
@ -1890,26 +1919,27 @@ int nsWidget::GotFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t
pWidget->DispatchStandardEvent(NS_GOTFOCUS);
if(gJustGotDeactivate)
if(!sWidgetCreating)
{
pWidget->DispatchStandardEvent(NS_ACTIVATE);
gJustGotDeactivate = PR_FALSE;
sJustGotDeactivated = PR_FALSE;
}
return Pt_CONTINUE;
}
int nsWidget::LostFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) {
nsWidget *pWidget = (nsWidget *) data;
int nsWidget::LostFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo )
{
// nsWidget *pWidget = (nsWidget *) data;
if(!widget->parent)
{
if(gFocusWidget)
if(sFocusWidget)
{
if(!gJustGotDeactivate)
if(!sJustGotDeactivated)
{
gFocusWidget->DispatchStandardEvent(NS_DEACTIVATE);
gJustGotDeactivate = PR_TRUE;
sFocusWidget->DispatchStandardEvent(NS_DEACTIVATE);
sJustGotDeactivated = PR_TRUE;
}
}
}
@ -1925,8 +1955,10 @@ int nsWidget::DestroyedCallback( PtWidget_t *widget, void *data, PtCallbackInfo_
nsWidget *pWidget = (nsWidget *) data;
if( !pWidget->mIsDestroying ) {
pWidget->RemoveDamagedWidget(pWidget->mWidget);
pWidget->OnDestroy();
#if 0
pWidget->RemoveDamagedWidget(pWidget->mWidget);
#endif
pWidget->OnDestroy();
}
return Pt_CONTINUE;
}
@ -2057,7 +2089,7 @@ case _value: eventName = (const PRUnichar *) _name ; break
{
char buf[32];
sprintf(buf,"UNKNOWN: %d",aPhEvent->type);
sprintf(buf,"UNKNOWN: %ld",aPhEvent->type);
eventName = (const PRUnichar *) buf;
}

View File

@ -252,8 +252,6 @@ protected:
PtWidget_t *mWidget;
nsIWidget *mParent;
static nsWidget* gFocusWidget; // Current Focus Widget;
// This is the composite update area (union of all the calls to Invalidate)
nsIRegion *mUpdateArea;
@ -262,6 +260,11 @@ protected:
PRUint32 mPreferredWidth, mPreferredHeight;
PRBool mListenForResizes;
// 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.
/* this is the rollup listener variables */
/* These variables help us close the Menu when the clicks outside the application */
static nsIRollupListener *gRollupListener;

View File

@ -101,7 +101,9 @@ nsWindow::~nsWindow()
Destroy();
RemoveResizeWidget();
RemoveDamagedWidget( mWidget );
#if 0
RemoveDamagedWidget( mWidget );
#endif
}
PRBool nsWindow::IsChild() const
@ -128,8 +130,9 @@ NS_IMETHODIMP nsWindow::WidgetToScreen( const nsRect& aOldRect, nsRect& aNewRect
void nsWindow::DestroyNative(void)
{
RemoveResizeWidget();
RemoveDamagedWidget( mWidget );
#if 0
RemoveDamagedWidget( mWidget );
#endif
if ( mClientWidget )
{
PtDestroyWidget(mClientWidget );
@ -154,7 +157,8 @@ void nsWindow::DestroyNativeChildren(void)
{
for(PtWidget_t *w=PtWidgetChildFront( mWidget ); w; w=PtWidgetBrotherBehind( w ))
{
nsWindow *childWindow = NS_STATIC_CAST(nsWindow *, GetInstance(w) );
if( w->flags & Pt_DESTROYED ) continue;
nsWindow *childWindow = NS_STATIC_CAST(nsWindow *, GetInstance(w) );
if( childWindow && !childWindow->mIsDestroying) childWindow->Destroy();
}
}
@ -190,13 +194,15 @@ NS_IMETHODIMP nsWindow::Invalidate(PRBool aIsSynchronous)
{
if (!mWidget) return NS_OK; // mWidget will be null during printing.
if (!PtWidgetIsRealized(mWidget)) return NS_OK;
#if 0
/* Damage has to be relative Widget coords */
mUpdateArea->SetTo( 0,0, mBounds.width, mBounds.height );
if (aIsSynchronous) UpdateWidgetDamage();
else QueueWidgetDamage();
#else
nsWidget::Invalidate(aIsSynchronous);
#endif
return NS_OK;
}
@ -204,7 +210,7 @@ NS_IMETHODIMP nsWindow::Invalidate(const nsRect &aRect, PRBool aIsSynchronous)
{
if (!mWidget) return NS_OK; // mWidget will be null during printing.
if (!PtWidgetIsRealized(mWidget)) return NS_OK;
#if 0
/* Offset the rect by the mBounds X,Y to fix damaging inside widget in test14 */
if (mWindowType == eWindowType_popup) mUpdateArea->Union(aRect.x, aRect.y, aRect.width, aRect.height);
else mUpdateArea->Union((aRect.x+mBounds.x), (aRect.y+mBounds.y), aRect.width, aRect.height);
@ -217,16 +223,19 @@ NS_IMETHODIMP nsWindow::Invalidate(const nsRect &aRect, PRBool aIsSynchronous)
{
QueueWidgetDamage();
}
#else
nsWidget::Invalidate(aRect, aIsSynchronous);
#endif
return NS_OK;
}
NS_IMETHODIMP nsWindow::InvalidateRegion(const nsIRegion* aRegion, PRBool aIsSynchronous)
{
nsIRegion *newRegion;
if (!mWidget) return NS_OK; // mWidget will be null during printing.
if (!PtWidgetIsRealized(mWidget)) return NS_OK;
#if 0
nsIRegion *newRegion;
newRegion = GetRegion( );
newRegion->SetTo( *aRegion );
@ -239,7 +248,9 @@ NS_IMETHODIMP nsWindow::InvalidateRegion(const nsIRegion* aRegion, PRBool aIsSyn
if (aIsSynchronous) UpdateWidgetDamage();
else QueueWidgetDamage();
#else
nsWidget::InvalidateRegion(aRegion,aIsSynchronous);
#endif
return NS_OK;
}
@ -297,10 +308,10 @@ NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) {
mIsToplevel = PR_FALSE;
break;
}
if ( mWindowType == eWindowType_child )
{
arg_count = 0;
arg_count = 0;
PtSetArg( &arg[arg_count++], Pt_ARG_POS, &pos, 0 );
PtSetArg( &arg[arg_count++], Pt_ARG_DIM, &dim, 0 );
PtSetArg( &arg[arg_count++], Pt_ARG_RESIZE_FLAGS, 0, Pt_RESIZE_XY_BITS );
@ -313,7 +324,7 @@ NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) {
else
{
// No border or decorations is the default
render_flags = 0;
render_flags = Ph_WM_RENDER_INLINE;
if( mWindowType != eWindowType_popup ) {
@ -324,10 +335,10 @@ NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) {
Ph_WM_RENDER_RESIZE | \
Ph_WM_RENDER_MAX | \
Ph_WM_RENDER_MIN | \
Ph_WM_RENDER_MENU
Ph_WM_RENDER_MENU
if( mBorderStyle & eBorderStyle_all ) render_flags = PH_BORDER_STYLE_ALL;
if( mBorderStyle & eBorderStyle_all ) render_flags |= PH_BORDER_STYLE_ALL;
else
{
if( mBorderStyle & eBorderStyle_border ) render_flags |= Ph_WM_RENDER_BORDER;
@ -339,8 +350,7 @@ NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) {
if( mBorderStyle & eBorderStyle_maximize ) render_flags |= Ph_WM_RENDER_MAX;
}
}
arg_count = 0;
arg_count = 0;
if (mWindowType == eWindowType_dialog)
{
// center on parent
@ -375,16 +385,17 @@ NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) {
PtSetArg( &arg[arg_count++], Pt_ARG_REGION_FLAGS, Ph_FORCE_FRONT, Ph_FORCE_FRONT );
PtSetArg( &arg[arg_count++], Pt_ARG_REGION_SENSE, sense | Ph_EV_DRAG|Ph_EV_EXPOSE, sense | Ph_EV_DRAG|Ph_EV_EXPOSE);
PtSetArg( &arg[arg_count++], Pt_ARG_REGION_OPAQUE, sense | Ph_EV_DRAG|Ph_EV_EXPOSE|Ph_EV_DRAW, sense |Ph_EV_DRAG|Ph_EV_EXPOSE|Ph_EV_DRAW);
PtSetArg( &arg[arg_count++], Pt_ARG_FLAGS, 0, Pt_GETS_FOCUS);
PtSetArg( &arg[arg_count++], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, Pt_GETS_FOCUS | Pt_DELAY_REALIZE);
PtSetArg( &arg[arg_count++], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0);
mWidget = PtCreateWidget( PtRegion, parentWidget, arg_count, arg);
// Must also create the client-area widget
arg_count = 0;
PtSetArg( &arg[arg_count++], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_ALL, -1 );
PtSetArg( &arg[arg_count++], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_ALL, ~0 );
PtSetArg( &arg[arg_count++], Pt_ARG_BORDER_WIDTH, 0 , 0 );
PtSetArg( &arg[arg_count++], Pt_ARG_MARGIN_WIDTH, 0 , 0 );
PtSetArg( &arg[arg_count++], Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
PhRect_t anch_offset = { 0, 0, 0, 0 };
PtSetArg( &arg[arg_count++], Pt_ARG_FILL_COLOR, Pg_GREEN, 0 );
PhRect_t anch_offset = {{0, 0},{0, 0}};
PtSetArg( &arg[arg_count++], Pt_ARG_ANCHOR_OFFSETS, &anch_offset, 0 );
PtSetArg( &arg[arg_count++], RDC_DRAW_FUNC, RawDrawFunc, 0 );
@ -396,8 +407,8 @@ NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) {
/* Dialog and TopLevel Windows */
PtSetArg( &arg[arg_count++], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, Pt_DELAY_REALIZE);
PtSetArg( &arg[arg_count++], Pt_ARG_WINDOW_RENDER_FLAGS, render_flags, 0xFFFFFFFF );
PtSetArg( &arg[arg_count++], Pt_ARG_FILL_COLOR, Pg_BLUE, 0 );
PtSetArg( &arg[arg_count++], Pt_ARG_WINDOW_RENDER_FLAGS, render_flags, -1 );
PtSetArg( &arg[arg_count++], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0 );
PtRawCallback_t cb_raw = { Ph_EV_INFO, EvInfo, NULL };
PtCallback_t cb_resize = { ResizeHandler, NULL };
@ -542,7 +553,7 @@ NS_METHOD nsWindow::Scroll( PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect ) {
PtEndFlux( widget);
PhRect_t source = { widget->area.pos.x, widget->area.pos.y, widget->area.pos.x+ widget->area.size.w, widget->area.pos.y + widget->area.size.h };
PhRect_t source = {{widget->area.pos.x, widget->area.pos.y},{widget->area.pos.x+ widget->area.size.w, widget->area.pos.y + widget->area.size.h}};
PhPoint_t point = { aDx, aDy };
PtBlit( widget, &source, &point );
@ -691,7 +702,7 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
Move(p.x, p.y); // the move should be in coordinates assuming the console is 0, 0
}
PtSetArg( &arg, Pt_ARG_DIM, &dim, 0 );
PtSetArg( &arg, Pt_ARG_DIM, &dim, 0 );
PtSetResources( mWidget, 1, &arg );
/* This fixes XUL dialogs */
if (mClientWidget) {
@ -781,12 +792,12 @@ NS_METHOD nsWindow::Show( PRBool bState ) {
if( mWindowType == eWindowType_popup ) {
EnableDamage( mWidget, PR_FALSE );
//EnableDamage( mWidget, PR_FALSE );
if( bState ) PtRealizeWidget( mWidget );
else PtUnrealizeWidget( mWidget );
EnableDamage( mWidget, PR_TRUE );
// EnableDamage( mWidget, PR_TRUE );
}
return nsWidget::Show(bState);
@ -809,7 +820,7 @@ void nsWindow::RawDrawFunc( PtWidget_t * pWidget, PhTile_t * damage )
PhTile_t * dmg = NULL;
PRBool aClipState;
nsPaintEvent pev;
PgFlush();
if( !PtWidgetIsRealized( pWidget ) ) return;
if( !pWin || !pWin->mContext ) return;
@ -819,7 +830,6 @@ void nsWindow::RawDrawFunc( PtWidget_t * pWidget, PhTile_t * damage )
if( pWin->mIsResizing ) return;
if ( pWin->mEventCallback ) {
PhRect_t rect;
PhArea_t area;
PhPoint_t offset;
nsRect nsDmg;
@ -838,14 +848,16 @@ void nsWindow::RawDrawFunc( PtWidget_t * pWidget, PhTile_t * damage )
if( pWin->mWindowType == eWindowType_popup ) {
/* for a eWindowType_popup widget, consider damaging the whole widget - because of problems displaying comboboxes and color pickers */
new_damage = PhRectsToTiles( &pWidget->extent, 1 );
}
}
else {
if( damage->next ) tiles = PhCopyTiles( damage->next );
else tiles = PhRectsToTiles( &damage->rect, 1 );
if( damage->next )
tiles = PhCopyTiles( damage->next );
else
tiles = PhRectsToTiles( &damage->rect, 1 );
/* new_damage is the same as tiles2... I need to release it later */
new_damage = PhClipTilings( tiles, clip_tiles, NULL);
}
}
PhFreeTiles( clip_tiles );
if( new_damage == nsnull ) return; /* tiles and clip_tiles have been released */
@ -860,14 +872,13 @@ void nsWindow::RawDrawFunc( PtWidget_t * pWidget, PhTile_t * damage )
for( dmg = new_damage; dmg; dmg = dmg->next ) {
/* Copy the Damage Rect - Do I need to Translate it?? If so by what? offset? offset+area? */
nsDmg.x = dmg->rect.ul.x - area.pos.x;
nsDmg.y = dmg->rect.ul.y - area.pos.y;
nsDmg.width = dmg->rect.lr.x - dmg->rect.ul.x + 1;
nsDmg.height = dmg->rect.lr.y - dmg->rect.ul.y + 1;
nsDmg.x = dmg->rect.ul.x - area.pos.x;
nsDmg.y = dmg->rect.ul.y - area.pos.y;
nsDmg.width = dmg->rect.lr.x - dmg->rect.ul.x + 1;
nsDmg.height = dmg->rect.lr.y - dmg->rect.ul.y + 1;
if( (nsDmg.width <= 0 ) || (nsDmg.height <= 0 ) ) { /* Move to the next Damage Tile */
if( (nsDmg.width <= 0 ) || (nsDmg.height <= 0 ) ) /* Move to the next Damage Tile */
continue;
}
/* Re-Setup Paint Event */
pWin->InitEvent(pev, NS_PAINT);
@ -885,12 +896,12 @@ void nsWindow::RawDrawFunc( PtWidget_t * pWidget, PhTile_t * damage )
/* You can turn off most drawing if you take this out */
result = pWin->DispatchWindowEvent(&pev);
}
}
}
NS_RELEASE(pev.renderingContext);
PhFreeTiles( new_damage );
}
}
}
void nsWindow::ScreenToWidget( PhPoint_t &pt ) {
@ -911,14 +922,18 @@ PhTile_t *nsWindow::GetWindowClipping( ) {
PtWidget_t *w, *aWidget = (PtWidget_t *)GetNativeData(NS_NATIVE_WIDGET);
PhTile_t *clip_tiles = NULL, *last = NULL;
PhPoint_t w_offset;
PhRect_t w_extent;
PtWidgetOffset( aWidget, &w_offset );
PtWidgetExtent( aWidget, &w_extent);
w_offset.x += w_extent.ul.x;
w_offset.y += w_extent.ul.y;
for( w = PtWidgetChildFront( aWidget ); w; w=PtWidgetBrotherBehind( w ) ) {
long flags = PtWidgetFlags( w );
// if( (flags & Pt_OPAQUE) && (w != PtFindDisjoint(w)) && PtWidgetIsRealized( w ) ) {
if( (flags & (Pt_OPAQUE|Pt_REALIZED)) && (w != PtFindDisjoint(w)) ) {
if( (flags & (Pt_OPAQUE|Pt_REALIZED)) && !(PtIsDisjoint(w))) {
PhTile_t *tile = PhGetTile( );
if( !tile ) return NULL;
@ -1007,7 +1022,7 @@ void nsWindow::ResizeHoldOff() {
if( PR_FALSE == mResizeQueueInited ) {
// This is to guarantee that the Invalidation work-proc is in place prior to the resize work-proc.
if( !mDmgQueueInited ) Invalidate( PR_FALSE );
// if( !mDmgQueueInited ) Invalidate( PR_FALSE );
PtWidget_t *top = PtFindDisjoint( mWidget );