summaryrefslogtreecommitdiff
path: root/mozilla-1669495.patch
blob: 3ef027ceff76d5e4ac7914f0bc8399af785f214e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
diff -up firefox-81.0.1/layout/xul/nsMenuPopupFrame.cpp.1669495 firefox-81.0.1/layout/xul/nsMenuPopupFrame.cpp
--- firefox-81.0.1/layout/xul/nsMenuPopupFrame.cpp.1669495	2020-10-08 10:09:23.765819989 +0200
+++ firefox-81.0.1/layout/xul/nsMenuPopupFrame.cpp	2020-10-08 10:09:23.771820010 +0200
@@ -533,6 +533,26 @@ void nsMenuPopupFrame::LayoutPopup(nsBox
   }
   prefSize = XULBoundsCheck(minSize, prefSize, maxSize);
 
+#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 (inWayland) {
+    // If prefSize it is not a whole number in css pixels we need round it up
+    // to avoid reflow of the tooltips/popups and putting the text on two lines
+    // (usually happens with 200% scale factor and font scale factor <> 1)
+    // because GTK thrown away the decimals.
+    int32_t appPerCSS = AppUnitsPerCSSPixel();
+    if (prefSize.width % appPerCSS > 0) {
+      prefSize.width += appPerCSS;
+    }
+    if (prefSize.height % appPerCSS > 0) {
+      prefSize.height += appPerCSS;
+    }
+  }
+
   bool sizeChanged = (mPrefSize != prefSize);
   // if the size changed then set the bounds to be the preferred size
   if (sizeChanged) {
diff -up firefox-81.0.1/widget/gtk/nsWindow.cpp.1669495 firefox-81.0.1/widget/gtk/nsWindow.cpp
--- firefox-81.0.1/widget/gtk/nsWindow.cpp.1669495	2020-10-08 10:09:23.770820007 +0200
+++ firefox-81.0.1/widget/gtk/nsWindow.cpp	2020-10-08 10:10:29.225052014 +0200
@@ -1090,11 +1090,13 @@ void nsWindow::Show(bool aState) {
 
 void nsWindow::ResizeInt(int aX, int aY, int aWidth, int aHeight, bool aMove,
                          bool aRepaint) {
-  LOG(("nsWindow::ResizeInt [%p] %d %d -> %d %d repaint %d\n", (void*)this, aX,
-       aY, aWidth, aHeight, aRepaint));
+  LOG(("nsWindow::ResizeInt [%p] x:%d y:%d -> w:%d h:%d repaint %d aMove %d\n",
+       (void*)this, aX, aY, aWidth, aHeight, aRepaint, aMove));
 
   ConstrainSize(&aWidth, &aHeight);
 
+  LOG(("  ConstrainSize: w:%d h;%d\n", aWidth, aHeight));
+
   if (aMove) {
     mBounds.x = aX;
     mBounds.y = aY;
@@ -1132,8 +1134,7 @@ void nsWindow::ResizeInt(int aX, int aY,
 }
 
 void nsWindow::Resize(double aWidth, double aHeight, bool aRepaint) {
-  LOG(("nsWindow::Resize [%p] %d %d\n", (void*)this, (int)aWidth,
-       (int)aHeight));
+  LOG(("nsWindow::Resize [%p] %f %f\n", (void*)this, aWidth, aHeight));
 
   double scale =
       BoundsUseDesktopPixels() ? GetDesktopToDeviceScale().scale : 1.0;
@@ -1145,8 +1146,8 @@ void nsWindow::Resize(double aWidth, dou
 
 void nsWindow::Resize(double aX, double aY, double aWidth, double aHeight,
                       bool aRepaint) {
-  LOG(("nsWindow::Resize [%p] %d %d repaint %d\n", (void*)this, (int)aWidth,
-       (int)aHeight, aRepaint));
+  LOG(("nsWindow::Resize [%p] %f %f repaint %d\n", (void*)this, aWidth, aHeight,
+       aRepaint));
 
   double scale =
       BoundsUseDesktopPixels() ? GetDesktopToDeviceScale().scale : 1.0;
@@ -1469,14 +1470,15 @@ void nsWindow::NativeMoveResizeWaylandPo
 
   newBounds.x = GdkCoordToDevicePixels(newBounds.x);
   newBounds.y = GdkCoordToDevicePixels(newBounds.y);
-  LOG(("  new mBounds  x=%d y=%d width=%d height=%d\n", newBounds.x,
-       newBounds.y, newBounds.width, newBounds.height));
 
   double scale =
       BoundsUseDesktopPixels() ? GetDesktopToDeviceScale().scale : 1.0;
   int32_t newWidth = NSToIntRound(scale * newBounds.width);
   int32_t newHeight = NSToIntRound(scale * newBounds.height);
 
+  LOG(("  new mBounds  x=%d y=%d width=%d height=%d\n", newBounds.x,
+       newBounds.y, newWidth, newHeight));
+
   bool needsPositionUpdate =
       (newBounds.x != mBounds.x || newBounds.y != mBounds.y);
   bool needsSizeUpdate =
@@ -1484,6 +1486,7 @@ void nsWindow::NativeMoveResizeWaylandPo
   // Update view
 
   if (needsSizeUpdate) {
+    LOG(("  needSizeUpdate\n"));
     int32_t p2a = AppUnitsPerCSSPixel() / gfxPlatformGtk::GetFontScaleFactor();
     mPreferredPopupRect = nsRect(NSIntPixelsToAppUnits(newBounds.x, p2a),
                                  NSIntPixelsToAppUnits(newBounds.y, p2a),
@@ -1502,6 +1505,7 @@ void nsWindow::NativeMoveResizeWaylandPo
   }
 
   if (needsPositionUpdate) {
+    LOG(("  needPositionUpdate\n"));
     // The newBounds are in coordinates relative to the parent window/popup.
     // The NotifyWindowMoved requires the coordinates relative to the toplevel.
     // We use the gdk_window_get_origin to get correct coordinates.
@@ -4211,6 +4215,8 @@ nsresult nsWindow::Create(nsIWidget* aPa
 
   // save our bounds
   mBounds = aRect;
+  LOG(("  mBounds: x:%d y:%d w:%d h:%d\n", mBounds.x, mBounds.y, mBounds.width,
+       mBounds.height));
 
   mPreferredPopupRectFlushed = false;
 
@@ -5061,13 +5067,16 @@ void nsWindow::NativeShow(bool aAction)
         }
       }
 
+      LOG(("  calling gtk_widget_show(mShell)\n"));
       gtk_widget_show(mShell);
       if (!mIsX11Display) {
         WaylandStartVsync();
       }
     } else if (mContainer) {
+      LOG(("  calling gtk_widget_show(mContainer)\n"));
       gtk_widget_show(GTK_WIDGET(mContainer));
     } else if (mGdkWindow) {
+      LOG(("  calling gdk_window_show_unraised\n"));
       gdk_window_show_unraised(mGdkWindow);
     }
   } else {
bgstack15