From dd51e969a49a342244af636424d6c23708c8bb20 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Thu, 17 Feb 2005 20:22:38 +0000 Subject: [PATCH] Backing out bug 278353 since it causes Tdhtml to crash --- widget/src/gtk/nsWidget.cpp | 38 --------------- widget/src/gtk/nsWidget.h | 13 +---- widget/src/gtk/nsWindow.cpp | 97 +++++++++++++++++++++---------------- widget/src/gtk/nsWindow.h | 3 -- 4 files changed, 58 insertions(+), 93 deletions(-) diff --git a/widget/src/gtk/nsWidget.cpp b/widget/src/gtk/nsWidget.cpp index 201d1ca9325..997aacbfc61 100644 --- a/widget/src/gtk/nsWidget.cpp +++ b/widget/src/gtk/nsWidget.cpp @@ -493,44 +493,6 @@ NS_IMETHODIMP nsWidget::CaptureRollupEvents(nsIRollupListener * aListener, PRBoo return NS_OK; } -GdkWindow* nsWidget::GetLayeringWindow() -{ - return mWidget->window; -} - -void nsWidget::ResetZOrder() -{ - if (!GetNextSibling()) { - GdkWindow* window = GetLayeringWindow(); - if (window) { - gdk_window_raise(window); - } - } else { - // Move this widget and all the widgets above it to the top, in - // the right order - for (nsWidget* w = this; w; - w = NS_STATIC_CAST(nsWidget*, w->GetNextSibling())) { - GdkWindow* window = w->GetLayeringWindow(); - if (window) { - gdk_window_raise(window); - } - } - } -} - -NS_IMETHODIMP nsWidget::SetZIndex(PRInt32 aZIndex) -{ - nsIWidget* oldPrev = GetPrevSibling(); - - nsBaseWidget::SetZIndex(aZIndex); - - if (GetPrevSibling() == oldPrev) { - return NS_OK; - } - - ResetZOrder(); -} - NS_IMETHODIMP nsWidget::IsVisible(PRBool &aState) { if (mWidget) diff --git a/widget/src/gtk/nsWidget.h b/widget/src/gtk/nsWidget.h index 973caa69341..a3e8be9f17a 100644 --- a/widget/src/gtk/nsWidget.h +++ b/widget/src/gtk/nsWidget.h @@ -124,8 +124,6 @@ public: virtual PRBool OnResize(nsRect &aRect); virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); - NS_IMETHOD SetZIndex(PRInt32 aZIndex); - nsIFontMetrics *GetFont(void); NS_IMETHOD SetFont(const nsFont &aFont); @@ -199,9 +197,6 @@ public: // Return the Gdk window used for rendering virtual GdkWindow * GetRenderWindow(GtkObject * aGtkWidget); - // Return the Gdk window used for positioning, raising and lowering - virtual GdkWindow* GetLayeringWindow(); - // get the toplevel window for this widget virtual GtkWindow *GetTopLevelWindow(void); @@ -324,13 +319,9 @@ public: // This reduces problems with 16-bit coordinates wrapping. virtual void ResetInternalVisibility(); - // Reestablish the correct Z-ordering of this widget among - // its siblings - void ResetZOrder(); - protected: - // override this method to do whatever you have to do to make this - // widget visible or invisibile --- i.e., the real work of Show() + // override this method to do whatever you have to do to make this widget + // visible or invisibile --- i.e., the real work of Show() virtual void SetInternalVisibility(PRBool aVisible); ////////////////////////////////////////////////////////////////// diff --git a/widget/src/gtk/nsWindow.cpp b/widget/src/gtk/nsWindow.cpp index 0ec55689b79..6d85bde923d 100644 --- a/widget/src/gtk/nsWindow.cpp +++ b/widget/src/gtk/nsWindow.cpp @@ -2498,15 +2498,7 @@ void nsWindow::SetInternalVisibility(PRBool aVisible) { // don't show if we are too small if (mIsTooSmall) - { - aVisible = PR_FALSE; - } - - // Bail out now if we have nothing to do - if (aVisible == mInternalShown) - { return; - } mInternalShown = aVisible; @@ -2534,13 +2526,6 @@ void nsWindow::SetInternalVisibility(PRBool aVisible) if (mShell) gtk_widget_show(mShell); } - - // We just brought ourselves to the top. If we're not supposed to - // be at the top, put us back where we belong. - if (GetNextSibling()) { - ResetZOrder(); - } - // and if we've been grabbed, grab for good measure. if (sGrabWindow == this && mLastGrabFailed && !nsWindow::DragInProgress()) NativeGrab(PR_TRUE); @@ -2647,6 +2632,8 @@ NS_IMETHODIMP nsWindow::Move(PRInt32 aX, PRInt32 aY) mBounds.x = aX; mBounds.y = aY; + ResetInternalVisibility(); + if (mIsToplevel && mShell) { #ifdef DEBUG @@ -2676,14 +2663,12 @@ NS_IMETHODIMP nsWindow::Move(PRInt32 aX, PRInt32 aY) else if (mSuperWin) { gdk_window_move(mSuperWin->shell_window, aX, aY); } - - ResetInternalVisibility(); - return NS_OK; } NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) { + PRBool nNeedToShow = PR_FALSE; PRInt32 sizeHeight = aHeight; PRInt32 sizeWidth = aWidth; @@ -2699,21 +2684,61 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) mBounds.width = aWidth; mBounds.height = aHeight; - // code to keep the window from showing before it has been moved or - // resized - // if we are resized to 1x1 or less, we will hide the window. - // Show(TRUE) will be ignored until a larger resize has happened + ResetInternalVisibility(); + for (nsIWidget* kid = mFirstChild; kid; kid = kid->GetNextSibling()) { + NS_STATIC_CAST(nsWidget*, kid)->ResetInternalVisibility(); + } + + // code to keep the window from showing before it has been moved or resized + + // if we are resized to 1x1 or less, we will hide the window. Show(TRUE) will be ignored until a + // larger resize has happened if (aWidth <= 1 || aHeight <= 1) { - aWidth = 1; - aHeight = 1; - mIsTooSmall = PR_TRUE; + if (mMozArea) + { + aWidth = 1; + aHeight = 1; + mIsTooSmall = PR_TRUE; + if (mShell) + { + if (GTK_WIDGET_VISIBLE(mShell)) + { + gtk_widget_hide(mMozArea); + gtk_widget_hide(mShell); + gtk_widget_unmap(mShell); + } + } + else + { + gtk_widget_hide(mMozArea); + } + } + else + { + aWidth = 1; + aHeight = 1; + mIsTooSmall = PR_TRUE; + + NS_ASSERTION(mSuperWin,"no super window!"); + if (!mSuperWin) return NS_ERROR_FAILURE; + + gdk_window_hide(mSuperWin->bin_window); + gdk_window_hide(mSuperWin->shell_window); + } + mInternalShown = PR_FALSE; } else { - mIsTooSmall = PR_FALSE; + if (mIsTooSmall) + { + // if we are not shown, we don't want to force a show here, so check and see if Show(TRUE) has been called + nNeedToShow = mShown; + mIsTooSmall = PR_FALSE; + } } + if (mSuperWin) { // toplevel window? if so, we should resize it as well. if (mIsToplevel && mShell) @@ -2746,15 +2771,13 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) //g_print("not sending resize event\n"); } + if (nNeedToShow) { + Show(PR_TRUE); + } + if (aRepaint) Invalidate(PR_FALSE); - // Do the actual work of showing or hiding the window as necessary - ResetInternalVisibility(); - for (nsIWidget* kid = mFirstChild; kid; kid = kid->GetNextSibling()) { - NS_STATIC_CAST(nsWidget*, kid)->ResetInternalVisibility(); - } - return NS_OK; } @@ -3035,12 +3058,6 @@ nsWindow::GetGdkGrabWindow(void) } -GdkWindow * -nsWindow::GetLayeringWindow() -{ - return mSuperWin->shell_window; -} - /* virtual */ GdkWindow * nsWindow::GetRenderWindow(GtkObject * aGtkObject) { @@ -4321,10 +4338,8 @@ nsWindow::HideWindowChrome(PRBool aShouldHide) gdk_window_set_decorations(mShell->window, (GdkWMDecoration) wmd); - if (mShown) + if (mShown) gdk_window_show(mShell->window); - // XXX This brought the window to the front, which maybe isn't what - // we wanted. // For some window managers, adding or removing window decorations // requires unmapping and remapping our toplevel window. Go ahead diff --git a/widget/src/gtk/nsWindow.h b/widget/src/gtk/nsWindow.h index 0b62b55fdc6..597411bedb2 100644 --- a/widget/src/gtk/nsWindow.h +++ b/widget/src/gtk/nsWindow.h @@ -189,9 +189,6 @@ public: static nsWindow *GetGrabWindow(void); GdkWindow *GetGdkGrabWindow(void); - // Return the Gdk window used for positioning, raising and lowering - virtual GdkWindow* GetLayeringWindow(); - virtual void DispatchSetFocusEvent(void); virtual void DispatchLostFocusEvent(void); virtual void DispatchActivateEvent(void);