Bug 1681356 [Linux] Rename CSDSupportLevel to GtkWindowDecoration, r=jhorak

Differential Revision: https://phabricator.services.mozilla.com/D104403
This commit is contained in:
stransky 2021-02-17 13:04:39 +00:00
parent 64445cc463
commit ae40623709
3 changed files with 55 additions and 53 deletions

View File

@ -776,7 +776,7 @@ nsresult nsLookAndFeel::NativeGetInt(IntID aID, int32_t& aResult) {
// Enable transparent titlebar corners for titlebar mode.
GdkScreen* screen = gdk_screen_get_default();
aResult = gdk_screen_is_composited(screen)
? (nsWindow::GetSystemCSDSupportLevel() !=
? (nsWindow::GtkWindowDecoration() !=
nsWindow::GTK_DECORATION_NONE)
: false;
break;
@ -1435,7 +1435,7 @@ void nsLookAndFeel::EnsureInit() {
g_object_unref(labelWidget);
mCSDAvailable =
nsWindow::GetSystemCSDSupportLevel() != nsWindow::GTK_DECORATION_NONE;
nsWindow::GtkWindowDecoration() != nsWindow::GTK_DECORATION_NONE;
mCSDHideTitlebarByDefault = nsWindow::HideTitlebarByDefault();
mCSDCloseButton = false;

View File

@ -309,7 +309,8 @@ static SystemTimeConverter<guint32>& TimeConverter() {
return sTimeConverterSingleton;
}
nsWindow::CSDSupportLevel nsWindow::sCSDSupportLevel = GTK_DECORATION_UNKNOWN;
nsWindow::GtkWindowDecoration nsWindow::sGtkWindowDecoration =
GTK_DECORATION_UNKNOWN;
bool nsWindow::sTransparentMainWindow = false;
static bool sIgnoreChangedSettings = false;
@ -540,7 +541,7 @@ nsWindow::nsWindow() {
mLastScrollEventTime = GDK_CURRENT_TIME;
mPendingConfigures = 0;
mCSDSupportLevel = GTK_DECORATION_NONE;
mGtkWindowDecoration = GTK_DECORATION_NONE;
mDrawToContainer = false;
mDrawInTitlebar = false;
mTitlebarBackdropState = false;
@ -1071,7 +1072,7 @@ void nsWindow::SetSizeConstraints(const SizeConstraints& aConstraints) {
void nsWindow::AddCSDDecorationSize(int* aWidth, int* aHeight) {
if (mSizeState == nsSizeMode_Normal &&
mCSDSupportLevel == GTK_DECORATION_CLIENT && mDrawInTitlebar) {
mGtkWindowDecoration == GTK_DECORATION_CLIENT && mDrawInTitlebar) {
GtkBorder decorationSize = GetCSDDecorationSize(!mIsTopLevel);
*aWidth += decorationSize.left + decorationSize.right;
*aHeight += decorationSize.top + decorationSize.bottom;
@ -1081,7 +1082,7 @@ void nsWindow::AddCSDDecorationSize(int* aWidth, int* aHeight) {
#ifdef MOZ_WAYLAND
bool nsWindow::GetCSDDecorationOffset(int* aDx, int* aDy) {
if (mSizeState == nsSizeMode_Normal &&
mCSDSupportLevel == GTK_DECORATION_CLIENT && mDrawInTitlebar) {
mGtkWindowDecoration == GTK_DECORATION_CLIENT && mDrawInTitlebar) {
GtkBorder decorationSize = GetCSDDecorationSize(!mIsTopLevel);
*aDx = decorationSize.left;
*aDy = decorationSize.top;
@ -2312,7 +2313,7 @@ LayoutDeviceIntRect nsWindow::GetClientBounds() {
void nsWindow::UpdateClientOffsetFromFrameExtents() {
AUTO_PROFILER_LABEL("nsWindow::UpdateClientOffsetFromFrameExtents", OTHER);
if (mCSDSupportLevel == GTK_DECORATION_CLIENT && mDrawInTitlebar) {
if (mGtkWindowDecoration == GTK_DECORATION_CLIENT && mDrawInTitlebar) {
return;
}
@ -3216,7 +3217,7 @@ void nsWindow::OnSizeAllocate(GtkAllocation* aAllocation) {
// is enabled. In either cases (Wayland or system titlebar is off on X11)
// we don't get _NET_FRAME_EXTENTS X11 property notification so we derive
// it from mContainer position.
if (mCSDSupportLevel == GTK_DECORATION_CLIENT) {
if (mGtkWindowDecoration == GTK_DECORATION_CLIENT) {
if (!mIsX11Display || (mIsX11Display && mDrawInTitlebar)) {
UpdateClientOffsetFromCSDWindow();
}
@ -4225,7 +4226,7 @@ void nsWindow::OnScaleChanged(GtkAllocation* aAllocation) {
// is enabled. In ither cases (Wayland or system titlebar is off on X11)
// we don't get _NET_FRAME_EXTENTS X11 property notification so we derive
// it from mContainer position.
if (mCSDSupportLevel == GTK_DECORATION_CLIENT) {
if (mGtkWindowDecoration == GTK_DECORATION_CLIENT) {
if (!mIsX11Display || (mIsX11Display && mDrawInTitlebar)) {
UpdateClientOffsetFromCSDWindow();
}
@ -4419,7 +4420,7 @@ bool nsWindow::IsToplevelWindowTransparent() {
// Enable transparent toplevel window if we can draw main window
// without system titlebar as Gtk+ themes use titlebar round corners.
sTransparentMainWindow =
GetSystemCSDSupportLevel() != GTK_DECORATION_NONE;
GetSystemGtkWindowDecoration() != GTK_DECORATION_NONE;
}
}
transparencyConfigured = true;
@ -4621,7 +4622,7 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
if (mWindowType == eWindowType_toplevel ||
mWindowType == eWindowType_dialog) {
mCSDSupportLevel = GetSystemCSDSupportLevel();
mGtkWindowDecoration = GetSystemGtkWindowDecoration();
}
// Don't use transparency for PictureInPicture windows.
@ -4810,7 +4811,7 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
*/
GtkStyleContext* style = gtk_widget_get_style_context(mShell);
mDrawToContainer = !mIsX11Display ||
(mCSDSupportLevel == GTK_DECORATION_CLIENT) ||
(mGtkWindowDecoration == GTK_DECORATION_CLIENT) ||
gtk_style_context_has_class(style, "csd");
eventWidget = (mDrawToContainer) ? container : mShell;
@ -7676,22 +7677,22 @@ nsresult nsWindow::SetNonClientMargins(LayoutDeviceIntMargin& aMargins) {
}
void nsWindow::SetDrawsInTitlebar(bool aState) {
LOG(("nsWindow::SetDrawsInTitlebar() [%p] State %d mCSDSupportLevel %d\n",
(void*)this, aState, (int)mCSDSupportLevel));
LOG(("nsWindow::SetDrawsInTitlebar() [%p] State %d mGtkWindowDecoration %d\n",
(void*)this, aState, (int)mGtkWindowDecoration));
if (mIsPIPWindow && aState == mDrawInTitlebar) {
gtk_window_set_decorated(GTK_WINDOW(mShell), !aState);
return;
}
if (!mShell || mCSDSupportLevel == GTK_DECORATION_NONE ||
if (!mShell || mGtkWindowDecoration == GTK_DECORATION_NONE ||
aState == mDrawInTitlebar) {
return;
}
if (mCSDSupportLevel == GTK_DECORATION_SYSTEM) {
if (mGtkWindowDecoration == GTK_DECORATION_SYSTEM) {
SetWindowDecoration(aState ? eBorderStyle_border : mBorderStyle);
} else if (mCSDSupportLevel == GTK_DECORATION_CLIENT) {
} else if (mGtkWindowDecoration == GTK_DECORATION_CLIENT) {
LOG((" Using CSD mode\n"));
/* Window manager does not support GDK_DECOR_BORDER,
@ -8031,39 +8032,39 @@ nsresult nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
return NS_OK;
}
nsWindow::CSDSupportLevel nsWindow::GetSystemCSDSupportLevel() {
if (sCSDSupportLevel != GTK_DECORATION_UNKNOWN) {
return sCSDSupportLevel;
nsWindow::GtkWindowDecoration nsWindow::GetSystemGtkWindowDecoration() {
if (sGtkWindowDecoration != GTK_DECORATION_UNKNOWN) {
return sGtkWindowDecoration;
}
// Allow MOZ_GTK_TITLEBAR_DECORATION to override our heuristics
const char* decorationOverride = getenv("MOZ_GTK_TITLEBAR_DECORATION");
if (decorationOverride) {
if (strcmp(decorationOverride, "none") == 0) {
sCSDSupportLevel = GTK_DECORATION_NONE;
sGtkWindowDecoration = GTK_DECORATION_NONE;
} else if (strcmp(decorationOverride, "client") == 0) {
sCSDSupportLevel = GTK_DECORATION_CLIENT;
sGtkWindowDecoration = GTK_DECORATION_CLIENT;
} else if (strcmp(decorationOverride, "system") == 0) {
sCSDSupportLevel = GTK_DECORATION_SYSTEM;
sGtkWindowDecoration = GTK_DECORATION_SYSTEM;
}
return sCSDSupportLevel;
return sGtkWindowDecoration;
}
// nsWindow::GetSystemCSDSupportLevel can be called from various threads
// nsWindow::GetSystemGtkWindowDecoration can be called from various threads
// so we can't use gfxPlatformGtk here.
if (!GDK_IS_X11_DISPLAY(gdk_display_get_default())) {
sCSDSupportLevel = GTK_DECORATION_CLIENT;
return sCSDSupportLevel;
sGtkWindowDecoration = GTK_DECORATION_CLIENT;
return sGtkWindowDecoration;
}
// GTK_CSD forces CSD mode - use also CSD because window manager
// decorations does not work with CSD.
// We check GTK_CSD as well as gtk_window_should_use_csd() does.
if (sCSDSupportLevel == GTK_DECORATION_SYSTEM) {
if (sGtkWindowDecoration == GTK_DECORATION_SYSTEM) {
const char* csdOverride = getenv("GTK_CSD");
if (csdOverride && atoi(csdOverride)) {
sCSDSupportLevel = GTK_DECORATION_CLIENT;
return sCSDSupportLevel;
sGtkWindowDecoration = GTK_DECORATION_CLIENT;
return sGtkWindowDecoration;
}
}
@ -8071,47 +8072,47 @@ nsWindow::CSDSupportLevel nsWindow::GetSystemCSDSupportLevel() {
if (currentDesktop) {
// GNOME Flashback (fallback)
if (strstr(currentDesktop, "GNOME-Flashback:GNOME") != nullptr) {
sCSDSupportLevel = GTK_DECORATION_SYSTEM;
sGtkWindowDecoration = GTK_DECORATION_SYSTEM;
// Pop Linux Bug 1629198
} else if (strstr(currentDesktop, "pop:GNOME") != nullptr) {
sCSDSupportLevel = GTK_DECORATION_CLIENT;
sGtkWindowDecoration = GTK_DECORATION_CLIENT;
// gnome-shell
} else if (strstr(currentDesktop, "GNOME") != nullptr) {
sCSDSupportLevel = GTK_DECORATION_SYSTEM;
sGtkWindowDecoration = GTK_DECORATION_SYSTEM;
} else if (strstr(currentDesktop, "XFCE") != nullptr) {
sCSDSupportLevel = GTK_DECORATION_CLIENT;
sGtkWindowDecoration = GTK_DECORATION_CLIENT;
} else if (strstr(currentDesktop, "X-Cinnamon") != nullptr) {
sCSDSupportLevel = GTK_DECORATION_SYSTEM;
sGtkWindowDecoration = GTK_DECORATION_SYSTEM;
// KDE Plasma
} else if (strstr(currentDesktop, "KDE") != nullptr) {
sCSDSupportLevel = GTK_DECORATION_CLIENT;
sGtkWindowDecoration = GTK_DECORATION_CLIENT;
} else if (strstr(currentDesktop, "Enlightenment") != nullptr) {
sCSDSupportLevel = GTK_DECORATION_CLIENT;
sGtkWindowDecoration = GTK_DECORATION_CLIENT;
} else if (strstr(currentDesktop, "LXDE") != nullptr) {
sCSDSupportLevel = GTK_DECORATION_CLIENT;
sGtkWindowDecoration = GTK_DECORATION_CLIENT;
} else if (strstr(currentDesktop, "openbox") != nullptr) {
sCSDSupportLevel = GTK_DECORATION_CLIENT;
sGtkWindowDecoration = GTK_DECORATION_CLIENT;
} else if (strstr(currentDesktop, "i3") != nullptr) {
sCSDSupportLevel = GTK_DECORATION_NONE;
sGtkWindowDecoration = GTK_DECORATION_NONE;
} else if (strstr(currentDesktop, "MATE") != nullptr) {
sCSDSupportLevel = GTK_DECORATION_CLIENT;
sGtkWindowDecoration = GTK_DECORATION_CLIENT;
// Ubuntu Unity
} else if (strstr(currentDesktop, "Unity") != nullptr) {
sCSDSupportLevel = GTK_DECORATION_SYSTEM;
sGtkWindowDecoration = GTK_DECORATION_SYSTEM;
// Elementary OS
} else if (strstr(currentDesktop, "Pantheon") != nullptr) {
sCSDSupportLevel = GTK_DECORATION_SYSTEM;
sGtkWindowDecoration = GTK_DECORATION_SYSTEM;
} else if (strstr(currentDesktop, "LXQt") != nullptr) {
sCSDSupportLevel = GTK_DECORATION_SYSTEM;
sGtkWindowDecoration = GTK_DECORATION_SYSTEM;
} else if (strstr(currentDesktop, "Deepin") != nullptr) {
sCSDSupportLevel = GTK_DECORATION_CLIENT;
sGtkWindowDecoration = GTK_DECORATION_CLIENT;
} else {
sCSDSupportLevel = GTK_DECORATION_CLIENT;
sGtkWindowDecoration = GTK_DECORATION_CLIENT;
}
} else {
sCSDSupportLevel = GTK_DECORATION_CLIENT;
sGtkWindowDecoration = GTK_DECORATION_NONE;
}
return sCSDSupportLevel;
return sGtkWindowDecoration;
}
bool nsWindow::TitlebarUseShapeMask() {
@ -8148,7 +8149,8 @@ bool nsWindow::HideTitlebarByDefault() {
// Don't hide titlebar when it's disabled on current desktop.
const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP");
if (!currentDesktop || GetSystemCSDSupportLevel() == GTK_DECORATION_NONE) {
if (!currentDesktop ||
GetSystemGtkWindowDecoration() == GTK_DECORATION_NONE) {
return false;
}

View File

@ -406,12 +406,12 @@ class nsWindow final : public nsBaseWidget {
GTK_DECORATION_CLIENT, // CSD without shadows
GTK_DECORATION_NONE, // WM does not support CSD at all
GTK_DECORATION_UNKNOWN
} CSDSupportLevel;
} GtkWindowDecoration;
/**
* Get the support of Client Side Decoration by checking
* the XDG_CURRENT_DESKTOP environment variable.
*/
static CSDSupportLevel GetSystemCSDSupportLevel();
static GtkWindowDecoration GetSystemGtkWindowDecoration();
static bool HideTitlebarByDefault();
static bool GetTopLevelWindowActiveState(nsIFrame* aFrame);
@ -563,7 +563,7 @@ class nsWindow final : public nsBaseWidget {
// Window titlebar rendering mode, GTK_DECORATION_NONE if it's disabled
// for this window.
CSDSupportLevel mCSDSupportLevel;
GtkWindowDecoration mGtkWindowDecoration;
// Use dedicated GdkWindow for mContainer
bool mDrawToContainer;
// If true, draw our own window titlebar.
@ -712,7 +712,7 @@ class nsWindow final : public nsBaseWidget {
RefPtr<mozilla::widget::IMContextWrapper> mIMContext;
mozilla::UniquePtr<mozilla::CurrentX11TimeGetter> mCurrentTimeGetter;
static CSDSupportLevel sCSDSupportLevel;
static GtkWindowDecoration sGtkWindowDecoration;
static bool sTransparentMainWindow;
};