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
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2019 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -231,7 +231,7 @@ public static Frame new_Frame (final Composite parent) {
});
break;
case SWT.Resize:
final Rectangle clientArea = DPIUtil.autoScaleUp(parent.getClientArea());
final Rectangle clientArea = parent.getClientArea();
EventQueue.invokeLater(() -> frame[0].setSize (clientArea.width, clientArea.height));
break;
}
Expand All @@ -241,7 +241,7 @@ public static Frame new_Frame (final Composite parent) {

parent.getDisplay().asyncExec(() -> {
if (parent.isDisposed()) return;
final Rectangle clientArea = DPIUtil.autoScaleUp(parent.getClientArea());
final Rectangle clientArea = parent.getClientArea();
EventQueue.invokeLater(() -> {
frame[0].setSize (clientArea.width, clientArea.height);
frame[0].validate ();
Expand Down Expand Up @@ -285,7 +285,7 @@ public void componentResized (ComponentEvent e) {
display.syncExec (() -> {
if (shell.isDisposed()) return;
Dimension dim = parent.getSize ();
shell.setSize (DPIUtil.autoScaleDown(new Point(dim.width, dim.height)));
shell.setSize (new Point(dim.width, dim.height));
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4534,10 +4534,8 @@ static long toDisplay (long gdkResource, long x, long y) {
} else {
GDK.gdk_window_get_origin (gdkResource, origin_x, origin_y);
}
int scaledX = DPIUtil.autoScaleDown (origin_x [0]);
int scaledY = DPIUtil.autoScaleDown (origin_y [0]);
C.memmove (x, new int[] {scaledX}, 4);
C.memmove (y, new int[] {scaledY}, 4);
C.memmove (x, new int[] {origin_x [0]}, 4);
C.memmove (y, new int[] {origin_y [0]}, 4);
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2018 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -792,7 +792,7 @@ boolean setEventData(long context, int x, int y, int time, DNDEvent event) {
long window = GTK3.gtk_widget_get_window (control.handle);
GDK.gdk_window_get_origin(window, origin_x, origin_y);
}
Point coordinates = DPIUtil.autoScaleDown(new Point(origin_x[0] + x, origin_y[0] + y));
Point coordinates = new Point(origin_x[0] + x, origin_y[0] + y);

event.widget = this;
event.x = coordinates.x;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -136,7 +136,7 @@ public void dragOver(DropTargetEvent event) {
long handle = table.handle;
int effect = checkEffect(event.feedback);
Point coordinates = new Point(event.x, event.y);
coordinates = DPIUtil.autoScaleUp(table.toControl(coordinates));
coordinates = table.toControl(coordinates);
long [] path = new long [1];
GTK.gtk_tree_view_get_path_at_pos (handle, coordinates.x, coordinates.y, path, null, null, null);
int index = -1;
Expand All @@ -154,7 +154,7 @@ public void dragOver(DropTargetEvent event) {
} else {
if (index != -1 && scrollIndex == index && scrollBeginTime != 0) {
if (System.currentTimeMillis() >= scrollBeginTime) {
if (coordinates.y < DPIUtil.autoScaleUp(table.getItemHeight())) {
if (coordinates.y < table.getItemHeight()) {
GTK.gtk_tree_path_prev(path[0]);
} else {
GTK.gtk_tree_path_next(path[0]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -150,7 +150,7 @@ public void dragOver(DropTargetEvent event) {

long handle = tree.handle;
Point coordinates = new Point(event.x, event.y);
coordinates = DPIUtil.autoScaleUp(tree.toControl(coordinates));
coordinates = tree.toControl(coordinates);
long [] path = new long [1];
GTK.gtk_tree_view_get_path_at_pos (handle, coordinates.x, coordinates.y, path, null, null, null);
int index = -1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2018 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -15,7 +15,6 @@

import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
import org.eclipse.swt.internal.gtk3.*;
import org.eclipse.swt.internal.opengl.glx.*;
Expand Down Expand Up @@ -164,7 +163,7 @@ public GLCanvas (Composite parent, int style, GLData data) {
GLX.glViewport (viewport [0],viewport [1],viewport [2],viewport [3]);
break;
case SWT.Resize:
Rectangle clientArea = DPIUtil.autoScaleUp(getClientArea());
Rectangle clientArea = getClientArea();
GDK.gdk_window_move (glWindow, clientArea.x, clientArea.y);
GDK.gdk_window_resize (glWindow, clientArea.width, clientArea.height);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1835,7 +1835,7 @@ void onDispose (Event e) {
}

void onResize (Event e) {
Rectangle rect = DPIUtil.autoScaleUp(browser.getClientArea ());
Rectangle rect = browser.getClientArea ();
if (webView == 0)
return;
GTK.gtk_widget_set_size_request (webView, rect.width, rect.height);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2021 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -14,7 +14,6 @@
package org.eclipse.swt.graphics;

import org.eclipse.swt.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;

/**
Expand Down Expand Up @@ -219,10 +218,6 @@ public Path (Device device, PathData data) {
public void addArc(float x, float y, float width, float height, float startAngle, float arcAngle) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (width == 0 || height == 0 || arcAngle == 0) return;
x = DPIUtil.autoScaleUp(x);
y = DPIUtil.autoScaleUp(y);
width = DPIUtil.autoScaleUp(width);
height = DPIUtil.autoScaleUp(height);
addArcInPixels(x, y, width, height, startAngle, arcAngle);
}

Expand Down Expand Up @@ -292,10 +287,6 @@ public void addPath(Path path) {
*/
public void addRectangle(float x, float y, float width, float height) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
x = DPIUtil.autoScaleUp(x);
y = DPIUtil.autoScaleUp(y);
width = DPIUtil.autoScaleUp(width);
height = DPIUtil.autoScaleUp(height);
addRectangleInPixels(x, y, width, height);
}

Expand Down Expand Up @@ -326,11 +317,8 @@ public void addString(String string, float x, float y, Font font) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (font == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
x = DPIUtil.autoScaleUp(x);
y = DPIUtil.autoScaleUp(y);
// Scale up the font
FontData fd = font.getFontData()[0];
fd.setHeight(DPIUtil.autoScaleUp(fd.getHeight()));
Font scaledFont = new Font(font.getDevice(), fd);
addStringInPixels(string, x, y, scaledFont);
scaledFont.dispose(); // Dispose the scaled up font
Expand Down Expand Up @@ -384,8 +372,6 @@ public boolean contains(float x, float y, GC gc, boolean outline) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (gc.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
x = DPIUtil.autoScaleUp(x);
y = DPIUtil.autoScaleUp(y);
return containsInPixels(x, y, gc, outline);
}
boolean containsInPixels(float x, float y, GC gc, boolean outline) {
Expand Down Expand Up @@ -423,12 +409,6 @@ boolean containsInPixels(float x, float y, GC gc, boolean outline) {
*/
public void cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
cx1 = DPIUtil.autoScaleUp(cx1);
cy1 = DPIUtil.autoScaleUp(cy1);
cx2 = DPIUtil.autoScaleUp(cx2);
cy2 = DPIUtil.autoScaleUp(cy2);
x = DPIUtil.autoScaleUp(x);
y = DPIUtil.autoScaleUp(y);
cubicToInPixels(cx1, cy1, cx2, cy2, x, y);
}
void cubicToInPixels(float cx1, float cy1, float cx2, float cy2, float x, float y) {
Expand Down Expand Up @@ -462,9 +442,6 @@ public void getBounds(float[] bounds) {
if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (bounds.length < 4) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
getBoundsInPixels(bounds);
for (int i = 0; i < bounds.length; i++) {
bounds [i] = DPIUtil.autoScaleDown(bounds[i]);
}
}
void getBoundsInPixels(float[] bounds) {
long copy = Cairo.cairo_copy_path(handle);
Expand Down Expand Up @@ -540,9 +517,6 @@ void getBoundsInPixels(float[] bounds) {
public void getCurrentPoint(float[] point) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
getCurrentPointInPixels(point);
for (int i = 0; i < point.length; i++) {
point [i] = DPIUtil.autoScaleDown(point[i]);
}
}

void getCurrentPointInPixels(float[] point) {
Expand All @@ -567,9 +541,7 @@ void getCurrentPointInPixels(float[] point) {
*/
public PathData getPathData() {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
PathData result = getPathDataInPixels();
result.points = DPIUtil.autoScaleDown(result.points);
return result;
return getPathDataInPixels();
}

PathData getPathDataInPixels() {
Expand Down Expand Up @@ -647,8 +619,6 @@ PathData getPathDataInPixels() {
*/
public void lineTo(float x, float y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
x = DPIUtil.autoScaleUp(x);
y = DPIUtil.autoScaleUp(y);
lineToInPixels(x, y);
}
void lineToInPixels(float x, float y) {
Expand Down Expand Up @@ -676,8 +646,6 @@ void lineToInPixels(float x, float y) {
*/
public void moveTo(float x, float y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
x = DPIUtil.autoScaleUp(x);
y = DPIUtil.autoScaleUp(y);
moveToInPixels(x, y);
}
void moveToInPixels(float x, float y) {
Expand Down Expand Up @@ -707,10 +675,6 @@ void moveToInPixels(float x, float y) {
*/
public void quadTo(float cx, float cy, float x, float y) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
x = DPIUtil.autoScaleUp(x);
y = DPIUtil.autoScaleUp(y);
cx = DPIUtil.autoScaleUp(cx);
cy = DPIUtil.autoScaleUp(cy);
quadToInPixels(cx, cy, x, y);
}
void quadToInPixels(float cx, float cy, float x, float y) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2016 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -14,7 +14,6 @@
package org.eclipse.swt.graphics;

import org.eclipse.swt.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;

/**
Expand Down Expand Up @@ -173,10 +172,6 @@ public Pattern(Device device, float x1, float y1, float x2, float y2, Color colo
*/
public Pattern(Device device, float x1, float y1, float x2, float y2, Color color1, int alpha1, Color color2, int alpha2) {
super(device);
x1 = DPIUtil.autoScaleUp(x1);
y1 = DPIUtil.autoScaleUp(y1);
x2 = DPIUtil.autoScaleUp(x2);
y2 = DPIUtil.autoScaleUp(y2);
if (color1 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
if (color1.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
if (color2 == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2016 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -14,7 +14,6 @@
package org.eclipse.swt.graphics;

import org.eclipse.swt.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cairo.*;

/**
Expand Down Expand Up @@ -147,7 +146,7 @@ public Transform (Device device, float m11, float m12, float m21, float m22, flo
super(device);
handle = new double[6];
if (handle == null) SWT.error(SWT.ERROR_NO_HANDLES);
Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, DPIUtil.autoScaleUp(dx), DPIUtil.autoScaleUp(dy));
Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, dx, dy);
init();
}

Expand Down Expand Up @@ -184,8 +183,8 @@ public void getElements(float[] elements) {
elements[1] = (float)handle[1];
elements[2] = (float)handle[2];
elements[3] = (float)handle[3];
elements[4] = DPIUtil.autoScaleDown((float)handle[4]);
elements[5] = DPIUtil.autoScaleDown((float)handle[5]);
elements[4] = (float)handle[4];
elements[5] = (float)handle[5];
}

/**
Expand Down Expand Up @@ -320,7 +319,7 @@ public void scale(float scaleX, float scaleY) {
*/
public void setElements(float m11, float m12, float m21, float m22, float dx, float dy) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, DPIUtil.autoScaleUp(dx), DPIUtil.autoScaleUp(dy));
Cairo.cairo_matrix_init(handle, m11, m12, m21, m22, dx, dy);
}

/**
Expand Down Expand Up @@ -362,11 +361,11 @@ public void transform(float[] pointArray) {
double[] dx = new double[1], dy = new double[1];
int length = pointArray.length / 2;
for (int i = 0, j = 0; i < length; i++, j += 2) {
dx[0] = DPIUtil.autoScaleUp(pointArray[j]);
dy[0] = DPIUtil.autoScaleUp(pointArray[j + 1]);
dx[0] = pointArray[j];
dy[0] = pointArray[j + 1];
Cairo.cairo_matrix_transform_point(handle, dx, dy);
pointArray[j] = DPIUtil.autoScaleDown((float)dx[0]);
pointArray[j + 1] = DPIUtil.autoScaleDown((float)dy[0]);
pointArray[j] = (float)dx[0];
pointArray[j + 1] = (float)dy[0];
}
}

Expand All @@ -383,7 +382,7 @@ public void transform(float[] pointArray) {
*/
public void translate(float offsetX, float offsetY) {
if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);
Cairo.cairo_matrix_translate(handle, DPIUtil.autoScaleUp(offsetX), DPIUtil.autoScaleUp(offsetY));
Cairo.cairo_matrix_translate(handle, offsetX, offsetY);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2018 IBM Corporation and others.
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -367,7 +367,7 @@ protected void destroy () {
*/
public Rectangle getBounds () {
checkDevice ();
return DPIUtil.autoScaleDown (getBoundsInPixels ());
return getBoundsInPixels ();
}

private Rectangle getBoundsInPixels () {
Expand Down
Loading
Loading