Bug 1624921 [Linux/X11] Use CSD for PIP windows only, r=jhorak
authorMartin Stransky <stransky@redhat.com>
Thu, 26 Mar 2020 12:08:26 +0000
changeset 520540 f733f4c24b29a5e0e27cf3b9420f9ebcfffd75eb
parent 520539 a5081d4443a95fd506cbe5db2835804f3bdc9a3c
child 520541 d3f2d9592869b925fbefe4ecf90ca62bae5d3c69
push id37253
push usernerli@mozilla.com
push dateThu, 26 Mar 2020 21:36:52 +0000
treeherdermozilla-central@c644dd16e2cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhorak
bugs1624921
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1624921 [Linux/X11] Use CSD for PIP windows only, r=jhorak Differential Revision: https://phabricator.services.mozilla.com/D68330
widget/gtk/nsWindow.cpp
widget/gtk/nsWindow.h
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -3956,17 +3956,17 @@ nsresult nsWindow::Create(nsIWidget* aPa
       bool useWebRender =
           gfx::gfxVars::UseWebRender() && AllowWebRenderForThisWindow();
 
       mIsAccelerated = ComputeShouldAccelerate();
       MOZ_ASSERT(mIsAccelerated | !useWebRender);
 
       if (mWindowType == eWindowType_toplevel) {
         // We enable titlebar rendering for toplevel windows only.
-        mCSDSupportLevel = GetSystemCSDSupportLevel();
+        mCSDSupportLevel = GetSystemCSDSupportLevel(mIsPIPWindow);
 
         // There's no point to configure transparency
         // on non-composited screens.
         // Also disable transparency for PictureInPicture windows.
         GdkScreen* screen = gdk_screen_get_default();
         if (gdk_screen_is_composited(screen) && !mIsPIPWindow) {
           // Some Gtk+ themes use non-rectangular toplevel windows. To fully
           // support such themes we need to make toplevel window transparent
@@ -7464,17 +7464,18 @@ nsresult nsWindow::SynthesizeNativeTouch
   event.touch.y = DevicePixelsToGdkCoordRoundDown(pointInWindow.y);
 
   gdk_event_put(&event);
 
   return NS_OK;
 }
 #endif
 
-nsWindow::CSDSupportLevel nsWindow::GetSystemCSDSupportLevel() {
+nsWindow::CSDSupportLevel nsWindow::GetSystemCSDSupportLevel(
+    bool aIsPIPWindow) {
   if (sCSDSupportLevel != CSD_SUPPORT_UNKNOWN) {
     return sCSDSupportLevel;
   }
 
   // Require GTK 3.10 for GtkHeaderBar support and compatible window manager.
   if (gtk_check_version(3, 10, 0) != nullptr) {
     sCSDSupportLevel = CSD_SUPPORT_NONE;
     return sCSDSupportLevel;
@@ -7498,20 +7499,20 @@ nsWindow::CSDSupportLevel nsWindow::GetS
     sCSDSupportLevel = CSD_SUPPORT_CLIENT;
     return sCSDSupportLevel;
   }
 
   const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP");
   if (currentDesktop) {
     // GNOME Flashback (fallback)
     if (strstr(currentDesktop, "GNOME-Flashback:GNOME") != nullptr) {
-      sCSDSupportLevel = CSD_SUPPORT_CLIENT;
+      sCSDSupportLevel = aIsPIPWindow ? CSD_SUPPORT_CLIENT : CSD_SUPPORT_SYSTEM;
       // gnome-shell
     } else if (strstr(currentDesktop, "GNOME") != nullptr) {
-      sCSDSupportLevel = CSD_SUPPORT_CLIENT;
+      sCSDSupportLevel = aIsPIPWindow ? CSD_SUPPORT_CLIENT : CSD_SUPPORT_SYSTEM;
     } else if (strstr(currentDesktop, "XFCE") != nullptr) {
       sCSDSupportLevel = CSD_SUPPORT_CLIENT;
     } else if (strstr(currentDesktop, "X-Cinnamon") != nullptr) {
       sCSDSupportLevel = CSD_SUPPORT_SYSTEM;
       // KDE Plasma
     } else if (strstr(currentDesktop, "KDE") != nullptr) {
       sCSDSupportLevel = CSD_SUPPORT_CLIENT;
     } else if (strstr(currentDesktop, "Enlightenment") != nullptr) {
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -415,17 +415,17 @@ class nsWindow final : public nsBaseWidg
     CSD_SUPPORT_CLIENT,  // CSD without shadows
     CSD_SUPPORT_NONE,    // WM does not support CSD at all
     CSD_SUPPORT_UNKNOWN
   } CSDSupportLevel;
   /**
    * Get the support of Client Side Decoration by checking
    * the XDG_CURRENT_DESKTOP environment variable.
    */
-  static CSDSupportLevel GetSystemCSDSupportLevel();
+  static CSDSupportLevel GetSystemCSDSupportLevel(bool aIsPIPWindow = false);
 
   static bool HideTitlebarByDefault();
   static bool GetTopLevelWindowActiveState(nsIFrame* aFrame);
   static bool TitlebarCanUseShapeMask();
 #ifdef MOZ_WAYLAND
   virtual nsresult GetScreenRect(LayoutDeviceIntRect* aRect) override;
 #endif
   bool IsRemoteContent() { return HasRemoteContent(); }