diff --git a/mozilla/widget/src/xlib/nsAppShell.cpp b/mozilla/widget/src/xlib/nsAppShell.cpp index 624794aafd6..00af559652d 100644 --- a/mozilla/widget/src/xlib/nsAppShell.cpp +++ b/mozilla/widget/src/xlib/nsAppShell.cpp @@ -271,6 +271,11 @@ nsAppShell::EventIsForModalWindow(PRBool aRealEvent, void *aEvent, nsresult nsAppShell::DispatchNativeEvent(PRBool aRealEvent, void *aEvent) { + if (aEvent == 0) { + return NS_ERROR_FAILURE; + } + XEvent *event = (XEvent *)aEvent; + DispatchXEvent(event); return NS_OK; } @@ -292,7 +297,6 @@ void nsAppShell::DispatchXEvent(XEvent *event) { nsWidget *widget; - XEvent config_event; widget = nsWidget::GetWidgetForWindow(event->xany.window); // switch on the type of event @@ -312,26 +316,6 @@ nsAppShell::DispatchXEvent(XEvent *event) event->xconfigure.width, event->xconfigure.height)); - while (XCheckWindowEvent(mDisplay, - event->xany.window, - StructureNotifyMask, - &config_event) == True) - { - // make sure that we don't get other types of events. - // StructureNotifyMask includes other kinds of events, too. - if (config_event.type == ConfigureNotify) - { - *event = config_event; - - PR_LOG(XlibWidgetsLM, PR_LOG_DEBUG, ("DispatchEvent: Extra ConfigureNotify event for window 0x%lx %d %d %d %d\n", - event->xconfigure.window, - event->xconfigure.x, - event->xconfigure.y, - event->xconfigure.width, - event->xconfigure.height)); - } - } - HandleConfigureNotifyEvent(event, widget); break; @@ -471,9 +455,29 @@ void nsAppShell::HandleConfigureNotifyEvent(XEvent *event, nsWidget *aWidget) { PR_LOG(XlibWidgetsLM, PR_LOG_DEBUG, ("ConfigureNotify event for window 0x%lx %d %d %d %d\n", - event->xconfigure.window, - event->xconfigure.x, event->xconfigure.y, + event->xconfigure.window, + event->xconfigure.x, event->xconfigure.y, event->xconfigure.width, event->xconfigure.height)); + XEvent config_event; + while (XCheckWindowEvent(event->xany.display, + event->xany.window, + StructureNotifyMask, + &config_event) == True) { + // make sure that we don't get other types of events. + // StructureNotifyMask includes other kinds of events, too. + if (config_event.type == ConfigureNotify) + { + *event = config_event; + + PR_LOG(XlibWidgetsLM, PR_LOG_DEBUG, ("DispatchEvent: Extra ConfigureNotify event for window 0x%lx %d %d %d %d\n", + event->xconfigure.window, + event->xconfigure.x, + event->xconfigure.y, + event->xconfigure.width, + event->xconfigure.height)); + } + } + nsSizeEvent sevent; sevent.message = NS_SIZE; sevent.widget = aWidget; diff --git a/mozilla/widget/src/xlib/nsAppShell.h b/mozilla/widget/src/xlib/nsAppShell.h index 37741548b82..a6466e8634b 100644 --- a/mozilla/widget/src/xlib/nsAppShell.h +++ b/mozilla/widget/src/xlib/nsAppShell.h @@ -44,10 +44,9 @@ class nsAppShell : public nsIAppShell NS_IMETHOD SetDispatchListener(nsDispatchListener* aDispatchListener); NS_IMETHOD Exit(); virtual void * GetNativeData(PRUint32 aDataType); - + static void DispatchXEvent(XEvent *event); private: nsDispatchListener* mDispatchListener; - void DispatchXEvent(XEvent *event); static void HandleButtonEvent(XEvent *event, nsWidget *aWidget); static void HandleMotionNotifyEvent(XEvent *event, nsWidget *aWidget); static void HandleExposeEvent(XEvent *event, nsWidget *aWidget); diff --git a/mozilla/widget/src/xlib/nsWidget.cpp b/mozilla/widget/src/xlib/nsWidget.cpp index 5dfbf28f236..cebd46134d7 100644 --- a/mozilla/widget/src/xlib/nsWidget.cpp +++ b/mozilla/widget/src/xlib/nsWidget.cpp @@ -17,6 +17,7 @@ */ #include +#include "nsIXlibWindowService.h" #include "nsWidget.h" #include "nsGfxCIID.h" @@ -32,6 +33,11 @@ nsHashtable *nsWidget::window_list = nsnull; // this is a class for generating keys for // the list of windows managed by mozilla. +// this is possibly the class impl that will be +// called whenever a new window is created/destroyed + +nsXlibWindowCallback *nsWidget::mWindowCallback = nsnull; + class nsWindowKey : public nsHashKey { protected: Window mKey; @@ -639,6 +645,11 @@ nsWidget::AddWindowCallback(Window aWindow, nsWidget *aWidget) window_list->Put(window_key, aWidget); // add a new ref to this widget NS_ADDREF(aWidget); + // make sure that if someone is listening that we inform + // them of the new window + if (mWindowCallback) { + mWindowCallback->WindowCreated(aWindow); + } delete window_key; } @@ -649,6 +660,9 @@ nsWidget::DeleteWindowCallback(Window aWindow) nsWidget *widget = (nsWidget *)window_list->Get(window_key); NS_RELEASE(widget); window_list->Remove(window_key); + if (mWindowCallback) { + mWindowCallback->WindowDestroyed(aWindow); + } delete window_key; } @@ -959,3 +973,31 @@ void nsWidget::SetMapStatus(PRBool aState) { mIsMapped = aState; } + +nsresult +nsWidget::SetXlibWindowCallback(nsXlibWindowCallback *aCallback) +{ + if (aCallback == nsnull) { + return NS_ERROR_FAILURE; + } + else { + mWindowCallback = aCallback; + } + return NS_OK; +} + +nsresult +nsWidget::XWindowCreated(Window aWindow) { + if (mWindowCallback) { + mWindowCallback->WindowCreated(aWindow); + } + return NS_OK; +} + +nsresult +nsWidget::XWindowDestroyed(Window aWindow) { + if (mWindowCallback) { + mWindowCallback->WindowDestroyed(aWindow); + } + return NS_OK; +} diff --git a/mozilla/widget/src/xlib/nsWidget.h b/mozilla/widget/src/xlib/nsWidget.h index e450343ed0c..440551043d3 100644 --- a/mozilla/widget/src/xlib/nsWidget.h +++ b/mozilla/widget/src/xlib/nsWidget.h @@ -25,6 +25,7 @@ #include "nsBaseWidget.h" #include "nsHashtable.h" #include "prlog.h" +#include #ifdef DEBUG_blizzard #define XLIB_WIDGET_NOISY @@ -116,6 +117,10 @@ public: PRBool DispatchWindowEvent(nsGUIEvent & aEvent); + static nsresult SetXlibWindowCallback(nsXlibWindowCallback *aCallback); + static nsresult XWindowCreated(Window aWindow); + static nsresult XWindowDestroyed(Window aWindow); + protected: // private event functions @@ -137,6 +142,7 @@ protected: static void AddWindowCallback (Window aWindow, nsWidget *aWidget); static void DeleteWindowCallback(Window aWindow); static nsHashtable *window_list; + static nsXlibWindowCallback *mWindowCallback; // here's how we add children // there's no geometry information here because that should be in the mBounds