Bug 1351832 - Always put the primary monitor at the top of the screen list. r?kanru draft
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Thu, 30 Mar 2017 22:49:10 +0900
changeset 553840 b913fe2239382f884d7469b1169bd8a277eab5e9
parent 553679 03d602fd723ad6ff4588c04855884ffa1dee9410
child 622211 498a87eb53c5cd9e0e7aaae79e95069c5224cc04
push id51794
push userVYV03354@nifty.ne.jp
push dateThu, 30 Mar 2017 20:42:44 +0000
reviewerskanru
bugs1351832
milestone55.0a1
Bug 1351832 - Always put the primary monitor at the top of the screen list. r?kanru MozReview-Commit-ID: 3ZrInOUJ5bj
widget/windows/ScreenHelperWin.cpp
--- a/widget/windows/ScreenHelperWin.cpp
+++ b/widget/windows/ScreenHelperWin.cpp
@@ -53,19 +53,25 @@ CollectMonitors(HMONITOR aMon, HDC, LPRE
     // If a device uses 32 bits per pixel, it's still only using 8 bits
     // per color component, which is what our callers want to know.
     // (Some devices report 32 and some devices report 24.)
     pixelDepth = 24;
   }
   MOZ_LOG(sScreenLog, LogLevel::Debug, ("New screen [%d %d %d %d %d %f]",
                                         rect.x, rect.y, rect.width, rect.height,
                                         pixelDepth, defaultCssScaleFactor.scale));
-  screens->AppendElement(new Screen(rect, availRect,
-                                    pixelDepth, pixelDepth,
-                                    contentsScaleFactor, defaultCssScaleFactor));
+  auto screen = new Screen(rect, availRect,
+                           pixelDepth, pixelDepth,
+                           contentsScaleFactor, defaultCssScaleFactor);
+  if (info.dwFlags & MONITORINFOF_PRIMARY) {
+    // The primary monitor must be the first element of the screen list.
+    screens->InsertElementAt(0, Move(screen));
+  } else {
+    screens->AppendElement(Move(screen));
+  }
   return TRUE;
 }
 
 float
 ScreenHelperWin::GetSystemDefaultScale()
 {
   HMONITOR primary = widget::WinUtils::GetPrimaryMonitor();
   return float(widget::WinUtils::LogToPhysFactor(primary));