From c009860f8f8bf015da87b9f2fb9bc0a17ae6855f Mon Sep 17 00:00:00 2001 From: "syd%netscape.com" Date: Sun, 13 Jun 1999 20:56:08 +0000 Subject: [PATCH] Add SetModal() widget interface to nsIWidget, and provide an implementation for Gtk+. Now, when we do modal dialogs, Gtk+ calls a routine that makes the dialog modal within Gtk+; this is in addition to the code in nsWebShellWindow that is being invoked to support modals on the other platforms. For Gtk+, the nsWebShellWindow code doesn't appear to be enough; in order for the event plumbing to stay alive, we need to call into Gtk+, and unless we actually make the dialog modal using Gtk+ mechanisms, the user can still get to the menu bar, which is not good. git-svn-id: svn://10.0.0.236/trunk@35095 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/public/nsIWidget.h | 8 ++++++++ mozilla/widget/src/gtk/nsWidget.cpp | 13 +++++++++++++ mozilla/widget/src/gtk/nsWidget.h | 1 + mozilla/widget/src/xpwidgets/nsBaseWidget.cpp | 4 ++++ mozilla/widget/src/xpwidgets/nsBaseWidget.h | 1 + mozilla/xpfe/appshell/src/nsWebShellWindow.cpp | 1 + 6 files changed, 28 insertions(+) diff --git a/mozilla/widget/public/nsIWidget.h b/mozilla/widget/public/nsIWidget.h index 99979c7080b..eab1b1129cd 100644 --- a/mozilla/widget/public/nsIWidget.h +++ b/mozilla/widget/public/nsIWidget.h @@ -253,6 +253,14 @@ class nsIWidget : public nsISupports { */ NS_IMETHOD Show(PRBool aState) = 0; + /** + * Make the window modal + * + * + * + */ + NS_IMETHOD SetModal(void) = 0; + /** * Returns whether the window is visible * diff --git a/mozilla/widget/src/gtk/nsWidget.cpp b/mozilla/widget/src/gtk/nsWidget.cpp index 7e523e5fa21..258cb45eb11 100644 --- a/mozilla/widget/src/gtk/nsWidget.cpp +++ b/mozilla/widget/src/gtk/nsWidget.cpp @@ -248,6 +248,19 @@ NS_METHOD nsWidget::Show(PRBool bState) return NS_OK; } +NS_METHOD nsWidget::SetModal(void) +{ + GtkWindow *toplevel; + + if (!mWidget) + return NS_ERROR_FAILURE; + toplevel = (GtkWindow *) ::gtk_widget_get_toplevel( mWidget ); + if ( !toplevel ) + return NS_ERROR_FAILURE; + ::gtk_window_set_modal(toplevel, PR_TRUE); + return NS_OK; +} + NS_METHOD nsWidget::IsVisible(PRBool &aState) { if (mWidget) { diff --git a/mozilla/widget/src/gtk/nsWidget.h b/mozilla/widget/src/gtk/nsWidget.h index 472ca4c7fb4..b7df228a6bd 100644 --- a/mozilla/widget/src/gtk/nsWidget.h +++ b/mozilla/widget/src/gtk/nsWidget.h @@ -64,6 +64,7 @@ class nsWidget : public nsBaseWidget NS_IMETHOD Destroy(void); nsIWidget* GetParent(void); + NS_IMETHOD SetModal(void); NS_IMETHOD Show(PRBool state); NS_IMETHOD IsVisible(PRBool &aState); diff --git a/mozilla/widget/src/xpwidgets/nsBaseWidget.cpp b/mozilla/widget/src/xpwidgets/nsBaseWidget.cpp index c0f89e9b305..bcc466892ab 100644 --- a/mozilla/widget/src/xpwidgets/nsBaseWidget.cpp +++ b/mozilla/widget/src/xpwidgets/nsBaseWidget.cpp @@ -784,3 +784,7 @@ NS_METHOD nsBaseWidget::EnableFileDrop(PRBool aEnable) return NS_OK; } +NS_METHOD nsBaseWidget::SetModal(void) +{ + return NS_ERROR_FAILURE; +} diff --git a/mozilla/widget/src/xpwidgets/nsBaseWidget.h b/mozilla/widget/src/xpwidgets/nsBaseWidget.h index 1d8fe871d51..499fd4e8b51 100644 --- a/mozilla/widget/src/xpwidgets/nsBaseWidget.h +++ b/mozilla/widget/src/xpwidgets/nsBaseWidget.h @@ -74,6 +74,7 @@ public: virtual nsIDeviceContext* GetDeviceContext(); virtual nsIAppShell * GetAppShell(); virtual nsIToolkit* GetToolkit(); + NS_IMETHOD SetModal(void); NS_IMETHOD SetBorderStyle(nsBorderStyle aBorderStyle); NS_IMETHOD SetTitle(const nsString& aTitle); NS_IMETHOD SetTooltips(PRUint32 aNumberOfTips,nsRect* aTooltipAreas[]); diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index a61ea25bee9..0dbc6166a49 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -1380,6 +1380,7 @@ nsWebShellWindow::ShowModalInternal() subshell->Spinup(); nsIWidget *window = GetWidget(); + window->SetModal(); NS_ADDREF(window); mContinueModalLoop = PR_TRUE; while (NS_SUCCEEDED(rv) && mContinueModalLoop == PR_TRUE) {