From 68a0eee3bbb9d59d9d4e2da8c31af129fdf6fcbe Mon Sep 17 00:00:00 2001 From: "pavlov%netscape.com" Date: Mon, 27 Sep 1999 02:16:18 +0000 Subject: [PATCH] make menus partially dismiss on unix --- widget/src/gtk/nsGtkEventHandler.cpp | 2 +- widget/src/gtk/nsWidget.cpp | 44 ++++++++++++++++++++++++++-- widget/src/gtk/nsWidget.h | 1 + widget/src/gtk/nsWindow.cpp | 9 +++++- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/widget/src/gtk/nsGtkEventHandler.cpp b/widget/src/gtk/nsGtkEventHandler.cpp index 2991009240df..b818354f90b6 100644 --- a/widget/src/gtk/nsGtkEventHandler.cpp +++ b/widget/src/gtk/nsGtkEventHandler.cpp @@ -46,7 +46,7 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CI #include #ifdef DEBUG_pavlov -#define DEBUG_EVENTS 1 +//#define DEBUG_EVENTS 1 #endif struct EventInfo { diff --git a/widget/src/gtk/nsWidget.cpp b/widget/src/gtk/nsWidget.cpp index 5e9d3b926194..24e055f8d1bc 100644 --- a/widget/src/gtk/nsWidget.cpp +++ b/widget/src/gtk/nsWidget.cpp @@ -29,7 +29,7 @@ #include "nsWidgetsCID.h" #include "nsGfxCIID.h" #include - +#include "nsIRollupListener.h" #ifdef USE_XIM #include "nsIServiceManager.h" @@ -43,6 +43,11 @@ static NS_DEFINE_CID(kRegionCID, NS_REGION_CID); nsILookAndFeel *nsWidget::sLookAndFeel = nsnull; PRUint32 nsWidget::sWidgetCount = 0; + +static nsIRollupListener *gRollupListener = nsnull; +static nsIWidget *gRollupWidget = nsnull; + + // // Keep track of the last widget being "dragged" // @@ -314,6 +319,30 @@ NS_IMETHODIMP nsWidget::Show(PRBool bState) return NS_OK; } + +NS_IMETHODIMP nsWidget::CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture) +{ + // printf("nsWindow::CaptureRollupEvents() this = %p , doCapture = %i\n", this, aDoCapture); + + if (aDoCapture) { + // gtk_grab_add(mWidget); + NS_IF_RELEASE(gRollupListener); + NS_IF_RELEASE(gRollupWidget); + gRollupListener = aListener; + NS_ADDREF(aListener); + gRollupWidget = this; + NS_ADDREF(this); + } else { + // gtk_grab_remove(mWidget); + NS_IF_RELEASE(gRollupListener); + //gRollupListener = nsnull; + NS_IF_RELEASE(gRollupWidget); + } + + return NS_OK; +} + + NS_IMETHODIMP nsWidget::SetModal(void) { GtkWindow *toplevel; @@ -1630,8 +1659,19 @@ nsWidget::OnButtonPressSignal(GdkEventButton * aGdkButtonEvent) nsMouseEvent event; PRUint32 eventType = 0; + if (gRollupWidget && gRollupListener) + { + GtkWidget *rollupWidget = GTK_WIDGET(gRollupWidget->GetNativeData(NS_NATIVE_WIDGET)); + GtkWidget *thisWidget = GTK_WIDGET(GetNativeData(NS_NATIVE_WIDGET)); + if (rollupWidget != thisWidget && gtk_widget_get_toplevel(thisWidget) != rollupWidget) + { + gRollupListener->Rollup(); + return; + } + } + #ifdef DEBUG_pavlov - printf("button press\n"); + // printf("button press\n"); #endif // Switch on single, double, triple click. diff --git a/widget/src/gtk/nsWidget.h b/widget/src/gtk/nsWidget.h index c32de2fdc24b..837f4c9250ba 100644 --- a/widget/src/gtk/nsWidget.h +++ b/widget/src/gtk/nsWidget.h @@ -84,6 +84,7 @@ public: NS_IMETHOD SetModal(void); NS_IMETHOD Show(PRBool state); + NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener, PRBool aDoCapture); NS_IMETHOD IsVisible(PRBool &aState); NS_IMETHOD Move(PRInt32 aX, PRInt32 aY); diff --git a/widget/src/gtk/nsWindow.cpp b/widget/src/gtk/nsWindow.cpp index c76aa3fc50cc..669b6a4abc10 100644 --- a/widget/src/gtk/nsWindow.cpp +++ b/widget/src/gtk/nsWindow.cpp @@ -42,6 +42,7 @@ #include "stdio.h" + //------------------------------------------------------------------------- // // nsWindow constructor @@ -641,6 +642,7 @@ NS_IMETHODIMP nsWindow::Show(PRBool bState) if (mIsToplevel && mShell) { gtk_widget_hide(mShell); + gtk_widget_unmap(mShell); } gtk_widget_hide(mWidget); @@ -768,7 +770,10 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) aHeight = 1; mIsTooSmall = PR_TRUE; if (GTK_WIDGET_VISIBLE(mShell)) + { gtk_widget_hide(mShell); + gtk_widget_unmap(mShell); + } } else { @@ -776,6 +781,7 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) aHeight = 1; mIsTooSmall = PR_TRUE; gtk_widget_hide(mWidget); + gtk_widget_unmap(mWidget); } } else @@ -827,8 +833,9 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) NS_IMETHODIMP nsWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) { - Resize(aWidth,aHeight,aRepaint); Move(aX,aY); + // resize can cause a show to happen, so do this last + Resize(aWidth,aHeight,aRepaint); return NS_OK; }