Bug 1489097 - [Linux/Gtk] Enable default ARGB visual for toplevel windows on GNOME, r=jhorak

Some Gtk+ themes use non-rectangular toplevel windows. To fully support
such themes we need to make toplevel window transparent with ARGB visual.

It may cause performanance issue so make it configurable
and enable it by default for GNOME right now as it already uses ARGB visual
for widgets.

Also use mozilla.widget.use-argb-visuals to override this.

Differential Revision: https://phabricator.services.mozilla.com/D5754

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Martin Stransky 2018-09-17 09:56:05 +00:00
parent 79c60b26c5
commit 15f23785df
3 changed files with 32 additions and 10 deletions

View File

@ -5901,11 +5901,6 @@ pref("dom.events.asyncClipboard.dataTransfer", false);
// Should only be enabled in tests
pref("dom.events.testing.asyncClipboard", false);
// Enable to correctly draw CSD window headerbar
#if defined(MOZ_WIDGET_GTK)
pref("mozilla.widget.use-argb-visuals", false);
#endif
#ifdef NIGHTLY_BUILD
// Disable moz* APIs in DataTransfer
pref("dom.datatransfer.mozAtAPIs", false);

View File

@ -3670,11 +3670,10 @@ nsWindow::Create(nsIWidget* aParent,
// Some Gtk+ themes use non-rectangular toplevel windows. To fully support
// such themes we need to make toplevel window transparent with ARGB visual.
// It may cause performanance issue so let's put it under a preference
// and allow distros to enable it per default theme.
if (mWindowType == eWindowType_toplevel &&
Preferences::GetBool("mozilla.widget.use-argb-visuals", false)) {
needsAlphaVisual = true;
// It may cause performanance issue so make it configurable
// and enable it by default for selected window managers.
if (mWindowType == eWindowType_toplevel) {
needsAlphaVisual = TopLevelWindowUseARGBVisual();
}
if (aParent) {
@ -7219,6 +7218,33 @@ nsWindow::GetSystemCSDSupportLevel() {
return sCSDSupportLevel;
}
bool
nsWindow::TopLevelWindowUseARGBVisual()
{
static int useARGBVisual = -1;
if (useARGBVisual != -1) {
return useARGBVisual;
}
if (Preferences::HasUserValue("mozilla.widget.use-argb-visuals")) {
useARGBVisual =
Preferences::GetBool("mozilla.widget.use-argb-visuals", false);
} else {
const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP");
useARGBVisual =
(currentDesktop &&
GetSystemCSDSupportLevel() != CSD_SUPPORT_NONE);
if (useARGBVisual) {
useARGBVisual =
(strstr(currentDesktop, "GNOME-Flashback:GNOME") != nullptr ||
strstr(currentDesktop, "GNOME") != nullptr);
}
}
return useARGBVisual;
}
int32_t
nsWindow::RoundsWidgetCoordinatesTo()
{

View File

@ -429,6 +429,7 @@ public:
*/
static CSDSupportLevel GetSystemCSDSupportLevel();
static bool TopLevelWindowUseARGBVisual();
static bool GetTopLevelWindowActiveState(nsIFrame *aFrame);
protected: