From 83d38b8f5f0ab67d3902543ac91d051ffd8c5034 Mon Sep 17 00:00:00 2001 From: "bryner%netscape.com" Date: Tue, 16 Jul 2002 22:49:33 +0000 Subject: [PATCH] Implement nsIWidget::HideWindowChrome() for gtk (bug 157371). r=blizzard, sr=jag, a=asa. --- widget/src/gtk/nsWindow.cpp | 36 ++++++++++++++++++++++++++++++++++++ widget/src/gtk/nsWindow.h | 1 + 2 files changed, 37 insertions(+) diff --git a/widget/src/gtk/nsWindow.cpp b/widget/src/gtk/nsWindow.cpp index 4cc0b162224c..a565ebfe7b1d 100644 --- a/widget/src/gtk/nsWindow.cpp +++ b/widget/src/gtk/nsWindow.cpp @@ -4040,3 +4040,39 @@ NS_IMETHODIMP nsWindow::ResetInputState() #endif // USE_XIM return NS_OK; } + +NS_IMETHODIMP +nsWindow::HideWindowChrome(PRBool aShouldHide) +{ + if (!mShell) { + // This is not a top-level window widget. + return NS_ERROR_FAILURE; + } + + // Sawfish, metacity, and presumably other window managers get + // confused if we change the window decorations while the window + // is visible. + + if (mShown) + gdk_window_hide(mShell->window); + + gint wmd; + if (aShouldHide) + wmd = 0; + else + wmd = ConvertBorderStyles(mBorderStyle); + + gdk_window_set_decorations(mShell->window, (GdkWMDecoration) wmd); + + if (mShown) + gdk_window_show(mShell->window); + + // For some window managers, adding or removing window decorations + // requires unmapping and remapping our toplevel window. Go ahead + // and flush the queue here so that we don't end up with a BadWindow + // error later when this happens (when the persistence timer fires + // and GetWindowPos is called). + XSync(GDK_DISPLAY(), False); + + return NS_OK; +} diff --git a/widget/src/gtk/nsWindow.h b/widget/src/gtk/nsWindow.h index 2b31fba88faa..24fc8065ec4f 100644 --- a/widget/src/gtk/nsWindow.h +++ b/widget/src/gtk/nsWindow.h @@ -113,6 +113,7 @@ public: NS_IMETHOD SetFocus(PRBool aRaise); NS_IMETHOD GetAttention(void); NS_IMETHOD Destroy(); + NS_IMETHOD HideWindowChrome(PRBool aShouldHide); GdkCursor *GtkCreateCursor(nsCursor aCursorType); virtual void LoseFocus(void);