From 241622eda8cb858ba2ef99a930f85726175f683c Mon Sep 17 00:00:00 2001 From: "amardare%qnx.com" Date: Mon, 5 Jan 2004 23:04:07 +0000 Subject: [PATCH] Changes for the photon platform - it should not affect ( building/runtime ) other platforms. git-svn-id: svn://10.0.0.236/trunk@150895 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/embedding/browser/Makefile.in | 4 - mozilla/embedding/browser/photon/Makefile.in | 2 +- .../browser/photon/src/EmbedPrivate.cpp | 4 +- .../browser/photon/src/EmbedWindow.cpp | 6 +- .../embedding/browser/photon/src/Makefile.in | 30 +- mozilla/gfx/src/photon/nsDeviceContextPh.cpp | 57 ++-- mozilla/gfx/src/photon/nsDeviceContextPh.h | 5 +- .../gfx/src/photon/nsDeviceContextSpecPh.cpp | 18 ++ mozilla/gfx/src/photon/nsDrawingSurfacePh.cpp | 6 + mozilla/gfx/src/photon/nsFontMetricsPh.cpp | 1 - mozilla/gfx/src/photon/nsImagePh.cpp | 31 +- mozilla/gfx/src/photon/nsImagePh.h | 1 + .../gfx/src/photon/nsRenderingContextPh.cpp | 140 ++++++--- mozilla/gfx/src/photon/nsRenderingContextPh.h | 5 +- mozilla/widget/src/photon/Makefile.in | 9 +- mozilla/widget/src/photon/nsAppShell.cpp | 90 ++++++ mozilla/widget/src/photon/nsAppShell.h | 3 +- mozilla/widget/src/photon/nsClipboard.cpp | 296 +++++++++++------- mozilla/widget/src/photon/nsClipboard.h | 2 +- mozilla/widget/src/photon/nsFilePicker.cpp | 21 +- mozilla/widget/src/photon/nsToolkit.cpp | 27 -- mozilla/widget/src/photon/nsToolkit.h | 6 - mozilla/widget/src/photon/nsWidget.cpp | 32 +- mozilla/widget/src/photon/nsWidgetFactory.cpp | 24 ++ mozilla/widget/src/photon/nsWindow.cpp | 23 +- mozilla/widget/src/photon/nsWindow.h | 2 - 26 files changed, 562 insertions(+), 283 deletions(-) diff --git a/mozilla/embedding/browser/Makefile.in b/mozilla/embedding/browser/Makefile.in index 6c022a936b0..39bcad68b9e 100644 --- a/mozilla/embedding/browser/Makefile.in +++ b/mozilla/embedding/browser/Makefile.in @@ -27,10 +27,6 @@ include $(DEPTH)/config/autoconf.mk DIRS=webBrowser build chrome -ifdef MOZ_ENABLE_PHOTON -DIRS += photon -endif - ifeq ($(OS_ARCH),WINNT) ifndef MOZ_NO_ACTIVEX_SUPPORT DIRS += activex/src diff --git a/mozilla/embedding/browser/photon/Makefile.in b/mozilla/embedding/browser/photon/Makefile.in index 9099b4b3dbf..15f7c0984a5 100644 --- a/mozilla/embedding/browser/photon/Makefile.in +++ b/mozilla/embedding/browser/photon/Makefile.in @@ -25,7 +25,7 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -DIRS=src webserver +DIRS=src mozserver ifdef ENABLE_TESTS DIRS += tests diff --git a/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp b/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp index e3a5ea15963..e9ead137a21 100644 --- a/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp +++ b/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp @@ -348,7 +348,7 @@ EmbedPrivate::LoadCurrentURI(void) if (mURI.Length()) mNavigation->LoadURI(mURI.get(), // URI string nsIWebNavigation::LOAD_FLAGS_NONE, // Load flags - nsnull, // Referring URI + nsnull, // Refering URI nsnull, // Post data nsnull); // extra headers } @@ -627,7 +627,7 @@ EmbedPrivate::SaveURI(char *aURI, char *fname) if (mWindow && mFixup) { nsIURI* uri; - mFixup->CreateFixupURI( NS_LITERAL_STRING(aURI), 0, &(uri)); + mFixup->CreateFixupURI( NS_LITERAL_CSTRING(aURI), 0, &(uri)); return (mWindow->SaveURI(uri, fname)); } diff --git a/mozilla/embedding/browser/photon/src/EmbedWindow.cpp b/mozilla/embedding/browser/photon/src/EmbedWindow.cpp index 0e81bfa4328..02b9243378f 100644 --- a/mozilla/embedding/browser/photon/src/EmbedWindow.cpp +++ b/mozilla/embedding/browser/photon/src/EmbedWindow.cpp @@ -544,8 +544,11 @@ EmbedWindow::OnHideTooltip(void) return NS_OK; } + // nsIDNSListener +#if 0 + /* void OnStartLookup (in nsISupports ctxt, in string hostname); */ NS_IMETHODIMP EmbedWindow::OnStartLookup(nsISupports *ctxt, const char *hostname) { @@ -586,9 +589,10 @@ NS_IMETHODIMP EmbedWindow::OnFound(nsISupports *ctxt, const char *hostname, nsHo return NS_OK; } +#endif /* void OnStopLookup (in nsISupports ctxt, in string hostname, in nsresult status); */ -NS_IMETHODIMP EmbedWindow::OnStopLookup(nsISupports *ctxt, const char *hostname, nsresult status) +NS_IMETHODIMP EmbedWindow::OnLookupComplete(nsIDNSRequest *aRequest, nsIDNSRecord *aRecord, nsresult aStatus) { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/mozilla/embedding/browser/photon/src/Makefile.in b/mozilla/embedding/browser/photon/src/Makefile.in index 28d1619ff00..ece1e9d2a8b 100644 --- a/mozilla/embedding/browser/photon/src/Makefile.in +++ b/mozilla/embedding/browser/photon/src/Makefile.in @@ -21,7 +21,7 @@ DEPTH = ../../../.. topsrcdir = @top_srcdir@ srcdir = @srcdir@ -VPATH = @srcdir@ +VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk @@ -114,14 +114,20 @@ ifdef BUILD_STATIC_LIBS # This is so sick! We'll work backwards from the embedding manifest to # produce the set of components that we need to link in to a # ``minimal'' embedding harness. +ifdef MINIMO +EMBED_MANIFEST=$(topsrcdir)/embedding/config/minimo-unix +else EMBED_MANIFEST=$(topsrcdir)/embedding/config/basebrowser-qnx +endif ifdef MOZ_FAT_EMBED EMBED_LINK_COMPS=$(FINAL_LINK_COMPS) EMBED_LINK_COMP_NAMES=$(FINAL_LINK_COMP_NAMES) +EMBED_LINK_COMP_MODULES = $(FINAL_LINK_COMP_NAMES) else EMBED_LINK_COMPS=embed-link-comps EMBED_LINK_COMP_NAMES=embed-link-comp-names +EMBED_LINK_COMP_MODULES = embed-link-comp-modules endif # Create a map that we can use to go from library name to component @@ -149,6 +155,7 @@ embed-link-comps: $(EMBED_MANIFEST) components sed -e 's.^components/lib..' -e 's/\.so//' | \ sort | \ join -o 1.1 - components > $@ + sort -u -o $@ $@ # Compute the symbols we'll need for the ``minimal embedding client'' # by joining the compoent list with the sorted list of embedding @@ -156,13 +163,26 @@ embed-link-comps: $(EMBED_MANIFEST) components embed-link-comp-names: embed-link-comps components sort embed-link-comps | join -o 1.1 - components > $@ #sort embed-link-comps | join -o 2.2 - components > $@ + sort -u -o $@ $@ -EmbedComponents.cpp: EmbedComponents.cpp.in Makefile Makefile.in $(EMBED_LINK_COMP_NAMES) +# since embed-link-comp-names is filled with the static library names, we cannot use them - we need something +# filled with the modules names ( foe instance nsCookieModule instead of cookie +embed-link-comp-modules: embed-link-comp-names + for i in `cat embed-link-comp-names` ; \ + do ( \ + objdump -x ../../../../dist/lib/components/lib$$i.a | \ + grep _gModuleInfo | \ + awk '{ print $$6; }' | \ + sed -e "s/_gModuleInfo//" ) ; \ + done \ + > $@ + +EmbedComponents.cpp: EmbedComponents.cpp.in Makefile Makefile.in $(EMBED_LINK_COMP_MODULES) cat $< | \ - sed -e "s|%DECL_NSGETMODULES%|$(foreach m,$(shell cat $(EMBED_LINK_COMP_NAMES)),DECL_NSGETMODULE($(m)))|" | \ - sed -e "s|%MODULE_LIST%|$(foreach m, $(shell cat $(EMBED_LINK_COMP_NAMES)),MODULE($(m)),)|" \ + sed -e "s|%DECL_NSGETMODULES%|$(foreach m,$(shell cat $(EMBED_LINK_COMP_MODULES)),DECL_NSGETMODULE($(m)))|" | \ + sed -e "s|%MODULE_LIST%|$(foreach m, $(shell cat $(EMBED_LINK_COMP_MODULES)),MODULE($(m)),)|" \ > $@ -GARBAGE += EmbedComponents.cpp embed-link-comp-names embed-link-comps components +GARBAGE += EmbedComponents.cpp embed-link-comp-names embed-link-comps components embed-link-comp-modules endif diff --git a/mozilla/gfx/src/photon/nsDeviceContextPh.cpp b/mozilla/gfx/src/photon/nsDeviceContextPh.cpp index 477543f9a2a..4d732e92673 100644 --- a/mozilla/gfx/src/photon/nsDeviceContextPh.cpp +++ b/mozilla/gfx/src/photon/nsDeviceContextPh.cpp @@ -77,7 +77,7 @@ nsDeviceContextPh :: nsDeviceContextPh( ) mSpec = nsnull; mDC = nsnull; - mIsPrinting = 0; + mIsPrintingStart = 0; } nsDeviceContextPh :: ~nsDeviceContextPh( ) { @@ -132,17 +132,11 @@ nsresult nsDeviceContextPh :: Init( nsNativeDeviceContext aContext, nsIDeviceCon mAppUnitsToDevUnits = (a2d / t2d) * mTwipsToPixels; mDevUnitsToAppUnits = 1.0f / mAppUnitsToDevUnits; - // for printers - const PhDim_t *psize; - PhDim_t dim; - PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext(); + int w, h; + GetPrinterRect( &w, &h ); + mWidthFloat = w; + mHeightFloat = h; - PpPrintGetPC(pc, Pp_PC_PAPER_SIZE, (const void **)&psize ); - mWidthFloat = (float)(psize->w / 10); - mHeightFloat = (float)(psize->h / 10); - dim.w = psize->w / 10; - dim.h = psize->h / 10; - PpPrintSetPC(pc, INITIAL_PC, 0 , Pp_PC_SOURCE_SIZE, &dim ); return NS_OK; } @@ -226,6 +220,14 @@ void nsDeviceContextPh :: CommonInit( nsNativeDeviceContext aDC ) { } NS_IMETHODIMP nsDeviceContextPh :: CreateRenderingContext( nsIRenderingContext *&aContext ) { + +#ifdef NS_PRINT_PREVIEW + // Defer to Alt when there is one + if(mAltDC && ((mUseAltDC & kUseAltDCFor_CREATERC_PAINT) || (mUseAltDC & kUseAltDCFor_CREATERC_REFLOW))) { + return mAltDC->CreateRenderingContext(aContext); + } +#endif + nsIRenderingContext *pContext; nsresult rv; nsDrawingSurfacePh *surf; @@ -419,19 +421,6 @@ NS_IMETHODIMP nsDeviceContextPh :: GetSystemFont( nsSystemFontID aID, nsFont *aF } -NS_IMETHODIMP nsDeviceContextPh :: GetClientRect( nsRect &aRect ) { - nsresult rv = NS_OK; - if( mIsPrinting ) { //( mSpec ) - // we have a printer device - aRect.x = 0; - aRect.y = 0; - aRect.width = NSToIntRound(mWidth * mDevUnitsToAppUnits); - aRect.height = NSToIntRound(mHeight * mDevUnitsToAppUnits); - } - else rv = GetRect ( aRect ); - return rv; - } - NS_IMETHODIMP nsDeviceContextPh :: CheckFontExistence( const nsString& aFontName ) { char *fontName = ToNewCString(aFontName); @@ -485,11 +474,13 @@ printf( "\t\t Not Found in cache\n" ); NS_IMETHODIMP nsDeviceContextPh :: GetDeviceSurfaceDimensions( PRInt32 &aWidth, PRInt32 &aHeight ) { - if( mIsPrinting ) { //(mSpec) - aWidth = NSToIntRound(mWidthFloat * mDevUnitsToAppUnits); - aHeight = NSToIntRound(mHeightFloat * mDevUnitsToAppUnits); - return NS_OK; + +#ifdef NS_PRINT_PREVIEW + // Defer to Alt when there is one + if (mAltDC && (mUseAltDC & kUseAltDCFor_SURFACE_DIM)) { + return mAltDC->GetDeviceSurfaceDimensions(aWidth, aHeight); } +#endif if( mWidth == -1 ) mWidth = NSToIntRound(mWidthFloat * mDevUnitsToAppUnits); if( mHeight == -1 ) mHeight = NSToIntRound(mHeightFloat * mDevUnitsToAppUnits); @@ -565,7 +556,6 @@ NS_IMETHODIMP nsDeviceContextPh :: BeginDocument(PRUnichar *t, PRUnichar* aPrint if( mSpec ) { PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext(); PpStartJob(pc); - mIsPrinting = 1; mIsPrintingStart = 1; } return NS_OK; @@ -575,7 +565,6 @@ NS_IMETHODIMP nsDeviceContextPh :: EndDocument( void ) { if( mSpec ) { PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext(); PpEndJob(pc); - mIsPrinting = 0; } return NS_OK; } @@ -587,9 +576,11 @@ NS_IMETHODIMP nsDeviceContextPh :: AbortDocument( void ) { NS_IMETHODIMP nsDeviceContextPh :: BeginPage( void ) { if( mSpec ) { PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext(); - if( !mIsPrintingStart ) PpPrintNewPage( pc ); + if( mIsPrintingStart ) { + PpPrintNewPage( pc ); + mIsPrintingStart = 0; + } PpContinueJob( pc ); - mIsPrintingStart = 0; } return NS_OK; } @@ -602,8 +593,6 @@ NS_IMETHODIMP nsDeviceContextPh :: EndPage( void ) { return NS_OK; } -int nsDeviceContextPh :: IsPrinting( void ) { return mIsPrinting ? 1 : 0; } - /* Get the size and color depth of the display */ diff --git a/mozilla/gfx/src/photon/nsDeviceContextPh.h b/mozilla/gfx/src/photon/nsDeviceContextPh.h index 55e7f27359a..f10b422d9d5 100644 --- a/mozilla/gfx/src/photon/nsDeviceContextPh.h +++ b/mozilla/gfx/src/photon/nsDeviceContextPh.h @@ -108,7 +108,7 @@ public: NS_IMETHOD CheckFontExistence(const nsString& aFontName); NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight); - NS_IMETHOD GetClientRect(nsRect &aRect); + inline NS_IMETHOD GetClientRect(nsRect &aRect) { return GetRect ( aRect ); } NS_IMETHOD GetRect(nsRect &aRect); NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice, @@ -130,7 +130,6 @@ public: static int prefChanged(const char *aPref, void *aClosure); nsresult SetDPI(PRInt32 dpi); - int IsPrinting(void); protected: @@ -155,7 +154,7 @@ protected: static nscoord mDpi; - PRBool mIsPrinting, mIsPrintingStart; + PRBool mIsPrintingStart; private: nsCOMPtr mScreenManager; diff --git a/mozilla/gfx/src/photon/nsDeviceContextSpecPh.cpp b/mozilla/gfx/src/photon/nsDeviceContextSpecPh.cpp index de8033f68a7..e3375aefd63 100644 --- a/mozilla/gfx/src/photon/nsDeviceContextSpecPh.cpp +++ b/mozilla/gfx/src/photon/nsDeviceContextSpecPh.cpp @@ -127,6 +127,13 @@ NS_IMETHODIMP nsDeviceContextSpecPh :: Init(nsIWidget* aWidget, char rev = reversed == PR_TRUE ? 1 : 0; PpSetPC( mPC, Pp_PC_REVERSED, &rev, 0 ); + double margin_top, margin_left, margin_right, margin_bottom; + PhRect_t rmargin = { { 0, 0 }, { 0, 0 } }; + aPS->GetMarginTop( &margin_top ); + aPS->GetMarginLeft( &margin_left ); + aPS->GetMarginRight( &margin_right ); + aPS->GetMarginBottom( &margin_bottom ); + PRInt16 unit; double width, height; @@ -140,13 +147,24 @@ NS_IMETHODIMP nsDeviceContextSpecPh :: Init(nsIWidget* aWidget, if( unit == nsIPrintSettings::kPaperSizeInches ) { dim.w = width * 1000; dim.h = height * 1000; + + rmargin.ul.x = margin_left * 1000; + rmargin.ul.y = margin_top * 1000; + rmargin.lr.x = margin_right * 1000; + rmargin.lr.y = margin_bottom * 1000; } else if( unit == nsIPrintSettings::kPaperSizeMillimeters ) { dim.w = short(NS_TWIPS_TO_INCHES(NS_MILLIMETERS_TO_TWIPS(float(width*1000)))); dim.h = short(NS_TWIPS_TO_INCHES(NS_MILLIMETERS_TO_TWIPS(float(height*1000)))); + + rmargin.ul.x = short(NS_TWIPS_TO_INCHES(NS_MILLIMETERS_TO_TWIPS(float(margin_left*1000)))); + rmargin.ul.y = short(NS_TWIPS_TO_INCHES(NS_MILLIMETERS_TO_TWIPS(float(margin_top*1000)))); + rmargin.lr.x = short(NS_TWIPS_TO_INCHES(NS_MILLIMETERS_TO_TWIPS(float(margin_right*1000)))); + rmargin.lr.y = short(NS_TWIPS_TO_INCHES(NS_MILLIMETERS_TO_TWIPS(float(margin_bottom*1000)))); } PpSetPC( mPC, Pp_PC_PAPER_SIZE, &dim, 0 ); + PpSetPC( mPC, Pp_PC_NONPRINT_MARGINS, &rmargin, 0 ); } else { /* silent is set - used when the call is comming from the embedded version */ PRInt32 p; diff --git a/mozilla/gfx/src/photon/nsDrawingSurfacePh.cpp b/mozilla/gfx/src/photon/nsDrawingSurfacePh.cpp index 194bf61a908..74bf3656f61 100644 --- a/mozilla/gfx/src/photon/nsDrawingSurfacePh.cpp +++ b/mozilla/gfx/src/photon/nsDrawingSurfacePh.cpp @@ -222,6 +222,9 @@ NS_IMETHODIMP nsDrawingSurfacePh :: Init( PRUint32 aWidth, PRUint32 aHeight, PRU mDrawContext = (PhDrawContext_t *)PdCreateOffscreenContext(0, mWidth, mHeight, 0); if( !mDrawContext ) return NS_ERROR_FAILURE; + PhDCSetCurrent( mDrawContext ); + PgSetDrawBufferSize( 0xffff ); + nsresult rv; nsCOMPtr prefs(do_GetService(kPrefCID, &rv)); if (NS_SUCCEEDED(rv)) { @@ -246,6 +249,9 @@ int nsDrawingSurfacePh::prefChanged(const char *aPref, void *aClosure) surface->mDrawContext = (PhDrawContext_t *)PdCreateOffscreenContext(0, surface->mWidth, surface->mHeight, 0); if( !surface->mDrawContext ) return NS_ERROR_FAILURE; + PhDCSetCurrent( surface->mDrawContext ); + PgSetDrawBufferSize( 0xffff ); + PgDestroyGC(surface->mDrawContext->gc); surface->mDrawContext->gc = surface->mGC; /* use the gc provided */ diff --git a/mozilla/gfx/src/photon/nsFontMetricsPh.cpp b/mozilla/gfx/src/photon/nsFontMetricsPh.cpp index 84a89d0e961..c2d8ddae39f 100644 --- a/mozilla/gfx/src/photon/nsFontMetricsPh.cpp +++ b/mozilla/gfx/src/photon/nsFontMetricsPh.cpp @@ -233,7 +233,6 @@ printf( "\tCall PfLoadMetrics for NSFullFontName=%s\n", NSFullFontName ); gFontMetricsCache->Put(&key, node); - PfLoadFont( NSFullFontName, PHFONT_LOAD_METRICS, nsnull ); PfLoadMetrics( NSFullFontName ); } diff --git a/mozilla/gfx/src/photon/nsImagePh.cpp b/mozilla/gfx/src/photon/nsImagePh.cpp index 939bea17599..5f76939b6c9 100644 --- a/mozilla/gfx/src/photon/nsImagePh.cpp +++ b/mozilla/gfx/src/photon/nsImagePh.cpp @@ -339,33 +339,44 @@ nsresult nsImagePh :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMas break; case nsMaskRequirements_kNeeds1Bit: + { mAlphaRowBytes = (aWidth + 7) / 8; mAlphaDepth = 1; // 32-bit align each row mAlphaRowBytes = (mAlphaRowBytes + 3) & ~0x3; - mAlphaBits = new PRUint8[mAlphaRowBytes * aHeight]; + int alphasize = mAlphaRowBytes * aHeight; + mAlphaBits = new PRUint8[ alphasize ]; + memset( mAlphaBits, 0, alphasize ); + mAlphaWidth = aWidth; mAlphaHeight = aHeight; + } break; case nsMaskRequirements_kNeeds8Bit: + { mAlphaRowBytes = aWidth; mAlphaDepth = 8; // 32-bit align each row mAlphaRowBytes = (mAlphaRowBytes + 3) & ~0x3; - mAlphaBits = new PRUint8[mAlphaRowBytes * aHeight]; + + int alphasize = mAlphaRowBytes * aHeight; + mAlphaBits = new PRUint8[ alphasize ]; + memset( mAlphaBits, 0, alphasize ); + mAlphaWidth = aWidth; mAlphaHeight = aHeight; + } break; } mPhImage.image_tag = PtCRC((char *)mImageBits, mSizeImage); mPhImage.image = (char *)mImageBits; mPhImage.size.w = mWidth; - mPhImage.size.h = mHeight; + mPhImage.size.h = 0; mRowBytes = mPhImage.bpl = mNumBytesPixel * mWidth; mPhImage.type = type; if (aMaskRequirements == nsMaskRequirements_kNeeds1Bit) @@ -449,16 +460,19 @@ NS_IMETHODIMP nsImagePh :: Draw(nsIRenderingContext &aContext, nsDrawingSurface map.bpp = mAlphaDepth; map.map = (char *)mAlphaBits; PgSetAlphaBlend(&map, 0); + PgAlphaOn(); PgDrawRepPhImagemx( &mPhImage, 0, &pos, &rep, &space ); PgAlphaOff(); + + PgSetAlphaBlend( NULL, 0 ); /* this shouldn't be necessary, but the ph lib's gc is holding onto our mAlphaBits */ } PgSetMultiClip( 0, NULL ); return NS_OK; } - else { + else if( mPhImage.size.h > 0 ) { /* keeping the proportions, what is the size of mPhImageZoom that can give use the aDWidth and aDHeight? */ PRInt32 scaled_w = aDWidth * mPhImage.size.w / aSWidth; @@ -503,10 +517,12 @@ NS_IMETHODIMP nsImagePh :: Draw(nsIRenderingContext &aContext, nsDrawingSurface map.bpp = mAlphaDepth; map.map = (char *)mAlphaBits; PgSetAlphaBlend(&map, 0); + PgAlphaOn(); PgDrawPhImagemx( &pos, use_zoom ? mPhImageZoom : &mPhImage, 0 ); PgAlphaOff(); - + + PgSetAlphaBlend( NULL, 0 ); /* this shouldn't be necessary, but the ph lib's gc is holding onto our mAlphaBits */ } PgSetMultiClip( 0, NULL ); } @@ -557,9 +573,12 @@ NS_IMETHODIMP nsImagePh :: Draw(nsIRenderingContext &aContext, nsDrawingSurface map.bpp = mAlphaDepth; map.map = (char *)mAlphaBits; PgSetAlphaBlend(&map, 0); + PgAlphaOn(); PgDrawPhImagemx( &pos, &mPhImage, 0 ); PgAlphaOff(); + + PgSetAlphaBlend( NULL, 0 ); /* this shouldn't be necessary, but the ph lib's gc is holding onto our mAlphaBits */ } } @@ -767,7 +786,7 @@ NS_IMETHODIMP nsImagePh::DrawToImage(nsIImage* aDstImage, darea.size.w = sarea.size.w = aDWidth; darea.size.h = sarea.size.h = aDHeight; - if ((aDWidth != mPhImage.size.w) || (aDHeight != mPhImage.size.h)) + if( mPhImage.size.h > 0 && ( aDWidth != mPhImage.size.w || aDHeight != mPhImage.size.h ) ) { release = 1; if ((aDHeight * mPhImage.bpl) < IMAGE_SHMEM_THRESHOLD) diff --git a/mozilla/gfx/src/photon/nsImagePh.h b/mozilla/gfx/src/photon/nsImagePh.h index be4321c2e05..ae4447ca9c9 100644 --- a/mozilla/gfx/src/photon/nsImagePh.h +++ b/mozilla/gfx/src/photon/nsImagePh.h @@ -107,6 +107,7 @@ public: if( y > mDecodedY2 ) mDecodedY2 = y; if( x > mDecodedX2 ) mDecodedX2 = x; mDirtyFlags = aFlags; + mPhImage.size.h = mDecodedY2; } virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements); diff --git a/mozilla/gfx/src/photon/nsRenderingContextPh.cpp b/mozilla/gfx/src/photon/nsRenderingContextPh.cpp index 84e7af6a94f..941d5103ac1 100644 --- a/mozilla/gfx/src/photon/nsRenderingContextPh.cpp +++ b/mozilla/gfx/src/photon/nsRenderingContextPh.cpp @@ -452,7 +452,7 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawLine( nscoord aX0, nscoord aY0, nscoor { mTranMatrix->TransformCoord( &aX0, &aY0 ); mTranMatrix->TransformCoord( &aX1, &aY1 ); - + if( aY0 != aY1 ) aY1--; if( aX0 != aX1 ) aX1--; @@ -464,7 +464,6 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawLine( nscoord aX0, nscoord aY0, nscoor NS_IMETHODIMP nsRenderingContextPh :: DrawStdLine( nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1 ) { - if( aY0 != aY1 ) aY1--; if( aX0 != aX1 ) aX1--; @@ -555,7 +554,33 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawPolygon( const nsPoint aPoints[], PRIn pts[i].x = x; pts[i].y = y; } + UpdateGC(); + + + if( aNumPoints == 4 ) { + /* this code makes the edges of the controls like buttons, texts etc appear less heavy */ + int dx = pts[1].x - pts[0].x; + int dy = pts[1].y - pts[0].y; + if( !dx ) { + /* the edge is vertical - move us (0,1) closer to the other 2 points (2,3) */ + pts[0].y++; + pts[1].y--; + int diff = pts[3].x > pts[0].x ? 1 : -1; + pts[0].x += diff; + pts[1].x += diff; + } + if( !dy ) { + /* the edge is horizontal - move the other 2 points (2,3) closer to us (0,1) */ + pts[2].x++; + pts[3].x--; + int diff = pts[3].y > pts[0].y ? -1 : 1; + pts[2].y += diff; + pts[3].y += diff; + } + } + + PgDrawPolygon( pts, aNumPoints, &pos, Pg_DRAW_STROKE ); delete [] pts; } @@ -581,7 +606,33 @@ NS_IMETHODIMP nsRenderingContextPh :: FillPolygon( const nsPoint aPoints[], PRIn pts[i].x = x; pts[i].y = y; } + UpdateGC(); + + + if( aNumPoints == 4 ) { + /* this code makes the edges of the controls like buttons, texts etc appear less heavy */ + int dx = pts[1].x - pts[0].x; + int dy = pts[1].y - pts[0].y; + if( !dx ) { + /* the edge is vertical - move us (0,1) closer to the other 2 points (2,3) */ + pts[0].y++; + pts[1].y--; + int diff = pts[3].x > pts[0].x ? 1 : -1; + pts[0].x += diff; + pts[1].x += diff; + } + if( !dy ) { + /* the edge is horizontal - move the other 2 points (2,3) closer to us (0,1) */ + pts[2].x++; + pts[3].x--; + int diff = pts[3].y > pts[0].y ? -1 : 1; + pts[2].y += diff; + pts[3].y += diff; + } + } + + PgDrawPolygon( pts, aNumPoints, &pos, Pg_DRAW_FILL ); delete [] pts; } @@ -680,54 +731,37 @@ NS_IMETHODIMP nsRenderingContextPh :: FillArc( nscoord aX, nscoord aY, nscoord a NS_IMETHODIMP nsRenderingContextPh :: GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth ) { PhRect_t extent; - nsresult ret_code = NS_ERROR_FAILURE; - - aWidth = 0; // Initialize to zero in case we fail. - - if( nsnull != mFontMetrics ) + + /* Check for the very common case of trying to get the width of a single space */ + if( aString[0] == ' ' && aLength == 1 ) + return mFontMetrics->GetSpaceWidth(aWidth); + + if( PfExtentText( &extent, NULL, mPhotonFontName, aString, aLength ) ) { - if( PfExtentText( &extent, NULL, mPhotonFontName, aString, aLength ) ) - { - aWidth = NSToCoordRound((int) ((extent.lr.x - extent.ul.x + 1) * mP2T)); - ret_code = NS_OK; - } + aWidth = NSToCoordRound((int) ((extent.lr.x - extent.ul.x + 1) * mP2T)); + return NS_OK; } - else - ret_code = NS_ERROR_FAILURE; - return ret_code; + aWidth = 0; + return NS_ERROR_FAILURE; } NS_IMETHODIMP nsRenderingContextPh :: GetWidth( const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth, PRInt32 *aFontID ) { - nsresult ret_code = NS_ERROR_FAILURE; - - aWidth = 0; // Initialize to zero in case we fail. - if( nsnull != mFontMetrics ) { - NS_ConvertUCS2toUTF8 theUnicodeString (aString, aLength); - ret_code = GetWidth( theUnicodeString.get(), strlen(theUnicodeString.get()), aWidth ); - } - if( nsnull != aFontID ) - *aFontID = 0; - return ret_code; + NS_ConvertUCS2toUTF8 theUnicodeString (aString, aLength); + const char *s = theUnicodeString.get(); + return GetWidth( s, strlen(s), aWidth ); } NS_IMETHODIMP nsRenderingContextPh::GetTextDimensions(const PRUnichar* aString, PRUint32 aLength, nsTextDimensions& aDimensions, PRInt32* aFontID) { - nsresult ret_code = NS_ERROR_FAILURE; - - aDimensions.Clear(); - if( nsnull != mFontMetrics ) { - mFontMetrics->GetMaxAscent(aDimensions.ascent); - mFontMetrics->GetMaxDescent(aDimensions.descent); + mFontMetrics->GetMaxAscent(aDimensions.ascent); + mFontMetrics->GetMaxDescent(aDimensions.descent); - NS_ConvertUCS2toUTF8 theUnicodeString (aString, aLength); - ret_code = GetWidth( theUnicodeString.get(), strlen(theUnicodeString.get()), aDimensions.width ); - } - if (nsnull != aFontID) - *aFontID = 0; - return NS_OK; + NS_ConvertUCS2toUTF8 theUnicodeString (aString, aLength); + const char *s = theUnicodeString.get(); + return GetWidth( s, strlen(s), aDimensions.width ); } NS_IMETHODIMP nsRenderingContextPh::DrawString(const char *aString, PRUint32 aLength, @@ -742,25 +776,39 @@ NS_IMETHODIMP nsRenderingContextPh::DrawString(const char *aString, PRUint32 aLe PgSetFont( mPhotonFontName ); +#if 0 /* turn this feature off since it has problems */ if( !aSpacing ) { +#endif mTranMatrix->TransformCoord( &aX, &aY ); PhPoint_t pos = { aX, aY }; PgDrawTextChars( aString, aLength, &pos, Pg_TEXT_LEFT); +#if 0 /* turn this feature off since it has problems */ } else { + nscoord* trSpacing; + nscoord trSpacingArray[500]; + if( aLength > 500 ) + trSpacing = new nscoord[aLength]; + else trSpacing = trSpacingArray; + + mTranMatrix->ScaleXCoords(aSpacing, aLength, trSpacing); + nscoord x = aX; nscoord y = aY; - const char* end = aString + aLength; - while( aString < end ) { - char ch = *aString++; - nscoord xx = x; - nscoord yy = y; - mTranMatrix->TransformCoord(&xx, &yy); - PhPoint_t pos = { xx, yy }; - PgDrawText( &ch, 1, &pos, Pg_TEXT_LEFT); - x += *aSpacing++; + mTranMatrix->TransformCoord(&x, &y); + PhPoint_t pos = { x, y }; + + const char *current = aString; + for( int i=0; iGetSpaceWidth(aWidth); return GetWidth( &aC, 1, aWidth ); } @@ -306,7 +306,6 @@ public: inline NS_IMETHODIMP GetTextDimensions(const char* aString, PRUint32 aLength, nsTextDimensions& aDimensions) { - aDimensions.Clear(); mFontMetrics->GetMaxAscent(aDimensions.ascent); mFontMetrics->GetMaxDescent(aDimensions.descent); return GetWidth(aString, aLength, aDimensions.width); @@ -314,7 +313,7 @@ public: NS_IMETHOD GetTextDimensions(const PRUnichar *aString, PRUint32 aLength, nsTextDimensions& aDimensions, PRInt32 *aFontID); - + inline NS_IMETHODIMP DrawImage(nsIImage *aImage, nscoord aX, nscoord aY) { diff --git a/mozilla/widget/src/photon/Makefile.in b/mozilla/widget/src/photon/Makefile.in index 33e8261fe5c..1786ccd6598 100644 --- a/mozilla/widget/src/photon/Makefile.in +++ b/mozilla/widget/src/photon/Makefile.in @@ -32,8 +32,8 @@ EXPORT_LIBRARY = 1 IS_COMPONENT = 1 MODULE_NAME = nsWidgetPhModule REQUIRES = xpcom \ - string \ - appshell \ + string \ + appshell \ gfx \ pref \ dom \ @@ -62,6 +62,11 @@ CPPSRCS = \ nsSound.cpp \ $(NULL) +ifdef MOZ_ENABLE_XREMOTE +REQUIRES += xremoteservice +CPPSRCS += nsPhMozRemoteHelper.cpp +endif + SHARED_LIBRARY_LIBS = $(DIST)/lib/libxpwidgets_s.a EXTRA_DSO_LDOPTS = $(MOZ_COMPONENT_LIBS) \ diff --git a/mozilla/widget/src/photon/nsAppShell.cpp b/mozilla/widget/src/photon/nsAppShell.cpp index e3d2be26a77..23c2868fd13 100644 --- a/mozilla/widget/src/photon/nsAppShell.cpp +++ b/mozilla/widget/src/photon/nsAppShell.cpp @@ -43,11 +43,16 @@ #include "nsIEventQueueService.h" #include "nsICmdLineService.h" +#ifdef MOZ_ENABLE_XREMOTE +#include +#endif + #include #include "nsIWidget.h" #include "nsIPref.h" #include "nsPhWidgetLog.h" +#include "nsCRT.h" #include #include @@ -58,6 +63,9 @@ PRBool nsAppShell::gExitMainLoop = PR_FALSE; static PLHashTable *sQueueHashTable = nsnull; static PLHashTable *sCountHashTable = nsnull; +// Set our static member +PRBool nsAppShell::mPtInited = PR_FALSE; + //------------------------------------------------------------------------- // // XPCOM CIDs @@ -125,6 +133,55 @@ static int event_processor_callback(int fd, void *data, unsigned mode) } + +//------------------------------------------------------------------------- +// +// A client has connected and probably will want to xremote control us +// +//------------------------------------------------------------------------- + +#ifdef MOZ_ENABLE_XREMOTE + +/* the connector name that a client can use to remote control this instance of mozilla */ +#define BrowserRemoteServerName "MozillaBrowserRemoteServer" +#define MailRemoteServerName "MozillaMailRemoteServer" + +#define MOZ_REMOTE_MSG_TYPE 100 + +static void const * RemoteMsgHandler( PtConnectionServer_t *connection, void *user_data, + unsigned long type, void const *msg, unsigned len, unsigned *reply_len ) +{ + if( type != MOZ_REMOTE_MSG_TYPE ) return NULL; + + /* we are given strings and we reply with strings */ + char *command = ( char * ) msg, *response = NULL; + + // parse the command + nsCOMPtr remoteService; + remoteService = do_GetService(NS_IXREMOTESERVICE_CONTRACTID); + + if( remoteService ) { + command[len] = 0; + /* it seems we can pass any non-null value as the first argument - if this changes, pass a valid nsWidget* and move this code to nsWidget.cpp */ + remoteService->ParseCommand( (nsIWidget*)0x1, command, &response ); + } + + PtConnectionReply( connection, response ? strlen( response ) : 0, response ); + + if( response ) nsCRT::free( response ); + + return ( void * ) 1; /* return any non NULL value to indicate we handled the message */ +} + +static void client_connect( PtConnector_t *cntr, PtConnectionServer_t *csrvr, void *data ) +{ + PtConnectionMsgHandler_t handlers[] = { { 0, RemoteMsgHandler } }; + PtConnectionAddMsgHandlers( csrvr, handlers, sizeof(handlers)/sizeof(handlers[0]) ); +} + +#endif + + //------------------------------------------------------------------------- // // Create the application shell @@ -154,6 +211,38 @@ NS_IMETHODIMP nsAppShell::Create(int *bac, char **bav) argv = bav; } + /* + This used to be done in the init function of nsToolkit. It was moved here because the phoenix + browser may ( when -ProfileManager is used ) create/ListenToEventQueue of an nsAppShell before + the toolkit is initialized and ListenToEventQueue relies on the Pt being already initialized + */ + if( !mPtInited ) + { + PtInit( NULL ); + PtChannelCreate(); // Force use of pulses + mPtInited = PR_TRUE; + +#ifdef MOZ_ENABLE_XREMOTE + + char *RemoteServerName = BrowserRemoteServerName; + char *RemoteServerNameExtra = nsnull; + + if( argc > 0 && argv && argv[0] ) { + if( PL_strstr( argv[0], "Firebird" ) ) RemoteServerName = BrowserRemoteServerName; + else if( PL_strstr( argv[0], "thunderbird" ) ) RemoteServerName = MailRemoteServerName; + else { + /* full mozilla creates 2 connectors one for the browser side and another one for the mail side */ + RemoteServerName = BrowserRemoteServerName; + RemoteServerNameExtra = MailRemoteServerName; + } + } + + /* create a connector for the xremote control */ + PtConnectorCreate( RemoteServerName, client_connect, NULL ); + if( RemoteServerNameExtra ) PtConnectorCreate( RemoteServerNameExtra, client_connect, NULL ); +#endif + } + return NS_OK; } @@ -278,6 +367,7 @@ IntHashKey(PRInt32 key) NS_IMETHODIMP nsAppShell::ListenToEventQueue(nsIEventQueue *aQueue, PRBool aListen) { + if (!sQueueHashTable) { sQueueHashTable = PL_NewHashTable(3, (PLHashFunction)IntHashKey, PL_CompareValues, PL_CompareValues, 0, 0); diff --git a/mozilla/widget/src/photon/nsAppShell.h b/mozilla/widget/src/photon/nsAppShell.h index 40419d3f4c8..98ff1192a03 100644 --- a/mozilla/widget/src/photon/nsAppShell.h +++ b/mozilla/widget/src/photon/nsAppShell.h @@ -80,7 +80,8 @@ public: private: nsIEventQueue* mEventQueue; - int mFD; + int mFD; + static PRBool mPtInited; }; diff --git a/mozilla/widget/src/photon/nsClipboard.cpp b/mozilla/widget/src/photon/nsClipboard.cpp index 528a4b7ed29..d9c226d8c10 100644 --- a/mozilla/widget/src/photon/nsClipboard.cpp +++ b/mozilla/widget/src/photon/nsClipboard.cpp @@ -51,8 +51,9 @@ // unicode conversion #include "nsIPlatformCharset.h" +#include "nsICharsetConverterManager.h" -#define DEBUG_CLIPBOARD +//#define DEBUG_CLIPBOARD // Define this to enable the obsolete X cut buffer mechanism @@ -65,6 +66,8 @@ NS_IMPL_ISUPPORTS1(nsClipboard, nsIClipboard) #define Ph_CLIPBOARD_TYPE_IMAGE "IMAG" #define Ph_CLIPBOARD_TYPE_HTML "HTML" +static unsigned long get_flavour_timestamp( char *type ); + //------------------------------------------------------------------------- // // nsClipboard constructor @@ -73,7 +76,7 @@ NS_IMPL_ISUPPORTS1(nsClipboard, nsIClipboard) nsClipboard::nsClipboard() { #ifdef DEBUG_CLIPBOARD - //printf("nsClipboard::nsClipboard()\n"); + printf("nsClipboard::nsClipboard()\n"); #endif /* DEBUG_CLIPBOARD */ NS_INIT_ISUPPORTS(); @@ -92,7 +95,7 @@ nsClipboard::nsClipboard() nsClipboard::~nsClipboard() { #ifdef DEBUG_CLIPBOARD - // printf("nsClipboard::~nsClipboard()\n"); + printf("nsClipboard::~nsClipboard()\n"); #endif /* DEBUG_CLIPBOARD */ } @@ -144,7 +147,7 @@ NS_IMETHODIMP nsClipboard::GetData(nsITransferable * aTransferable, PRInt32 aWhi else { #ifdef DEBUG_CLIPBOARD - //printf(" nsClipboard::GetData(), aTransferable is NULL.\n"); + printf(" nsClipboard::GetData(), aTransferable is NULL.\n"); #endif } @@ -204,16 +207,16 @@ NS_IMETHODIMP nsClipboard::SetNativeClipboardData(PRInt32 aWhichClipboard) return (NS_ERROR_FAILURE); #ifdef DEBUG_CLIPBOARD - //printf(" nsClipboard::SetNativeClipboardData(%i)\n", aWhichClipboard); + printf(" nsClipboard::SetNativeClipboardData(%i)\n", aWhichClipboard); #endif /* DEBUG_CLIPBOARD */ - nsCOMPtr transferable(GetTransferable(aWhichClipboard)); + nsCOMPtr transferable(GetTransferable(aWhichClipboard)); // make sure we have a good transferable if (nsnull == transferable) { #ifdef DEBUG_CLIPBOARD - //printf("nsClipboard::SetNativeClipboardData(): no transferable!\n"); + printf("nsClipboard::SetNativeClipboardData(): no transferable!\n"); #endif return NS_ERROR_FAILURE; } @@ -243,7 +246,7 @@ NS_IMETHODIMP nsClipboard::SetNativeClipboardData(PRInt32 aWhichClipboard) nsXPIDLCString flavorStr; currentFlavor->ToString(getter_Copies(flavorStr)); - nsresult err = GetFormat( flavorStr, &cliphdr[index] ); + nsresult err = GetFormat( flavorStr, cliphdr[index].type ); if( err != NS_OK ) continue; @@ -252,18 +255,33 @@ NS_IMETHODIMP nsClipboard::SetNativeClipboardData(PRInt32 aWhichClipboard) transferable->GetTransferData( flavorStr, getter_AddRefs(genericDataWrapper), &dataLen ); nsPrimitiveHelpers::CreateDataFromPrimitive ( flavorStr, genericDataWrapper, &data, dataLen ); - if (strcmp(cliphdr[index].type, Ph_CLIPBOARD_TYPE_MOZ_BOOKMARK) == 0) + if( !strcmp(cliphdr[index].type, Ph_CLIPBOARD_TYPE_TEXT) || + !strcmp(cliphdr[index].type, Ph_CLIPBOARD_TYPE_HTML) || + !strcmp(cliphdr[index].type, Ph_CLIPBOARD_TYPE_MOZ_BOOKMARK) ) { - cliphdr[index].length = dataLen; - cliphdr[index].data = data; - } - else if (strcmp(cliphdr[index].type, Ph_CLIPBOARD_TYPE_TEXT) == 0) - { - int len = 0; - char *plain; - nsPrimitiveHelpers::ConvertUnicodeToPlatformPlainText( (PRUnichar*)data, dataLen/2, &plain, &len ); - cliphdr[index].length = len+1; - cliphdr[index].data = plain; + PRUnichar* castedUnicode = NS_REINTERPRET_CAST(PRUnichar*, data); + char *utf8String = ToNewUTF8String(nsDependentString(castedUnicode, dataLen/2)); + nsMemory::Free(NS_REINTERPRET_CAST(char*, data)); + + if( !strcmp(cliphdr[index].type, Ph_CLIPBOARD_TYPE_TEXT) ) + { + /* we have to create a null terminated string, because + PhClipboardCopyString does that and some other applications + rely on the null terminated thing + */ + PRInt32 len = strlen(utf8String); + char *temp = ( char * ) nsMemory::Alloc( len + 1 ); + memcpy( temp, utf8String, len ); + temp[len] = 0; + nsMemory::Free(NS_REINTERPRET_CAST(char*, utf8String)); + + cliphdr[index].length = len+1; + cliphdr[index].data = temp; + } + else { + cliphdr[index].length = strlen(utf8String); + cliphdr[index].data = utf8String; + } } index++; } @@ -271,7 +289,7 @@ NS_IMETHODIMP nsClipboard::SetNativeClipboardData(PRInt32 aWhichClipboard) PhClipboardCopy( 1, index, cliphdr ); for( PRUint32 k=0; k 0) { - void *clipPtr; - PhClipHeader cliptype; - PhClipHeader *cliphdr; - void *data = nsnull; - PRUint32 dataLen; + void *clipPtr; + PhClipHeader *cliphdr; + char *data = nsnull, type[8]; + PRUint32 dataLen; - clipPtr = PhClipboardPasteStart( 1 ); - if(!clipPtr) - return NS_ERROR_FAILURE; + clipPtr = PhClipboardPasteStart( 1 ); + if(!clipPtr) return NS_ERROR_FAILURE; - for ( PRUint32 i = 0; i < cnt; ++i ) + /* + Look at the timestamps of the data in the clipboard and eliminate the flavours if they are not synchronized. + We can have a HTML flavour from a previous copy and a TEXT flavour from a more recent copy from another application + ( from instance from ped or pterm ). The HTML flavour and TEXT flavour are desynchronized and we have + to use only the most recent one */ + unsigned long *dont_use_flavour = ( unsigned long * ) calloc( 1, cnt ); + if( !dont_use_flavour ) { + PhClipboardPasteFinish( clipPtr ); + return NS_ERROR_FAILURE; + } + + unsigned long max_time = 0; + PRUint32 i; + + for ( i = 0; i < cnt; ++i ) { nsCOMPtr genericFlavor; flavorList->GetElementAt ( i, getter_AddRefs(genericFlavor) ); @@ -338,65 +369,102 @@ nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable, { nsXPIDLCString flavorStr; currentFlavor->ToString ( getter_Copies(flavorStr) ); - nsresult err = GetFormat( flavorStr, &cliptype); + + nsresult err = GetFormat( flavorStr, type ); if (err != NS_OK) continue; - cliphdr = PhClipboardPasteType( clipPtr, cliptype.type ); - if (cliphdr) - { - int len_unicode; - PRUnichar *unicode; - - data = cliphdr->data; - dataLen = cliphdr->length; - - nsCOMPtr genericDataWrapper; - if (strcmp(cliptype.type, Ph_CLIPBOARD_TYPE_MOZ_BOOKMARK) == 0) - { - len_unicode = cliphdr->length; - nsPrimitiveHelpers::CreatePrimitiveForData ( flavorStr, cliphdr->data, len_unicode, getter_AddRefs(genericDataWrapper) ); - } - else if ((strcmp(cliptype.type, Ph_CLIPBOARD_TYPE_TEXT) == 0) || (strcmp(cliptype.type, Ph_CLIPBOARD_TYPE_HTML) == 0)) - { - nsPrimitiveHelpers::ConvertPlatformPlainTextToUnicode( (char*) data, dataLen, &unicode, &len_unicode ); - len_unicode--; - len_unicode *= 2; - nsPrimitiveHelpers::CreatePrimitiveForData ( flavorStr, unicode, len_unicode, getter_AddRefs(genericDataWrapper) ); - } - - aTransferable->SetTransferData(flavorStr, genericDataWrapper, len_unicode ); - break; - } + dont_use_flavour[i] = get_flavour_timestamp( type ); + if( dont_use_flavour[i] > max_time ) max_time = dont_use_flavour[i]; } } + + for ( i = 0; i < cnt; ++i ) + { + if( abs( dont_use_flavour[i] - max_time ) >= 4 ) + dont_use_flavour[i] = 1; /* this flavour is desynchronized */ + else dont_use_flavour[i] = 0; /* this flavour is ok */ + } + + for ( i = 0; i < cnt; ++i ) + { + if( dont_use_flavour[i] ) continue; /* this flavour is desynchronized */ + nsCOMPtr genericFlavor; + flavorList->GetElementAt ( i, getter_AddRefs(genericFlavor) ); + nsCOMPtr currentFlavor ( do_QueryInterface(genericFlavor) ); + if ( currentFlavor ) + { + nsXPIDLCString flavorStr; + currentFlavor->ToString ( getter_Copies(flavorStr) ); + + nsresult err = GetFormat( flavorStr, type ); + if (err != NS_OK) + continue; + + cliphdr = PhClipboardPasteType( clipPtr, type ); + if (cliphdr) + { + data = (char*)cliphdr->data; + + if( !strcmp(type, Ph_CLIPBOARD_TYPE_TEXT) ) + /* for the Ph_CLIPBOARD_TYPE_TEXT, we null terminate the data, since PhClipboardCopyString() does that */ + dataLen = cliphdr->length - 1; + else dataLen = cliphdr->length; + + + if( !strcmp(type, Ph_CLIPBOARD_TYPE_TEXT) || + !strcmp(type, Ph_CLIPBOARD_TYPE_HTML) || + !strcmp(type, Ph_CLIPBOARD_TYPE_MOZ_BOOKMARK) ) + { + nsresult rv; + PRInt32 outUnicodeLen; + PRUnichar *unicodeData = nsnull; + + // get the decoder + nsCOMPtr decoder; + nsCOMPtr ccm = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv); + rv = ccm->GetUnicodeDecoderRaw("UTF-8", getter_AddRefs(decoder)); + + if( NS_SUCCEEDED(rv) ) + { + + decoder->GetMaxLength(data, dataLen, &outUnicodeLen); // |outUnicodeLen| is number of chars + if (outUnicodeLen) { + unicodeData = NS_REINTERPRET_CAST(PRUnichar*, nsMemory::Alloc((outUnicodeLen + 1) * sizeof(PRUnichar))); + if ( unicodeData ) { + PRInt32 numberTmp = dataLen; + rv = decoder->Convert(data, &numberTmp, unicodeData, &outUnicodeLen); +#ifdef DEBUG_CLIPBOARD + if (numberTmp != dataLen) + printf("didn't consume all the bytes\n"); +#endif + + (unicodeData)[outUnicodeLen] = '\0'; // null terminate. Convert() doesn't do it for us + } + } // if valid length + + + data = NS_REINTERPRET_CAST(char*,unicodeData); + dataLen = outUnicodeLen * 2; + + nsCOMPtr genericDataWrapper; + nsPrimitiveHelpers::CreatePrimitiveForData( flavorStr, data, dataLen, getter_AddRefs(genericDataWrapper) ); + aTransferable->SetTransferData( flavorStr, genericDataWrapper, dataLen ); + + /* free the allocated memory */ + nsMemory::Free( unicodeData ); + + break; + } + } + } + } + } + + free( dont_use_flavour ); PhClipboardPasteFinish( clipPtr ); } -#if 0 - // We're back from the callback, no longer blocking: - mBlocking = PR_FALSE; - - // - // Now we have data in mSelectionData.data. - // We just have to copy it to the transferable. - // - - if ( foundData ) { - nsCOMPtr genericDataWrapper; - nsPrimitiveHelpers::CreatePrimitiveForData(foundFlavor.get(), mSelectionData.data, - mSelectionData.length, getter_AddRefs(genericDataWrapper)); - aTransferable->SetTransferData(foundFlavor.get(), - genericDataWrapper, - mSelectionData.length); - } - - // transferable is now owning the data, so we can free it. - nsMemory::Free(mSelectionData.data); - mSelectionData.data = nsnull; - mSelectionData.length = 0; -#endif - return NS_OK; } @@ -412,13 +480,13 @@ NS_IMETHODIMP nsClipboard::ForceDataToClipboard(PRInt32 aWhichClipboard) if (aWhichClipboard == kSelectionClipboard) return (NS_ERROR_FAILURE); #ifdef DEBUG_CLIPBOARD - //printf(" nsClipboard::ForceDataToClipboard()\n"); + printf(" nsClipboard::ForceDataToClipboard()\n"); #endif /* DEBUG_CLIPBOARD */ // make sure we have a good transferable - nsITransferable *transferable = GetTransferable(aWhichClipboard); + nsITransferable *transferable = GetTransferable(aWhichClipboard); - if (!transferable) + if (!transferable) return NS_ERROR_FAILURE; return NS_OK; @@ -440,7 +508,7 @@ nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList, // in GetNativeClipboardData(). From this point on, no client will // ever ask for text/plain explicitly. If they do, you must ASSERT! #ifdef DEBUG_CLIPBOARD -// printf(" nsClipboard::HasDataMatchingFlavors()\n {\n"); + printf(" nsClipboard::HasDataMatchingFlavors()\n {\n"); #endif nsresult res = NS_OK; @@ -453,7 +521,7 @@ nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList, nsCAutoString foundFlavor; if (cnt > 0) { void *clipPtr; - PhClipHeader cliptype; + char type[8]; PhClipHeader *cliphdr; clipPtr = PhClipboardPasteStart( 1 ); @@ -470,10 +538,10 @@ nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList, nsXPIDLCString flavorStr; currentFlavor->ToString ( getter_Copies(flavorStr) ); - nsresult err = GetFormat( flavorStr, &cliptype); + nsresult err = GetFormat( flavorStr, type ); if (err != NS_OK) continue; - cliphdr = PhClipboardPasteType( clipPtr, cliptype.type ); + cliphdr = PhClipboardPasteType( clipPtr, type ); if (cliphdr) { @@ -491,24 +559,19 @@ nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList, } -nsresult nsClipboard::GetFormat(const char* aMimeStr, PhClipHeader *cliphdr ) +nsresult nsClipboard::GetFormat(const char* aMimeStr, char *format ) { - nsCAutoString mimeStr ( CBufDescriptor(NS_CONST_CAST(char*,aMimeStr), PR_TRUE, PL_strlen(aMimeStr)+1) ); + nsCAutoString mimeStr ( CBufDescriptor(NS_CONST_CAST(char*,aMimeStr), PR_TRUE, PL_strlen(aMimeStr)+1) ); + int ret = NS_OK; - cliphdr->type[0]=0; - if (mimeStr.Equals(kUnicodeMime) || mimeStr.Equals(kHTMLMime) || mimeStr.Equals(kTextMime)) - strcpy( cliphdr->type, Ph_CLIPBOARD_TYPE_TEXT ); - else if (mimeStr.Equals(kHTMLMime)) - strcpy( cliphdr->type, Ph_CLIPBOARD_TYPE_HTML ); - else if (mimeStr.Equals("moz/bookmarkclipboarditem")) - strcpy( cliphdr->type, Ph_CLIPBOARD_TYPE_MOZ_BOOKMARK ); -// else if (mimeStr.Equals(kPNGImageMime) || mimeStr.Equals(kJPEGImageMime) || mimeStr.Equals(kGIFImageMime)) -// strcpy( cliphdr->type, Ph_CLIPBOARD_TYPE_IMAGE); - - if (cliphdr->type[0] == 0) - return NS_ERROR_FAILURE; - else - return NS_OK; + if( mimeStr.Equals(kUnicodeMime) || mimeStr.Equals(kTextMime) ) + strcpy( format, Ph_CLIPBOARD_TYPE_TEXT ); + else if( mimeStr.Equals(kHTMLMime) ) + strcpy( format, Ph_CLIPBOARD_TYPE_HTML ); + else if (mimeStr.Equals("moz/bookmarkclipboarditem")) + strcpy( format, Ph_CLIPBOARD_TYPE_MOZ_BOOKMARK ); + else ret = NS_ERROR_FAILURE; + return ret; } /* inline */ @@ -526,4 +589,27 @@ nsITransferable *nsClipboard::GetTransferable(PRInt32 aWhichClipboard) return transferable; } +static unsigned long get_flavour_timestamp( char *type ) +{ + int ig = 1; /* we always use input group 1 in mozilla */ + char fname[512]; + extern struct _Ph_ctrl *_Ph_; + strcpy( fname, "/var/clipboard/" ); + if( access( fname, X_OK ) != 0 ) + return 0; + + struct stat buf; + if( fstat( _Ph_->fd, &buf ) != 0 ) + return 0; + + if(gethostname(&fname[strlen(fname)],PATH_MAX-40)!=0) + strcpy(&fname[strlen(fname)],"localhost"); + + sprintf( &fname[strlen(fname)], "/%08x/%d.%s",buf.st_uid, ig, type ); + struct stat st; + if( stat( fname, &st ) != 0 ) + return 0; + + return st.st_mtime; +} diff --git a/mozilla/widget/src/photon/nsClipboard.h b/mozilla/widget/src/photon/nsClipboard.h index 78c4ed125a7..0d8785276d3 100644 --- a/mozilla/widget/src/photon/nsClipboard.h +++ b/mozilla/widget/src/photon/nsClipboard.h @@ -57,7 +57,7 @@ protected: NS_IMETHOD SetNativeClipboardData(PRInt32 aWhichClipboard); NS_IMETHOD GetNativeClipboardData(nsITransferable * aTransferable, PRInt32 aWhichClipboard ); -nsresult GetFormat(const char* aMimeStr, PhClipHeader *cliphdr ); +nsresult GetFormat(const char* aMimeStr, char *format ); PRBool mIgnoreEmptyNotification; inline nsITransferable *GetTransferable(PRInt32 aWhichClipboard); diff --git a/mozilla/widget/src/photon/nsFilePicker.cpp b/mozilla/widget/src/photon/nsFilePicker.cpp index eb3be4d379f..0b131de7fbe 100644 --- a/mozilla/widget/src/photon/nsFilePicker.cpp +++ b/mozilla/widget/src/photon/nsFilePicker.cpp @@ -79,12 +79,13 @@ nsFilePicker::~nsFilePicker() // Show - Display the file dialog // //------------------------------------------------------------------------- -NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval) +NS_IMETHODIMP nsFilePicker::Show(PRInt16 *aReturnVal) { - PRBool result = PR_TRUE; PRInt32 flags = 0; char *btn1; + NS_ENSURE_ARG_POINTER(aReturnVal); + if (mMode == modeGetFolder) { flags |= Pt_FSR_SELECT_DIRS|Pt_FSR_NO_SELECT_FILES; btn1 = "&Select"; @@ -163,12 +164,26 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval) return NS_ERROR_FAILURE; } + *aReturnVal = returnOK; + if( info.ret == Pt_FSDIALOG_BTN2 ) { - result = PR_FALSE; + *aReturnVal = returnCancel; } else if( mMode != modeOpenMultiple ) { mFile.SetLength(0); mFile.Append( info.path ); + + if( mMode == modeSave ) { + nsCOMPtr file(do_CreateInstance("@mozilla.org/file/local;1")); + NS_ENSURE_TRUE(file, NS_ERROR_FAILURE); + + file->InitWithNativePath( mFile ); + + PRBool exists = PR_FALSE; + file->Exists(&exists); + if (exists) + *aReturnVal = returnReplace; + } } else { /* here mMode is modeOpenMultiple */ PtFileSelectorInfo_t *minfo = info.minfo; diff --git a/mozilla/widget/src/photon/nsToolkit.cpp b/mozilla/widget/src/photon/nsToolkit.cpp index 2ee32568177..04202d71cd9 100644 --- a/mozilla/widget/src/photon/nsToolkit.cpp +++ b/mozilla/widget/src/photon/nsToolkit.cpp @@ -40,9 +40,6 @@ #include "nsPhWidgetLog.h" -// Set our static member to NULL -PhDrawContext_t *nsToolkit::mDefaultPhotonDrawContext = nsnull; -PRBool nsToolkit::mPtInited = PR_FALSE; // // Static thread local storage index of the Toolkit // object associated with a given thread... @@ -80,33 +77,9 @@ nsToolkit::~nsToolkit() //------------------------------------------------------------------------- NS_METHOD nsToolkit::Init(PRThread *aThread) { - /* Run this only once per application startup */ - if( !mPtInited ) - { - PtInit( NULL ); - PtChannelCreate(); // Force use of pulses - mPtInited = PR_TRUE; - } - - if (mDefaultPhotonDrawContext == nsnull) - { - mDefaultPhotonDrawContext = PhDCGetCurrent(); - } - return NS_OK; } -PhDrawContext_t *nsToolkit::GetDefaultPhotonDrawContext() -{ - if (mDefaultPhotonDrawContext == NULL) - { - NS_ASSERTION(mDefaultPhotonDrawContext, "nsToolkit::GetDefaultPhotonDrawContext mDefaultPhotonDrawContext is NULL"); - abort(); - } - - return nsToolkit::mDefaultPhotonDrawContext; -} - //------------------------------------------------------------------------- // // Return the nsIToolkit for the current thread. If a toolkit does not diff --git a/mozilla/widget/src/photon/nsToolkit.h b/mozilla/widget/src/photon/nsToolkit.h index ab803f88493..d76b0d443f9 100644 --- a/mozilla/widget/src/photon/nsToolkit.h +++ b/mozilla/widget/src/photon/nsToolkit.h @@ -51,12 +51,6 @@ public: NS_DECL_ISUPPORTS NS_IMETHOD Init( PRThread *aThread ); - - static PhDrawContext_t *GetDefaultPhotonDrawContext(); - -private: - static PRBool mPtInited; - static PhDrawContext_t *mDefaultPhotonDrawContext; }; diff --git a/mozilla/widget/src/photon/nsWidget.cpp b/mozilla/widget/src/photon/nsWidget.cpp index b470657ac4d..07321ca3463 100644 --- a/mozilla/widget/src/photon/nsWidget.cpp +++ b/mozilla/widget/src/photon/nsWidget.cpp @@ -429,7 +429,7 @@ NS_METHOD nsWidget::SetCursor( nsCursor aCursor ) { // Only change cursor if it's changing if( aCursor != mCursor ) { - unsigned short curs = 0; + unsigned short curs = Ph_CURSOR_POINTER; PgColor_t color = Ph_CURSOR_DEFAULT_COLOR; switch( aCursor ) { @@ -534,7 +534,7 @@ NS_METHOD nsWidget::SetCursor( nsCursor aCursor ) { break; } - if( mWidget && curs ) { + if( mWidget ) { PtArg_t args[2]; PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE, curs, 0 ); @@ -797,6 +797,7 @@ static struct nsKeyConverter nsKeycodes[] = { { NS_VK_CANCEL, Pk_Cancel, PR_FALSE }, { NS_VK_BACK, Pk_BackSpace, PR_FALSE }, { NS_VK_TAB, Pk_Tab, PR_FALSE }, + { NS_VK_TAB, Pk_KP_Tab, PR_FALSE }, { NS_VK_CLEAR, Pk_Clear, PR_FALSE }, { NS_VK_RETURN, Pk_Return, PR_FALSE }, { NS_VK_SHIFT, Pk_Shift_L, PR_FALSE }, @@ -898,11 +899,10 @@ inline void nsWidget::InitKeyEvent(PhKeyEvent_t *aPhKeyEvent, anEvent.point.y = 0; PRBool IsChar; - unsigned long keysym; - if (Pk_KF_Cap_Valid & aPhKeyEvent->key_flags) - keysym = nsConvertKey(aPhKeyEvent->key_sym, &IsChar); - else - keysym = nsConvertKey(aPhKeyEvent->key_cap, &IsChar); + unsigned long vkey; + if (Pk_KF_Cap_Valid & aPhKeyEvent->key_flags) + vkey = nsConvertKey(aPhKeyEvent->key_cap, &IsChar); + else vkey = nsConvertKey(aPhKeyEvent->key_sym, &IsChar); anEvent.isShift = ( aPhKeyEvent->key_mods & Pk_KM_Shift ) ? PR_TRUE : PR_FALSE; anEvent.isControl = ( aPhKeyEvent->key_mods & Pk_KM_Ctrl ) ? PR_TRUE : PR_FALSE; @@ -911,16 +911,15 @@ inline void nsWidget::InitKeyEvent(PhKeyEvent_t *aPhKeyEvent, if ((aEventType == NS_KEY_PRESS) && (IsChar == PR_TRUE)) { anEvent.charCode = aPhKeyEvent->key_sym; - anEvent.keyCode = 0; /* I think the spec says this should be 0 */ + anEvent.keyCode = 0; /* I think the spec says this should be 0 */ if ((anEvent.isControl) || (anEvent.isAlt)) anEvent.charCode = aPhKeyEvent->key_cap; - else - anEvent.isShift = anEvent.isControl = anEvent.isAlt = anEvent.isMeta = PR_FALSE; + else anEvent.isShift = anEvent.isControl = anEvent.isAlt = anEvent.isMeta = PR_FALSE; } else { anEvent.charCode = 0; - anEvent.keyCode = (keysym & 0x00FF); + anEvent.keyCode = vkey; } } @@ -1191,15 +1190,14 @@ int nsWidget::GotFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t pWidget->DispatchWindowEvent(&event); } } - else { - if( sJustGotActivated ) { - sJustGotActivated = PR_FALSE; - pWidget->DispatchStandardEvent(NS_ACTIVATE); - } - } pWidget->DispatchStandardEvent(NS_GOTFOCUS); + if( sJustGotActivated ) { + sJustGotActivated = PR_FALSE; + pWidget->DispatchStandardEvent(NS_ACTIVATE); + } + return Pt_CONTINUE; } diff --git a/mozilla/widget/src/photon/nsWidgetFactory.cpp b/mozilla/widget/src/photon/nsWidgetFactory.cpp index d8cdd61daf3..7777bfa9c7c 100644 --- a/mozilla/widget/src/photon/nsWidgetFactory.cpp +++ b/mozilla/widget/src/photon/nsWidgetFactory.cpp @@ -48,12 +48,18 @@ #include "nsLookAndFeel.h" #include "nsTransferable.h" #include "nsClipboard.h" +#include "nsClipboardHelper.h" #include "nsHTMLFormatConverter.h" #include "nsDragService.h" #include "nsSound.h" #ifdef IBMBIDI #include "nsBidiKeyboard.h" #endif + +#ifdef MOZ_ENABLE_XREMOTE +#include "nsPhMozRemoteHelper.h" +#endif + #include "nsFilePicker.h" #include @@ -67,10 +73,16 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit) NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel) NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker) + +#ifdef MOZ_ENABLE_XREMOTE +NS_GENERIC_FACTORY_CONSTRUCTOR(nsPhXRemoteWidgetHelper) +#endif + #ifdef IBMBIDI NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) #endif @@ -105,6 +117,10 @@ static nsModuleComponentInfo components[] = NS_CLIPBOARD_CID, "@mozilla.org/widget/clipboard;1", nsClipboardConstructor }, + { "Clipboard Helper", + NS_CLIPBOARDHELPER_CID, + "@mozilla.org/widget/clipboardhelper;1", + nsClipboardHelperConstructor }, { "HTML Format Converter", NS_HTMLFORMATCONVERTER_CID, "@mozilla.org/widget/htmlformatconverter;1", @@ -123,6 +139,14 @@ static nsModuleComponentInfo components[] = "@mozilla.org/widget/bidikeyboard;1", nsBidiKeyboardConstructor }, #endif // IBMBIDI + +#ifdef MOZ_ENABLE_XREMOTE + { NS_IXREMOTEWIDGETHELPER_CLASSNAME, + NS_PHXREMOTEWIDGETHELPER_CID, + NS_IXREMOTEWIDGETHELPER_CONTRACTID, + nsPhXRemoteWidgetHelperConstructor }, +#endif + { "Photon File Picker", NS_FILEPICKER_CID, "@mozilla.org/filepicker;1", diff --git a/mozilla/widget/src/photon/nsWindow.cpp b/mozilla/widget/src/photon/nsWindow.cpp index 9652aa82e41..5df1a86d835 100644 --- a/mozilla/widget/src/photon/nsWindow.cpp +++ b/mozilla/widget/src/photon/nsWindow.cpp @@ -231,7 +231,7 @@ NS_METHOD nsWindow::PreCreateWidget( nsWidgetInitData *aInitData ) { // //------------------------------------------------------------------------- NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) { - PtArg_t arg[20]; + PtArg_t arg[25]; int arg_count = 0; PhPoint_t pos; PhDim_t dim; @@ -275,7 +275,7 @@ NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) { else { // No border or decorations is the default - render_flags = Ph_WM_RENDER_INLINE | Ph_WM_RENDER_RESIZE; + render_flags = Ph_WM_RENDER_RESIZE; if( mWindowType != eWindowType_popup ) { @@ -367,19 +367,22 @@ NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) { mClientWidget = PtCreateWidget( PtRawDrawContainer, mWidget, arg_count, arg ); } else { - PtSetParentWidget( NULL ); - /* 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, -1 ); + PtSetArg( &arg[arg_count++], Pt_ARG_WINDOW_MANAGED_FLAGS, 0, Ph_WM_CLOSE ); + PtSetArg( &arg[arg_count++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Ph_WM_CLOSE|Ph_WM_MOVE, ~0 ); 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 }; + PtCallback_t cb_window = { WindowWMHandler, this }; + PtSetArg( &arg[arg_count++], Pt_CB_RESIZE, &cb_resize, NULL ); PtSetArg( &arg[arg_count++], Pt_CB_RAW, &cb_raw, NULL ); - mWidget = PtCreateWidget( PtWindow, NULL, arg_count, arg ); - } + PtSetArg( &arg[arg_count++], Pt_CB_WINDOW, &cb_window, 0 ); + mWidget = PtCreateWidget( PtWindow, parentWidget, arg_count, arg ); + } } if( mWidget ) { @@ -422,11 +425,6 @@ NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) { } else if( !parentWidget ) { if( mClientWidget ) PtAddCallback(mClientWidget, Pt_CB_RESIZE, ResizeHandler, nsnull ); - else { - PtAddCallback(mWidget, Pt_CB_RESIZE, ResizeHandler, nsnull ); - PtAddCallback(mWidget, Pt_CB_WINDOW, WindowWMHandler, this ); - PtSetResource( mWidget, Pt_ARG_WINDOW_NOTIFY_FLAGS, Ph_WM_CLOSE|Ph_WM_MOVE, ~0 ); - } } // call the event callback to notify about creation @@ -812,7 +810,7 @@ int nsWindow::EvInfo( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) nsCOMPtr presShell; docShell->GetPresShell( getter_AddRefs(presShell) ); - nsIViewManager* viewManager = presShell->GetViewManager(); + nsIViewManager* viewManager = presShell->GetViewManager(); NS_ENSURE_TRUE(viewManager, NS_ERROR_FAILURE); windowEnumerator->HasMoreElements(&more); @@ -892,7 +890,6 @@ NS_METHOD nsWindow::Move( PRInt32 aX, PRInt32 aY ) { } int nsWindow::MenuRegionCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) { -/* ATENTIE */ printf( "\n\n\n.......MenuRegionCallback\n\n" ); if( gRollupWidget && gRollupListener ) { /* rollup the menu */ gRollupListener->Rollup(); diff --git a/mozilla/widget/src/photon/nsWindow.h b/mozilla/widget/src/photon/nsWindow.h index f2d2caf5712..fb3f4c1351c 100644 --- a/mozilla/widget/src/photon/nsWindow.h +++ b/mozilla/widget/src/photon/nsWindow.h @@ -47,7 +47,6 @@ #include "nsString.h" #include -#include class nsFont; class nsIAppShell; @@ -100,7 +99,6 @@ public: inline NS_IMETHOD GetAttention(void) { -/* ATENTIE */ printf( "\n\n\n!!!!!!!!!!!!! GetAttention !!!!!!!!!!!!!!!!!!!!!!\n\n\n\n" ); if( mWidget ) PtWindowToFront( mWidget ); return NS_OK; }