зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1144745 - moves gdk_screen_get_monitor_scale_factor() call to nsScreenGtk :: GetGtkMonitorScaleFactor(). r=karlt
--HG-- extra : rebase_source : 34677048032e7b9e5c95dcd4f4bdf15e71fe232a
This commit is contained in:
Родитель
a4d2a8c99c
Коммит
b90a86d529
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <fontconfig/fontconfig.h>
|
||||
#include "gfxPlatformGtk.h"
|
||||
#include "nsScreenGtk.h"
|
||||
|
||||
#include "gtkdrawing.h"
|
||||
#include "nsStyleConsts.h"
|
||||
|
@ -739,12 +740,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
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "nsNativeThemeGTK.h"
|
||||
#include "nsThemeConstants.h"
|
||||
#include "gtkdrawing.h"
|
||||
#include "nsScreenGtk.h"
|
||||
|
||||
#include "gfx2DGlue.h"
|
||||
#include "nsIObserverService.h"
|
||||
|
@ -90,23 +91,6 @@ nsNativeThemeGTK::RefreshWidgetWindow(nsIFrame* aFrame)
|
|||
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)
|
||||
{
|
||||
|
@ -795,10 +779,11 @@ nsNativeThemeGTK::GetExtraSizeForWidget(nsIFrame* aFrame, uint8_t aWidgetType,
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -826,7 +811,7 @@ nsNativeThemeGTK::DrawWidgetBackground(nsRenderingContext* aContext,
|
|||
|
||||
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.
|
||||
|
@ -1065,10 +1050,11 @@ nsNativeThemeGTK::GetWidgetPadding(nsDeviceContext* aContext,
|
|||
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(nsPresContext* aPresContext,
|
|||
break;
|
||||
}
|
||||
|
||||
*aResult = *aResult * GdkScaleFactor();
|
||||
*aResult = *aResult * nsScreenGtk::GetGtkMonitorScaleFactor();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -63,6 +63,23 @@ nsScreenGtk :: GetAvailRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth
|
|||
|
||||
} // 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 *aColorDepth)
|
|||
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
|
||||
|
|
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче