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, 2020 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 @@ -266,7 +266,7 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
if (layout != null) {
if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
changed |= (state & LAYOUT_CHANGED) != 0;
size = DPIUtil.autoScaleUp(layout.computeSize (this, DPIUtil.autoScaleDown(wHint), DPIUtil.autoScaleDown(hHint), changed));
size = layout.computeSize (this, wHint, hHint, changed);
state &= ~LAYOUT_CHANGED;
} else {
size = new Point (wHint, hHint);
Expand All @@ -278,7 +278,7 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
}
if (wHint != SWT.DEFAULT) size.x = wHint;
if (hHint != SWT.DEFAULT) size.y = hHint;
Rectangle trim = DPIUtil.autoScaleUp (computeTrim (0, 0, DPIUtil.autoScaleDown(size.x), DPIUtil.autoScaleDown(size.y)));
Rectangle trim = computeTrim (0, 0, size.x, size.y);
return new Point (trim.width, trim.height);
}

Expand Down Expand Up @@ -550,9 +550,7 @@ void deregister () {
*/
public void drawBackground (GC gc, int x, int y, int width, int height, int offsetX, int offsetY) {
checkWidget();
Rectangle rect = DPIUtil.autoScaleUp(new Rectangle (x, y, width, height));
offsetX = DPIUtil.autoScaleUp(offsetX);
offsetY = DPIUtil.autoScaleUp(offsetY);
Rectangle rect = new Rectangle (x, y, width, height);
drawBackgroundInPixels(gc, rect.x, rect.y, rect.width, rect.height, offsetX, offsetY);
}

Expand Down Expand Up @@ -591,7 +589,7 @@ void drawBackgroundInPixels (GC gc, int x, int y, int width, int height, int off
Cairo.cairo_fill (cairo);
Cairo.cairo_restore (cairo);
} else {
gc.fillRectangle(DPIUtil.autoScaleDown(new Rectangle(x, y, width, height)));
gc.fillRectangle(new Rectangle(x, y, width, height));

}
}
Expand Down Expand Up @@ -1427,10 +1425,10 @@ Point minimumSize (int wHint, int hHint, boolean changed) {
* Since getClientArea can be overridden by subclasses, we cannot
* call getClientAreaInPixels directly.
*/
Rectangle clientArea = DPIUtil.autoScaleUp(getClientArea ());
Rectangle clientArea = getClientArea ();
int width = 0, height = 0;
for (int i=0; i<children.length; i++) {
Rectangle rect = DPIUtil.autoScaleUp(children [i].getBounds ());
Rectangle rect = children [i].getBounds ();
width = Math.max (width, rect.x - clientArea.x + rect.width);
height = Math.max (height, rect.y - clientArea.y + rect.height);
}
Expand All @@ -1446,7 +1444,7 @@ long parentingHandle () {
void printWidget (GC gc, long drawable, int depth, int x, int y) {
Region oldClip = new Region (gc.getDevice ());
Region newClip = new Region (gc.getDevice ());
Point loc = DPIUtil.autoScaleDown(new Point (x, y));
Point loc = new Point (x, y);
gc.getClipping (oldClip);
Rectangle rect = getBounds ();
newClip.add (oldClip);
Expand All @@ -1457,7 +1455,7 @@ void printWidget (GC gc, long drawable, int depth, int x, int y) {
Point pt = display.mapInPixels (this, parent, clientRect.x, clientRect.y);
clientRect.x = x + pt.x - rect.x;
clientRect.y = y + pt.y - rect.y;
newClip.intersect (DPIUtil.autoScaleDown(clientRect));
newClip.intersect (clientRect);
gc.setClipping (newClip);
Control [] children = _getChildren ();
for (int i=children.length-1; i>=0; --i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,9 +832,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget();
if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0;
if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0;
wHint = DPIUtil.autoScaleUp(wHint);
hHint = DPIUtil.autoScaleUp(hHint);
return DPIUtil.autoScaleDown (computeSizeInPixels (wHint, hHint, changed));
return computeSizeInPixels (wHint, hHint, changed);
}

Point computeSizeInPixels (int wHint, int hHint, boolean changed) {
Expand Down Expand Up @@ -933,7 +931,7 @@ Accessible _getAccessible () {
*/
public Rectangle getBounds () {
checkWidget();
return DPIUtil.autoScaleDown(getBoundsInPixels());
return getBoundsInPixels();
}

Rectangle getBoundsInPixels () {
Expand Down Expand Up @@ -975,7 +973,6 @@ Rectangle getBoundsInPixels () {
public void setBounds (Rectangle rect) {
checkWidget ();
if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
rect = DPIUtil.autoScaleUp(rect);
setBounds (rect.x, rect.y, Math.max (0, rect.width), Math.max (0, rect.height), true, true);
}

Expand Down Expand Up @@ -1015,7 +1012,7 @@ void setBoundsInPixels (Rectangle rect) {
*/
public void setBounds (int x, int y, int width, int height) {
checkWidget();
Rectangle rect = DPIUtil.autoScaleUp(new Rectangle (x, y, width, height));
Rectangle rect = new Rectangle (x, y, width, height);
setBounds (rect.x, rect.y, Math.max (0, rect.width), Math.max (0, rect.height), true, true);
}

Expand Down Expand Up @@ -1234,7 +1231,7 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
*/
public Point getLocation () {
checkWidget();
return DPIUtil.autoScaleDown(getLocationInPixels());
return getLocationInPixels();
}

Point getLocationInPixels () {
Expand Down Expand Up @@ -1271,7 +1268,6 @@ Point getLocationInPixels () {
public void setLocation (Point location) {
checkWidget ();
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
location = DPIUtil.autoScaleUp(location);
setBounds (location.x, location.y, 0, 0, true, false);
}

Expand Down Expand Up @@ -1301,7 +1297,7 @@ void setLocationInPixels (Point location) {
*/
public void setLocation(int x, int y) {
checkWidget();
Point loc = DPIUtil.autoScaleUp(new Point (x, y));
Point loc = new Point (x, y);
setBounds (loc.x, loc.y, 0, 0, true, false);
}

Expand All @@ -1325,7 +1321,7 @@ void setLocationInPixels(int x, int y) {
*/
public Point getSize () {
checkWidget();
return DPIUtil.autoScaleDown(getSizeInPixels());
return getSizeInPixels();
}

Point getSizeInPixels () {
Expand Down Expand Up @@ -1364,7 +1360,6 @@ Point getSizeInPixels () {
public void setSize (Point size) {
checkWidget ();
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
size = DPIUtil.autoScaleUp(size);
setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true);
}

Expand Down Expand Up @@ -1483,7 +1478,7 @@ void setRelations () {
*/
public void setSize (int width, int height) {
checkWidget();
Point size = DPIUtil.autoScaleUp(new Point (width, height));
Point size = new Point (width, height);
setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true);
}

Expand Down Expand Up @@ -1667,9 +1662,9 @@ public Point toControl(int x, int y) {
GDK.gdk_window_get_origin(window, origin_x, origin_y);
}

x -= DPIUtil.autoScaleDown(origin_x[0]);
y -= DPIUtil.autoScaleDown(origin_y[0]);
if ((style & SWT.MIRRORED) != 0) x = DPIUtil.autoScaleDown(getClientWidth()) - x;
x -= origin_x[0];
y -= origin_y[0];
if ((style & SWT.MIRRORED) != 0) x = getClientWidth() - x;

return new Point(x, y);
}
Expand Down Expand Up @@ -1732,9 +1727,9 @@ public Point toDisplay(int x, int y) {
GDK.gdk_window_get_origin(window, origin_x, origin_y);
}

if ((style & SWT.MIRRORED) != 0) x = DPIUtil.autoScaleDown(getClientWidth()) - x;
x += DPIUtil.autoScaleDown(origin_x[0]);
y += DPIUtil.autoScaleDown(origin_y[0]);
if ((style & SWT.MIRRORED) != 0) x = getClientWidth() - x;
x += origin_x[0];
y += origin_y[0];

return new Point(x, y);
}
Expand Down Expand Up @@ -3018,7 +3013,7 @@ GdkRGBA getBaseGdkRGBA () {
* </ul>
*/
public int getBorderWidth () {
return DPIUtil.autoScaleDown(getBorderWidthInPixels());
return getBorderWidthInPixels();
}

int getBorderWidthInPixels () {
Expand Down Expand Up @@ -3557,8 +3552,7 @@ long gtk_button_press_event (long widget, long event, boolean sendMouseDown) {
// See comment in #dragDetect()
if (OS.isX11()) {
if (dragging) {
Point scaledEvent = DPIUtil.autoScaleDown(new Point((int)eventX[0], (int) eventY[0]));
sendDragEvent (eventButton[0], eventState[0], scaledEvent.x, scaledEvent.y, false);
sendDragEvent (eventButton[0], eventState[0], (int)eventX[0], (int)eventY[0], false);
if (isDisposed ()) return 1;
}
}
Expand Down Expand Up @@ -3885,8 +3879,8 @@ long gtk_draw (long widget, long cairo) {
if (!hooksPaint ()) return 0;
Event event = new Event ();
event.count = 1;
Rectangle eventBounds = DPIUtil.autoScaleDown (new Rectangle (rect.x, rect.y, rect.width, rect.height));
if ((style & SWT.MIRRORED) != 0) eventBounds.x = DPIUtil.autoScaleDown (getClientWidth ()) - eventBounds.width - eventBounds.x;
Rectangle eventBounds = new Rectangle (rect.x, rect.y, rect.width, rect.height);
if ((style & SWT.MIRRORED) != 0) eventBounds.x = getClientWidth () - eventBounds.width - eventBounds.x;
event.setBounds (eventBounds);
GCData data = new GCData ();
/*
Expand Down Expand Up @@ -4175,7 +4169,7 @@ long gtk_motion_notify_event (long widget, long event) {
int eventType = GDK.gdk_event_get_event_type(event);
if (eventType == GDK.GDK_3BUTTON_PRESS) return 0;

Point scaledEvent = DPIUtil.autoScaleDown(new Point((int)eventX[0], (int) eventY[0]));
Point scaledEvent = new Point((int)eventX[0], (int) eventY[0]);

int [] eventButton = new int [1];
int [] eventState = new int [1];
Expand Down Expand Up @@ -4708,8 +4702,7 @@ void redraw (boolean all) {
*/
public void redraw (int x, int y, int width, int height, boolean all) {
checkWidget();
Rectangle rect = DPIUtil.autoScaleUp(new Rectangle(x, y, width, height));
redrawInPixels(rect.x, rect.y, rect.width, rect.height, all);
redrawInPixels(x, y, width, height, all);
}

void redrawInPixels (int x, int y, int width, int height, boolean all) {
Expand Down Expand Up @@ -4894,7 +4887,7 @@ boolean sendDragEvent (int button, int stateMask, int x, int y, boolean isStateM
event.button = button;
Rectangle eventRect = new Rectangle (x, y, 0, 0);
event.setBounds (eventRect);
if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown(getClientWidth ()) - event.x;
if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.x;
if (isStateMask) {
event.stateMask = stateMask;
} else {
Expand Down Expand Up @@ -5062,7 +5055,7 @@ boolean sendMouseEvent (int type, int button, int count, int detail, boolean sen
if (is_hint) {
// coordinates are already window-relative, see #gtk_motion_notify_event(..) and bug 94502
Rectangle eventRect = new Rectangle ((int)x, (int)y, 0, 0);
event.setBounds (DPIUtil.autoScaleDown (eventRect));
event.setBounds (eventRect);
} else {
int [] origin_x = new int [1], origin_y = new int [1];
Rectangle eventRect;
Expand All @@ -5071,15 +5064,15 @@ boolean sendMouseEvent (int type, int button, int count, int detail, boolean sen
// GDK.gdk_surface_get_origin (surface, origin_x, origin_y);
// eventRect = new Rectangle ((int)x - origin_x [0], (int)y - origin_y [0], 0, 0);
eventRect = new Rectangle ((int)x, (int)y, 0, 0);
event.setBounds (DPIUtil.autoScaleDown (eventRect));
event.setBounds (eventRect);
} else {
long window = eventWindow ();
GDK.gdk_window_get_origin (window, origin_x, origin_y);
eventRect = new Rectangle ((int)x - origin_x [0], (int)y - origin_y [0], 0, 0);
event.setBounds (DPIUtil.autoScaleDown (eventRect));
event.setBounds (eventRect);
}
}
if ((style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown (getClientWidth ()) - event.x;
if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.x;
setInputState (event, state);

/**
Expand Down Expand Up @@ -6309,7 +6302,7 @@ boolean showMenu (int x, int y) {
boolean showMenu (int x, int y, int detail) {
Event event = new Event ();
Rectangle eventRect = new Rectangle (x, y, 0, 0);
event.setBounds (DPIUtil.autoScaleDown (eventRect));
event.setBounds (eventRect);
event.detail = detail;
sendEvent (SWT.MenuDetect, event);
//widget could be disposed at this point
Expand All @@ -6332,7 +6325,7 @@ boolean showMenu (int x, int y, int detail) {

return true;
} else {
Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ());
Rectangle rect = event.getBounds ();
if (rect.x != x || rect.y != y) {
menu.setLocationInPixels (rect.x, rect.y);
}
Expand Down
Loading
Loading