Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSravan Kumar Lakkimsetti2018-05-15 06:56:43 -0400
committerSravan Kumar Lakkimsetti2018-05-15 07:51:04 -0400
commit918497a03146e470781caa9f737d37186e0bda00 (patch)
treef46b6be38c803fa2e69303bde8a8f97c752fa398
parent20ef526f3173960f099e3bcdaf613ab4f2f3960a (diff)
downloadeclipse.platform.swt-918497a03146e470781caa9f737d37186e0bda00.tar.gz
eclipse.platform.swt-918497a03146e470781caa9f737d37186e0bda00.tar.xz
eclipse.platform.swt-918497a03146e470781caa9f737d37186e0bda00.zip
Bug 518717 - [GTK3] Replace deprecated gdk_screen_width_mm()
Change-Id: Ibfa8e61d71f49dd0c64d0f94d79e403ec453542a Signed-off-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java21
1 files changed, 9 insertions, 12 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
index 19357d1248..0bff506f95 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
@@ -467,9 +467,14 @@ public FontData[] getFontList (String faceName, boolean scalable) {
}
Point getScreenDPI () {
- int widthMM = GDK.gdk_screen_width_mm ();
- int width = GDK.gdk_screen_width ();
- int dpi = Compatibility.round (254 * width, widthMM * 10);
+ long /*int*/ screen = GDK.gdk_screen_get_default();
+ int dpi = (int) GDK.gdk_screen_get_resolution (screen);
+ if (dpi <= 0) dpi = 96; // gdk_screen_get_resolution returns -1 in case of error
+ if (GTK.GTK_VERSION > OS.VERSION(3, 9, 0)) {
+ int monitor_num = GDK.gdk_screen_get_monitor_at_point (screen, 0, 0);
+ int scale = GDK.gdk_screen_get_monitor_scale_factor (screen, monitor_num);
+ dpi = dpi * scale;
+ }
return new Point (dpi, dpi);
}
@@ -1062,15 +1067,7 @@ int _getDPIx () {
* @since 3.105
*/
protected int getDeviceZoom() {
- long /*int*/ screen = GDK.gdk_screen_get_default();
- int dpi = (int) GDK.gdk_screen_get_resolution (screen);
- if (dpi <= 0) dpi = 96; // gdk_screen_get_resolution returns -1 in case of error
- if (GTK.GTK_VERSION > OS.VERSION(3, 9, 0)) {
- int monitor_num = GDK.gdk_screen_get_monitor_at_point (screen, 0, 0);
- int scale = GDK.gdk_screen_get_monitor_scale_factor (screen, monitor_num);
- dpi = dpi * scale;
- }
- return DPIUtil.mapDPIToZoom (dpi);
+ return DPIUtil.mapDPIToZoom (getScreenDPI().x);
}
/**
* @noreference This method is not intended to be referenced by clients.

Back to the top