WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch for landing
bug-210543-20200415171521.patch (text/plain), 3.31 KB, created by
Claudio Saavedra
on 2020-04-15 07:15:25 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Claudio Saavedra
Created:
2020-04-15 07:15:25 PDT
Size:
3.31 KB
patch
obsolete
>Subversion Revision: 260072 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 7a00483d20588f9ba5d71c1cc9664935ff00cfa9..336f636399caf9c2884eba51d648c7e3013280b6 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,30 @@ >+2020-04-15 Claudio Saavedra <csaavedra@igalia.com> >+ >+ [GTK] Make PlatformScreen::screenDPI() GTK4-ready >+ https://bugs.webkit.org/show_bug.cgi?id=210543 >+ >+ Reviewed by Adrian Perez de Castro. >+ >+ No new tests needed. >+ >+ This method is using deprecated and removed APIs >+ from GDK. Guard the removed API usage so that it's only >+ used in GTK3 and update to use the replacement APIs otherwise. >+ >+ Also, make it to also use the gtk-xft-dpi GtkSettings property. >+ This method is mostly used in response to a change in this >+ property, so ignoring its value doesn't seem a good idea. >+ >+ The following priority is used: >+ >+ 1. (GTK3 only) query gdk_screen_get_resolution(). >+ 2. Use the GtkSettings::gtk-xft-dpi property. >+ 3. Calculate the actual DPI from the monitor 0's properties. >+ 4. If none of these succeed, use the default DPI, 96. >+ >+ * platform/gtk/PlatformScreenGtk.cpp: >+ (WebCore::screenDPI): >+ > 2020-04-14 Claudio Saavedra <csaavedra@igalia.com> > > [GTK] Adapt to GdkVisual deprecation and removal >diff --git a/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp b/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp >index 13a878b424f09a96c3ee152f393bc0f465c8179d..212d0e9a1def1233f91082b59665ae7483df16dd 100644 >--- a/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp >+++ b/Source/WebCore/platform/gtk/PlatformScreenGtk.cpp >@@ -92,21 +92,39 @@ bool screenHasInvertedColors() > double screenDPI() > { > static const double defaultDpi = 96; >+#if !USE(GTK4) > GdkScreen* screen = gdk_screen_get_default(); >- if (!screen) >- return defaultDpi; >+ if (screen) { >+ double dpi = gdk_screen_get_resolution(screen); >+ if (dpi != -1) >+ return dpi; >+ } >+#endif > >- double dpi = gdk_screen_get_resolution(screen); >- if (dpi != -1) >- return dpi; >+ static GtkSettings* gtkSettings = gtk_settings_get_default(); >+ if (gtkSettings) { >+ int gtkXftDpi; >+ g_object_get(gtkSettings, "gtk-xft-dpi", >kXftDpi, nullptr); >+ return gtkXftDpi / 1024.0; >+ } > > static double cachedDpi = 0; > if (cachedDpi) > return cachedDpi; > > static const double millimetresPerInch = 25.4; >- double diagonalInPixels = std::hypot(gdk_screen_get_width(screen), gdk_screen_get_height(screen)); >- double diagonalInInches = std::hypot(gdk_screen_get_width_mm(screen), gdk_screen_get_height_mm(screen)) / millimetresPerInch; >+ >+ GdkDisplay* display = gdk_display_get_default(); >+ if (!display) >+ return defaultDpi; >+ GdkMonitor* monitor = gdk_display_get_monitor(display, 0); >+ if (!monitor) >+ return defaultDpi; >+ >+ GdkRectangle geometry; >+ gdk_monitor_get_geometry(monitor, &geometry); >+ double diagonalInPixels = std::hypot(geometry.width, geometry.height); >+ double diagonalInInches = std::hypot(gdk_monitor_get_width_mm(monitor), gdk_monitor_get_height_mm(monitor)) / millimetresPerInch; > cachedDpi = diagonalInPixels / diagonalInInches; > > return cachedDpi;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 210543
:
396521
| 396530