@@ -0,0 +1,1214 @@
+From: Robert O'Callahan <rocallahan@novell.com>
+Subject: implement startup-notification
+References:
+https://bugzilla.novell.com/show_bug.cgi?id=115417
+https://bugzilla.mozilla.org/show_bug.cgi?id=223492
+
+Index: configure.in
+================================================================================
+--- config/autoconf.mk.in
++++ config/autoconf.mk.in
+@@ -223,6 +223,10 @@
+ MOZ_GNOMEUI_CFLAGS = @MOZ_GNOMEUI_CFLAGS@
+ MOZ_GNOMEUI_LIBS = @MOZ_GNOMEUI_LIBS@
+
++MOZ_ENABLE_STARTUP_NOTIFICATION = @MOZ_ENABLE_STARTUP_NOTIFICATION@
++MOZ_STARTUP_NOTIFICATION_CFLAGS = @MOZ_STARTUP_NOTIFICATION_CFLAGS@
++MOZ_STARTUP_NOTIFICATION_LIBS = @MOZ_STARTUP_NOTIFICATION_LIBS@
++
+ MOZ_GNOMEVFS_CFLAGS = @MOZ_GNOMEVFS_CFLAGS@
+ MOZ_GNOMEVFS_LIBS = @MOZ_GNOMEVFS_LIBS@
+
+--- configure.in
++++ configure.in
+@@ -125,6 +125,7 @@
+ GNOMEUI_VERSION=2.2.0
+ GCONF_VERSION=1.2.1
+ LIBGNOME_VERSION=2.0
++STARTUP_NOTIFICATION_VERSION=0.8
+
+ dnl Set various checks
+ dnl ========================================================
+@@ -4088,6 +4089,42 @@
+
+ AC_SUBST(MOZ_DEFAULT_TOOLKIT)
+
++dnl ========================================================
++dnl = startup-notification support module
++dnl ========================================================
++
++if test "$MOZ_ENABLE_GTK2"
++then
++ MOZ_ENABLE_STARTUP_NOTIFICATION=
++
++ MOZ_ARG_ENABLE_BOOL(startup-notification,
++ [ --enable-startup-notification Enable startup-notification support (default: disabled) ],
++ MOZ_ENABLE_STARTUP_NOTIFICATION=force,
++ MOZ_ENABLE_STARTUP_NOTIFICATION=)
++
++ if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"
++ then
++ PKG_CHECK_MODULES(MOZ_STARTUP_NOTIFICATION,
++ libstartup-notification-1.0 >= $STARTUP_NOTIFICATION_VERSION,
++ [MOZ_ENABLE_STARTUP_NOTIFICATION=1], [
++ if test "$MOZ_ENABLE_STARTUP_NOTIFICATION" = "force"
++ then
++ AC_MSG_ERROR([* * * Could not find startup-notification >= $STARTUP_NOTIFICATION_VERSION])
++ fi
++ MOZ_ENABLE_STARTUP_NOTIFICATION=
++ ])
++ fi
++
++ if test "$MOZ_ENABLE_STARTUP_NOTIFICATION"; then
++ AC_DEFINE(MOZ_ENABLE_STARTUP_NOTIFICATION)
++ fi
++
++ TK_LIBS="$TK_LIBS $MOZ_STARTUP_NOTIFICATION_LIBS"
++fi
++AC_SUBST(MOZ_ENABLE_STARTUP_NOTIFICATION)
++AC_SUBST(MOZ_STARTUP_NOTIFICATION_CFLAGS)
++AC_SUBST(MOZ_STARTUP_NOTIFICATION_LIBS)
++
+ AC_SUBST(GTK_CONFIG)
+ AC_SUBST(TK_CFLAGS)
+ AC_SUBST(TK_LIBS)
+--- toolkit/components/remote/Makefile.in
++++ toolkit/components/remote/Makefile.in
+@@ -56,8 +56,9 @@
+ string \
+ appcomps \
+ toolkitcomps \
+- appcomps \
++ appshell \
+ xulapp \
++ layout \
+ widget \
+ gfx \
+ dom \
+--- toolkit/components/remote/nsGTKRemoteService.cpp
++++ toolkit/components/remote/nsGTKRemoteService.cpp
+@@ -50,7 +50,7 @@
+
+ #include "nsIBaseWindow.h"
+ #include "nsIDocShell.h"
+-#include "nsIDOMWindow.h"
++#include "nsPIDOMWindow.h"
+ #include "nsIGenericFactory.h"
+ #include "nsILocalFile.h"
+ #include "nsIObserverService.h"
+@@ -58,6 +58,8 @@
+ #include "nsIServiceManager.h"
+ #include "nsIWeakReference.h"
+ #include "nsIWidget.h"
++#include "nsIAppShellService.h"
++#include "nsAppShellCID.h"
+
+ #include "nsCOMPtr.h"
+ #include "nsString.h"
+@@ -72,6 +74,10 @@
+ #include "nsISuiteRemoteService.h"
+ #endif
+
++#ifdef MOZ_WIDGET_GTK2
++#include "nsGTKToolkit.h"
++#endif
++
+ #define MOZILLA_VERSION_PROP "_MOZILLA_VERSION"
+ #define MOZILLA_LOCK_PROP "_MOZILLA_LOCK"
+ #define MOZILLA_COMMAND_PROP "_MOZILLA_COMMAND"
+@@ -155,20 +161,44 @@
+ return PL_DHASH_NEXT;
+ }
+
+-NS_IMETHODIMP
+-nsGTKRemoteService::RegisterWindow(nsIDOMWindow* aWindow)
++static nsIWidget* GetMainWidget(nsIDOMWindow* aWindow)
+ {
+ // get the native window for this instance
+ nsCOMPtr<nsIScriptGlobalObject> scriptObject
+ (do_QueryInterface(aWindow));
+- NS_ENSURE_TRUE(scriptObject, NS_ERROR_FAILURE);
++ NS_ENSURE_TRUE(scriptObject, nsnull);
+
+ nsCOMPtr<nsIBaseWindow> baseWindow
+ (do_QueryInterface(scriptObject->GetDocShell()));
+- NS_ENSURE_TRUE(baseWindow, NS_ERROR_FAILURE);
++ NS_ENSURE_TRUE(baseWindow, nsnull);
+
+ nsCOMPtr<nsIWidget> mainWidget;
+ baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
++ return mainWidget;
++}
++
++static nsGTKToolkit* GetGTKToolkit()
++{
++ nsCOMPtr<nsIAppShellService> svc = do_GetService(NS_APPSHELLSERVICE_CONTRACTID);
++ if (!svc)
++ return nsnull;
++ nsCOMPtr<nsIDOMWindowInternal> window;
++ svc->GetHiddenDOMWindow(getter_AddRefs(window));
++ if (!window)
++ return nsnull;
++ nsIWidget* widget = GetMainWidget(window);
++ if (!widget)
++ return nsnull;
++ nsIToolkit* toolkit = widget->GetToolkit();
++ if (!toolkit)
++ return nsnull;
++ return NS_STATIC_CAST(nsGTKToolkit*, toolkit);
++}
++
++NS_IMETHODIMP
++nsGTKRemoteService::RegisterWindow(nsIDOMWindow* aWindow)
++{
++ nsIWidget* mainWidget = GetMainWidget(aWindow);
+ NS_ENSURE_TRUE(mainWidget, NS_ERROR_FAILURE);
+
+ // walk up the widget tree and find the toplevel window in the
+@@ -260,7 +290,7 @@
+
+ #ifndef MOZ_XUL_APP
+ const char*
+-nsGTKRemoteService::HandleCommand(char* aCommand, nsIDOMWindow* aWindow)
++nsGTKRemoteService::HandleCommand(char* aCommand, nsIDOMWindow* aWindow, PRUint32 aTimestamp)
+ {
+ nsresult rv;
+
+@@ -283,8 +313,60 @@
+ }
+
+ #else //MOZ_XUL_APP
++
++// Set desktop startup ID to the passed ID, if there is one, so that any created
++// windows get created with the right window manager metadata, and any windows
++// that get new tabs and are activated also get the right WM metadata.
++// If there is no desktop startup ID, then use the X event's timestamp
++// for _NET_ACTIVE_WINDOW when the window gets focused or shown.
++static void
++SetDesktopStartupIDOrTimestamp(const nsACString& aDesktopStartupID,
++ PRUint32 aTimestamp) {
++#ifdef MOZ_WIDGET_GTK2
++ nsGTKToolkit* toolkit = GetGTKToolkit();
++ if (!toolkit)
++ return;
++ if (!aDesktopStartupID.IsEmpty()) {
++ toolkit->SetDesktopStartupID(aDesktopStartupID);
++ } else {
++ toolkit->SetFocusTimestamp(aTimestamp);
++ }
++#endif
|