Bug 1805939 - Have a central source of truth for desktop environment detection. r=stransky,jld

Gfx blocklist doesn't actually use the desktop environment filter so
remove that functionality. We can reintroduce it in the future if we
need it.

Differential Revision: https://phabricator.services.mozilla.com/D166090
This commit is contained in:
Emilio Cobos Álvarez 2023-01-20 11:26:11 +00:00
Родитель 9cd2050749
Коммит 46df319668
14 изменённых файлов: 342 добавлений и 546 удалений

Просмотреть файл

@ -82,8 +82,7 @@ nsresult nsGNOMEShellService::Init() {
if (!giovfs && !gsettings) return NS_ERROR_NOT_AVAILABLE;
#ifdef MOZ_ENABLE_DBUS
const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP");
if (currentDesktop && strstr(currentDesktop, "GNOME") != nullptr &&
if (widget::IsGnomeDesktopEnvironment() &&
Preferences::GetBool("browser.gnome-search-provider.enabled", false)) {
mSearchProvider.Startup();
}
@ -334,19 +333,12 @@ NS_IMETHODIMP
nsGNOMEShellService::GetCanSetDesktopBackground(bool* aResult) {
// setting desktop background is currently only supported
// for Gnome or desktops using the same GSettings keys
const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP");
if (currentDesktop && strstr(currentDesktop, "GNOME") != nullptr) {
if (widget::IsGnomeDesktopEnvironment()) {
*aResult = true;
return NS_OK;
}
const char* gnomeSession = getenv("GNOME_DESKTOP_SESSION_ID");
if (gnomeSession) {
*aResult = true;
} else {
*aResult = false;
}
*aResult = !!getenv("GNOME_DESKTOP_SESSION_ID");
return NS_OK;
}

Просмотреть файл

@ -11,6 +11,7 @@
#include "nsServiceManagerUtils.h"
#include "nsIGSettingsService.h"
using namespace mozilla;
using namespace mozilla::intl;
OSPreferences::OSPreferences() = default;
@ -46,45 +47,33 @@ bool OSPreferences::ReadRegionalPrefsLocales(nsTArray<nsCString>& aLocaleList) {
* This looks up into gtk settings for hourCycle format.
*
* This works for all GUIs that use gtk settings like Gnome, Elementary etc.
* Ubuntu does not use those settings so we'll want to support them separately.
*
* We're taking the current 12/24h settings irrelevant of the locale, because
* in the UI user selects this setting for all locales.
*/
static int HourCycle() {
int rval = 0;
// Ubuntu 16.04 and lower report "Unity". Ubuntu 16.04 is supported until
// April 2021. This code can be removed once it hits EOL.
nsAutoCString schema;
nsAutoCString key;
const char* env = getenv("XDG_CURRENT_DESKTOP");
if (env && strcmp(env, "Unity") == 0) {
schema = "com.canonical.indicator.datetime";
key = "time-format";
} else {
schema = "org.gnome.desktop.interface";
key = "clock-format";
}
nsCOMPtr<nsIGSettingsService> gsettings =
do_GetService(NS_GSETTINGSSERVICE_CONTRACTID);
nsCOMPtr<nsIGSettingsCollection> desktop_settings;
if (gsettings) {
gsettings->GetCollectionForSchema(schema, getter_AddRefs(desktop_settings));
if (desktop_settings) {
nsAutoCString result;
desktop_settings->GetString(key, result);
if (result == "12h") {
rval = 12;
} else if (result == "24h") {
rval = 24;
}
}
if (!gsettings) {
return 0;
}
return rval;
nsCOMPtr<nsIGSettingsCollection> desktop_settings;
gsettings->GetCollectionForSchema("org.gnome.desktop.interface"_ns,
getter_AddRefs(desktop_settings));
if (!desktop_settings) {
return 0;
}
nsAutoCString result;
desktop_settings->GetString("clock-format"_ns, result);
if (result == "12h") {
return 12;
}
if (result == "24h") {
return 24;
}
return 0;
}
/**

Просмотреть файл

@ -16,8 +16,6 @@ uint64_t GfxDriverInfo::allDriverVersions = ~(uint64_t(0));
GfxDeviceFamily*
GfxDriverInfo::sDeviceFamilies[static_cast<size_t>(DeviceFamily::Max)];
nsAString* GfxDriverInfo::sDesktopEnvironment[static_cast<size_t>(
DesktopEnvironment::Max)];
nsAString*
GfxDriverInfo::sWindowProtocol[static_cast<size_t>(WindowProtocol::Max)];
nsAString*
@ -30,8 +28,6 @@ GfxDriverInfo::GfxDriverInfo()
mOperatingSystemVersion(0),
mScreen(ScreenSizeStatus::All),
mBattery(BatteryStatus::All),
mDesktopEnvironment(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::All)),
mWindowProtocol(GfxDriverInfo::GetWindowProtocol(WindowProtocol::All)),
mAdapterVendor(GfxDriverInfo::GetDeviceVendor(DeviceFamily::All)),
mDriverVendor(GfxDriverInfo::GetDriverVendor(DriverVendor::All)),
@ -48,17 +44,15 @@ GfxDriverInfo::GfxDriverInfo()
GfxDriverInfo::GfxDriverInfo(
OperatingSystem os, ScreenSizeStatus screen, BatteryStatus battery,
const nsAString& desktopEnv, const nsAString& windowProtocol,
const nsAString& vendor, const nsAString& driverVendor,
GfxDeviceFamily* devices, int32_t feature, int32_t featureStatus,
VersionComparisonOp op, uint64_t driverVersion, const char* ruleId,
const char* suggestedVersion /* = nullptr */, bool ownDevices /* = false */,
bool gpu2 /* = false */)
const nsAString& windowProtocol, const nsAString& vendor,
const nsAString& driverVendor, GfxDeviceFamily* devices, int32_t feature,
int32_t featureStatus, VersionComparisonOp op, uint64_t driverVersion,
const char* ruleId, const char* suggestedVersion /* = nullptr */,
bool ownDevices /* = false */, bool gpu2 /* = false */)
: mOperatingSystem(os),
mOperatingSystemVersion(0),
mScreen(screen),
mBattery(battery),
mDesktopEnvironment(desktopEnv),
mWindowProtocol(windowProtocol),
mAdapterVendor(vendor),
mDriverVendor(driverVendor),
@ -78,7 +72,6 @@ GfxDriverInfo::GfxDriverInfo(const GfxDriverInfo& aOrig)
mOperatingSystemVersion(aOrig.mOperatingSystemVersion),
mScreen(aOrig.mScreen),
mBattery(aOrig.mBattery),
mDesktopEnvironment(aOrig.mDesktopEnvironment),
mWindowProtocol(aOrig.mWindowProtocol),
mAdapterVendor(aOrig.mAdapterVendor),
mDriverVendor(aOrig.mDriverVendor),
@ -576,50 +569,6 @@ const GfxDeviceFamily* GfxDriverInfo::GetDeviceFamily(DeviceFamily id) {
return deviceFamily;
}
// Macro for assigning a desktop environment to a string.
#define DECLARE_DESKTOP_ENVIRONMENT_ID(name, desktopEnvId) \
case DesktopEnvironment::name: \
sDesktopEnvironment[idx]->AssignLiteral(desktopEnvId); \
break;
const nsAString& GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment id) {
if (id >= DesktopEnvironment::Max) {
MOZ_ASSERT_UNREACHABLE("DesktopEnvironment id is out of range");
id = DesktopEnvironment::All;
}
auto idx = static_cast<size_t>(id);
if (sDesktopEnvironment[idx]) {
return *sDesktopEnvironment[idx];
}
sDesktopEnvironment[idx] = new nsString();
switch (id) {
DECLARE_DESKTOP_ENVIRONMENT_ID(GNOME, "gnome");
DECLARE_DESKTOP_ENVIRONMENT_ID(KDE, "kde");
DECLARE_DESKTOP_ENVIRONMENT_ID(XFCE, "xfce");
DECLARE_DESKTOP_ENVIRONMENT_ID(Cinnamon, "cinnamon");
DECLARE_DESKTOP_ENVIRONMENT_ID(Enlightenment, "enlightment");
DECLARE_DESKTOP_ENVIRONMENT_ID(LXDE, "lxde");
DECLARE_DESKTOP_ENVIRONMENT_ID(Openbox, "openbox");
DECLARE_DESKTOP_ENVIRONMENT_ID(i3, "i3");
DECLARE_DESKTOP_ENVIRONMENT_ID(Sway, "sway");
DECLARE_DESKTOP_ENVIRONMENT_ID(Mate, "mate");
DECLARE_DESKTOP_ENVIRONMENT_ID(Unity, "unity");
DECLARE_DESKTOP_ENVIRONMENT_ID(Pantheon, "pantheon");
DECLARE_DESKTOP_ENVIRONMENT_ID(LXQT, "lxqt");
DECLARE_DESKTOP_ENVIRONMENT_ID(Deepin, "deepin");
DECLARE_DESKTOP_ENVIRONMENT_ID(Dwm, "dwm");
DECLARE_DESKTOP_ENVIRONMENT_ID(Budgie, "budgie");
DECLARE_DESKTOP_ENVIRONMENT_ID(Unknown, "unknown");
case DesktopEnvironment::Max: // Suppress a warning.
DECLARE_DESKTOP_ENVIRONMENT_ID(All, "");
}
return *sDesktopEnvironment[idx];
}
// Macro for assigning a window protocol id to a string.
#define DECLARE_WINDOW_PROTOCOL_ID(name, windowProtocolId) \
case WindowProtocol::name: \

Просмотреть файл

@ -14,106 +14,99 @@
// only on specific platforms (e.g. desktop environment and driver vendor
// for Linux.)
#define APPEND_TO_DRIVER_BLOCKLIST_EXT( \
os, screen, battery, desktopEnv, windowProtocol, driverVendor, devices, \
feature, featureStatus, driverComparator, driverVersion, ruleId, \
suggestedVersion) \
sDriverInfo->AppendElement(GfxDriverInfo( \
os, screen, battery, \
(nsAString&)GfxDriverInfo::GetDesktopEnvironment(desktopEnv), \
(nsAString&)GfxDriverInfo::GetWindowProtocol(windowProtocol), \
(nsAString&)GfxDriverInfo::GetDeviceVendor(devices), \
(nsAString&)GfxDriverInfo::GetDriverVendor(driverVendor), \
(GfxDeviceFamily*)GfxDriverInfo::GetDeviceFamily(devices), feature, \
featureStatus, driverComparator, driverVersion, ruleId, \
#define APPEND_TO_DRIVER_BLOCKLIST_EXT( \
os, screen, battery, windowProtocol, driverVendor, devices, feature, \
featureStatus, driverComparator, driverVersion, ruleId, suggestedVersion) \
sDriverInfo->AppendElement(GfxDriverInfo( \
os, screen, battery, \
(nsAString&)GfxDriverInfo::GetWindowProtocol(windowProtocol), \
(nsAString&)GfxDriverInfo::GetDeviceVendor(devices), \
(nsAString&)GfxDriverInfo::GetDriverVendor(driverVendor), \
(GfxDeviceFamily*)GfxDriverInfo::GetDeviceFamily(devices), feature, \
featureStatus, driverComparator, driverVersion, ruleId, \
suggestedVersion))
#define APPEND_TO_DRIVER_BLOCKLIST(os, devices, feature, featureStatus, \
driverComparator, driverVersion, ruleId, \
suggestedVersion) \
APPEND_TO_DRIVER_BLOCKLIST_EXT( \
os, ScreenSizeStatus::All, BatteryStatus::All, DesktopEnvironment::All, \
WindowProtocol::All, DriverVendor::All, devices, feature, featureStatus, \
driverComparator, driverVersion, ruleId, suggestedVersion)
#define APPEND_TO_DRIVER_BLOCKLIST(os, devices, feature, featureStatus, \
driverComparator, driverVersion, ruleId, \
suggestedVersion) \
APPEND_TO_DRIVER_BLOCKLIST_EXT( \
os, ScreenSizeStatus::All, BatteryStatus::All, WindowProtocol::All, \
DriverVendor::All, devices, feature, featureStatus, driverComparator, \
driverVersion, ruleId, suggestedVersion)
#define APPEND_TO_DRIVER_BLOCKLIST2_EXT( \
os, screen, battery, desktopEnv, windowProtocol, driverVendor, devices, \
feature, featureStatus, driverComparator, driverVersion, ruleId) \
sDriverInfo->AppendElement(GfxDriverInfo( \
os, screen, battery, \
(nsAString&)GfxDriverInfo::GetDesktopEnvironment(desktopEnv), \
(nsAString&)GfxDriverInfo::GetWindowProtocol(windowProtocol), \
(nsAString&)GfxDriverInfo::GetDeviceVendor(devices), \
(nsAString&)GfxDriverInfo::GetDriverVendor(driverVendor), \
(GfxDeviceFamily*)GfxDriverInfo::GetDeviceFamily(devices), feature, \
#define APPEND_TO_DRIVER_BLOCKLIST2_EXT( \
os, screen, battery, windowProtocol, driverVendor, devices, feature, \
featureStatus, driverComparator, driverVersion, ruleId) \
sDriverInfo->AppendElement(GfxDriverInfo( \
os, screen, battery, \
(nsAString&)GfxDriverInfo::GetWindowProtocol(windowProtocol), \
(nsAString&)GfxDriverInfo::GetDeviceVendor(devices), \
(nsAString&)GfxDriverInfo::GetDriverVendor(driverVendor), \
(GfxDeviceFamily*)GfxDriverInfo::GetDeviceFamily(devices), feature, \
featureStatus, driverComparator, driverVersion, ruleId))
#define APPEND_TO_DRIVER_BLOCKLIST2(os, devices, feature, featureStatus, \
driverComparator, driverVersion, ruleId) \
APPEND_TO_DRIVER_BLOCKLIST2_EXT( \
os, ScreenSizeStatus::All, BatteryStatus::All, DesktopEnvironment::All, \
WindowProtocol::All, DriverVendor::All, devices, feature, featureStatus, \
driverComparator, driverVersion, ruleId)
#define APPEND_TO_DRIVER_BLOCKLIST2(os, devices, feature, featureStatus, \
driverComparator, driverVersion, ruleId) \
APPEND_TO_DRIVER_BLOCKLIST2_EXT( \
os, ScreenSizeStatus::All, BatteryStatus::All, WindowProtocol::All, \
DriverVendor::All, devices, feature, featureStatus, driverComparator, \
driverVersion, ruleId)
#define APPEND_TO_DRIVER_BLOCKLIST_RANGE_EXT( \
os, screen, battery, desktopEnv, windowProtocol, driverVendor, devices, \
feature, featureStatus, driverComparator, driverVersion, driverVersionMax, \
ruleId, suggestedVersion) \
do { \
MOZ_ASSERT((driverComparator) == DRIVER_BETWEEN_EXCLUSIVE || \
(driverComparator) == DRIVER_BETWEEN_INCLUSIVE || \
(driverComparator) == DRIVER_BETWEEN_INCLUSIVE_START); \
GfxDriverInfo info( \
os, screen, battery, \
(nsAString&)GfxDriverInfo::GetDesktopEnvironment(desktopEnv), \
(nsAString&)GfxDriverInfo::GetWindowProtocol(windowProtocol), \
(nsAString&)GfxDriverInfo::GetDeviceVendor(devices), \
(nsAString&)GfxDriverInfo::GetDriverVendor(driverVendor), \
(GfxDeviceFamily*)GfxDriverInfo::GetDeviceFamily(devices), feature, \
featureStatus, driverComparator, driverVersion, ruleId, \
suggestedVersion); \
info.mDriverVersionMax = driverVersionMax; \
sDriverInfo->AppendElement(info); \
#define APPEND_TO_DRIVER_BLOCKLIST_RANGE_EXT( \
os, screen, battery, windowProtocol, driverVendor, devices, feature, \
featureStatus, driverComparator, driverVersion, driverVersionMax, ruleId, \
suggestedVersion) \
do { \
MOZ_ASSERT((driverComparator) == DRIVER_BETWEEN_EXCLUSIVE || \
(driverComparator) == DRIVER_BETWEEN_INCLUSIVE || \
(driverComparator) == DRIVER_BETWEEN_INCLUSIVE_START); \
GfxDriverInfo info( \
os, screen, battery, \
(nsAString&)GfxDriverInfo::GetWindowProtocol(windowProtocol), \
(nsAString&)GfxDriverInfo::GetDeviceVendor(devices), \
(nsAString&)GfxDriverInfo::GetDriverVendor(driverVendor), \
(GfxDeviceFamily*)GfxDriverInfo::GetDeviceFamily(devices), feature, \
featureStatus, driverComparator, driverVersion, ruleId, \
suggestedVersion); \
info.mDriverVersionMax = driverVersionMax; \
sDriverInfo->AppendElement(info); \
} while (false)
#define APPEND_TO_DRIVER_BLOCKLIST_RANGE( \
os, devices, feature, featureStatus, driverComparator, driverVersion, \
driverVersionMax, ruleId, suggestedVersion) \
APPEND_TO_DRIVER_BLOCKLIST_RANGE_EXT( \
os, ScreenSizeStatus::All, BatteryStatus::All, DesktopEnvironment::All, \
WindowProtocol::All, DriverVendor::All, devices, feature, featureStatus, \
driverComparator, driverVersion, driverVersionMax, ruleId, \
suggestedVersion)
#define APPEND_TO_DRIVER_BLOCKLIST_RANGE( \
os, devices, feature, featureStatus, driverComparator, driverVersion, \
driverVersionMax, ruleId, suggestedVersion) \
APPEND_TO_DRIVER_BLOCKLIST_RANGE_EXT( \
os, ScreenSizeStatus::All, BatteryStatus::All, WindowProtocol::All, \
DriverVendor::All, devices, feature, featureStatus, driverComparator, \
driverVersion, driverVersionMax, ruleId, suggestedVersion)
#define APPEND_TO_DRIVER_BLOCKLIST_RANGE_GPU2_EXT( \
os, screen, battery, desktopEnv, windowProtocol, driverVendor, devices, \
feature, featureStatus, driverComparator, driverVersion, driverVersionMax, \
ruleId, suggestedVersion) \
do { \
MOZ_ASSERT((driverComparator) == DRIVER_BETWEEN_EXCLUSIVE || \
(driverComparator) == DRIVER_BETWEEN_INCLUSIVE || \
(driverComparator) == DRIVER_BETWEEN_INCLUSIVE_START); \
GfxDriverInfo info( \
os, screen, battery, \
(nsAString&)GfxDriverInfo::GetDesktopEnvironment(desktopEnv), \
(nsAString&)GfxDriverInfo::GetWindowProtocol(windowProtocol), \
(nsAString&)GfxDriverInfo::GetDeviceVendor(devices), \
(nsAString&)GfxDriverInfo::GetDriverVendor(driverVendor), \
(GfxDeviceFamily*)GfxDriverInfo::GetDeviceFamily(devices), feature, \
featureStatus, driverComparator, driverVersion, ruleId, \
suggestedVersion, false, true); \
info.mDriverVersionMax = driverVersionMax; \
sDriverInfo->AppendElement(info); \
#define APPEND_TO_DRIVER_BLOCKLIST_RANGE_GPU2_EXT( \
os, screen, battery, windowProtocol, driverVendor, devices, feature, \
featureStatus, driverComparator, driverVersion, driverVersionMax, ruleId, \
suggestedVersion) \
do { \
MOZ_ASSERT((driverComparator) == DRIVER_BETWEEN_EXCLUSIVE || \
(driverComparator) == DRIVER_BETWEEN_INCLUSIVE || \
(driverComparator) == DRIVER_BETWEEN_INCLUSIVE_START); \
GfxDriverInfo info( \
os, screen, battery, \
(nsAString&)GfxDriverInfo::GetWindowProtocol(windowProtocol), \
(nsAString&)GfxDriverInfo::GetDeviceVendor(devices), \
(nsAString&)GfxDriverInfo::GetDriverVendor(driverVendor), \
(GfxDeviceFamily*)GfxDriverInfo::GetDeviceFamily(devices), feature, \
featureStatus, driverComparator, driverVersion, ruleId, \
suggestedVersion, false, true); \
info.mDriverVersionMax = driverVersionMax; \
sDriverInfo->AppendElement(info); \
} while (false)
#define APPEND_TO_DRIVER_BLOCKLIST_RANGE_GPU2( \
os, devices, feature, featureStatus, driverComparator, driverVersion, \
driverVersionMax, ruleId, suggestedVersion) \
APPEND_TO_DRIVER_BLOCKLIST_RANGE_GPU2_EXT( \
os, ScreenSizeStatus::All, BatteryStatus::All, DesktopEnvironment::All, \
WindowProtocol::All, DriverVendor::All, devices, feature, featureStatus, \
driverComparator, driverVersion, driverVersionMax, ruleId, \
suggestedVersion)
#define APPEND_TO_DRIVER_BLOCKLIST_RANGE_GPU2( \
os, devices, feature, featureStatus, driverComparator, driverVersion, \
driverVersionMax, ruleId, suggestedVersion) \
APPEND_TO_DRIVER_BLOCKLIST_RANGE_GPU2_EXT( \
os, ScreenSizeStatus::All, BatteryStatus::All, WindowProtocol::All, \
DriverVendor::All, devices, feature, featureStatus, driverComparator, \
driverVersion, driverVersionMax, ruleId, suggestedVersion)
namespace mozilla {
namespace widget {
@ -253,28 +246,6 @@ enum DriverVendor : uint8_t {
Max
};
enum class DesktopEnvironment : uint8_t {
All, // There is an assumption that this is the first enum
GNOME,
KDE,
XFCE,
Cinnamon,
Enlightenment,
LXDE,
Openbox,
i3,
Mate,
Unity,
Pantheon,
LXQT,
Deepin,
Dwm,
Budgie,
Sway,
Unknown,
Max
};
enum class WindowProtocol : uint8_t {
All, // There is an assumption that this is the first enum
X11,
@ -325,10 +296,10 @@ struct GfxDriverInfo {
// If |ownDevices| is true, you are transferring ownership of the devices
// array, and it will be deleted when this GfxDriverInfo is destroyed.
GfxDriverInfo(OperatingSystem os, ScreenSizeStatus aScreen,
BatteryStatus aBattery, const nsAString& desktopEnv,
const nsAString& windowProtocol, const nsAString& vendor,
const nsAString& driverVendor, GfxDeviceFamily* devices,
int32_t feature, int32_t featureStatus, VersionComparisonOp op,
BatteryStatus aBattery, const nsAString& windowProtocol,
const nsAString& vendor, const nsAString& driverVendor,
GfxDeviceFamily* devices, int32_t feature,
int32_t featureStatus, VersionComparisonOp op,
uint64_t driverVersion, const char* ruleId,
const char* suggestedVersion = nullptr, bool ownDevices = false,
bool gpu2 = false);
@ -341,7 +312,6 @@ struct GfxDriverInfo {
uint32_t mOperatingSystemVersion;
ScreenSizeStatus mScreen;
BatteryStatus mBattery;
nsString mDesktopEnvironment;
nsString mWindowProtocol;
nsString mAdapterVendor;
@ -374,10 +344,6 @@ struct GfxDriverInfo {
static GfxDeviceFamily*
sDeviceFamilies[static_cast<size_t>(DeviceFamily::Max)];
static const nsAString& GetDesktopEnvironment(DesktopEnvironment id);
static nsAString*
sDesktopEnvironment[static_cast<size_t>(DesktopEnvironment::Max)];
static const nsAString& GetWindowProtocol(WindowProtocol id);
static nsAString* sWindowProtocol[static_cast<size_t>(WindowProtocol::Max)];

Просмотреть файл

@ -78,11 +78,6 @@ class ShutdownObserver : public nsIObserver {
deviceFamily = nullptr;
}
for (auto& desktop : GfxDriverInfo::sDesktopEnvironment) {
delete desktop;
desktop = nullptr;
}
for (auto& windowProtocol : GfxDriverInfo::sWindowProtocol) {
delete windowProtocol;
windowProtocol = nullptr;
@ -668,8 +663,6 @@ static bool BlocklistEntryToDriverInfo(const nsACString& aBlocklistEntry,
aDriverInfo.mOperatingSystem = BlocklistOSToOperatingSystem(dataValue);
} else if (key.EqualsLiteral("osversion")) {
aDriverInfo.mOperatingSystemVersion = strtoul(value.get(), nullptr, 10);
} else if (key.EqualsLiteral("desktopEnvironment")) {
aDriverInfo.mDesktopEnvironment = dataValue;
} else if (key.EqualsLiteral("windowProtocol")) {
aDriverInfo.mWindowProtocol = dataValue;
} else if (key.EqualsLiteral("vendor")) {
@ -1074,11 +1067,6 @@ int32_t GfxInfoBase::FindBlocklistedDeviceInList(
continue;
}
if (!DoesDesktopEnvironmentMatch(info[i].mDesktopEnvironment,
desktopEnvironment)) {
continue;
}
if (!DoesWindowProtocolMatch(info[i].mWindowProtocol, windowProtocol)) {
continue;
}
@ -1237,15 +1225,6 @@ void GfxInfoBase::SetFeatureStatus(nsTArray<gfx::GfxInfoFeatureStatus>&& aFS) {
InitFeatureStatus(new nsTArray<gfx::GfxInfoFeatureStatus>(std::move(aFS)));
}
bool GfxInfoBase::DoesDesktopEnvironmentMatch(
const nsAString& aBlocklistDesktop, const nsAString& aDesktopEnv) {
return aBlocklistDesktop.Equals(aDesktopEnv,
nsCaseInsensitiveStringComparator) ||
aBlocklistDesktop.Equals(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::All),
nsCaseInsensitiveStringComparator);
}
bool GfxInfoBase::DoesWindowProtocolMatch(
const nsAString& aBlocklistWindowProtocol,
const nsAString& aWindowProtocol) {

Просмотреть файл

@ -127,9 +127,6 @@ class GfxInfoBase : public nsIGfxInfo,
virtual void DescribeFeatures(JSContext* aCx, JS::Handle<JSObject*> obj);
bool DoesDesktopEnvironmentMatch(const nsAString& aBlocklistDesktop,
const nsAString& aDesktopEnv);
virtual bool DoesWindowProtocolMatch(
const nsAString& aBlocklistWindowProtocol,
const nsAString& aWindowProtocol);

Просмотреть файл

@ -21,6 +21,8 @@
#include "nsCRTGlue.h"
#include "nsExceptionHandler.h"
#include "nsPrintfCString.h"
#include "nsString.h"
#include "nsStringFwd.h"
#include "nsUnicharUtils.h"
#include "nsWhitespaceTokenizer.h"
#include "prenv.h"
@ -74,7 +76,8 @@ void GfxInfo::AddCrashReportAnnotations() {
CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::IsWayland,
mIsWayland);
CrashReporter::AnnotateCrashReport(
CrashReporter::Annotation::DesktopEnvironment, mDesktopEnvironment);
CrashReporter::Annotation::DesktopEnvironment,
GetDesktopEnvironmentIdentifier());
if (mHasMultipleGPUs) {
nsAutoCString note;
@ -492,120 +495,6 @@ void GfxInfo::GetData() {
mIsWayland = GdkIsWaylandDisplay();
mIsXWayland = IsXWaylandProtocol();
// Make a best effort guess at the desktop environment in use. Sadly there
// does not appear to be a standard way to do this, so we check a few
// different environment variables and search for relevant keywords.
//
// Note that some users manually change these values. Some applications check
// the environment variable like we are here, and either not work or restrict
// functionality. There may be some heroics we could go through to determine
// the truth, but for the moment, this is the best we can do. This is
// something to keep in mind when updating the blocklist.
const char* desktopEnv = getenv("XDG_CURRENT_DESKTOP");
if (!desktopEnv) {
desktopEnv = getenv("DESKTOP_SESSION");
}
if (desktopEnv) {
std::string currentDesktop(desktopEnv);
for (auto& c : currentDesktop) {
c = std::tolower(c);
}
if (currentDesktop.find("budgie") != std::string::npos) {
// We need to check for Budgie first, because it might incorporate GNOME
// into the environment variable value.
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::Budgie),
mDesktopEnvironment);
} else if (currentDesktop.find("gnome") != std::string::npos) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::GNOME),
mDesktopEnvironment);
} else if (currentDesktop.find("kde") != std::string::npos) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::KDE),
mDesktopEnvironment);
} else if (currentDesktop.find("xfce") != std::string::npos) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::XFCE),
mDesktopEnvironment);
} else if (currentDesktop.find("cinnamon") != std::string::npos) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::Cinnamon),
mDesktopEnvironment);
} else if (currentDesktop.find("enlightenment") != std::string::npos) {
CopyUTF16toUTF8(GfxDriverInfo::GetDesktopEnvironment(
DesktopEnvironment::Enlightenment),
mDesktopEnvironment);
} else if (currentDesktop.find("lxde") != std::string::npos ||
currentDesktop.find("lubuntu") != std::string::npos) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::LXDE),
mDesktopEnvironment);
} else if (currentDesktop.find("openbox") != std::string::npos) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::Openbox),
mDesktopEnvironment);
} else if (currentDesktop.find("i3") != std::string::npos) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::i3),
mDesktopEnvironment);
} else if (currentDesktop.find("sway") != std::string::npos) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::Sway),
mDesktopEnvironment);
} else if (currentDesktop.find("mate") != std::string::npos) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::Mate),
mDesktopEnvironment);
} else if (currentDesktop.find("unity") != std::string::npos) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::Unity),
mDesktopEnvironment);
} else if (currentDesktop.find("pantheon") != std::string::npos) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::Pantheon),
mDesktopEnvironment);
} else if (currentDesktop.find("lxqt") != std::string::npos) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::LXQT),
mDesktopEnvironment);
} else if (currentDesktop.find("deepin") != std::string::npos) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::Deepin),
mDesktopEnvironment);
} else if (currentDesktop.find("dwm") != std::string::npos) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::Dwm),
mDesktopEnvironment);
}
}
if (mDesktopEnvironment.IsEmpty()) {
if (getenv("GNOME_DESKTOP_SESSION_ID")) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::GNOME),
mDesktopEnvironment);
} else if (getenv("KDE_FULL_SESSION")) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::KDE),
mDesktopEnvironment);
} else if (getenv("MATE_DESKTOP_SESSION_ID")) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::Mate),
mDesktopEnvironment);
} else if (getenv("LXQT_SESSION_CONFIG")) {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::LXQT),
mDesktopEnvironment);
} else {
CopyUTF16toUTF8(
GfxDriverInfo::GetDesktopEnvironment(DesktopEnvironment::Unknown),
mDesktopEnvironment);
}
}
if (!ddxDriver.IsEmpty()) {
PRInt32 start = 0;
PRInt32 loc = ddxDriver.Find(";", start);
@ -659,26 +548,26 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
// to query device IDs backing a GL context for blocklisting.
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::MesaAll,
DeviceFamily::All, GfxDriverInfo::allFeatures,
nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
V(10, 0, 0, 0), "FEATURE_FAILURE_OLD_MESA", "Mesa 10.0");
WindowProtocol::All, DriverVendor::MesaAll, DeviceFamily::All,
GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
DRIVER_LESS_THAN, V(10, 0, 0, 0), "FEATURE_FAILURE_OLD_MESA",
"Mesa 10.0");
// NVIDIA Mesa baseline (see bug 1714391).
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::MesaNouveau,
DeviceFamily::All, GfxDriverInfo::allFeatures,
nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
V(11, 0, 0, 0), "FEATURE_FAILURE_OLD_NV_MESA", "Mesa 11.0");
WindowProtocol::All, DriverVendor::MesaNouveau, DeviceFamily::All,
GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
DRIVER_LESS_THAN, V(11, 0, 0, 0), "FEATURE_FAILURE_OLD_NV_MESA",
"Mesa 11.0");
// NVIDIA baseline (ported from old blocklist)
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::NonMesaAll,
DeviceFamily::NvidiaAll, GfxDriverInfo::allFeatures,
nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
V(257, 21, 0, 0), "FEATURE_FAILURE_OLD_NVIDIA", "NVIDIA 257.21");
WindowProtocol::All, DriverVendor::NonMesaAll, DeviceFamily::NvidiaAll,
GfxDriverInfo::allFeatures, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
DRIVER_LESS_THAN, V(257, 21, 0, 0), "FEATURE_FAILURE_OLD_NVIDIA",
"NVIDIA 257.21");
// fglrx baseline (chosen arbitrarily as 2013-07-22 release).
APPEND_TO_DRIVER_BLOCKLIST(
@ -693,8 +582,7 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
// All Mesa software drivers, they should get Software WebRender instead.
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All,
DriverVendor::SoftwareMesaAll, DeviceFamily::All,
WindowProtocol::All, DriverVendor::SoftwareMesaAll, DeviceFamily::All,
nsIGfxInfo::FEATURE_WEBRENDER, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
DRIVER_COMPARISON_IGNORED, V(0, 0, 0, 0), "FEATURE_FAILURE_SOFTWARE_GL",
"");
@ -709,17 +597,17 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
// Nvidia Mesa baseline, see bug 1563859.
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::MesaAll,
DeviceFamily::NvidiaAll, nsIGfxInfo::FEATURE_WEBRENDER,
WindowProtocol::All, DriverVendor::MesaAll, DeviceFamily::NvidiaAll,
nsIGfxInfo::FEATURE_WEBRENDER,
nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
V(18, 2, 0, 0), "FEATURE_FAILURE_WEBRENDER_OLD_MESA", "Mesa 18.2.0.0");
// Disable on all older Nvidia drivers due to stability issues.
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::NonMesaAll,
DeviceFamily::NvidiaAll, nsIGfxInfo::FEATURE_WEBRENDER,
nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_LESS_THAN, V(460, 82, 0, 0),
WindowProtocol::All, DriverVendor::NonMesaAll, DeviceFamily::NvidiaAll,
nsIGfxInfo::FEATURE_WEBRENDER, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
DRIVER_LESS_THAN, V(460, 82, 0, 0),
"FEATURE_FAILURE_WEBRENDER_OLD_NVIDIA", "460.82.0");
// Older generation NVIDIA devices do not perform well with WebRender.
@ -734,8 +622,8 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
// WebRender on old drivers with outstanding bugs to work around.
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::MesaAll,
DeviceFamily::All, nsIGfxInfo::FEATURE_WEBRENDER,
WindowProtocol::All, DriverVendor::MesaAll, DeviceFamily::All,
nsIGfxInfo::FEATURE_WEBRENDER,
nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
V(17, 0, 0, 0), "FEATURE_FAILURE_WEBRENDER_OLD_MESA", "Mesa 17.0.0.0");
@ -743,9 +631,8 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
// often have less mature drivers so let's block older Mesa versions.
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All,
DriverVendor::MesaNonIntelNvidiaAtiAll, DeviceFamily::All,
nsIGfxInfo::FEATURE_WEBRENDER,
WindowProtocol::All, DriverVendor::MesaNonIntelNvidiaAtiAll,
DeviceFamily::All, nsIGfxInfo::FEATURE_WEBRENDER,
nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
V(22, 2, 0, 0), "FEATURE_FAILURE_WEBRENDER_OLD_MESA_OTHER",
"Mesa 22.2.0.0");
@ -754,8 +641,8 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
// AMD r600 driver to avoid shader compilation issues.
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::MesaR600,
DeviceFamily::All, nsIGfxInfo::FEATURE_WEBRENDER,
WindowProtocol::All, DriverVendor::MesaR600, DeviceFamily::All,
nsIGfxInfo::FEATURE_WEBRENDER,
nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
V(17, 3, 0, 0), "FEATURE_FAILURE_WEBRENDER_OLD_MESA_R600",
"Mesa 17.3.0.0");
@ -763,18 +650,18 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
// Disable on all ATI devices not using Mesa for now.
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::NonMesaAll,
DeviceFamily::AtiAll, nsIGfxInfo::FEATURE_WEBRENDER,
nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_COMPARISON_IGNORED,
V(0, 0, 0, 0), "FEATURE_FAILURE_WEBRENDER_NO_LINUX_ATI", "");
WindowProtocol::All, DriverVendor::NonMesaAll, DeviceFamily::AtiAll,
nsIGfxInfo::FEATURE_WEBRENDER, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
DRIVER_COMPARISON_IGNORED, V(0, 0, 0, 0),
"FEATURE_FAILURE_WEBRENDER_NO_LINUX_ATI", "");
// Bug 1673939 - Garbled text on RS880 GPUs with Mesa drivers.
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::MesaAll,
DeviceFamily::AmdR600, nsIGfxInfo::FEATURE_WEBRENDER,
nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_COMPARISON_IGNORED,
V(0, 0, 0, 0), "FEATURE_FAILURE_WEBRENDER_BUG_1673939",
WindowProtocol::All, DriverVendor::MesaAll, DeviceFamily::AmdR600,
nsIGfxInfo::FEATURE_WEBRENDER, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
DRIVER_COMPARISON_IGNORED, V(0, 0, 0, 0),
"FEATURE_FAILURE_WEBRENDER_BUG_1673939",
"https://gitlab.freedesktop.org/mesa/mesa/-/issues/3720");
// Bug 1635186 - Poor performance with video playing in a background window
@ -783,8 +670,8 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
// on Wayland rigth now.
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::XWayland,
DriverVendor::MesaAll, DeviceFamily::All, nsIGfxInfo::FEATURE_WEBRENDER,
WindowProtocol::XWayland, DriverVendor::MesaAll, DeviceFamily::All,
nsIGfxInfo::FEATURE_WEBRENDER,
nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
V(21, 0, 0, 0), "FEATURE_FAILURE_WEBRENDER_BUG_1635186",
"Mesa 21.0.0.0");
@ -801,34 +688,34 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
// FEATURE_X11_EGL
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::MesaAll,
DeviceFamily::All, nsIGfxInfo::FEATURE_X11_EGL,
nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
V(21, 0, 0, 0), "FEATURE_ROLLOUT_X11_EGL_MESA", "Mesa 21.0.0.0");
WindowProtocol::All, DriverVendor::MesaAll, DeviceFamily::All,
nsIGfxInfo::FEATURE_X11_EGL, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
DRIVER_LESS_THAN, V(21, 0, 0, 0), "FEATURE_ROLLOUT_X11_EGL_MESA",
"Mesa 21.0.0.0");
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::NonMesaAll,
DeviceFamily::NvidiaAll, nsIGfxInfo::FEATURE_X11_EGL,
nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
V(470, 82, 0, 0), "FEATURE_ROLLOUT_X11_EGL_NVIDIA_BINARY", "470.82.0");
WindowProtocol::All, DriverVendor::NonMesaAll, DeviceFamily::NvidiaAll,
nsIGfxInfo::FEATURE_X11_EGL, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
DRIVER_LESS_THAN, V(470, 82, 0, 0),
"FEATURE_ROLLOUT_X11_EGL_NVIDIA_BINARY", "470.82.0");
// Disable on all AMD devices not using Mesa.
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::NonMesaAll,
DeviceFamily::AtiAll, nsIGfxInfo::FEATURE_X11_EGL,
nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_COMPARISON_IGNORED,
V(0, 0, 0, 0), "FEATURE_FAILURE_X11_EGL_NO_LINUX_ATI", "");
WindowProtocol::All, DriverVendor::NonMesaAll, DeviceFamily::AtiAll,
nsIGfxInfo::FEATURE_X11_EGL, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
DRIVER_COMPARISON_IGNORED, V(0, 0, 0, 0),
"FEATURE_FAILURE_X11_EGL_NO_LINUX_ATI", "");
////////////////////////////////////
// FEATURE_DMABUF
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::NonMesaAll,
DeviceFamily::NvidiaAll, nsIGfxInfo::FEATURE_DMABUF,
nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
V(495, 44, 0, 0), "FEATURE_FAILURE_NO_GBM", "495.44.0");
WindowProtocol::All, DriverVendor::NonMesaAll, DeviceFamily::NvidiaAll,
nsIGfxInfo::FEATURE_DMABUF, nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION,
DRIVER_LESS_THAN, V(495, 44, 0, 0), "FEATURE_FAILURE_NO_GBM",
"495.44.0");
////////////////////////////////////
// FEATURE_DMABUF_SURFACE_EXPORT
@ -837,8 +724,8 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
// https://gitlab.freedesktop.org/mesa/mesa/-/issues/6796
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::MesaAll,
DeviceFamily::AtiAll, nsIGfxInfo::FEATURE_DMABUF_SURFACE_EXPORT,
WindowProtocol::All, DriverVendor::MesaAll, DeviceFamily::AtiAll,
nsIGfxInfo::FEATURE_DMABUF_SURFACE_EXPORT,
nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_COMPARISON_IGNORED,
V(0, 0, 0, 0), "FEATURE_FAILURE_BROKEN_DRIVER", "");
@ -846,8 +733,8 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
// https://gitlab.freedesktop.org/mesa/mesa/-/issues/6688
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::MesaAll,
DeviceFamily::IntelAll, nsIGfxInfo::FEATURE_DMABUF_SURFACE_EXPORT,
WindowProtocol::All, DriverVendor::MesaAll, DeviceFamily::IntelAll,
nsIGfxInfo::FEATURE_DMABUF_SURFACE_EXPORT,
nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_COMPARISON_IGNORED,
V(0, 0, 0, 0), "FEATURE_FAILURE_BROKEN_DRIVER", "");
@ -855,8 +742,8 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
// https://gitlab.freedesktop.org/mesa/mesa/-/issues/6988
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::MesaAll,
DeviceFamily::QualcommAll, nsIGfxInfo::FEATURE_DMABUF_SURFACE_EXPORT,
WindowProtocol::All, DriverVendor::MesaAll, DeviceFamily::QualcommAll,
nsIGfxInfo::FEATURE_DMABUF_SURFACE_EXPORT,
nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_COMPARISON_IGNORED,
V(0, 0, 0, 0), "FEATURE_FAILURE_BROKEN_DRIVER", "");
@ -864,8 +751,8 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
// FEATURE_HARDWARE_VIDEO_DECODING
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::MesaAll,
DeviceFamily::All, nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
WindowProtocol::All, DriverVendor::MesaAll, DeviceFamily::All,
nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION, DRIVER_LESS_THAN,
V(21, 0, 0, 0), "FEATURE_HARDWARE_VIDEO_DECODING_MESA",
"Mesa 21.0.0.0");
@ -873,16 +760,16 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
// Disable on all NVIDIA hardware
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::All,
DeviceFamily::NvidiaAll, nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
WindowProtocol::All, DriverVendor::All, DeviceFamily::NvidiaAll,
nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_COMPARISON_IGNORED,
V(0, 0, 0, 0), "FEATURE_HARDWARE_VIDEO_DECODING_NO_LINUX_NVIDIA", "");
// Disable on all AMD devices not using Mesa.
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::NonMesaAll,
DeviceFamily::AtiAll, nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
WindowProtocol::All, DriverVendor::NonMesaAll, DeviceFamily::AtiAll,
nsIGfxInfo::FEATURE_HARDWARE_VIDEO_DECODING,
nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_COMPARISON_IGNORED,
V(0, 0, 0, 0), "FEATURE_HARDWARE_VIDEO_DECODING_NO_LINUX_AMD", "");
@ -899,8 +786,8 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
// FEATURE_WEBRENDER_PARTIAL_PRESENT
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::X11, DriverVendor::NonMesaAll,
DeviceFamily::NvidiaAll, nsIGfxInfo::FEATURE_WEBRENDER_PARTIAL_PRESENT,
WindowProtocol::X11, DriverVendor::NonMesaAll, DeviceFamily::NvidiaAll,
nsIGfxInfo::FEATURE_WEBRENDER_PARTIAL_PRESENT,
nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_COMPARISON_IGNORED,
V(0, 0, 0, 0), "FEATURE_ROLLOUT_WR_PARTIAL_PRESENT_NVIDIA_BINARY", "");
@ -908,10 +795,10 @@ const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
APPEND_TO_DRIVER_BLOCKLIST_EXT(
OperatingSystem::Linux, ScreenSizeStatus::All, BatteryStatus::All,
DesktopEnvironment::All, WindowProtocol::All, DriverVendor::MesaNouveau,
DeviceFamily::All, nsIGfxInfo::FEATURE_THREADSAFE_GL,
nsIGfxInfo::FEATURE_BLOCKED_DEVICE, DRIVER_COMPARISON_IGNORED,
V(0, 0, 0, 0), "FEATURE_FAILURE_THREADSAFE_GL", "");
WindowProtocol::All, DriverVendor::MesaNouveau, DeviceFamily::All,
nsIGfxInfo::FEATURE_THREADSAFE_GL, nsIGfxInfo::FEATURE_BLOCKED_DEVICE,
DRIVER_COMPARISON_IGNORED, V(0, 0, 0, 0),
"FEATURE_FAILURE_THREADSAFE_GL", "");
}
return *sDriverInfo;
}
@ -1089,8 +976,7 @@ GfxInfo::GetWindowProtocol(nsAString& aWindowProtocol) {
NS_IMETHODIMP
GfxInfo::GetDesktopEnvironment(nsAString& aDesktopEnvironment) {
GetData();
AppendASCIItoUTF16(mDesktopEnvironment, aDesktopEnvironment);
CopyUTF8toUTF16(GetDesktopEnvironmentIdentifier(), aDesktopEnvironment);
return NS_OK;
}

Просмотреть файл

@ -89,7 +89,6 @@ class GfxInfo final : public GfxInfoBase {
uint32_t mAdapterRAM;
nsCString mOS;
nsCString mOSRelease;
nsAutoCStringN<16> mDesktopEnvironment;
nsCString mTestType;
nsCString mSecondaryVendorId;

Просмотреть файл

@ -521,15 +521,10 @@ RefPtr<nsIScreen> ScreenGetterWayland::GetScreenForWindow(nsWindow* aWindow) {
return mScreenList[monitor];
}
static bool IsGNOMECompositor() {
const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP");
return currentDesktop && strstr(currentDesktop, "GNOME") != nullptr;
}
#endif
RefPtr<nsIScreen> ScreenHelperGTK::GetScreenForWindow(nsWindow* aWindow) {
return gScreenGetter->GetScreenForWindow(aWindow);
}
#endif
gint ScreenHelperGTK::GetGTKMonitorScaleFactor(gint aMonitorNum) {
GdkScreen* screen = gdk_screen_get_default();
@ -542,7 +537,7 @@ ScreenHelperGTK::ScreenHelperGTK() {
// to track screen size changes (which are wrongly reported by mutter)
// and causes issues on Sway (Bug 1730476).
// https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/3941
if (GdkIsWaylandDisplay() && IsGNOMECompositor()) {
if (GdkIsWaylandDisplay() && IsGnomeDesktopEnvironment()) {
gScreenGetter = MakeUnique<ScreenGetterWayland>();
}
#endif

Просмотреть файл

@ -5,9 +5,12 @@
#include "WidgetUtilsGtk.h"
#include "MainThreadUtils.h"
#include "mozilla/StaticPrefs_widget.h"
#include "mozilla/UniquePtr.h"
#include "nsReadableUtils.h"
#include "nsString.h"
#include "nsStringFwd.h"
#include "nsWindow.h"
#include "nsIGfxInfo.h"
#include "mozilla/Components.h"
@ -312,4 +315,131 @@ RefPtr<FocusRequestPromise> RequestWaylandFocusPromise() {
#endif
}
// https://specifications.freedesktop.org/wm-spec/1.3/ar01s05.html
static nsCString GetWindowManagerName() {
if (!GdkIsX11Display()) {
return {};
}
#ifdef MOZ_X11
Display* xdisplay = gdk_x11_get_default_xdisplay();
Window root_win =
GDK_WINDOW_XID(gdk_screen_get_root_window(gdk_screen_get_default()));
int actual_format_return;
Atom actual_type_return;
unsigned long nitems_return;
unsigned long bytes_after_return;
unsigned char* prop_return = nullptr;
auto releaseXProperty = MakeScopeExit([&] {
if (prop_return) {
XFree(prop_return);
}
});
Atom property = XInternAtom(xdisplay, "_NET_SUPPORTING_WM_CHECK", true);
Atom req_type = XInternAtom(xdisplay, "WINDOW", true);
if (!property || !req_type) {
return {};
}
int result =
XGetWindowProperty(xdisplay, root_win, property,
0L, // offset
sizeof(Window) / 4, // length
false, // delete
req_type, &actual_type_return, &actual_format_return,
&nitems_return, &bytes_after_return, &prop_return);
if (result != Success || bytes_after_return != 0 || nitems_return != 1) {
return {};
}
Window wmWindow = reinterpret_cast<Window*>(prop_return)[0];
if (!wmWindow) {
return {};
}
XFree(prop_return);
prop_return = nullptr;
property = XInternAtom(xdisplay, "_NET_WM_NAME", true);
req_type = XInternAtom(xdisplay, "UTF8_STRING", true);
if (!property || !req_type) {
return {};
}
result =
XGetWindowProperty(xdisplay, wmWindow, property,
0L, // offset
INT32_MAX, // length
false, // delete
req_type, &actual_type_return, &actual_format_return,
&nitems_return, &bytes_after_return, &prop_return);
if (result != Success || bytes_after_return != 0) {
return {};
}
return nsCString(reinterpret_cast<const char*>(prop_return));
#else
return {};
#endif
}
// Getting a reliable identifier is quite tricky. We try to use the standard
// XDG_CURRENT_DESKTOP environment first, _NET_WM_NAME later, and a set of
// legacy / non-standard environment variables otherwise.
//
// Documentation for some of those can be found in:
//
// https://wiki.archlinux.org/title/Environment_variables#Examples
// https://wiki.archlinux.org/title/Xdg-utils#Environment_variables
const nsCString& GetDesktopEnvironmentIdentifier() {
MOZ_ASSERT(NS_IsMainThread());
static const nsDependentCString sIdentifier = [] {
nsCString ident = [] {
if (const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP")) {
return nsCString(currentDesktop);
}
if (auto wm = GetWindowManagerName(); !wm.IsEmpty()) {
return wm;
}
if (const char* sessionDesktop = getenv("XDG_SESSION_DESKTOP")) {
// This is not really standardized in freedesktop.org, but it is
// documented here, and should be set in systemd systems.
// https://www.freedesktop.org/software/systemd/man/pam_systemd.html#%24XDG_SESSION_DESKTOP
return nsCString(sessionDesktop);
}
// We try first the DE-specific variables, then SESSION_DESKTOP, to match
// the documented order in:
// https://wiki.archlinux.org/title/Xdg-utils#Environment_variables
if (getenv("GNOME_DESKTOP_SESSION_ID")) {
return nsCString("gnome"_ns);
}
if (getenv("KDE_FULL_SESSION")) {
return nsCString("kde"_ns);
}
if (getenv("MATE_DESKTOP_SESSION_ID")) {
return nsCString("mate"_ns);
}
if (getenv("LXQT_SESSION_CONFIG")) {
return nsCString("lxqt"_ns);
}
if (const char* desktopSession = getenv("DESKTOP_SESSION")) {
// Try the legacy DESKTOP_SESSION as a last resort.
return nsCString(desktopSession);
}
return nsCString();
}();
ToLowerCase(ident);
// Intentionally put into a ToNewCString copy, rather than just making a
// static nsCString to avoid leakchecking errors, since we really want to
// leak this string.
return nsDependentCString(ToNewCString(ident), ident.Length());
}();
return sIdentifier;
}
bool IsGnomeDesktopEnvironment() {
return FindInReadable("gnome"_ns, GetDesktopEnvironmentIdentifier());
}
} // namespace mozilla::widget

Просмотреть файл

@ -58,6 +58,15 @@ enum class PortalKind {
};
bool ShouldUsePortal(PortalKind);
// Tries to get a descriptive identifier for the desktop environment that the
// program is running under. Always normalized to lowercase.
// See the implementation for the different environment variables and desktop
// information we try to use.
//
// If we can't find a reasonable environment, the empty string is returned.
const nsCString& GetDesktopEnvironmentIdentifier();
bool IsGnomeDesktopEnvironment();
// Parse text/uri-list
nsTArray<nsCString> ParseTextURIList(const nsACString& data);

Просмотреть файл

@ -36,6 +36,7 @@
#include "ScrollbarDrawing.h"
#include "gtkdrawing.h"
#include "nsString.h"
#include "nsStyleConsts.h"
#include "gfxFontConstants.h"
#include "WidgetUtils.h"
@ -2075,15 +2076,13 @@ bool nsLookAndFeel::GetDefaultDrawInTitlebar() {
}
// Don't hide titlebar when it's disabled on current desktop.
const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP");
if (!currentDesktop || !sCSDAvailable) {
if (!sCSDAvailable) {
return false;
}
// We hide system titlebar on Gnome/ElementaryOS without any restriction.
return strstr(currentDesktop, "GNOME-Flashback:GNOME") ||
strstr(currentDesktop, "GNOME") ||
strstr(currentDesktop, "Pantheon");
return IsGnomeDesktopEnvironment() ||
FindInReadable("pantheon"_ns, GetDesktopEnvironmentIdentifier());
}();
return drawInTitlebar;
}

Просмотреть файл

@ -2819,72 +2819,6 @@ void nsWindow::SetSizeMode(nsSizeMode aMode) {
mLastSizeModeRequest = aMode;
}
static bool GetWindowManagerName(GdkScreen* screen, nsACString& wmName) {
if (!GdkIsX11Display()) {
return false;
}
#ifdef MOZ_X11
Display* xdisplay = gdk_x11_get_default_xdisplay();
Window root_win = GDK_WINDOW_XID(gdk_screen_get_root_window(screen));
int actual_format_return;
Atom actual_type_return;
unsigned long nitems_return;
unsigned long bytes_after_return;
unsigned char* prop_return = nullptr;
auto releaseXProperty = MakeScopeExit([&] {
if (prop_return) {
XFree(prop_return);
}
});
Atom property = XInternAtom(xdisplay, "_NET_SUPPORTING_WM_CHECK", true);
Atom req_type = XInternAtom(xdisplay, "WINDOW", true);
if (!property || !req_type) {
return false;
}
int result =
XGetWindowProperty(xdisplay, root_win, property,
0L, // offset
sizeof(Window) / 4, // length
false, // delete
req_type, &actual_type_return, &actual_format_return,
&nitems_return, &bytes_after_return, &prop_return);
if (result != Success || bytes_after_return != 0 || nitems_return != 1) {
return false;
}
Window wmWindow = reinterpret_cast<Window*>(prop_return)[0];
if (!wmWindow) {
return false;
}
XFree(prop_return);
prop_return = nullptr;
property = XInternAtom(xdisplay, "_NET_WM_NAME", true);
req_type = XInternAtom(xdisplay, "UTF8_STRING", true);
if (!property || !req_type) {
return false;
}
result =
XGetWindowProperty(xdisplay, wmWindow, property,
0L, // offset
INT32_MAX, // length
false, // delete
req_type, &actual_type_return, &actual_format_return,
&nitems_return, &bytes_after_return, &prop_return);
if (result != Success || bytes_after_return != 0) {
return false;
}
wmName = reinterpret_cast<const char*>(prop_return);
return true;
#endif
}
#define kDesktopMutterSchema "org.gnome.mutter"_ns
#define kDesktopDynamicWorkspacesKey "dynamic-workspaces"_ns
@ -2896,8 +2830,7 @@ static bool WorkspaceManagementDisabled(GdkScreen* screen) {
return Preferences::GetBool("widget.workspace-management");
}
static const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP");
if (currentDesktop && strstr(currentDesktop, "GNOME")) {
if (IsGnomeDesktopEnvironment()) {
// Gnome uses dynamic workspaces by default so disable workspace management
// in that case.
bool usesDynamicWorkspaces = true;
@ -2915,20 +2848,8 @@ static bool WorkspaceManagementDisabled(GdkScreen* screen) {
return usesDynamicWorkspaces;
}
// When XDG_CURRENT_DESKTOP is missing, try to get window manager name.
if (!currentDesktop) {
nsAutoCString wmName;
if (GetWindowManagerName(screen, wmName)) {
if (wmName.EqualsLiteral("bspwm")) {
return true;
}
if (wmName.EqualsLiteral("i3")) {
return true;
}
}
}
return false;
const auto& desktop = GetDesktopEnvironmentIdentifier();
return desktop.EqualsLiteral("bspwm") || desktop.EqualsLiteral("i3");
}
void nsWindow::GetWorkspaceID(nsAString& workspaceID) {
@ -3652,17 +3573,8 @@ void nsWindow::CaptureRollupEvents(bool aDoCapture) {
//
// We don't do it for most common desktops, if only because it causes X11
// crashes like bug 1607713.
if (const char* desktopSession = getenv("XDG_SESSION_DESKTOP")) {
if (!strcmp(desktopSession, "twm")) {
return true;
}
}
nsAutoCString wmName;
if (NS_WARN_IF(!GetWindowManagerName(gdk_screen_get_default(), wmName))) {
return false;
}
return wmName.EqualsLiteral("Sawfish");
const auto& desktop = GetDesktopEnvironmentIdentifier();
return desktop.EqualsLiteral("twm") || desktop.EqualsLiteral("sawfish");
}();
const bool grabPointer = [] {
@ -8465,8 +8377,7 @@ static nsresult initialize_prefs(void) {
if (Preferences::HasUserValue("widget.use-aspect-ratio")) {
gUseAspectRatio = Preferences::GetBool("widget.use-aspect-ratio", true);
} else {
const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP");
gUseAspectRatio = currentDesktop && strstr(currentDesktop, "GNOME");
gUseAspectRatio = IsGnomeDesktopEnvironment();
}
return NS_OK;
@ -9280,6 +9191,7 @@ nsWindow::GtkWindowDecoration nsWindow::GetSystemGtkWindowDecoration() {
return GTK_DECORATION_CLIENT;
}
// TODO: Consider switching this to GetDesktopEnvironmentIdentifier().
const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP");
if (!currentDesktop) {
return GTK_DECORATION_NONE;
@ -9304,14 +9216,8 @@ bool nsWindow::TitlebarUseShapeMask() {
// We can't use shape masks on Mutter/X.org as we can't resize Firefox
// window there (Bug 1530252).
const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP");
if (currentDesktop) {
if (strstr(currentDesktop, "GNOME")) {
const char* sessionType = getenv("XDG_SESSION_TYPE");
if (sessionType && strstr(sessionType, "x11")) {
return false;
}
}
if (IsGnomeDesktopEnvironment()) {
return false;
}
return Preferences::GetBool("widget.titlebar-x11-use-shape-mask", false);

Просмотреть файл

@ -396,8 +396,8 @@ class nsWindow final : public nsBaseWidget {
GTK_DECORATION_NONE, // WM does not support CSD at all
} GtkWindowDecoration;
/**
* Get the support of Client Side Decoration by checking
* the XDG_CURRENT_DESKTOP environment variable.
* Get the support of Client Side Decoration by checking the desktop
* environment.
*/
static GtkWindowDecoration GetSystemGtkWindowDecoration();