From 2fce16f9cc9057cc3fec99e383d5e3bf79ef0218 Mon Sep 17 00:00:00 2001 From: "ramiro%netscape.com" Date: Wed, 7 Jul 1999 11:46:22 +0000 Subject: [PATCH] Cut down on the noise. git-svn-id: svn://10.0.0.236/trunk@38685 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/xlib/Makefile.in | 4 ++ mozilla/widget/src/xlib/nsAppShell.cpp | 24 +++++++- mozilla/widget/src/xlib/nsLookAndFeel.cpp | 15 +++++ mozilla/widget/src/xlib/nsScrollBar.cpp | 54 ++++++++++++++++++ mozilla/widget/src/xlib/nsWidget.cpp | 67 +++++++++++++++++++++++ mozilla/widget/src/xlib/nsWidget.h | 4 ++ mozilla/widget/src/xlib/nsWindow.cpp | 11 ++++ 7 files changed, 176 insertions(+), 3 deletions(-) diff --git a/mozilla/widget/src/xlib/Makefile.in b/mozilla/widget/src/xlib/Makefile.in index c7b5f97f23c..de17d4cbab0 100644 --- a/mozilla/widget/src/xlib/Makefile.in +++ b/mozilla/widget/src/xlib/Makefile.in @@ -33,6 +33,10 @@ REQUIRES=util img xpcom raptor netlib DEFINES += -D_IMPL_NS_WIDGET +ifdef DEBUG_ramiro +DEFINES += -DXLIB_WIDGET_NOISY +endif + INCLUDES+= -I$(srcdir)/../xpwidgets -I$(srcdir)/../xlib -I$(srcdir)/. INCLUDES += $(TK_CFLAGS) diff --git a/mozilla/widget/src/xlib/nsAppShell.cpp b/mozilla/widget/src/xlib/nsAppShell.cpp index 679056b5174..61be1b9ca25 100644 --- a/mozilla/widget/src/xlib/nsAppShell.cpp +++ b/mozilla/widget/src/xlib/nsAppShell.cpp @@ -120,7 +120,7 @@ NS_METHOD nsAppShell::Create(int* argc, char ** argv) mDisplay = XOpenDisplay(NULL); if (mDisplay == NULL) - { + { fprintf(stderr, "%s: Cannot connect to X server %s\n", argv[0], XDisplayName(NULL)); @@ -134,8 +134,7 @@ NS_METHOD nsAppShell::Create(int* argc, char ** argv) xlib_rgb_init(mDisplay, mScreen); - printf("nsAppShell::Create(dpy=%p screen=%p)\ -n", + printf("nsAppShell::Create(dpy=%p screen=%p)\n", mDisplay, mScreen); @@ -307,9 +306,18 @@ nsAppShell::DispatchEvent(XEvent *event) case MotionNotify: HandleMotionNotifyEvent(event, widget); break; + + case NoExpose: + break; + default: + +#ifdef XLIB_WIDGET_NOISY printf("Unhandled window event: Window 0x%lx Got a %s event\n", event->xany.window, event_names[event->type]); + +#endif + break; } } @@ -334,8 +342,12 @@ nsAppShell::HandleButtonEvent(XEvent *event, nsWidget *aWidget) { nsMouseEvent mevent; PRUint32 eventType = 0; + +#ifdef XLIB_WIDGET_NOISY printf("Button event for window 0x%lx button %d type %s\n", event->xany.window, event->xbutton.button, (event->type == ButtonPress ? "ButtonPress" : "ButtonRelease")); +#endif + switch(event->type) { case ButtonPress: switch(event->xbutton.button) { @@ -380,8 +392,11 @@ nsAppShell::HandleButtonEvent(XEvent *event, nsWidget *aWidget) void nsAppShell::HandleExposeEvent(XEvent *event, nsWidget *aWidget) { +#ifdef XLIB_WIDGET_NOISY printf("Expose event for window 0x%lx %d %d %d %d\n", event->xany.window, event->xexpose.x, event->xexpose.y, event->xexpose.width, event->xexpose.height); +#endif + nsPaintEvent pevent; pevent.message = NS_PAINT; pevent.widget = aWidget; @@ -399,10 +414,13 @@ nsAppShell::HandleExposeEvent(XEvent *event, nsWidget *aWidget) void nsAppShell::HandleConfigureNotifyEvent(XEvent *event, nsWidget *aWidget) { +#ifdef XLIB_WIDGET_NOISY printf("ConfigureNotify event for window 0x%lx %d %d %d %d\n", event->xconfigure.window, event->xconfigure.x, event->xconfigure.y, event->xconfigure.width, event->xconfigure.height); +#endif + nsSizeEvent sevent; sevent.message = NS_SIZE; sevent.widget = aWidget; diff --git a/mozilla/widget/src/xlib/nsLookAndFeel.cpp b/mozilla/widget/src/xlib/nsLookAndFeel.cpp index 5e09e2269cf..9ea0e48d79b 100644 --- a/mozilla/widget/src/xlib/nsLookAndFeel.cpp +++ b/mozilla/widget/src/xlib/nsLookAndFeel.cpp @@ -25,23 +25,35 @@ NS_IMPL_ISUPPORTS(nsLookAndFeel, kILookAndFeelIID) nsLookAndFeel::nsLookAndFeel() : nsILookAndFeel() { NS_INIT_REFCNT(); + +#ifdef XLIB_WIDGET_NOISY printf("nsLookAndFeel::nsLookAndFeel()\n"); +#endif } nsLookAndFeel::~nsLookAndFeel() { +#ifdef XLIB_WIDGET_NOISY printf("nsLookAndFeel::~nsLookAndFeel()\n"); +#endif + } NS_IMETHODIMP nsLookAndFeel::GetColor(const nsColorID aID, nscolor &aColor) { +#ifdef XLIB_WIDGET_NOISY printf("nsLookAndFeel::GetColor()\n"); +#endif + return NS_OK; } NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) { +#ifdef XLIB_WIDGET_NOISY printf("nsLookAndFeel::GetMetric()\n"); +#endif + // XXX These are not complete! nsresult res = NS_OK; switch (aID) { @@ -105,7 +117,10 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID, float & aMetric) { +#ifdef XLIB_WIDGET_NOISY printf("nsLookAndFeel::GetMetric()\n"); +#endif + // XXX this is not complete nsresult res = NS_OK; switch (aID) { diff --git a/mozilla/widget/src/xlib/nsScrollBar.cpp b/mozilla/widget/src/xlib/nsScrollBar.cpp index 0e56b5c3ae9..ac78623416f 100644 --- a/mozilla/widget/src/xlib/nsScrollBar.cpp +++ b/mozilla/widget/src/xlib/nsScrollBar.cpp @@ -19,6 +19,8 @@ #include "nsScrollBar.h" #include "nsGfxCIID.h" +#include "xlibrgb.h" + NS_IMPL_ADDREF(nsScrollbar) NS_IMPL_RELEASE(nsScrollbar) @@ -61,8 +63,11 @@ nsresult nsScrollbar::QueryInterface(const nsIID& aIID, void** aInstancePtr) NS_METHOD nsScrollbar::SetMaxRange(PRUint32 aEndRange) { +#ifdef XLIB_WIDGET_NOISY printf("nsScrollbar::SetMaxRange()\n"); printf("Max Range set to %d\n", aEndRange); +#endif + mMaxRange = aEndRange; CalcBarBounds(); LayoutBar(); @@ -71,15 +76,21 @@ NS_METHOD nsScrollbar::SetMaxRange(PRUint32 aEndRange) PRUint32 nsScrollbar::GetMaxRange(PRUint32& aRange) { +#ifdef XLIB_WIDGET_NOISY printf("nsScrollbar::GetMaxRange()\n"); +#endif + aRange = mMaxRange; return NS_OK; } NS_METHOD nsScrollbar::SetPosition(PRUint32 aPos) { +#ifdef XLIB_WIDGET_NOISY printf("nsScrollbar::SetPosition()\n"); printf("Scroll to %d\n", aPos); +#endif + mPosition = aPos; CalcBarBounds(); LayoutBar(); @@ -88,15 +99,21 @@ NS_METHOD nsScrollbar::SetPosition(PRUint32 aPos) PRUint32 nsScrollbar::GetPosition(PRUint32& aPosition) { +#ifdef XLIB_WIDGET_NOISY printf("nsScrollbar::GetPosition()\n"); +#endif + aPosition = mPosition; return NS_OK; } NS_METHOD nsScrollbar::SetThumbSize(PRUint32 aSize) { +#ifdef XLIB_WIDGET_NOISY printf("nsScrollbar::SetThumbSize()\n"); printf("Thumb size set to %d\n", aSize); +#endif + mThumbSize = aSize; CalcBarBounds(); LayoutBar(); @@ -105,15 +122,21 @@ NS_METHOD nsScrollbar::SetThumbSize(PRUint32 aSize) NS_METHOD nsScrollbar::GetThumbSize(PRUint32& aSize) { +#ifdef XLIB_WIDGET_NOISY printf("nsScrollbar::GetThumbSize()\n"); +#endif + aSize = mThumbSize; return NS_OK; } NS_METHOD nsScrollbar::SetLineIncrement(PRUint32 aSize) { +#ifdef XLIB_WIDGET_NOISY printf("nsScrollbar::SetLineIncrement()\n"); printf("Set Line Increment to %d\n", aSize); +#endif + mLineIncrement = aSize; CalcBarBounds(); LayoutBar(); @@ -122,7 +145,10 @@ NS_METHOD nsScrollbar::SetLineIncrement(PRUint32 aSize) NS_METHOD nsScrollbar::GetLineIncrement(PRUint32& aSize) { +#ifdef XLIB_WIDGET_NOISY printf("nsScrollbar::GetLineIncrement()\n"); +#endif + aSize = mLineIncrement; return NS_OK; } @@ -130,9 +156,13 @@ NS_METHOD nsScrollbar::GetLineIncrement(PRUint32& aSize) NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, PRUint32 aPosition, PRUint32 aLineIncrement) { +#ifdef XLIB_WIDGET_NOISY printf("nsScrollbar::SetParameters()\n"); + printf("MaxRange = %d ThumbSize = %d aPosition = %d LineIncrement = %d\n", aMaxRange, aThumbSize, aPosition, aLineIncrement); +#endif + SetMaxRange(aMaxRange); SetThumbSize(aThumbSize); SetPosition(aPosition); @@ -144,7 +174,10 @@ NS_METHOD nsScrollbar::SetParameters(PRUint32 aMaxRange, PRUint32 aThumbSize, PRBool nsScrollbar::OnScroll(PRUint32 scrollCode, int cPos) { +#ifdef XLIB_WIDGET_NOISY printf("nsScrollbar::OnScroll\n"); +#endif + PRBool result = PR_FALSE; switch (scrollCode) { case NS_SCROLLBAR_PAGE_NEXT: @@ -162,7 +195,11 @@ PRBool nsScrollbar::OnScroll(PRUint32 scrollCode, int cPos) PRBool nsScrollbar::OnResize(nsSizeEvent &event) { PRBool result; + +#ifdef XLIB_WIDGET_NOISY printf("nsScrollbar::OnResize\n"); +#endif + nsWidget::OnResize(event); CalcBarBounds(); LayoutBar(); @@ -173,7 +210,11 @@ PRBool nsScrollbar::OnResize(nsSizeEvent &event) PRBool nsScrollbar::DispatchMouseEvent(nsMouseEvent &aEvent) { PRBool result; + +#ifdef XLIB_WIDGET_NOISY printf("nsScrollbar::DispatchMouseEvent\n"); +#endif + // check to see if this was on the main window. switch (aEvent.message) { case NS_MOUSE_LEFT_BUTTON_DOWN: @@ -343,14 +384,24 @@ void nsScrollbar::CalcBarBounds(void) if (mMaxRange == 0) { bar_start = 0; bar_end = 0; +#ifdef XLIB_WIDGET_NOISY printf("CalcBarBounds: max range is zero.\n"); +#endif + } else { + +#ifdef XLIB_WIDGET_NOISY printf("CalcBarBounds: position: %d max: %d thumb: %d\n", mPosition, mMaxRange, mThumbSize); +#endif + bar_start = (float)mPosition / (float)mMaxRange; bar_end = ((float)mThumbSize + (float)mPosition ) / (float)mMaxRange; +#ifdef XLIB_WIDGET_NOISY printf("CalcBarBounds: start: %f end: %f\n", bar_start, bar_end); +#endif + } if (mIsVertical == PR_TRUE) { @@ -371,7 +422,10 @@ void nsScrollbar::CalcBarBounds(void) if (mBarBounds.width == 0) { mBarBounds.width = 1; } + +#ifdef XLIB_WIDGET_NOISY printf("CalcBarBounds: bar is (%s) %d %d %d %d\n", ((mIsVertical == PR_TRUE) ? "vertical" : "horizontal" ), mBarBounds.x, mBarBounds.y, mBarBounds.width, mBarBounds.height); +#endif } void nsScrollbar::LayoutBar(void) diff --git a/mozilla/widget/src/xlib/nsWidget.cpp b/mozilla/widget/src/xlib/nsWidget.cpp index 5e1029ea1af..6dab6ab6d3d 100644 --- a/mozilla/widget/src/xlib/nsWidget.cpp +++ b/mozilla/widget/src/xlib/nsWidget.cpp @@ -161,16 +161,28 @@ NS_IMETHODIMP nsWidget::Destroy() NS_IMETHODIMP nsWidget::Move(PRUint32 aX, PRUint32 aY) { +#ifdef XLIB_WIDGET_NOISY printf("nsWidget::Move(x, y)\n"); +#endif + if (aX < 0) { +#ifdef XLIB_WIDGET_NOISY printf("*** x is %d, fixing.\n", aX); +#endif + aX = 0; } if (aY < 0) { +#ifdef XLIB_WIDGET_NOISY printf("*** y is %d, fixing.\n", aY); +#endif + aY = 0; } +#ifdef XLIB_WIDGET_NOISY printf("Moving window 0x%lx to %d, %d\n", mBaseWindow, aX, aY); +#endif + XMoveWindow(mDisplay, mBaseWindow, aX, aY); return NS_OK; } @@ -179,16 +191,28 @@ NS_IMETHODIMP nsWidget::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint) { +#ifdef XLIB_WIDGET_NOISY printf("nsWidget::Resize(width, height)\n"); +#endif + if (aWidth <= 0) { +#ifdef XLIB_WIDGET_NOISY printf("*** width is %d, fixing.\n", aWidth); +#endif + aWidth = 1; } if (aHeight <= 0) { +#ifdef XLIB_WIDGET_NOISY printf("*** height is %d, fixing.\n", aHeight); +#endif + aHeight = 1; } +#ifdef XLIB_WIDGET_NOISY printf("Resizing window 0x%lx to %d, %d\n", mBaseWindow, aWidth, aHeight); +#endif + mBounds.width = aWidth; mBounds.height = aHeight; XResizeWindow(mDisplay, mBaseWindow, aWidth, aHeight); @@ -201,25 +225,42 @@ NS_IMETHODIMP nsWidget::Resize(PRUint32 aX, PRUint32 aHeight, PRBool aRepaint) { +#ifdef XLIB_WIDGET_NOISY printf("nsWidget::Resize(x, y, width, height)\n"); +#endif + if (aWidth <= 0) { +#ifdef XLIB_WIDGET_NOISY printf("*** width is %d, fixing.\n", aWidth); +#endif + aWidth = 1; } if (aHeight <= 0) { +#ifdef XLIB_WIDGET_NOISY printf("*** height is %d, fixing.\n", aHeight); +#endif + aHeight = 1; } if (aX < 0) { +#ifdef XLIB_WIDGET_NOISY printf("*** x is %d, fixing.\n", aX); +#endif + aX = 0; } if (aY < 0) { +#ifdef XLIB_WIDGET_NOISY printf("*** y is %d, fixing.\n", aY); +#endif + aY = 0; } +#ifdef XLIB_WIDGET_NOISY printf("Resizing window 0x%lx to %d, %d\n", mBaseWindow, aWidth, aHeight); printf("Moving window 0x%lx to %d, %d\n", mBaseWindow, aX, aY); +#endif mBounds.width = aWidth; mBounds.height = aHeight; XMoveResizeWindow(mDisplay, mBaseWindow, aX, aY, aWidth, aHeight); @@ -238,13 +279,19 @@ NS_IMETHODIMP nsWidget::SetFocus(void) NS_IMETHODIMP nsWidget::Invalidate(PRBool aIsSynchronous) { +#ifdef XLIB_WIDGET_NOISY printf("nsWidget::Invalidate(sync)\n"); +#endif + return NS_OK; } NS_IMETHODIMP nsWidget::Invalidate(const nsRect & aRect, PRBool aIsSynchronous) { +#ifdef XLIB_WIDGET_NOISY printf("nsWidget::Invalidate(rect, sync)\n"); +#endif + return NS_OK; } @@ -356,13 +403,19 @@ NS_IMETHODIMP nsWidget::SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight) NS_IMETHODIMP nsWidget::Update() { +#ifdef XLIB_WIDGET_NOISY printf("nsWidget::Update()\n"); +#endif + return NS_OK; } NS_IMETHODIMP nsWidget::SetBackgroundColor(const nscolor &aColor) { +#ifdef XLIB_WIDGET_NOISY printf("nsWidget::SetBackgroundColor()\n"); +#endif + nsBaseWidget::SetBackgroundColor(aColor); mBackgroundPixel = xlib_rgb_xpixel_from_rgb(mBackground); // set the window attrib @@ -430,23 +483,35 @@ void nsWidget::CreateNativeWindow(Window aParent, nsRect aRect, int width; int height; +#ifdef XLIB_WIDGET_NOISY printf("*** Warning: nsWidget::CreateNative falling back to sane default for widget type \"%s\"\n", (const char *) nsAutoCString(mName)); if (mName == "unnamed") { printf("What freaking widget is this, anyway?\n"); } +#endif + +#ifdef XLIB_WIDGET_NOISY printf("Creating XWindow: x %d y %d w %d h %d\n", aRect.x, aRect.y, aRect.width, aRect.height); +#endif + if (aRect.width <= 0) { +#ifdef XLIB_WIDGET_NOISY printf("*** Fixing width...\n"); +#endif + width = 1; } else { width = aRect.width; } if (aRect.height <= 0) { +#ifdef XLIB_WIDGET_NOISY printf("*** Fixing height...\n"); +#endif + height = 1; } else { @@ -464,8 +529,10 @@ void nsWidget::CreateNativeWindow(Window aParent, nsRect aRect, aMask, &aAttr); +#ifdef XLIB_WIDGET_NOISY printf("nsWidget: Created window 0x%lx with parent 0x%lx\n", mBaseWindow, aParent); +#endif // XXX when we stop getting lame values for this remove it. // sometimes the dimensions have been corrected by the code above. diff --git a/mozilla/widget/src/xlib/nsWidget.h b/mozilla/widget/src/xlib/nsWidget.h index 22482731766..32a21da788e 100644 --- a/mozilla/widget/src/xlib/nsWidget.h +++ b/mozilla/widget/src/xlib/nsWidget.h @@ -25,6 +25,10 @@ #include "nsBaseWidget.h" #include "nsHashtable.h" +#ifdef DEBUG_blizzard +#define XLIB_WIDGET_NOISY +#endif + class nsWidget : public nsBaseWidget { public: diff --git a/mozilla/widget/src/xlib/nsWindow.cpp b/mozilla/widget/src/xlib/nsWindow.cpp index fd7ffbd9cf2..2dce337c3eb 100644 --- a/mozilla/widget/src/xlib/nsWindow.cpp +++ b/mozilla/widget/src/xlib/nsWindow.cpp @@ -73,7 +73,9 @@ void nsWindow::CreateNative(Window aParent, nsRect aRect) NS_IMETHODIMP nsWindow::Invalidate(PRBool aIsSynchronous) { +#ifdef XLIB_WIDGET_NOISY printf("nsWindow::Invalidate(sync)\n"); +#endif nsPaintEvent pevent; pevent.message = NS_PAINT; pevent.widget = this; @@ -91,7 +93,10 @@ NS_IMETHODIMP nsWindow::Invalidate(PRBool aIsSynchronous) NS_IMETHODIMP nsWindow::Invalidate(const nsRect & aRect, PRBool aIsSynchronous) { +#ifdef XLIB_WIDGET_NOISY printf("nsWindow::Invalidate(rect, sync)\n"); +#endif + nsPaintEvent pevent; pevent.message = NS_PAINT; pevent.widget = this; @@ -109,7 +114,10 @@ NS_IMETHODIMP nsWindow::Invalidate(const nsRect & aRect, PRBool aIsSynchronous) NS_IMETHODIMP nsWindow::Update() { +#ifdef XLIB_WIDGET_NOISY printf("nsWindow::Update()\n"); +#endif + nsPaintEvent pevent; pevent.message = NS_PAINT; pevent.widget = this; @@ -127,7 +135,10 @@ NS_IMETHODIMP nsWindow::Update() NS_IMETHODIMP nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) { +#ifdef XLIB_WIDGET_NOISY printf("nsWindow::Scroll()\n"); +#endif + if (aClipRect) Invalidate(*aClipRect, PR_TRUE); else