mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1151753 - Set program class name when not using --class command line option. r=karlt
GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=747634 Before 3.16.3, GDK cannot override classname by --class command line option when program uses gdk_set_program_class(). So if 3.16.3+, we should call gdk_set_program_class() to set program class name of default. MozReview-Commit-ID: KvNc3U6xHr7 --HG-- extra : rebase_source : aae14973022bb29eb89787b67323a845763c0650
This commit is contained in:
parent
f95226e22b
commit
18c5223126
@ -7,9 +7,11 @@
|
||||
|
||||
#include "mozilla/WidgetUtils.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIBidiKeyboard.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsTArray.h"
|
||||
#ifdef XP_WIN
|
||||
#include "WinUtils.h"
|
||||
@ -137,5 +139,26 @@ WidgetUtils::SendBidiKeyboardInfoToContent()
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
WidgetUtils::GetBrandShortName(nsAString& aBrandName)
|
||||
{
|
||||
aBrandName.Truncate();
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> bundleService =
|
||||
mozilla::services::GetStringBundleService();
|
||||
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
if (bundleService) {
|
||||
bundleService->CreateBundle(
|
||||
"chrome://branding/locale/brand.properties",
|
||||
getter_AddRefs(bundle));
|
||||
}
|
||||
|
||||
if (bundle) {
|
||||
bundle->GetStringFromName("brandShortName", aBrandName);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace widget
|
||||
} // namespace mozilla
|
||||
|
@ -91,6 +91,12 @@ public:
|
||||
* Send bidi keyboard information to content process
|
||||
*/
|
||||
static void SendBidiKeyboardInfoToContent();
|
||||
|
||||
/**
|
||||
* Get branchShortName from string bundle
|
||||
*/
|
||||
static void GetBrandShortName(nsAString& aBrandName);
|
||||
|
||||
};
|
||||
|
||||
} // namespace widget
|
||||
|
@ -71,6 +71,7 @@ STUB(gdk_screen_get_width)
|
||||
STUB(gdk_screen_height)
|
||||
STUB(gdk_screen_is_composited)
|
||||
STUB(gdk_screen_width)
|
||||
STUB(gdk_set_program_class)
|
||||
STUB(gdk_unicode_to_keyval)
|
||||
STUB(gdk_visual_get_depth)
|
||||
STUB(gdk_visual_get_system)
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "prenv.h"
|
||||
#include "mozilla/HangMonitor.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "mozilla/WidgetUtils.h"
|
||||
#include "GeckoProfiler.h"
|
||||
#include "nsIPowerManagerService.h"
|
||||
#ifdef MOZ_ENABLE_DBUS
|
||||
@ -176,6 +177,18 @@ nsAppShell::Init()
|
||||
}
|
||||
}
|
||||
|
||||
if (gtk_check_version(3, 16, 3) == nullptr) {
|
||||
// Before 3.16.3, GDK cannot override classname by --class command line
|
||||
// option when program uses gdk_set_program_class().
|
||||
//
|
||||
// See https://bugzilla.gnome.org/show_bug.cgi?id=747634
|
||||
nsAutoString brandName;
|
||||
mozilla::widget::WidgetUtils::GetBrandShortName(brandName);
|
||||
if (!brandName.IsEmpty()) {
|
||||
gdk_set_program_class(NS_ConvertUTF16toUTF8(brandName).get());
|
||||
}
|
||||
}
|
||||
|
||||
#if MOZ_WIDGET_GTK == 3
|
||||
if (!sReal_gtk_window_check_resize &&
|
||||
gtk_check_version(3,8,0) != nullptr) { // GTK 3.0 to GTK 3.6.
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "mozilla/FileUtils.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "mozilla/WidgetUtils.h"
|
||||
#include "nsIXULAppInfo.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "gfxPlatform.h"
|
||||
@ -125,21 +125,11 @@ ca_context_get_default()
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> bundleService =
|
||||
mozilla::services::GetStringBundleService();
|
||||
if (bundleService) {
|
||||
nsCOMPtr<nsIStringBundle> brandingBundle;
|
||||
bundleService->CreateBundle("chrome://branding/locale/brand.properties",
|
||||
getter_AddRefs(brandingBundle));
|
||||
if (brandingBundle) {
|
||||
nsAutoString wbrand;
|
||||
brandingBundle->GetStringFromName("brandShortName", wbrand);
|
||||
NS_ConvertUTF16toUTF8 brand(wbrand);
|
||||
|
||||
ca_context_change_props(ctx, "application.name", brand.get(),
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
nsAutoString wbrand;
|
||||
WidgetUtils::GetBrandShortName(wbrand);
|
||||
ca_context_change_props(ctx, "application.name",
|
||||
NS_ConvertUTF16toUTF8(wbrand).get(),
|
||||
nullptr);
|
||||
|
||||
nsCOMPtr<nsIXULAppInfo> appInfo = do_GetService("@mozilla.org/xre/app-info;1");
|
||||
if (appInfo) {
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/TouchEvents.h"
|
||||
#include "mozilla/UniquePtrExtensions.h"
|
||||
#include "mozilla/WidgetUtils.h"
|
||||
#include <algorithm>
|
||||
|
||||
#include "GeckoProfiler.h"
|
||||
@ -76,7 +77,6 @@
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIGConfService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsGtkUtils.h"
|
||||
#include "nsIObserverService.h"
|
||||
@ -176,8 +176,6 @@ static GdkWindow *get_inner_gdk_window (GdkWindow *aWindow,
|
||||
static int is_parent_ungrab_enter(GdkEventCrossing *aEvent);
|
||||
static int is_parent_grab_leave(GdkEventCrossing *aEvent);
|
||||
|
||||
static void GetBrandName(nsAString& brandName);
|
||||
|
||||
/* callbacks from widgets */
|
||||
#if (MOZ_WIDGET_GTK == 2)
|
||||
static gboolean expose_event_cb (GtkWidget *widget,
|
||||
@ -1777,7 +1775,10 @@ nsWindow::SetIcon(const nsAString& aIconSpec)
|
||||
|
||||
if (aIconSpec.EqualsLiteral("default")) {
|
||||
nsAutoString brandName;
|
||||
GetBrandName(brandName);
|
||||
WidgetUtils::GetBrandShortName(brandName);
|
||||
if (brandName.IsEmpty()) {
|
||||
brandName.AssignLiteral(u"Mozilla");
|
||||
}
|
||||
AppendUTF16toUTF8(brandName, iconName);
|
||||
ToLowerCase(iconName);
|
||||
} else {
|
||||
@ -3521,25 +3522,6 @@ nsWindow::OnTouchEvent(GdkEventTouch* aEvent)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
GetBrandName(nsAString& aBrandName)
|
||||
{
|
||||
nsCOMPtr<nsIStringBundleService> bundleService =
|
||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
||||
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
if (bundleService)
|
||||
bundleService->CreateBundle(
|
||||
"chrome://branding/locale/brand.properties",
|
||||
getter_AddRefs(bundle));
|
||||
|
||||
if (bundle)
|
||||
bundle->GetStringFromName("brandShortName", aBrandName);
|
||||
|
||||
if (aBrandName.IsEmpty())
|
||||
aBrandName.AssignLiteral(u"Mozilla");
|
||||
}
|
||||
|
||||
static GdkWindow *
|
||||
CreateGdkWindow(GdkWindow *parent, GtkWidget *widget)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user