Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ public Point getDPI() {
}
}

@SuppressWarnings("deprecation")
Point getIndependentDPI() {
return super.getDPI();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ public PDFDocument(Device device, String filename, double width, double height)
int screenDpiX = 96;
int screenDpiY = 96;
if (this.device != null) {
@SuppressWarnings("deprecation")
Point dpi = this.device.getDPI();
screenDpiX = dpi.x;
screenDpiY = dpi.y;
Expand Down Expand Up @@ -427,6 +428,7 @@ public long internal_new_GC(GCData data) {
int screenDpiX = 96;
int screenDpiY = 96;
if (device != null) {
@SuppressWarnings("deprecation")
Point dpi = device.getDPI();
screenDpiX = dpi.x;
screenDpiY = dpi.y;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,18 @@ public int getDepth () {
* @exception SWTException <ul>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @deprecated <p>This method returns a single global DPI value
* that does not reflect per-monitor DPI settings on modern operating systems.
* In environments with different scaling factors across monitors, it may provide
* a misleading or meaningless result, as it does not correspond to the actual DPI
* of any specific monitor.</p>
*
* <p>Note: While deprecated for general {@code Device} instances like {@code Display},
* this method may still be validly used when called on a {@code Printer} instance,
* where a single global DPI value is meaningful and expected.</p>
*/
@Deprecated
public Point getDPI () {
checkDevice ();
return getScreenDPI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,18 @@ public int getDepth () {
* @exception SWTException <ul>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @deprecated <p>This method returns a single global DPI value
* that does not reflect per-monitor DPI settings on modern operating systems.
* In environments with different scaling factors across monitors, it may provide
* a misleading or meaningless result, as it does not correspond to the actual DPI
* of any specific monitor.</p>
*
* <p>Note: While deprecated for general {@code Device} instances like {@code Display},
* this method may still be validly used when called on a {@code Printer} instance,
* where a single global DPI value is meaningful and expected.</p>
*/
@Deprecated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deprecation on Device is then wrong here in my opinion and Display should override the method and deprecate it individually. One might even define this for a display to return the smallest DPI setting of all monitors, or return the one of the primary monitor.

public Point getDPI () {
checkDevice ();
return getScreenDPI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5052,7 +5052,9 @@ String debugInfoForIndex(long index) {
}

void dpiChanged(int newScaleFactor) {
DPIUtil.setDeviceZoom (DPIUtil.mapDPIToZoom(getDPI().x * newScaleFactor));
@SuppressWarnings("deprecation")
int dpiX = getDPI().x;
DPIUtil.setDeviceZoom (DPIUtil.mapDPIToZoom(dpiX * newScaleFactor));
Shell[] shells = getShells();
for (int i = 0; i < shells.length; i++) {
shells[i].layout(true, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,18 @@ public int getDepth () {
* @exception SWTException <ul>
* <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
* </ul>
*
* @deprecated <p>This method returns a single global DPI value
* that does not reflect per-monitor DPI settings on modern operating systems.
* In environments with different scaling factors across monitors, it may provide
* a misleading or meaningless result, as it does not correspond to the actual DPI
* of any specific monitor.</p>
*
* <p>Note: While deprecated for general {@code Device} instances like {@code Display},
* this method may still be validly used when called on a {@code Printer} instance,
* where a single global DPI value is meaningful and expected.</p>
*/
@Deprecated
public Point getDPI () {
checkDevice ();
long hDC = internal_new_GC (null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,7 @@ public void test_wake() {
/* custom */
boolean disposeExecRan;

@SuppressWarnings("deprecation")
@Test
public void test_getDPI() {
Display display = new Display();
Expand Down
Loading