Skip to content

Commit

Permalink
Bug 1297520 - For Snap, only install language for system locale. r=na…
Browse files Browse the repository at this point in the history
…lexander,OlivierTilloy

Differential Revision: https://phabricator.services.mozilla.com/D151052
  • Loading branch information
mkaply committed Sep 12, 2022
1 parent f4fb662 commit 0ce6d5d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions intl/locale/LocaleService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#ifdef XP_WIN
# include "WinUtils.h"
#endif
#ifdef MOZ_WIDGET_GTK
# include "mozilla/WidgetUtilsGtk.h"
#endif

#define INTL_SYSTEM_LOCALES_CHANGED "intl:system-locales-changed"

Expand Down Expand Up @@ -69,6 +72,8 @@ static void ReadRequestedLocales(nsTArray<nsCString>& aRetVal) {
const bool isRepack =
#ifdef XP_WIN
!mozilla::widget::WinUtils::HasPackageIdentity();
#elif defined(MOZ_WIDGET_GTK)
!widget::IsRunningUnderSnap();
#else
true;
#endif
Expand Down
2 changes: 1 addition & 1 deletion toolkit/profile/xpcshell/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function simulateSnapEnvironment() {
let env = Cc["@mozilla.org/process/environment;1"].getService(
Ci.nsIEnvironment
);
env.set("SNAP_NAME", AppConstants.MOZ_APP_NAME);
env.set("SNAP_INSTANCE_NAME", AppConstants.MOZ_APP_NAME);

gIsLegacy = true;
}
Expand Down
2 changes: 2 additions & 0 deletions widget/gtk/WidgetUtilsGtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ void SetLastMousePressEvent(GdkEvent* aEvent) {
sLastMousePressEvent = event.release();
}

bool IsRunningUnderSnap() { return g_getenv("SNAP_INSTANCE_NAME") != nullptr; }

bool IsRunningUnderFlatpak() {
// https://gitlab.gnome.org/GNOME/gtk/-/blob/4300a5c609306ce77cbc8a3580c19201dccd8d13/gdk/gdk.c#L472
static bool sRunning = [] {
Expand Down
2 changes: 1 addition & 1 deletion widget/gtk/WidgetUtilsGtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ GdkEvent* GetLastMousePressEvent();

// Return the snap's instance name, or null when not running as a snap.
const char* GetSnapInstanceName();
inline bool IsRunningUnderSnap() { return !!GetSnapInstanceName(); }
bool IsRunningUnderSnap();
bool IsRunningUnderFlatpak();
inline bool IsRunningUnderFlatpakOrSnap() {
return IsRunningUnderFlatpak() || IsRunningUnderSnap();
Expand Down

0 comments on commit 0ce6d5d

Please sign in to comment.