From 19b68aa17638a8fe2d2176c84fc5690c3025421f Mon Sep 17 00:00:00 2001 From: "ssu%netscape.com" Date: Sun, 18 Nov 2001 02:24:45 +0000 Subject: [PATCH] checking in patch for Roland Mainz. r=ssu. not part of normal build process --- widget/src/xlib/nsClipboard.cpp | 4 ++-- widget/src/xlib/nsWindow.cpp | 35 +++++++++++++++++---------------- widget/src/xlib/nsWindow.h | 2 ++ 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/widget/src/xlib/nsClipboard.cpp b/widget/src/xlib/nsClipboard.cpp index 89582503f6f4..b30436e65dfe 100644 --- a/widget/src/xlib/nsClipboard.cpp +++ b/widget/src/xlib/nsClipboard.cpp @@ -140,7 +140,7 @@ nsEventStatus PR_CALLBACK nsClipboard::Callback(nsGUIEvent *event) { // Get the data from the Transferable - char *dataFlavor = kUnicodeMime; + const char *dataFlavor = kUnicodeMime; nsCOMPtr genDataWrapper; nsresult rv; PRUint32 dataLength; @@ -328,7 +328,7 @@ NS_IMETHODIMP nsClipboard::GetData(nsITransferable *aTransferable, // internally, otherwise get the data from the X server if (XGetSelectionOwner(sDisplay, XA_PRIMARY) == sWindow) { - char *dataFlavor = kUnicodeMime; + const char *dataFlavor = kUnicodeMime; nsCOMPtr genDataWrapper; nsresult rv; PRUint32 dataLength; diff --git a/widget/src/xlib/nsWindow.cpp b/widget/src/xlib/nsWindow.cpp index 0b3452ddc6b8..73fb036a0c06 100644 --- a/widget/src/xlib/nsWindow.cpp +++ b/widget/src/xlib/nsWindow.cpp @@ -221,11 +221,16 @@ nsWindow::nsWindow() : nsWidget() mWindowType = eWindowType_child; mBorderStyle = eBorderStyle_default; mIsToplevel = PR_FALSE; + + mScrollGC = nsnull; } nsWindow::~nsWindow() { + if (mScrollGC) + XFreeGC(mDisplay, mScrollGC); + // Release grab if (sGrabWindow == this) { @@ -385,7 +390,7 @@ NS_IMETHODIMP nsWindow::SetFocus(PRBool aRaise) if (mBlockFocusEvents) return NS_OK; - + mBlockFocusEvents = PR_TRUE; event.message = NS_GOTFOCUS; @@ -399,10 +404,7 @@ NS_IMETHODIMP nsWindow::SetFocus(PRBool aRaise) DispatchEvent(&event, status); Release(); - - event.message = NS_ACTIVATE; - event.widget = this; event.eventStructType = NS_GUI_EVENT; event.time = 0; @@ -460,10 +462,11 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, nsWidget::Resize(aWidth, aHeight, aRepaint); nsSizeEvent sevent; + nsRect sevent_windowSize(0, 0, aWidth, aHeight); sevent.message = NS_SIZE; sevent.widget = this; sevent.eventStructType = NS_SIZE_EVENT; - sevent.windowSize = new nsRect (0, 0, aWidth, aHeight); + sevent.windowSize = &sevent_windowSize; sevent.point.x = 0; sevent.point.y = 0; sevent.mWinWidth = aWidth; @@ -472,7 +475,6 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, AddRef(); OnResize(sevent); Release(); - delete sevent.windowSize; if (NeedToShow) Show(PR_TRUE); @@ -499,10 +501,11 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aX, nsWidget::Resize(aX, aY, aWidth, aHeight, aRepaint); nsSizeEvent sevent; + nsRect sevent_windowSize(0, 0, aWidth, aHeight); sevent.message = NS_SIZE; sevent.widget = this; sevent.eventStructType = NS_SIZE_EVENT; - sevent.windowSize = new nsRect (0, 0, aWidth, aHeight); + sevent.windowSize = &sevent_windowSize; sevent.point.x = 0; sevent.point.y = 0; sevent.mWinWidth = aWidth; @@ -511,7 +514,6 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aX, AddRef(); OnResize(sevent); Release(); - delete sevent.windowSize; return NS_OK; } @@ -552,7 +554,6 @@ NS_IMETHODIMP nsWindow::Invalidate(PRBool aIsSynchronous) else QueueDraw(); - return NS_OK; } @@ -657,9 +658,11 @@ NS_IMETHODIMP nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) PRInt32 srcX = 0, srcY = 0, destX = 0, destY = 0, width = 0, height = 0; nsRect aRect; - GC gc; - gc = XCreateGC(mDisplay, mBaseWindow, 0, NULL); - + + /* only create GC for scolling once ... */ + if (!mScrollGC) + mScrollGC = XCreateGC(mDisplay, mBaseWindow, 0, nsnull); + if (aDx < 0 || aDy < 0) { srcX = mBounds.x + ABS(aDx); @@ -668,8 +671,8 @@ NS_IMETHODIMP nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) destY = mBounds.y; width = mBounds.width - ABS(aDx); height = mBounds.height - ABS(aDy); - } else - if (aDx > 0 || aDy > 0) + } + else if (aDx > 0 || aDy > 0) { srcX = mBounds.x; srcY = mBounds.y; @@ -679,11 +682,9 @@ NS_IMETHODIMP nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) height = mBounds.height - ABS(aDy); } - XCopyArea(mDisplay, mBaseWindow, mBaseWindow, gc, + XCopyArea(mDisplay, mBaseWindow, mBaseWindow, mScrollGC, srcX, srcY, width, height, destX, destY); - XFreeGC(mDisplay, gc); - width = mBounds.width; height = mBounds.height; diff --git a/widget/src/xlib/nsWindow.h b/widget/src/xlib/nsWindow.h index 00a03ee831e3..ebf6c9809541 100644 --- a/widget/src/xlib/nsWindow.h +++ b/widget/src/xlib/nsWindow.h @@ -128,6 +128,8 @@ protected: PRBool mIsUpdating; PRBool mBlockFocusEvents; PRBool mIsTooSmall; + + GC mScrollGC; // GC used by nsWindow::Scroll() static PRBool sIsGrabbing; static nsWindow *sGrabWindow;