Bug 1589601 - Return the fallback to primary monitor on Wayland to not break PIP; r=stransky
authorJan Horak <jhorak@redhat.com>
Tue, 05 Nov 2019 08:14:18 +0000
changeset 500559 52dba68c5cba1eccd3ebb4ef768d5f51fca2b439
parent 500558 7ff4a4f0f9496dd26171fe8d6a7a61db9de5a0e8
child 500560 dba6eaea1fa995ec72ded64e621c7caf4086c33d
push id114166
push userapavel@mozilla.com
push dateThu, 07 Nov 2019 10:04:01 +0000
treeherdermozilla-inbound@d271c572a9bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstransky
bugs1589601
milestone72.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 1589601 - Return the fallback to primary monitor on Wayland to not break PIP; r=stransky Differential Revision: https://phabricator.services.mozilla.com/D51600
layout/xul/nsMenuPopupFrame.cpp
widget/ScreenManager.cpp
--- a/layout/xul/nsMenuPopupFrame.cpp
+++ b/layout/xul/nsMenuPopupFrame.cpp
@@ -1666,17 +1666,23 @@ LayoutDeviceIntRect nsMenuPopupFrame::Ge
   LayoutDeviceIntRect screenRectPixels;
 
   // determine the available screen space. It will be reduced by the OS chrome
   // such as menubars. It addition, for content shells, it will be the area of
   // the content rather than the screen.
   nsCOMPtr<nsIScreen> screen;
   nsCOMPtr<nsIScreenManager> sm(
       do_GetService("@mozilla.org/gfx/screenmanager;1"));
-  if (sm) {
+#ifdef MOZ_WAYLAND
+  static bool inWayland = gdk_display_get_default() &&
+                          !GDK_IS_X11_DISPLAY(gdk_display_get_default());
+#else
+  static bool inWayland = false;
+#endif
+  if (sm && !inWayland) {
     // for content shells, get the screen where the root frame is located.
     // This is because we need to constrain the content to this content area,
     // so we should use the same screen. Otherwise, use the screen where the
     // anchor is located.
     DesktopToLayoutDeviceScale scale =
         PresContext()->DeviceContext()->GetDesktopToDeviceScale();
     DesktopRect rect =
         (mInContentShell ? aRootScreenRect : aAnchorRect) / scale;
@@ -1690,25 +1696,24 @@ LayoutDeviceIntRect nsMenuPopupFrame::Ge
       // get the total screen area if the popup is allowed to overlap it.
       if (!dontOverlapOSBar && mMenuCanOverlapOSBar && !mInContentShell)
         screen->GetRect(&screenRectPixels.x, &screenRectPixels.y,
                         &screenRectPixels.width, &screenRectPixels.height);
       else
         screen->GetAvailRect(&screenRectPixels.x, &screenRectPixels.y,
                              &screenRectPixels.width, &screenRectPixels.height);
     }
+  }
 #ifdef MOZ_WAYLAND
-    else {
-      if (GetWidget() &&
-          GetWidget()->GetScreenRect(&screenRectPixels) != NS_OK) {
-        NS_WARNING("Cannot get screen rect from widget!");
-      }
+  else {
+    if (GetWidget() && GetWidget()->GetScreenRect(&screenRectPixels) != NS_OK) {
+      NS_WARNING("Cannot get screen rect from widget!");
     }
+  }
 #endif
-  }
 
   if (mInContentShell) {
     // for content shells, clip to the client area rather than the screen area
     screenRectPixels.IntersectRect(screenRectPixels, aRootScreenRect);
   } else if (!mOverrideConstraintRect.IsEmpty()) {
     LayoutDeviceIntRect overrideConstrainRect =
         LayoutDeviceIntRect::FromAppUnitsToNearest(
             mOverrideConstraintRect, PresContext()->AppUnitsPerDevPixel());
--- a/widget/ScreenManager.cpp
+++ b/widget/ScreenManager.cpp
@@ -109,18 +109,17 @@ void ScreenManager::CopyScreensToAllRemo
 NS_IMETHODIMP
 ScreenManager::ScreenForRect(int32_t aX, int32_t aY, int32_t aWidth,
                              int32_t aHeight, nsIScreen** aOutScreen) {
 #ifdef MOZ_WAYLAND
   static bool inWayland = gdk_display_get_default() &&
                           !GDK_IS_X11_DISPLAY(gdk_display_get_default());
 
   if (inWayland) {
-    *aOutScreen = nullptr;
-    return NS_OK;
+    NS_WARNING("Getting screen in wayland, primary display will be returned.");
   }
 #endif
 
   if (mScreenList.IsEmpty()) {
     MOZ_LOG(sScreenLog, LogLevel::Warning,
             ("No screen available. This can happen in xpcshell."));
     RefPtr<Screen> ret = new Screen(
         LayoutDeviceIntRect(), LayoutDeviceIntRect(), 0, 0,