return 0;
}
-int getActualDPI () {
+/**
+ * Returns DPI in x direction. In the modern monitors DPI for
+ * X and Y directions is same.
+ *
+ * @return the horizontal DPI
+ */
+int _getDPIx () {
long /*int*/ screen = OS.gdk_screen_get_default();
- Rectangle rect = getBounds();
- int monitor = OS.gdk_screen_get_monitor_at_point(screen, rect.x, rect.y);
+ int monitor = OS.gdk_screen_get_monitor_at_point(screen, 0, 0);
GdkRectangle dest = new GdkRectangle ();
OS.gdk_screen_get_monitor_geometry(screen, monitor, dest);
}
int getDeviceZoom () {
- return DPIUtil.mapDPIToZoom (device.getActualDPI ());
+ return DPIUtil.mapDPIToZoom (device._getDPIx ());
}
/**
* @return true if image is refreshed
*/
boolean refreshImageForZoom () {
- int deviceZoomLevel = getDeviceZoom();
boolean refreshed = false;
- if (deviceZoomLevel != currentDeviceZoom) {
- if (imageFileNameProvider != null) {
+ if (imageFileNameProvider != null) {
+ int deviceZoomLevel = getDeviceZoom();
+ if (deviceZoomLevel != currentDeviceZoom) {
boolean[] found = new boolean[1];
String filename = DPIUtil.validateAndGetImagePathAtZoom (imageFileNameProvider, deviceZoomLevel, found);
/* Avoid re-creating the fall-back image, when current zoom is already 100% */
init ();
refreshed = true;
}
- } else if (imageDataProvider != null) {
+ currentDeviceZoom = deviceZoomLevel;
+ }
+ } else if (imageDataProvider != null) {
+ int deviceZoomLevel = getDeviceZoom();
+ if (deviceZoomLevel != currentDeviceZoom) {
boolean[] found = new boolean[1];
ImageData data = DPIUtil.validateAndGetImageDataAtZoom (imageDataProvider, deviceZoomLevel, found);
/* Avoid re-creating the fall-back image, when current zoom is already 100% */
init();
refreshed = true;
}
+ currentDeviceZoom = deviceZoomLevel;
}
- currentDeviceZoom = deviceZoomLevel;
}
return refreshed;
}
package org.eclipse.swt.graphics;
+import org.eclipse.swt.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gdip.*;
import org.eclipse.swt.internal.win32.*;
-import org.eclipse.swt.*;
/**
* This class is the abstract superclass of all device objects,
}
/**
+ * Returns DPI in x direction. In the modern monitors DPI for
+ * X and Y directions is same.
+ *
+ * @return the horizontal DPI
+ */
+int _getDPIx () {
+ long /*int*/ hDC = internal_new_GC (null);
+ int dpi = OS.GetDeviceCaps (hDC, OS.LOGPIXELSX);
+ internal_dispose_GC (hDC, null);
+ return dpi;
+}
+/**
* Returns <code>FontData</code> objects which describe
* the fonts that match the given arguments. If the
* <code>faceName</code> is null, all fonts will be returned.
}
int getDeviceZoom () {
- return DPIUtil.mapDPIToZoom (device.getDPI ().x);
+ return DPIUtil.mapDPIToZoom (device._getDPIx ());
}
/**
* @return true if image is refreshed
*/
boolean refreshImageForZoom () {
- int deviceZoomLevel = getDeviceZoom();
boolean refreshed = false;
- if (deviceZoomLevel != currentDeviceZoom) {
- if (imageFileNameProvider != null) {
+ if (imageFileNameProvider != null) {
+ int deviceZoomLevel = getDeviceZoom();
+ if (deviceZoomLevel != currentDeviceZoom) {
boolean[] found = new boolean[1];
String filename = DPIUtil.validateAndGetImagePathAtZoom (imageFileNameProvider, deviceZoomLevel, found);
/* Avoid re-creating the fall-back image, when current zoom is already 100% */
init();
refreshed = true;
}
- } else if (imageDataProvider != null) {
+ currentDeviceZoom = deviceZoomLevel;
+ }
+ } else if (imageDataProvider != null) {
+ int deviceZoomLevel = getDeviceZoom();
+ if (deviceZoomLevel != currentDeviceZoom) {
boolean[] found = new boolean[1];
ImageData data = DPIUtil.validateAndGetImageDataAtZoom (imageDataProvider, deviceZoomLevel, found);
/* Avoid re-creating the fall-back image, when current zoom is already 100% */
init();
refreshed = true;
}
+ currentDeviceZoom = deviceZoomLevel;
}
- currentDeviceZoom = deviceZoomLevel;
}
return refreshed;
}