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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
diff -up mozilla-release/widget/gtk/nsLookAndFeel.cpp.1144745-2 mozilla-release/widget/gtk/nsLookAndFeel.cpp
--- mozilla-release/widget/gtk/nsLookAndFeel.cpp.1144745-2 2015-05-13 10:30:08.204367309 +0200
+++ mozilla-release/widget/gtk/nsLookAndFeel.cpp 2015-05-13 10:30:08.208367321 +0200
@@ -18,6 +18,7 @@
#include <fontconfig/fontconfig.h>
#include "gfxPlatformGtk.h"
+#include "nsScreenGtk.h"
#include "gtkdrawing.h"
#include "nsStyleConsts.h"
@@ -742,12 +743,7 @@ GetSystemFontInfo(GtkWidget *aWidget,
// Scale fonts up on HiDPI displays.
// This would be done automatically with cairo, but we manually manage
// the display scale for platform consistency.
- static auto sGdkScreenGetMonitorScaleFactorPtr = (gint (*)(GdkScreen*,gint))
- dlsym(RTLD_DEFAULT, "gdk_screen_get_monitor_scale_factor");
- if (sGdkScreenGetMonitorScaleFactorPtr) {
- GdkScreen *screen = gdk_screen_get_default();
- size *= (*sGdkScreenGetMonitorScaleFactorPtr)(screen, 0);
- }
+ size *= nsScreenGtk::GetGtkMonitorScaleFactor();
// |size| is now pixels
diff -up mozilla-release/widget/gtk/nsNativeThemeGTK.cpp.1144745-2 mozilla-release/widget/gtk/nsNativeThemeGTK.cpp
--- mozilla-release/widget/gtk/nsNativeThemeGTK.cpp.1144745-2 2015-05-13 10:30:08.206367315 +0200
+++ mozilla-release/widget/gtk/nsNativeThemeGTK.cpp 2015-05-13 10:30:46.966488584 +0200
@@ -6,6 +6,7 @@
#include "nsNativeThemeGTK.h"
#include "nsThemeConstants.h"
#include "gtkdrawing.h"
+#include "nsScreenGtk.h"
#include "nsIObserverService.h"
#include "nsIServiceManager.h"
@@ -89,23 +90,6 @@ nsNativeThemeGTK::RefreshWidgetWindow(ns
vm->InvalidateAllViews();
}
-gint
-nsNativeThemeGTK::GdkScaleFactor()
-{
-#if (MOZ_WIDGET_GTK >= 3)
- // Since GDK 3.10
- static auto sGdkScreenGetMonitorScaleFactorPtr = (gint (*)(GdkScreen*, gint))
- dlsym(RTLD_DEFAULT, "gdk_screen_get_monitor_scale_factor");
- if (sGdkScreenGetMonitorScaleFactorPtr) {
- // FIXME: In the future, we'll want to fix this for GTK on Wayland which
- // supports a variable scale factor per display.
- GdkScreen *screen = gdk_screen_get_default();
- return sGdkScreenGetMonitorScaleFactorPtr(screen, 0);
- }
-#endif
- return 1;
-}
-
static bool IsFrameContentNodeInNamespace(nsIFrame *aFrame, uint32_t aNamespace)
{
@@ -796,10 +780,11 @@ nsNativeThemeGTK::GetExtraSizeForWidget(
default:
return false;
}
- aExtra->top *= GdkScaleFactor();
- aExtra->right *= GdkScaleFactor();
- aExtra->bottom *= GdkScaleFactor();
- aExtra->left *= GdkScaleFactor();
+ gint scale = nsScreenGtk::GetGtkMonitorScaleFactor();
+ aExtra->top *= scale;
+ aExtra->right *= scale;
+ aExtra->bottom *= scale;
+ aExtra->left *= scale;
return true;
}
@@ -827,7 +812,7 @@ nsNativeThemeGTK::DrawWidgetBackground(n
gfxRect rect = presContext->AppUnitsToGfxUnits(aRect);
gfxRect dirtyRect = presContext->AppUnitsToGfxUnits(aDirtyRect);
- gint scaleFactor = GdkScaleFactor();
+ gint scaleFactor = nsScreenGtk::GetGtkMonitorScaleFactor();
// Align to device pixels where sensible
// to provide crisper and faster drawing.
@@ -1066,10 +1051,11 @@ nsNativeThemeGTK::GetWidgetPadding(nsDev
aResult->left += horizontal_padding;
aResult->right += horizontal_padding;
- aResult->top *= GdkScaleFactor();
- aResult->right *= GdkScaleFactor();
- aResult->bottom *= GdkScaleFactor();
- aResult->left *= GdkScaleFactor();
+ gint scale = nsScreenGtk::GetGtkMonitorScaleFactor();
+ aResult->top *= scale;
+ aResult->right *= scale;
+ aResult->bottom *= scale;
+ aResult->left *= scale;
return true;
}
@@ -1332,7 +1318,7 @@ nsNativeThemeGTK::GetMinimumWidgetSize(n
break;
}
- *aResult = *aResult * GdkScaleFactor();
+ *aResult = *aResult * nsScreenGtk::GetGtkMonitorScaleFactor();
return NS_OK;
}
diff -up mozilla-release/widget/gtk/nsNativeThemeGTK.h.1144745-2 mozilla-release/widget/gtk/nsNativeThemeGTK.h
--- mozilla-release/widget/gtk/nsNativeThemeGTK.h.1144745-2 2015-05-13 10:30:08.206367315 +0200
+++ mozilla-release/widget/gtk/nsNativeThemeGTK.h 2015-05-13 10:30:08.209367325 +0200
@@ -81,7 +81,6 @@ private:
nsIntMargin* aExtra);
void RefreshWidgetWindow(nsIFrame* aFrame);
- gint GdkScaleFactor();
uint8_t mDisabledWidgetTypes[32];
uint8_t mSafeWidgetStates[1024]; // 256 widgets * 32 bits per widget
diff -up mozilla-release/widget/gtk/nsScreenGtk.cpp.1144745-2 mozilla-release/widget/gtk/nsScreenGtk.cpp
--- mozilla-release/widget/gtk/nsScreenGtk.cpp.1144745-2 2015-05-08 18:55:27.000000000 +0200
+++ mozilla-release/widget/gtk/nsScreenGtk.cpp 2015-05-13 10:30:08.209367325 +0200
@@ -63,6 +63,23 @@ nsScreenGtk :: GetAvailRect(int32_t *out
} // GetAvailRect
+gint
+nsScreenGtk :: GetGtkMonitorScaleFactor()
+{
+#if (MOZ_WIDGET_GTK >= 3)
+ // Since GDK 3.10
+ static auto sGdkScreenGetMonitorScaleFactorPtr = (gint (*)(GdkScreen*, gint))
+ dlsym(RTLD_DEFAULT, "gdk_screen_get_monitor_scale_factor");
+ if (sGdkScreenGetMonitorScaleFactorPtr) {
+ // FIXME: In the future, we'll want to fix this for GTK on Wayland which
+ // supports a variable scale factor per display.
+ GdkScreen *screen = gdk_screen_get_default();
+ return sGdkScreenGetMonitorScaleFactorPtr(screen, 0);
+ }
+#endif
+ return 1;
+}
+
double
nsScreenGtk :: GetDPIScale()
{
@@ -127,20 +144,9 @@ nsScreenGtk :: GetColorDepth(int32_t *aC
void
nsScreenGtk :: Init (GdkWindow *aRootWindow)
{
- gint width = gdk_screen_width();
- gint height = gdk_screen_height();
-
- // Since GDK 3.10
- static auto sGdkScreenGetMonitorScaleFactorPtr = (gint (*)(GdkScreen*, gint))
- dlsym(RTLD_DEFAULT, "gdk_screen_get_monitor_scale_factor");
- if (sGdkScreenGetMonitorScaleFactorPtr) {
- // FIXME: In the future, we'll want to fix this for GTK on Wayland which
- // supports a variable scale factor per display.
- GdkScreen *screen = gdk_window_get_screen(aRootWindow);
- gint scale = sGdkScreenGetMonitorScaleFactorPtr(screen, 0);
- width *= scale;
- height *= scale;
- }
+ gint scale = nsScreenGtk::GetGtkMonitorScaleFactor();
+ gint width = gdk_screen_width()*scale;
+ gint height = gdk_screen_height()*scale;
// We listen for configure events on the root window to pick up
// changes to this rect. We could listen for "size_changed" signals
diff -up mozilla-release/widget/gtk/nsScreenGtk.h.1144745-2 mozilla-release/widget/gtk/nsScreenGtk.h
--- mozilla-release/widget/gtk/nsScreenGtk.h.1144745-2 2015-05-08 18:55:27.000000000 +0200
+++ mozilla-release/widget/gtk/nsScreenGtk.h 2015-05-13 10:30:08.209367325 +0200
@@ -43,7 +43,8 @@ public:
void Init(XineramaScreenInfo *aScreenInfo);
#endif /* MOZ_X11 */
- static double GetDPIScale();
+ static gint GetGtkMonitorScaleFactor();
+ static double GetDPIScale();
private:
uint32_t mScreenNum;
|