diff --git a/widget/public/nsIWidget.h b/widget/public/nsIWidget.h index 951355555eb..eff2ee3cc57 100644 --- a/widget/public/nsIWidget.h +++ b/widget/public/nsIWidget.h @@ -973,7 +973,7 @@ class nsIWidget : public nsISupports { /** * Classify the window for the window manager. Mostly for X11. */ - NS_IMETHOD SetWindowClass(const nsAString& aName, const nsAString& xulWinType) = 0; + NS_IMETHOD SetWindowClass(const nsAString& xulWinType) = 0; /** * Enables/Disables system capture of any and all events that would cause a diff --git a/widget/src/gtk2/nsWindow.cpp b/widget/src/gtk2/nsWindow.cpp index 449776986ce..f0930ce11c1 100644 --- a/widget/src/gtk2/nsWindow.cpp +++ b/widget/src/gtk2/nsWindow.cpp @@ -65,6 +65,7 @@ #include "nsIPrefService.h" #include "nsIPrefBranch.h" #include "nsIServiceManager.h" +#include "nsIStringBundle.h" #include "nsGfxCIID.h" #ifdef ACCESSIBILITY @@ -2568,6 +2569,27 @@ nsWindow::OnDragEnter(nscoord aX, nscoord aY) DispatchEvent(&event, status); } +static void +GetBrandName(nsXPIDLString& brandName) +{ + nsCOMPtr bundleService = + do_GetService(NS_STRINGBUNDLE_CONTRACTID); + + nsCOMPtr bundle; + if (bundleService) + bundleService->CreateBundle( + "chrome://branding/locale/brand.properties", + getter_AddRefs(bundle)); + + if (bundle) + bundle->GetStringFromName( + NS_LITERAL_STRING("brandShortName").get(), + getter_Copies(brandName)); + + if (brandName.IsEmpty()) + brandName.Assign(NS_LITERAL_STRING("Mozilla")); +} + nsresult nsWindow::NativeCreate(nsIWidget *aParent, nsNativeWidget aNativeParent, @@ -2688,9 +2710,15 @@ nsWindow::NativeCreate(nsIWidget *aParent, case eWindowType_toplevel: case eWindowType_invisible: { mIsTopLevel = PR_TRUE; + + nsXPIDLString brandName; + GetBrandName(brandName); + NS_ConvertUTF16toUTF8 cBrand(brandName); + if (mWindowType == eWindowType_dialog) { mShell = gtk_window_new(GTK_WINDOW_TOPLEVEL); SetDefaultIcon(); + gtk_window_set_wmclass(GTK_WINDOW(mShell), "Dialog", cBrand.get()); gtk_window_set_type_hint(GTK_WINDOW(mShell), GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_set_transient_for(GTK_WINDOW(mShell), @@ -2719,7 +2747,8 @@ nsWindow::NativeCreate(nsIWidget *aParent, } else if (mWindowType == eWindowType_popup) { mShell = gtk_window_new(GTK_WINDOW_POPUP); - gtk_window_set_wmclass(GTK_WINDOW(mShell), "Popup", "Mozilla"); + gtk_window_set_wmclass(GTK_WINDOW(mShell), "Popup", cBrand.get()); + if (topLevelParent) { gtk_window_set_transient_for(GTK_WINDOW(mShell), topLevelParent); @@ -2735,7 +2764,7 @@ nsWindow::NativeCreate(nsIWidget *aParent, else { // must be eWindowType_toplevel mShell = gtk_window_new(GTK_WINDOW_TOPLEVEL); SetDefaultIcon(); - gtk_window_set_wmclass(GTK_WINDOW(mShell), "Toplevel", "Mozilla"); + gtk_window_set_wmclass(GTK_WINDOW(mShell), "Toplevel", cBrand.get()); // each toplevel window gets its own window group mWindowGroup = gtk_window_group_new(); @@ -2942,12 +2971,14 @@ nsWindow::NativeCreate(nsIWidget *aParent, } NS_IMETHODIMP -nsWindow::SetWindowClass(const nsAString& aName, - const nsAString &xulWinType) +nsWindow::SetWindowClass(const nsAString &xulWinType) { if (!mShell) return NS_ERROR_FAILURE; + nsXPIDLString brandName; + GetBrandName(brandName); + XClassHint *class_hint = XAllocClassHint(); if (!class_hint) return NS_ERROR_OUT_OF_MEMORY; @@ -2957,7 +2988,7 @@ nsWindow::SetWindowClass(const nsAString& aName, XFree(class_hint); return NS_ERROR_OUT_OF_MEMORY; } - class_hint->res_class = ToNewCString(aName); + class_hint->res_class = ToNewCString(brandName); if (!class_hint->res_class) { nsMemory::Free(class_hint->res_name); XFree(class_hint); diff --git a/widget/src/gtk2/nsWindow.h b/widget/src/gtk2/nsWindow.h index 3e338558f76..3505a811f73 100644 --- a/widget/src/gtk2/nsWindow.h +++ b/widget/src/gtk2/nsWindow.h @@ -138,8 +138,7 @@ public: NS_IMETHOD SetBorderStyle(nsBorderStyle aBorderStyle); NS_IMETHOD SetTitle(const nsAString& aTitle); NS_IMETHOD SetIcon(const nsAString& aIconSpec); - NS_IMETHOD SetWindowClass(const nsAString& aName, - const nsAString& xulWinType); + NS_IMETHOD SetWindowClass(const nsAString& xulWinType); NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar); NS_IMETHOD ShowMenuBar(PRBool aShow); NS_IMETHOD WidgetToScreen(const nsRect& aOldRect, diff --git a/widget/src/xpwidgets/nsBaseWidget.cpp b/widget/src/xpwidgets/nsBaseWidget.cpp index f3dbebc0a55..50109154b7c 100644 --- a/widget/src/xpwidgets/nsBaseWidget.cpp +++ b/widget/src/xpwidgets/nsBaseWidget.cpp @@ -685,8 +685,7 @@ void nsBaseWidget::OnDestroy() NS_IF_RELEASE(mToolkit); } -NS_METHOD nsBaseWidget::SetWindowClass(const nsAString& aName, - const nsAString& xulWinType) +NS_METHOD nsBaseWidget::SetWindowClass(const nsAString& xulWinType) { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/widget/src/xpwidgets/nsBaseWidget.h b/widget/src/xpwidgets/nsBaseWidget.h index f7f6588562f..799f119954c 100644 --- a/widget/src/xpwidgets/nsBaseWidget.h +++ b/widget/src/xpwidgets/nsBaseWidget.h @@ -115,8 +115,7 @@ public: NS_IMETHOD SetModal(PRBool aModal); NS_IMETHOD ModalEventFilter(PRBool aRealEvent, void *aEvent, PRBool *aForWindow); - NS_IMETHOD SetWindowClass(const nsAString& aName, - const nsAString& xulWinType); + NS_IMETHOD SetWindowClass(const nsAString& xulWinType); NS_IMETHOD SetBorderStyle(nsBorderStyle aBorderStyle); NS_IMETHOD AddMouseListener(nsIMouseListener * aListener); NS_IMETHOD AddEventListener(nsIEventListener * aListener); diff --git a/xpfe/appshell/src/nsXULWindow.cpp b/xpfe/appshell/src/nsXULWindow.cpp index e441ed919e5..9f1085a5c8d 100644 --- a/xpfe/appshell/src/nsXULWindow.cpp +++ b/xpfe/appshell/src/nsXULWindow.cpp @@ -1337,7 +1337,7 @@ NS_IMETHODIMP nsXULWindow::LoadWindowClassFromXUL() windowType); if (!windowType.IsEmpty()) { - mWindow->SetWindowClass(NS_LITERAL_STRING("Mozilla"), windowType); + mWindow->SetWindowClass(windowType); } return NS_OK;