From 52ca34f8c5055f2cf2340ebfa10bce8d025c617e Mon Sep 17 00:00:00 2001 From: Deepika Udayagiri Date: Wed, 26 Jun 2024 10:59:44 +0530 Subject: [PATCH] [GTK][HiDpi] Code cleanup for removal of non-cairo scale path Fixes https://github.com/eclipse-platform/eclipse.platform.swt/issues/1300 [GTK][HiDpi] Code cleanup for removal of non-cairo scale path Fixes #1300 [GTK][HiDpi] Code cleanup for removal of non-cairo scale path Fixes #1300 --- .../gtk/org/eclipse/swt/awt/SWT_AWT.java | 6 +- .../swt/accessibility/AccessibleObject.java | 6 +- .../gtk/org/eclipse/swt/dnd/DropTarget.java | 2 +- .../swt/dnd/TableDropTargetEffect.java | 4 +- .../eclipse/swt/dnd/TreeDropTargetEffect.java | 2 +- .../gtk/org/eclipse/swt/opengl/GLCanvas.java | 3 +- .../gtk/org/eclipse/swt/browser/WebKit.java | 2 +- .../cairo/org/eclipse/swt/graphics/Path.java | 56 +---- .../org/eclipse/swt/graphics/Pattern.java | 5 - .../org/eclipse/swt/graphics/Transform.java | 10 +- .../gtk/org/eclipse/swt/graphics/Device.java | 4 - .../gtk/org/eclipse/swt/graphics/GC.java | 190 ++--------------- .../gtk/org/eclipse/swt/graphics/Image.java | 59 +----- .../gtk/org/eclipse/swt/graphics/Region.java | 64 +----- .../org/eclipse/swt/graphics/TextLayout.java | 199 +++++------------- .../org/eclipse/swt/internal/ImageList.java | 45 +--- .../gtk/org/eclipse/swt/widgets/Button.java | 2 +- .../gtk/org/eclipse/swt/widgets/Canvas.java | 11 +- .../gtk/org/eclipse/swt/widgets/Caret.java | 61 +----- .../gtk/org/eclipse/swt/widgets/Combo.java | 18 +- .../org/eclipse/swt/widgets/Composite.java | 37 ++-- .../gtk/org/eclipse/swt/widgets/Control.java | 154 ++------------ .../gtk/org/eclipse/swt/widgets/DateTime.java | 42 ++-- .../gtk/org/eclipse/swt/widgets/Display.java | 143 ++++--------- .../org/eclipse/swt/widgets/ExpandBar.java | 12 +- .../org/eclipse/swt/widgets/ExpandItem.java | 14 +- .../gtk/org/eclipse/swt/widgets/Group.java | 10 +- .../gtk/org/eclipse/swt/widgets/Label.java | 4 +- .../gtk/org/eclipse/swt/widgets/Link.java | 43 ++-- .../gtk/org/eclipse/swt/widgets/List.java | 12 +- .../gtk/org/eclipse/swt/widgets/Menu.java | 12 +- .../gtk/org/eclipse/swt/widgets/Sash.java | 59 +++--- .../gtk/org/eclipse/swt/widgets/Scale.java | 2 +- .../org/eclipse/swt/widgets/ScrollBar.java | 17 -- .../org/eclipse/swt/widgets/Scrollable.java | 14 +- .../gtk/org/eclipse/swt/widgets/Shell.java | 89 +++----- .../gtk/org/eclipse/swt/widgets/Slider.java | 2 +- .../gtk/org/eclipse/swt/widgets/Spinner.java | 12 +- .../org/eclipse/swt/widgets/TabFolder.java | 24 +-- .../gtk/org/eclipse/swt/widgets/TabItem.java | 7 +- .../gtk/org/eclipse/swt/widgets/Table.java | 59 ++---- .../org/eclipse/swt/widgets/TableColumn.java | 12 +- .../org/eclipse/swt/widgets/TableItem.java | 51 +---- .../gtk/org/eclipse/swt/widgets/Text.java | 24 +-- .../gtk/org/eclipse/swt/widgets/ToolBar.java | 15 +- .../gtk/org/eclipse/swt/widgets/ToolItem.java | 21 +- .../gtk/org/eclipse/swt/widgets/ToolTip.java | 14 +- .../gtk/org/eclipse/swt/widgets/Tracker.java | 40 +--- .../gtk/org/eclipse/swt/widgets/Tree.java | 63 ++---- .../org/eclipse/swt/widgets/TreeColumn.java | 12 +- .../gtk/org/eclipse/swt/widgets/TreeItem.java | 37 +--- bundles/org.eclipse.swt/META-INF/MANIFEST.MF | 2 +- bundles/org.eclipse.swt/pom.xml | 2 +- 53 files changed, 410 insertions(+), 1400 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java index ad34ca74296..c6b32e3e51a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java +++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/gtk/org/eclipse/swt/awt/SWT_AWT.java @@ -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; } @@ -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 (); @@ -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)); }); } }; diff --git a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java index 6eeb54a0d2a..73e3c8c6364 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Accessibility/gtk/org/eclipse/swt/accessibility/AccessibleObject.java @@ -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, origin_x, 4); + C.memmove (y, origin_y, 4); return 0; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java index 8830850b1cb..78675f78b53 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java @@ -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; diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java index 8b14b6f23b3..9fa476f9fb1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java @@ -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; @@ -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]); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDropTargetEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDropTargetEffect.java index 0f77fc07745..3269b1b1dc8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDropTargetEffect.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDropTargetEffect.java @@ -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; diff --git a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java index d7dd4873eba..c4ded786ef9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java +++ b/bundles/org.eclipse.swt/Eclipse SWT OpenGL/gtk/org/eclipse/swt/opengl/GLCanvas.java @@ -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.*; @@ -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; diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java index 68b8f4cdc61..74fda155d7b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java +++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java @@ -1817,7 +1817,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); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java index d7ca68d5136..2273df459c5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Path.java @@ -219,14 +219,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); -} - -void addArcInPixels(float x, float y, float width, float height, float startAngle, float arcAngle) { moved = true; if (width == height) { float angle = -startAngle * (float)Math.PI / 180; @@ -292,14 +284,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); -} - -void addRectangleInPixels(float x, float y, float width, float height) { moved = false; Cairo.cairo_rectangle(handle, x, y, width, height); closed = true; @@ -326,19 +310,14 @@ 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())); + fd.setHeight(fd.getHeight()); Font scaledFont = new Font(font.getDevice(), fd); - addStringInPixels(string, x, y, scaledFont); - scaledFont.dispose(); // Dispose the scaled up font -} -void addStringInPixels(String string, float x, float y, Font font) { moved = false; GC.addCairoString(handle, string, x, y, font); closed = true; + scaledFont.dispose(); // Dispose the scaled up font } /** @@ -384,11 +363,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) { //TODO - see Windows gc.initCairo(); gc.checkGC(GC.LINE_CAP | GC.LINE_JOIN | GC.LINE_STYLE | GC.LINE_WIDTH); @@ -423,15 +397,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) { if (!moved) { double[] currentX = new double[1], currentY = new double[1]; Cairo.cairo_get_current_point(handle, currentX, currentY); @@ -647,11 +612,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) { if (!moved) { double[] currentX = new double[1], currentY = new double[1]; Cairo.cairo_get_current_point(handle, currentX, currentY); @@ -676,11 +636,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) { /* * Bug in Cairo. If cairo_move_to() is not called at the * begining of a subpath, the first cairo_line_to() or @@ -707,13 +662,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) { double[] currentX = new double[1], currentY = new double[1]; Cairo.cairo_get_current_point(handle, currentX, currentY); if (!moved) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java index 91a15888442..51a3424ae59 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Pattern.java @@ -14,7 +14,6 @@ package org.eclipse.swt.graphics; import org.eclipse.swt.*; -import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.cairo.*; /** @@ -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); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java index f9484fdba88..4ed39f4b218 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cairo/org/eclipse/swt/graphics/Transform.java @@ -147,7 +147,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(); } @@ -320,7 +320,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); } /** @@ -362,8 +362,8 @@ 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]); @@ -383,7 +383,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); } /** 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 3363ea5ae86..77cf257f985 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 @@ -346,10 +346,6 @@ protected void destroy () { */ public Rectangle getBounds () { checkDevice (); - return DPIUtil.autoScaleDown (getBoundsInPixels ()); -} - -private Rectangle getBoundsInPixels () { return new Rectangle(0, 0, 0, 0); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java index 70632dbc2ca..8c6842bb2c4 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java @@ -343,7 +343,7 @@ void checkGC (int mask) { Cairo.cairo_set_line_join(cairo, join_style); } if ((state & LINE_WIDTH) != 0) { - Cairo.cairo_set_line_width(cairo, data.lineWidth == 0 ? DPIUtil.autoScaleUp(drawable, 1) : data.lineWidth); + Cairo.cairo_set_line_width(cairo, data.lineWidth == 0 ? 1 : data.lineWidth); switch (data.lineStyle) { case SWT.LINE_DOT: case SWT.LINE_DASH: @@ -467,10 +467,6 @@ public void copyArea(Image image, int x, int y) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - Point loc = DPIUtil.autoScaleUp(drawable, new Point(x, y)); - copyAreaInPixels(image, loc.x, loc.y); -} -void copyAreaInPixels(Image image, int x, int y) { long cairo = Cairo.cairo_create(image.surface); if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES); Cairo.cairo_translate(cairo, -x, -y); @@ -507,13 +503,7 @@ void copyAreaInPixels(Image image, int x, int y) { */ public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle src = DPIUtil.autoScaleUp(drawable, new Rectangle(srcX, srcY, width, height)); - Point dest = DPIUtil.autoScaleUp(drawable, new Point(destX, destY)); - copyAreaInPixels(src.x, src.y, src.width, src.height, dest.x, dest.y); -} - -void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int destY) { - copyAreaInPixels(srcX, srcY, width, height, destX, destY, true); + copyArea(srcX, srcY, width, height, destX, destY, true); } /** * Copies a rectangular area of the receiver at the source @@ -535,11 +525,6 @@ void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int */ public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle srcLoc = DPIUtil.autoScaleUp(drawable, new Rectangle(srcX, srcY, width, height)); - Point destLoc = DPIUtil.autoScaleUp(drawable, new Point(destX, destY)); - copyAreaInPixels(srcLoc.x, srcLoc.y, srcLoc.width, srcLoc.height, destLoc.x, destLoc.y, paint); -} -void copyAreaInPixels(int srcX, int srcY, int width, int height, int destX, int destY, boolean paint) { if (width <= 0 || height <= 0) return; int deltaX = destX - srcX, deltaY = destY - srcY; if (deltaX == 0 && deltaY == 0) return; @@ -720,10 +705,6 @@ void destroy() { */ public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle loc = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height)); - drawArcInPixels(loc.x, loc.y, loc.width, loc.height, startAngle, arcAngle); -} -void drawArcInPixels(int x, int y, int width, int height, int startAngle, int arcAngle) { checkGC(DRAW); if (width < 0) { x = x + width; @@ -775,10 +756,6 @@ void drawArcInPixels(int x, int y, int width, int height, int startAngle, int ar */ public void drawFocus(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle loc = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height)); - drawFocusInPixels(loc.x, loc.y, loc.width, loc.height); -} -void drawFocusInPixels(int x, int y, int width, int height) { long cairo = data.cairo; checkGC(FOREGROUND); long context = GTK.gtk_widget_get_style_context(data.device.shellHandle); @@ -808,10 +785,6 @@ public void drawImage(Image image, int x, int y) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - Point loc = DPIUtil.autoScaleUp(drawable, new Point(x, y)); - drawImageInPixels(image, loc.x, loc.y); -} -void drawImageInPixels(Image image, int x, int y) { drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true); } @@ -855,8 +828,7 @@ public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeig } if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - Rectangle destRect = DPIUtil.autoScaleUp(drawable, new Rectangle(destX, destY, destWidth, destHeight)); - drawImage(image, srcX, srcY, srcWidth, srcHeight, destRect.x, destRect.y, destRect.width, destRect.height, false); + drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false); } void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) { /* Refresh Image as per zoom level, if required. */ @@ -933,11 +905,6 @@ void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, */ public void drawLine(int x1, int y1, int x2, int y2) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Point loc1 = DPIUtil.autoScaleUp(drawable, new Point(x1, y1)); - Point loc2 = DPIUtil.autoScaleUp(drawable, new Point(x2, y2)); - drawLineInPixels(loc1.x, loc1.y, loc2.x, loc2.y); -} -void drawLineInPixels(int x1, int y1, int x2, int y2) { checkGC(DRAW); long cairo = data.cairo; double xOffset = data.cairoXoffset, yOffset = data.cairoYoffset; @@ -972,10 +939,6 @@ void drawLineInPixels(int x1, int y1, int x2, int y2) { */ public void drawOval(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height)); - drawOvalInPixels(rect.x, rect.y, rect.width, rect.height); -} -void drawOvalInPixels(int x, int y, int width, int height) { checkGC(DRAW); if (width < 0) { x = x + width; @@ -1059,10 +1022,6 @@ public void drawPath(Path path) { */ public void drawPoint (int x, int y) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Point loc = DPIUtil.autoScaleUp(drawable, new Point(x, y)); - drawPointInPixels(loc.x, loc.y); -} -void drawPointInPixels (int x, int y) { checkGC(DRAW); long cairo = data.cairo; Cairo.cairo_rectangle(cairo, x, y, 1, 1); @@ -1089,10 +1048,6 @@ void drawPointInPixels (int x, int y) { public void drawPolygon(int[] pointArray) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - int [] scaledPointArray = DPIUtil.autoScaleUp(drawable, pointArray); - drawPolygonInPixels(scaledPointArray); -} -void drawPolygonInPixels(int[] pointArray) { checkGC(DRAW); long cairo = data.cairo; drawPolyline(cairo, pointArray, true); @@ -1119,10 +1074,6 @@ void drawPolygonInPixels(int[] pointArray) { public void drawPolyline(int[] pointArray) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - int [] scaledPointArray = DPIUtil.autoScaleUp(drawable, pointArray); - drawPolylineInPixels(scaledPointArray); -} -void drawPolylineInPixels(int[] pointArray) { checkGC(DRAW); long cairo = data.cairo; drawPolyline(cairo, pointArray, false); @@ -1157,9 +1108,6 @@ void drawPolyline(long cairo, int[] pointArray, boolean close) { */ public void drawRectangle(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - drawRectangle(new Rectangle(x, y, width, height)); -} -void drawRectangleInPixels(int x, int y, int width, int height) { checkGC(DRAW); if (width < 0) { x = x + width; @@ -1193,10 +1141,7 @@ void drawRectangleInPixels(int x, int y, int width, int height) { */ public void drawRectangle(Rectangle rect) { if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - drawRectangleInPixels(DPIUtil.autoScaleUp(drawable, rect)); -} -void drawRectangleInPixels(Rectangle rect) { - drawRectangleInPixels (rect.x, rect.y, rect.width, rect.height); + drawRectangle (rect.x, rect.y, rect.width, rect.height); } /** * Draws the outline of the round-cornered rectangle specified by @@ -1221,11 +1166,6 @@ void drawRectangleInPixels(Rectangle rect) { */ public void drawRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height)); - Point arcSize = DPIUtil.autoScaleUp(drawable, new Point(arcWidth, arcHeight)); - drawRoundRectangleInPixels(rect.x, rect.y, rect.width, rect.height, arcSize.x, arcSize.y); -} -void drawRoundRectangleInPixels(int x, int y, int width, int height, int arcWidth, int arcHeight) { checkGC(DRAW); int nx = x; int ny = y; @@ -1294,9 +1234,6 @@ public void drawString (String string, int x, int y) { drawString (string, x, y, false); } -void drawStringInPixels (String string, int x, int y) { - drawStringInPixels(string, x, y, false); -} /** * Draws the given string, using the receiver's current font and * foreground color. No tab expansion or carriage return processing @@ -1327,12 +1264,7 @@ void drawStringInPixels (String string, int x, int y) { public void drawString(String string, int x, int y, boolean isTransparent) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - Point loc = DPIUtil.autoScaleUp(drawable, new Point(x, y)); - drawStringInPixels(string, loc.x, loc.y, isTransparent); -} - -void drawStringInPixels(String string, int x, int y, boolean isTransparent) { - drawTextInPixels(string, x, y, isTransparent ? SWT.DRAW_TRANSPARENT : 0); + drawText(string, x, y, isTransparent ? SWT.DRAW_TRANSPARENT : 0); } /** @@ -1360,9 +1292,6 @@ void drawStringInPixels(String string, int x, int y, boolean isTransparent) { public void drawText(String string, int x, int y) { drawText(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB); } -void drawTextInPixels(String string, int x, int y) { - drawTextInPixels(string, x, y, SWT.DRAW_DELIMITER | SWT.DRAW_TAB); -} /** * Draws the given string, using the receiver's current font and @@ -1389,13 +1318,9 @@ void drawTextInPixels(String string, int x, int y) { * */ public void drawText(String string, int x, int y, boolean isTransparent) { - Point loc = DPIUtil.autoScaleUp(drawable, new Point (x, y)); - drawTextInPixels(string, loc.x, loc.y, isTransparent); -} -void drawTextInPixels(String string, int x, int y, boolean isTransparent) { int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB; if (isTransparent) flags |= SWT.DRAW_TRANSPARENT; - drawTextInPixels(string, x, y, flags); + drawText(string, x, y, flags); } /** @@ -1438,10 +1363,6 @@ void drawTextInPixels(String string, int x, int y, boolean isTransparent) { * */ public void drawText (String string, int x, int y, int flags) { - Point loc = DPIUtil.autoScaleUp(drawable, new Point (x, y)); - drawTextInPixels(string, loc.x, loc.y, flags); -} -void drawTextInPixels (String string, int x, int y, int flags) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (string.length() == 0) return; @@ -1524,10 +1445,6 @@ public boolean equals(Object object) { */ public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height)); - fillArcInPixels(rect.x, rect.y, rect.width, rect.height, startAngle, arcAngle); -} -void fillArcInPixels(int x, int y, int width, int height, int startAngle, int arcAngle) { checkGC(FILL); if (width < 0) { x = x + width; @@ -1583,11 +1500,6 @@ void fillArcInPixels(int x, int y, int width, int height, int startAngle, int ar */ public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height)); - fillGradientRectangleInPixels(rect.x, rect.y, rect.width, rect.height, vertical); -} - -void fillGradientRectangleInPixels(int x, int y, int width, int height, boolean vertical) { if ((width == 0) || (height == 0)) return; /* Rewrite this to use GdkPixbuf */ @@ -1615,22 +1527,14 @@ void fillGradientRectangleInPixels(int x, int y, int width, int height, boolean long cairo = data.cairo; long pattern; - if (DPIUtil.useCairoAutoScale() ) { - /* - * Here the co-ordinates passed are in points for GTK3. - * That means the user is expecting surface to be at - * device scale equal to current scale factor. So need - * to set the device scale to current scale factor - */ - long surface = Cairo.cairo_get_target(cairo); - if (surface != 0) { - float scaleFactor = DPIUtil.getDeviceZoom() / 100f; - Cairo.cairo_surface_set_device_scale(surface, scaleFactor, scaleFactor); - } + long surface = Cairo.cairo_get_target(cairo); + if (surface != 0) { + float scaleFactor = DPIUtil.getDeviceZoom() / 100f; + Cairo.cairo_surface_set_device_scale(surface, scaleFactor, scaleFactor); } if (fromRGB.equals(toRGB)) { - fillRectangleInPixels(x, y, width, height); + fillRectangle(x, y, width, height); return; } @@ -1669,10 +1573,6 @@ void fillGradientRectangleInPixels(int x, int y, int width, int height, boolean */ public void fillOval(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height)); - fillOvalInPixels(rect.x, rect.y, rect.width, rect.height); -} -void fillOvalInPixels(int x, int y, int width, int height) { checkGC(FILL); if (width < 0) { x = x + width; @@ -1754,10 +1654,6 @@ public void fillPath (Path path) { public void fillPolygon(int[] pointArray) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - int [] scaledPointArray = DPIUtil.autoScaleUp(drawable, pointArray); - fillPolygonInPixels(scaledPointArray); -} -void fillPolygonInPixels(int[] pointArray) { checkGC(FILL); long cairo = data.cairo; drawPolyline(cairo, pointArray, true); @@ -1781,9 +1677,6 @@ void fillPolygonInPixels(int[] pointArray) { */ public void fillRectangle(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - fillRectangle(new Rectangle(x, y, width, height)); -} -void fillRectangleInPixels(int x, int y, int width, int height) { checkGC(FILL); if (width < 0) { x = x + width; @@ -1820,10 +1713,7 @@ void fillRectangleInPixels(int x, int y, int width, int height) { public void fillRectangle(Rectangle rect) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - fillRectangleInPixels(DPIUtil.autoScaleUp(drawable, rect)); -} -void fillRectangleInPixels(Rectangle rect) { - fillRectangleInPixels(rect.x, rect.y, rect.width, rect.height); + fillRectangle(rect.x, rect.y, rect.width, rect.height); } /** @@ -1845,11 +1735,6 @@ void fillRectangleInPixels(Rectangle rect) { */ public void fillRoundRectangle(int x, int y, int width, int height, int arcWidth, int arcHeight) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - Rectangle rect = DPIUtil.autoScaleUp(drawable, new Rectangle(x, y, width, height)); - Point arcSize = DPIUtil.autoScaleUp(drawable, new Point(arcWidth, arcHeight)); - fillRoundRectangleInPixels(rect.x, rect.y, rect.width, rect.height, arcSize.x, arcSize.y); -} -void fillRoundRectangleInPixels(int x, int y, int width, int height, int arcWidth, int arcHeight) { checkGC(FILL); int nx = x; int ny = y; @@ -1922,7 +1807,7 @@ int fixMnemonic (char [] buffer) { public int getAdvanceWidth(char ch) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); //BOGUS - return stringExtentInPixels(new String(new char[]{ch})).x; + return stringExtent(new String(new char[]{ch})).x; } /** @@ -2053,7 +1938,7 @@ public Pattern getBackgroundPattern() { public int getCharWidth(char ch) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); //BOGUS - return stringExtentInPixels(new String(new char[]{ch})).x; + return stringExtent(new String(new char[]{ch})).x; } /** @@ -2070,9 +1955,6 @@ public int getCharWidth(char ch) { */ public Rectangle getClipping() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return DPIUtil.autoScaleDown(drawable, getClippingInPixels()); -} -Rectangle getClippingInPixels() { /* Calculate visible bounds in device space */ int x = 0, y = 0, width = 0, height = 0; int[] w = new int[1], h = new int[1]; @@ -2247,11 +2129,11 @@ public FontMetrics getFontMetrics() { FontMetrics fm = new FontMetrics(); int ascent = OS.pango_font_metrics_get_ascent(metrics); int descent = OS.pango_font_metrics_get_descent(metrics); - int ascentInPoints = DPIUtil.autoScaleDown(drawable, OS.PANGO_PIXELS(ascent)); + int ascentInPoints = OS.PANGO_PIXELS(ascent); fm.ascentInPoints = ascentInPoints; - int heightInPoints = DPIUtil.autoScaleDown(drawable, OS.PANGO_PIXELS(ascent + descent)); + int heightInPoints = OS.PANGO_PIXELS(ascent + descent); fm.descentInPoints = heightInPoints - ascentInPoints; - fm.averageCharWidthInPoints = DPIUtil.autoScaleDown(drawable, OS.PANGO_PIXELS(OS.pango_font_metrics_get_approximate_char_width(metrics))); + fm.averageCharWidthInPoints = OS.PANGO_PIXELS(OS.pango_font_metrics_get_approximate_char_width(metrics)); OS.pango_font_metrics_unref(metrics); return fm; } @@ -2347,11 +2229,6 @@ public int getInterpolation() { */ public LineAttributes getLineAttributes() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - LineAttributes attributes = getLineAttributesInPixels(); - attributes.width = DPIUtil.autoScaleDown(drawable, attributes.width); - return attributes; -} -LineAttributes getLineAttributesInPixels() { float[] dashes = null; if (data.lineDashes != null) { dashes = new float[data.lineDashes.length]; @@ -2449,9 +2326,6 @@ public int getLineStyle() { */ public int getLineWidth() { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return (int)DPIUtil.autoScaleDown(drawable, data.lineWidth); -} -int getLineWidthInPixels() { return (int)data.lineWidth; } @@ -3108,9 +2982,6 @@ void setClipping(long clipRgn) { */ public void setClipping(int x, int y, int width, int height) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - setClippingInPixels(DPIUtil.autoScaleUp(drawable, x), DPIUtil.autoScaleUp(drawable, y), DPIUtil.autoScaleUp(drawable, width), DPIUtil.autoScaleUp(drawable, height)); -} -void setClippingInPixels(int x, int y, int width, int height) { if (width < 0) { x = x + width; width = -width; @@ -3186,13 +3057,10 @@ public void setClipping(Path path) { */ public void setClipping(Rectangle rect) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - setClippingInPixels(DPIUtil.autoScaleUp(drawable, rect)); -} -void setClippingInPixels(Rectangle rect) { if (rect == null) { resetClipping(); } else { - setClippingInPixels(rect.x, rect.y, rect.width, rect.height); + setClipping(rect.x, rect.y, rect.width, rect.height); } } @@ -3411,10 +3279,7 @@ public void setInterpolation(int interpolation) { public void setLineAttributes(LineAttributes attributes) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (attributes == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - attributes.width = DPIUtil.autoScaleUp(drawable, attributes.width); - setLineAttributesInPixels(attributes); -} -void setLineAttributesInPixels(LineAttributes attributes) { + attributes.width = attributes.width; int mask = 0; float lineWidth = attributes.width; if (lineWidth != data.lineWidth) { @@ -3665,9 +3530,6 @@ public void setLineStyle(int lineStyle) { */ public void setLineWidth(int lineWidth) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - setLineWidthInPixels(DPIUtil.autoScaleUp(drawable, lineWidth)); -} -void setLineWidthInPixels(int lineWidth) { if (data.lineWidth == lineWidth) return; data.lineWidth = lineWidth; data.state &= ~(LINE_WIDTH | DRAW_OFFSET); @@ -3849,10 +3711,7 @@ public void setXORMode(boolean xor) { * */ public Point stringExtent(String string) { - return DPIUtil.autoScaleDown(drawable, stringExtentInPixels(string)); -} -Point stringExtentInPixels(String string) { - return textExtentInPixels(string, 0); + return textExtent(string, 0); } /** @@ -3875,11 +3734,7 @@ Point stringExtentInPixels(String string) { * */ public Point textExtent(String string) { - return DPIUtil.autoScaleDown(drawable, textExtentInPixels(string)); -} - -Point textExtentInPixels(String string) { - return textExtentInPixels(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB); + return textExtent(string, SWT.DRAW_DELIMITER | SWT.DRAW_TAB); } /** @@ -3916,9 +3771,6 @@ Point textExtentInPixels(String string) { public Point textExtent(String string, int flags) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - return DPIUtil.autoScaleDown(drawable, textExtentInPixels(string, flags)); -} -Point textExtentInPixels(String string, int flags) { setString(string, flags); checkGC(FONT); if (data.stringWidth == -1) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java index 6a44fc0c61a..14276c683cc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java @@ -205,9 +205,8 @@ public final class Image extends Resource implements Drawable { */ public Image(Device device, int width, int height) { super(device); - Point size = DPIUtil.autoScaleUp(new Point(width, height)); currentDeviceZoom = DPIUtil.getDeviceZoom(); - init(size.x, size.y); + init(width, height); init(); } @@ -275,7 +274,7 @@ public Image(Device device, Image srcImage, int flag) { boolean hasAlpha = format == Cairo.CAIRO_FORMAT_ARGB32; surface = Cairo.cairo_image_surface_create(format, width, height); if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES); - if (DPIUtil.getDeviceZoom() != currentDeviceZoom && DPIUtil.useCairoAutoScale()) { + if (DPIUtil.getDeviceZoom() != currentDeviceZoom) { double scaleFactor = DPIUtil.getDeviceZoom() / 100f; Cairo.cairo_surface_set_device_scale(surface, scaleFactor, scaleFactor); } @@ -383,8 +382,7 @@ public Image(Device device, Rectangle bounds) { super(device); if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); currentDeviceZoom = DPIUtil.getDeviceZoom(); - Rectangle bounds1 = DPIUtil.autoScaleUp (bounds); - init(bounds1.width, bounds1.height); + init(bounds.width, bounds.height); init(); } @@ -415,7 +413,6 @@ public Image(Device device, ImageData data) { super(device); if (data == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); currentDeviceZoom = DPIUtil.getDeviceZoom(); - data = DPIUtil.autoScaleUp (device, data); init(data); init(); } @@ -458,8 +455,6 @@ public Image(Device device, ImageData source, ImageData mask) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } currentDeviceZoom = DPIUtil.getDeviceZoom(); - source = DPIUtil.autoScaleUp (device, source); - mask = DPIUtil.autoScaleUp (device, mask); mask = ImageData.convertMask (mask); ImageData image = new ImageData(source.width, source.height, source.depth, source.palette, source.scanlinePad, source.data); image.maskPad = mask.scanlinePad; @@ -525,7 +520,6 @@ public Image(Device device, InputStream stream) { super(device); ImageData data = new ImageData(stream); currentDeviceZoom = DPIUtil.getDeviceZoom(); - data = DPIUtil.autoScaleUp (device, data); init(data); init(); } @@ -568,7 +562,6 @@ public Image(Device device, String filename) { ImageData data = new ImageData(filename); currentDeviceZoom = DPIUtil.getDeviceZoom(); - data = DPIUtil.autoScaleUp (device, data); init(data); init(); } @@ -722,19 +715,6 @@ boolean refreshImageForZoom () { refreshed = true; currentDeviceZoom = deviceZoomLevel; } - } else { - if (!DPIUtil.useCairoAutoScale()) { - int deviceZoomLevel = deviceZoom; - if (deviceZoomLevel != currentDeviceZoom) { - ImageData data = getImageDataAtCurrentZoom(); - destroy (); - ImageData resizedData = DPIUtil.autoScaleImageData(device, data, deviceZoomLevel, currentDeviceZoom); - init(resizedData); - init(); - refreshed = true; - currentDeviceZoom = deviceZoomLevel; - } - } } return refreshed; } @@ -772,7 +752,7 @@ void createFromPixbuf(int type, long pixbuf) { // Initialize surface with dimensions received from the pixbuf and set device_scale appropriately surface = Cairo.cairo_image_surface_create(format, pixbufWidth, pixbufHeight); if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES); - if (DPIUtil.useCairoAutoScale()) Cairo.cairo_surface_set_device_scale(surface, scaleFactor, scaleFactor); + Cairo.cairo_surface_set_device_scale(surface, scaleFactor, scaleFactor); long data = Cairo.cairo_image_surface_get_data(surface); int cairoStride = Cairo.cairo_image_surface_get_stride(surface); @@ -946,27 +926,6 @@ public Color getBackground() { * */ public Rectangle getBounds() { - if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return DPIUtil.autoScaleDown(getBoundsInPixels()); -} - -/** - * Returns the bounds of the receiver. The rectangle will always - * have x and y values of 0, and the width and height of the - * image in pixels. - * - * @return a rectangle specifying the image's bounds in pixels. - * - * @exception SWTException - * @since 3.105 - * @deprecated This API doesn't serve the purpose in an environment having - * multiple monitors with different DPIs, hence deprecated. - */ -@Deprecated -public Rectangle getBoundsInPixels() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width != -1 && height != -1) { return new Rectangle(0, 0, width, height); @@ -1199,12 +1158,8 @@ void init(int width, int height) { if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES); // When we create a blank image we need to set it to 100 in GTK3 as we draw using 100% scale. // Cairo will take care of scaling for us when image needs to be scaled. - if (DPIUtil.useCairoAutoScale()) { - currentDeviceZoom = 100; - Cairo.cairo_surface_set_device_scale(surface, 1f, 1f); - } else { - currentDeviceZoom = DPIUtil.getDeviceZoom(); - } + currentDeviceZoom = 100; + Cairo.cairo_surface_set_device_scale(surface, 1f, 1f); long cairo = Cairo.cairo_create(surface); if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES); Cairo.cairo_set_source_rgb(cairo, 1, 1, 1); @@ -1238,7 +1193,7 @@ void init(ImageData image) { // Initialize surface with dimensions received from the ImageData and set device_scale appropriately surface = Cairo.cairo_image_surface_create(format, imageDataWidth, imageDataHeight); if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES); - if (DPIUtil.useCairoAutoScale()) Cairo.cairo_surface_set_device_scale(surface, scaleFactor, scaleFactor); + Cairo.cairo_surface_set_device_scale(surface, scaleFactor, scaleFactor); int stride = Cairo.cairo_image_surface_get_stride(surface); long data = Cairo.cairo_image_surface_get_data(surface); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java index 283d19df049..b678ecfda6b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java @@ -15,7 +15,6 @@ import org.eclipse.swt.*; -import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.cairo.*; import org.eclipse.swt.internal.gtk.*; @@ -156,9 +155,6 @@ static void cairo_region_get_rectangles(long region, long [] rectangles, int[] n public void add (int[] pointArray) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - addInPixels(DPIUtil.autoScaleUp(pointArray)); -} -void addInPixels (int[] pointArray) { /* * Bug in GTK. If gdk_region_polygon() is called with one point, * it segment faults. The fix is to make sure that it is called @@ -187,10 +183,7 @@ void addInPixels (int[] pointArray) { public void add(Rectangle rect) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - addInPixels(DPIUtil.autoScaleUp(rect)); -} -void addInPixels(Rectangle rect) { - addInPixels (rect.x, rect.y, rect.width, rect.height); + add(rect.x, rect.y, rect.width, rect.height); } /** @@ -214,9 +207,6 @@ void addInPixels(Rectangle rect) { public void add(int x, int y, int width, int height) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - add(new Rectangle(x, y, width, height)); -} -void addInPixels(int x, int y, int width, int height) { cairo_rectangle_int_t rect = new cairo_rectangle_int_t(); rect.x = x; rect.y = y; @@ -262,9 +252,6 @@ public void add(Region region) { */ public boolean contains(int x, int y) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return contains(new Point(x, y)); -} -boolean containsInPixels(int x, int y) { return Cairo.cairo_region_contains_point(handle, x, y); } @@ -285,11 +272,8 @@ boolean containsInPixels(int x, int y) { */ public boolean contains(Point pt) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return containsInPixels(DPIUtil.autoScaleUp(pt)); -} -boolean containsInPixels(Point pt) { if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - return containsInPixels(pt.x, pt.y); + return contains(pt.x, pt.y); } @Override @@ -331,9 +315,6 @@ public boolean equals(Object object) { */ public Rectangle getBounds() { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return DPIUtil.autoScaleDown(getBoundsInPixels()); -} -Rectangle getBoundsInPixels() { cairo_rectangle_int_t rect = new cairo_rectangle_int_t(); Cairo.cairo_region_get_extents(handle, rect); return new Rectangle(rect.x, rect.y, rect.width, rect.height); @@ -393,11 +374,7 @@ public int hashCode() { public void intersect(Rectangle rect) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - intersectInPixels(DPIUtil.autoScaleUp(rect)); -} - -void intersectInPixels(Rectangle rect) { - intersectInPixels (rect.x, rect.y, rect.width, rect.height); + intersect(rect.x, rect.y, rect.width, rect.height); } /** @@ -421,10 +398,6 @@ void intersectInPixels(Rectangle rect) { public void intersect(int x, int y, int width, int height) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - intersect(new Rectangle(x, y, width, height)); -} - -void intersectInPixels(int x, int y, int width, int height) { cairo_rectangle_int_t rect = new cairo_rectangle_int_t(); rect.x = x; rect.y = y; @@ -478,10 +451,6 @@ public void intersect(Region region) { */ public boolean intersects (int x, int y, int width, int height) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return intersects(new Rectangle(x, y, width, height)); -} - -boolean intersectsInPixels (int x, int y, int width, int height) { cairo_rectangle_int_t rect = new cairo_rectangle_int_t(); rect.x = x; rect.y = y; @@ -509,11 +478,7 @@ boolean intersectsInPixels (int x, int y, int width, int height) { public boolean intersects(Rectangle rect) { if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - return intersectsInPixels(DPIUtil.autoScaleUp(rect)); -} - -boolean intersectsInPixels(Rectangle rect) { - return intersectsInPixels(rect.x, rect.y, rect.width, rect.height); + return intersects(rect.x, rect.y, rect.width, rect.height); } /** @@ -565,10 +530,6 @@ public boolean isEmpty() { public void subtract (int[] pointArray) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - subtractInPixels(DPIUtil.autoScaleUp(pointArray)); -} - -void subtractInPixels (int[] pointArray) { /* * Bug in GTK. If gdk_region_polygon() is called with one point, * it segment faults. The fix is to make sure that it is called @@ -598,11 +559,7 @@ void subtractInPixels (int[] pointArray) { public void subtract(Rectangle rect) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - subtractInPixels(DPIUtil.autoScaleUp(rect)); -} - -void subtractInPixels(Rectangle rect) { - subtractInPixels (rect.x, rect.y, rect.width, rect.height); + subtract(rect.x, rect.y, rect.width, rect.height); } /** @@ -626,10 +583,6 @@ void subtractInPixels(Rectangle rect) { public void subtract(int x, int y, int width, int height) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - subtract(new Rectangle(x, y, width, height)); -} - -void subtractInPixels(int x, int y, int width, int height) { cairo_rectangle_int_t rect = new cairo_rectangle_int_t (); rect.x = x; rect.y = y; @@ -682,10 +635,6 @@ public void translate (int x, int y) { translate(new Point(x, y)); } -void translateInPixels (int x, int y) { - Cairo.cairo_region_translate (handle, x, y); -} - /** * Translate all of the polygons the receiver maintains to describe * its area by the specified point. @@ -704,8 +653,7 @@ void translateInPixels (int x, int y) { public void translate (Point pt) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - pt = DPIUtil.autoScaleUp(pt); - translateInPixels(pt.x, pt.y); + Cairo.cairo_region_translate (handle, pt.x, pt.y); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java index a0eb06dee5e..7313a8f8d5e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/TextLayout.java @@ -107,9 +107,9 @@ public FontMetrics getFixedLineMetrics(Device device) { } FontMetrics result = new FontMetrics(); - result.ascentInPoints = DPIUtil.autoScaleDown(device, lineMetricsInPixels.ascentInPoints); - result.descentInPoints = DPIUtil.autoScaleDown(device, lineMetricsInPixels.descentInPoints); - result.averageCharWidthInPoints = DPIUtil.autoScaleDown(device, lineMetricsInPixels.averageCharWidthInPoints); + result.ascentInPoints = lineMetricsInPixels.ascentInPoints; + result.descentInPoints = lineMetricsInPixels.descentInPoints; + result.averageCharWidthInPoints = lineMetricsInPixels.averageCharWidthInPoints; return result; } @@ -121,9 +121,9 @@ public void setFixedLineMetrics(Device device, FontMetrics metrics) { } FontMetrics result = new FontMetrics(); - result.ascentInPoints = DPIUtil.autoScaleUp(device, metrics.ascentInPoints); - result.descentInPoints = DPIUtil.autoScaleUp(device, metrics.descentInPoints); - result.averageCharWidthInPoints = DPIUtil.autoScaleUp(device, metrics.averageCharWidthInPoints); + result.ascentInPoints = metrics.ascentInPoints; + result.descentInPoints = metrics.descentInPoints; + result.averageCharWidthInPoints = metrics.averageCharWidthInPoints; lineMetricsInPixels = result; } @@ -296,8 +296,8 @@ void computeRuns () { boolean useMinAscentDescent = !metricsAdapter.isFixedMetrics() && (ascentInPoints != -1 || descentInPoints != -1); if (useMinAscentDescent && segementsLength > 0) { PangoRectangle rect = new PangoRectangle(); - if (ascentInPoints != -1) rect.y = -(DPIUtil.autoScaleUp(getDevice(), ascentInPoints) * OS.PANGO_SCALE); - rect.height = DPIUtil.autoScaleUp(getDevice(), (Math.max(0, ascentInPoints) + Math.max(0, descentInPoints))) * OS.PANGO_SCALE; + if (ascentInPoints != -1) rect.y = -(ascentInPoints * OS.PANGO_SCALE); + rect.height = (Math.max(0, ascentInPoints) + Math.max(0, descentInPoints)) * OS.PANGO_SCALE; int lineCount = OS.pango_layout_get_line_count(layout); chars = new char[segementsLength + lineCount * 2]; lineOffsets = new int [lineCount]; @@ -481,9 +481,9 @@ void computeRuns () { GlyphMetrics metrics = style.metrics; if (metrics != null) { PangoRectangle rect = new PangoRectangle(); - rect.y = -(DPIUtil.autoScaleUp(getDevice(), metrics.ascent) * OS.PANGO_SCALE); - rect.height = DPIUtil.autoScaleUp(getDevice(), (metrics.ascent + metrics.descent)) * OS.PANGO_SCALE; - rect.width = DPIUtil.autoScaleUp(getDevice(), metrics.width) * OS.PANGO_SCALE; + rect.y = -(metrics.ascent) * OS.PANGO_SCALE; + rect.height = (metrics.ascent + metrics.descent) * OS.PANGO_SCALE; + rect.width = metrics.width * OS.PANGO_SCALE; long attr = OS.pango_attr_shape_new (rect, rect); OS.memmove (attribute, attr, PangoAttribute.sizeof); attribute.start_index = byteStart; @@ -494,7 +494,7 @@ void computeRuns () { } int rise = style.rise; if (rise != 0) { - long attr = OS.pango_attr_rise_new (DPIUtil.autoScaleUp(getDevice(), rise) * OS.PANGO_SCALE); + long attr = OS.pango_attr_rise_new (rise * OS.PANGO_SCALE); OS.memmove (attribute, attr, PangoAttribute.sizeof); attribute.start_index = byteStart; attribute.end_index = byteEnd; @@ -559,13 +559,7 @@ void destroy() { * */ public void draw(GC gc, int x, int y) { - x = DPIUtil.autoScaleUp(getDevice(), x); - y = DPIUtil.autoScaleUp(getDevice(), y); - drawInPixels(gc, x, y); -} - -void drawInPixels(GC gc, int x, int y) { - drawInPixels(gc, x, y, -1, -1, null, null); + draw(gc, x, y, -1, -1, null, null); } /** @@ -589,12 +583,7 @@ void drawInPixels(GC gc, int x, int y) { */ public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) { checkLayout (); - x = DPIUtil.autoScaleUp(getDevice(), x); - y = DPIUtil.autoScaleUp(getDevice(), y); - drawInPixels(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground); -} -void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground) { - drawInPixels(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, 0); + draw(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, 0); } /** @@ -625,12 +614,6 @@ void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Col * @since 3.3 */ public void draw(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) { - checkLayout (); - x = DPIUtil.autoScaleUp(getDevice(), x); - y = DPIUtil.autoScaleUp(getDevice(), y); - drawInPixels(gc, x, y, selectionStart, selectionEnd, selectionForeground, selectionBackground, flags); -} -void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Color selectionForeground, Color selectionBackground, int flags) { checkLayout (); computeRuns(); if (gc == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); @@ -685,7 +668,7 @@ void drawInPixels(GC gc, int x, int y, int selectionStart, int selectionEnd, Col int lineY = y + OS.PANGO_PIXELS(rect.y); int height = OS.PANGO_PIXELS(rect.height); if (ascentInPoints != -1 && descentInPoints != -1) { - height = Math.max (height, DPIUtil.autoScaleUp(getDevice(), ascentInPoints + descentInPoints)); + height = Math.max (height, ascentInPoints + descentInPoints); } int width = (flags & SWT.FULL_SELECTION) != 0 ? 0x7fff : height / 3; Cairo.cairo_rectangle(cairo, lineX, lineY, width, height); @@ -907,11 +890,7 @@ public int getAscent () { * @see #getLineBounds(int) */ public Rectangle getBounds() { - int spacingInPixels = getSpacingInPixels(); - return DPIUtil.autoScaleDown(getDevice(), getBoundsInPixels(spacingInPixels)); -} - -Rectangle getBoundsInPixels(int spacingInPixels) { + int spacing = getSpacing(); checkLayout(); computeRuns(); int[] w = new int[1], h = new int[1]; @@ -921,9 +900,9 @@ Rectangle getBoundsInPixels(int spacingInPixels) { int width = OS.PANGO_PIXELS(w[0]); int height = OS.PANGO_PIXELS(h[0]); if (ascentInPoints != -1 && descentInPoints != -1) { - height = Math.max (height, DPIUtil.autoScaleUp(getDevice(), ascentInPoints + descentInPoints)); + height = Math.max (height, ascentInPoints + descentInPoints); } - height += spacingInPixels; + height += spacing; return new Rectangle(0, 0, width, height + getScaledVerticalIndent()); } @@ -942,11 +921,6 @@ Rectangle getBoundsInPixels(int spacingInPixels) { * */ public Rectangle getBounds(int start, int end) { - checkLayout(); - return DPIUtil.autoScaleDown(getDevice(), getBoundsInPixels(start, end)); -} - -Rectangle getBoundsInPixels(int start, int end) { checkLayout(); computeRuns(); int length = text.length(); @@ -1049,10 +1023,6 @@ public Font getFont () { */ public int getIndent () { checkLayout(); - return DPIUtil.autoScaleDown(getDevice(), getIndentInPixels()); -} - -int getIndentInPixels () { return indent; } @@ -1131,10 +1101,6 @@ public int getLevel(int offset) { */ public Rectangle getLineBounds(int lineIndex) { checkLayout(); - return DPIUtil.autoScaleDown(getDevice(), getLineBoundsInPixels(lineIndex)); -} - -Rectangle getLineBoundsInPixels(int lineIndex) { computeRuns(); int lineCount = OS.pango_layout_get_line_count(layout); if (!(0 <= lineIndex && lineIndex < lineCount)) SWT.error(SWT.ERROR_INVALID_RANGE); @@ -1142,12 +1108,6 @@ Rectangle getLineBoundsInPixels(int lineIndex) { for (int i = 0; i < lineIndex; i++) { OS.pango_layout_iter_next_line(iter); } - Rectangle lineBoundsInPixels = getLineBoundsInPixels(lineIndex, iter); - OS.pango_layout_iter_free(iter); - return lineBoundsInPixels; -} - -private Rectangle getLineBoundsInPixels(int lineIndex, long iter) { if (iter == 0) SWT.error(SWT.ERROR_NO_HANDLES); PangoRectangle rect = new PangoRectangle(); metricsAdapter.pango_layout_iter_get_line_extents(iter, null, rect); @@ -1156,10 +1116,12 @@ private Rectangle getLineBoundsInPixels(int lineIndex, long iter) { int width = OS.PANGO_PIXELS(rect.width); int height = OS.PANGO_PIXELS(rect.height); if (ascentInPoints != -1 && descentInPoints != -1) { - height = Math.max (height, DPIUtil.autoScaleUp(getDevice(), ascentInPoints + descentInPoints)); + height = Math.max (height, ascentInPoints + descentInPoints); } x += Math.min (indent, wrapIndent); - return new Rectangle(x, y, width, height); + Rectangle lineBounds = new Rectangle(x, y, width, height); + OS.pango_layout_iter_free(iter); + return lineBounds; } /** @@ -1245,14 +1207,14 @@ public FontMetrics getLineMetrics (int lineIndex) { long metrics = OS.pango_context_get_metrics(context, font, lang); int ascent = OS.pango_font_metrics_get_ascent(metrics); int descent = OS.pango_font_metrics_get_descent(metrics); - ascentInPoints = DPIUtil.autoScaleDown(getDevice(), OS.PANGO_PIXELS(ascent)); - heightInPoints = DPIUtil.autoScaleDown(getDevice(), OS.PANGO_PIXELS(ascent + descent)); + ascentInPoints = OS.PANGO_PIXELS(ascent); + heightInPoints = OS.PANGO_PIXELS(ascent + descent); OS.pango_font_metrics_unref(metrics); } else { PangoRectangle rect = new PangoRectangle(); metricsAdapter.pango_layout_line_get_extents(OS.pango_layout_get_line(layout, lineIndex), null, rect); - ascentInPoints = DPIUtil.autoScaleDown(getDevice(), OS.PANGO_PIXELS(-rect.y)); - heightInPoints = DPIUtil.autoScaleDown(getDevice(), OS.PANGO_PIXELS(rect.height)); + ascentInPoints = OS.PANGO_PIXELS(-rect.y); + heightInPoints = OS.PANGO_PIXELS(rect.height); } heightInPoints = Math.max(this.ascentInPoints + this.descentInPoints, heightInPoints); ascentInPoints = Math.max(this.ascentInPoints, ascentInPoints); @@ -1310,10 +1272,6 @@ public int[] getLineOffsets() { */ public Point getLocation(int offset, boolean trailing) { checkLayout(); - return DPIUtil.autoScaleDown(getDevice(), getLocationInPixels(offset, trailing)); -} - -Point getLocationInPixels(int offset, boolean trailing) { computeRuns(); int length = text.length(); if (!(0 <= offset && offset <= length)) SWT.error(SWT.ERROR_INVALID_RANGE); @@ -1449,43 +1407,9 @@ int _getOffset (int offset, int movement, boolean forward) { */ public int getOffset(Point point, int[] trailing) { checkLayout(); - return getOffsetInPixels(DPIUtil.autoScaleUp(getDevice(), point), trailing); -} - -int getOffsetInPixels(Point point, int[] trailing) { if (point == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - return getOffsetInPixels(point.x, point.y, trailing); -} - -/** - * Returns the character offset for the specified point. - * For a typical character, the trailing argument will be filled in to - * indicate whether the point is closer to the leading edge (0) or - * the trailing edge (1). When the point is over a cluster composed - * of multiple characters, the trailing argument will be filled with the - * position of the character in the cluster that is closest to - * the point. - * - * @param x the x coordinate of the point - * @param y the y coordinate of the point - * @param trailing the trailing buffer - * @return the character offset - * - * @exception IllegalArgumentException - * @exception SWTException - * - * @see #getLocation(int, boolean) - */ -public int getOffset(int x, int y, int[] trailing) { - checkLayout(); - return getOffset(new Point(x, y), trailing); -} - -int getOffsetInPixels(int x, int y, int[] trailing) { + int x = point.x; + int y = point.y; computeRuns(); if (trailing != null && trailing.length < 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT); x -= Math.min (indent, wrapIndent); @@ -1531,6 +1455,35 @@ int getOffsetInPixels(int x, int y, int[] trailing) { return untranslateOffset(offset); } +/** + * Returns the character offset for the specified point. + * For a typical character, the trailing argument will be filled in to + * indicate whether the point is closer to the leading edge (0) or + * the trailing edge (1). When the point is over a cluster composed + * of multiple characters, the trailing argument will be filled with the + * position of the character in the cluster that is closest to + * the point. + * + * @param x the x coordinate of the point + * @param y the y coordinate of the point + * @param trailing the trailing buffer + * @return the character offset + * + * @exception IllegalArgumentException + * @exception SWTException + * + * @see #getLocation(int, boolean) + */ +public int getOffset(int x, int y, int[] trailing) { + checkLayout(); + return getOffset(new Point(x, y), trailing); +} + +/** /** * Returns the orientation of the receiver. * @@ -1675,10 +1628,6 @@ String getSegmentsText() { */ public int getSpacing () { checkLayout(); - return DPIUtil.autoScaleDown(getDevice(), getSpacingInPixels()); -} - -int getSpacingInPixels () { return OS.PANGO_PIXELS(OS.pango_layout_get_spacing(layout)); } @@ -1707,7 +1656,7 @@ private int getScaledVerticalIndent() { if (verticalIndentInPoints == 0) { return verticalIndentInPoints; } - return DPIUtil.autoScaleUp(getDevice(), verticalIndentInPoints); + return verticalIndentInPoints; } /** @@ -1777,10 +1726,6 @@ public TextStyle[] getStyles () { */ public int[] getTabs() { checkLayout(); - return DPIUtil.autoScaleDown (getDevice(), getTabsInPixels ()); -} - -int[] getTabsInPixels () { return tabs; } @@ -1824,10 +1769,6 @@ public int getTextDirection () { */ public int getWidth () { checkLayout (); - return DPIUtil.autoScaleDown(getDevice(), getWidthInPixels()); -} - -int getWidthInPixels () { return wrapWidth; } @@ -1844,9 +1785,6 @@ int getWidthInPixels () { */ public int getWrapIndent () { checkLayout (); - return DPIUtil.autoScaleDown(getDevice(), getWrapIndentInPixels()); -} -int getWrapIndentInPixels () { return wrapIndent; } @@ -2031,11 +1969,6 @@ public void setFont (Font font) { * @since 3.2 */ public void setIndent (int indent) { - checkLayout (); - setIndentInPixels(DPIUtil.autoScaleUp(getDevice(), indent)); -} - -void setIndentInPixels (int indent) { checkLayout(); if (indent < 0) return; if (this.indent == indent) return; @@ -2105,10 +2038,6 @@ public void setOrientation(int orientation) { public void setSpacing (int spacing) { checkLayout(); if (spacing < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - setSpacingInPixels(DPIUtil.autoScaleUp(getDevice(), spacing)); -} - -void setSpacingInPixels (int spacing) { OS.pango_layout_set_spacing(layout, spacing * OS.PANGO_SCALE); } @@ -2328,10 +2257,6 @@ public void setStyle (TextStyle style, int start, int end) { public void setTabs(int[] tabs) { checkLayout(); if (this.tabs == null && tabs == null) return; - setTabsInPixels (DPIUtil.autoScaleUp (getDevice(), tabs)); -} - -void setTabsInPixels (int[] tabs) { if (Arrays.equals (this.tabs, tabs)) return; this.tabs = tabs; if (tabs == null) { @@ -2424,10 +2349,6 @@ public void setTextDirection (int textDirection) { public void setWidth (int width) { checkLayout (); if (width < -1 || width == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - setWidthInPixels(DPIUtil.autoScaleUp(getDevice(), width)); -} - -void setWidthInPixels (int width) { if (wrapWidth == width) return; freeRuns(); wrapWidth = width; @@ -2462,10 +2383,6 @@ void setWidth () { public void setWrapIndent (int wrapIndent) { checkLayout(); if (wrapIndent < 0) return; - setWrapIndentInPixels(DPIUtil.autoScaleUp(getDevice(), wrapIndent)); -} - -void setWrapIndentInPixels (int wrapIndent) { if (this.wrapIndent == wrapIndent) return; this.wrapIndent = wrapIndent; OS.pango_layout_set_indent(layout, (indent - wrapIndent) * OS.PANGO_SCALE); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java index 9bfbe4d9403..065b90af129 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java @@ -34,24 +34,18 @@ public static long convertSurface(Image image) { int type = Cairo.cairo_surface_get_type(newSurface); if (type != Cairo.CAIRO_SURFACE_TYPE_IMAGE) { Rectangle bounds; - if (DPIUtil.useCairoAutoScale()) { - bounds = image.getBounds(); - } else { - bounds = image.getBoundsInPixels(); - } + bounds = image.getBounds(); int format = Cairo.cairo_surface_get_content(newSurface) == Cairo.CAIRO_CONTENT_COLOR ? Cairo.CAIRO_FORMAT_RGB24 : Cairo.CAIRO_FORMAT_ARGB32; newSurface = Cairo.cairo_image_surface_create(format, bounds.width, bounds.height); if (newSurface == 0) SWT.error(SWT.ERROR_NO_HANDLES); //retain device scale set in the original surface - if (DPIUtil.useCairoAutoScale()) { - double sx[] = new double[1]; - double sy[] = new double[1]; - Cairo.cairo_surface_get_device_scale(image.surface, sx, sy); - if (sx[0] == 0 || sy[0] == 0){ - sx[0] = sy[0] = DPIUtil.getDeviceZoom() / 100f; - } - Cairo.cairo_surface_set_device_scale(newSurface, sx[0], sy[0]); + double sx[] = new double[1]; + double sy[] = new double[1]; + Cairo.cairo_surface_get_device_scale(image.surface, sx, sy); + if (sx[0] == 0 || sy[0] == 0){ + sx[0] = sy[0] = DPIUtil.getDeviceZoom() / 100f; } + Cairo.cairo_surface_set_device_scale(newSurface, sx[0], sy[0]); long cairo = Cairo.cairo_create(newSurface); if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES); Cairo.cairo_set_operator(cairo, Cairo.CAIRO_OPERATOR_SOURCE); @@ -296,11 +290,7 @@ void set (int index, Image image) { h /= (int)sy[0]; Rectangle bounds; - if (DPIUtil.useCairoAutoScale()) { - bounds = image.getBounds(); - } else { - bounds = image.getBoundsInPixels(); - } + bounds = image.getBounds(); if (w == 0) { w = bounds.width; } @@ -335,25 +325,8 @@ long scaleSurface(Image image, int width, int height) { if (cairo == 0) SWT.error(SWT.ERROR_NO_HANDLES); Rectangle bounds; - if (DPIUtil.useCairoAutoScale()) { - int w = Cairo.cairo_image_surface_get_width(image.surface); - int h = Cairo.cairo_image_surface_get_height(image.surface); - if ((w == 0) && (h == 0)) { - bounds = image.getBounds(); - } else { - bounds = new Rectangle(0, 0, w, h); - } + bounds = image.getBounds(); - double sx[] = new double[1]; - double sy[] = new double[1]; - Cairo.cairo_surface_get_device_scale(image.surface, sx, sy); - if (sx[0] == 0 || sy[0] == 0){ - sx[0] = sy[0] = DPIUtil.getDeviceZoom() / 100f; - } - Cairo.cairo_surface_set_device_scale(scaledSurface, sx[0], sy[0]); - } else { - bounds = image.getBoundsInPixels(); - } double scaleX = (double) width / (double) bounds.width; double scaleY = (double) height / (double) bounds.height; Cairo.cairo_scale(cairo, scaleX, scaleY); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java index 983ea961e0a..ef63871e911 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java @@ -187,7 +187,7 @@ public void addSelectionListener (SelectionListener listener) { } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { +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; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java index 3ee01839d18..05b518ab7f6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Canvas.java @@ -16,7 +16,6 @@ import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; -import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.cairo.*; import org.eclipse.swt.internal.gtk.*; @@ -318,12 +317,6 @@ public void scroll (int destX, int destY, int x, int y, int width, int height, b * as to why it's unneeded is left as a TODO. See bug 546274. */ if (GTK.GTK4) return; - Point destination = DPIUtil.autoScaleUp (new Point (destX, destY)); - Rectangle srcRect = DPIUtil.autoScaleUp (new Rectangle (x, y, width, height)); - scrollInPixels(destination.x, destination.y, srcRect.x, srcRect.y, srcRect.width, srcRect.height, all); -} - -void scrollInPixels (int destX, int destY, int x, int y, int width, int height, boolean all) { if ((style & SWT.MIRRORED) != 0) { int clientWidth = getClientWidth (); x = clientWidth - width - x; @@ -435,10 +428,10 @@ void scrollInPixels (int destX, int destY, int x, int y, int width, int height, Control [] children = _getChildren (); for (int i=0; i= Math.max (x, rect.x) && Math.min(y + height, rect.y + rect.height) >= Math.max (y, rect.y)) { - child.setLocationInPixels (rect.x + deltaX, rect.y + deltaY); + child.setLocation(rect.x + deltaX, rect.y + deltaY); } } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java index 73b1c713a33..d77951ba441 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Caret.java @@ -16,7 +16,6 @@ import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; -import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.cairo.*; import org.eclipse.swt.internal.gtk.*; @@ -142,14 +141,9 @@ private void drawInCellEditor(long window) { * */ public Rectangle getBounds () { - checkWidget(); - return DPIUtil.autoScaleDown(getBoundsInPixels()); -} - -Rectangle getBoundsInPixels () { checkWidget(); if (image != null) { - Rectangle rect = image.getBoundsInPixels (); + Rectangle rect = image.getBounds (); return new Rectangle (x, y, rect.width, rect.height); } else { if (width == 0) { @@ -202,11 +196,6 @@ public Image getImage () { * */ public Point getLocation () { - checkWidget(); - return DPIUtil.autoScaleDown(getLocationInPixels()); -} - -Point getLocationInPixels () { checkWidget(); return new Point (x, y); } @@ -237,14 +226,9 @@ public Canvas getParent () { * */ public Point getSize () { - checkWidget(); - return DPIUtil.autoScaleDown(getSizeInPixels()); -} - -Point getSizeInPixels () { checkWidget(); if (image != null) { - Rectangle rect = image.getBoundsInPixels (); + Rectangle rect = image.getBounds(); return new Point (rect.width, rect.height); } else { if (width == 0) { @@ -349,11 +333,6 @@ void releaseWidget () { * */ public void setBounds (int x, int y, int width, int height) { - checkWidget(); - setBounds (new Rectangle (x, y, width, height)); -} - -void setBoundsInPixels (int x, int y, int width, int height) { checkWidget(); if (this.x == x && this.y == y && this.width == width && this.height == height) return; boolean isFocus = isFocusCaret (); @@ -378,15 +357,9 @@ void setBoundsInPixels (int x, int y, int width, int height) { * */ public void setBounds (Rectangle rect) { - checkWidget(); - rect = DPIUtil.autoScaleUp(rect); - setBoundsInPixels(rect); -} - -void setBoundsInPixels (Rectangle rect) { checkWidget(); if (rect == null) error (SWT.ERROR_NULL_ARGUMENT); - setBoundsInPixels (rect.x, rect.y, rect.width, rect.height); + setBounds(rect.x, rect.y, rect.width, rect.height); } void setFocus () { @@ -459,12 +432,7 @@ public void setImage (Image image) { */ public void setLocation (int x, int y) { checkWidget(); - setLocation (new Point (x, y)); -} - -void setLocationInPixels (int x, int y) { - checkWidget(); - setBoundsInPixels (x, y, width, height); + setBounds(x, y, width, height); } /** @@ -480,14 +448,9 @@ void setLocationInPixels (int x, int y) { * */ public void setLocation (Point location) { - checkWidget(); - setLocationInPixels (DPIUtil.autoScaleUp (location)); -} - -void setLocationInPixels (Point location) { checkWidget(); if (location == null) error (SWT.ERROR_NULL_ARGUMENT); - setLocationInPixels (location.x, location.y); + setLocation(location.x, location.y); } /** @@ -503,12 +466,7 @@ void setLocationInPixels (Point location) { */ public void setSize (int width, int height) { checkWidget(); - setSize (new Point (width,height)); -} - -void setSizeInPixels (int width, int height) { - checkWidget(); - setBoundsInPixels (x, y, width, height); + setSize(new Point (width,height)); } /** @@ -525,14 +483,9 @@ void setSizeInPixels (int width, int height) { * */ public void setSize (Point size) { - checkWidget(); - setSizeInPixels(DPIUtil.autoScaleUp (size)); -} - -void setSizeInPixels (Point size) { checkWidget(); if (size == null) error (SWT.ERROR_NULL_ARGUMENT); - setSizeInPixels (size.x, size.y); + setSize(size.x, size.y); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java index 1da4e63a030..e5810362727 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java @@ -448,7 +448,7 @@ void clearText () { } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { +public Point computeSize(int wHint, int hHint, boolean changed) { checkWidget (); return computeNativeSize (handle, wHint, hHint, changed); } @@ -1080,12 +1080,6 @@ long eventSurface () { * @since 3.8 */ public Point getCaretLocation () { - checkWidget (); - return DPIUtil.autoScaleDown(getCaretLocationInPixels()); -} - - -Point getCaretLocationInPixels () { checkWidget (); if ((style & SWT.READ_ONLY) != 0) { return new Point (0, 0); @@ -1098,7 +1092,7 @@ Point getCaretLocationInPixels () { PangoRectangle pos = new PangoRectangle (); OS.pango_layout_index_to_pos (layout, index, pos); Point thickness = getThickness (entryHandle); - int x = offset_x [0] + OS.PANGO_PIXELS (pos.x) - getBorderWidthInPixels () - thickness.x; + int x = offset_x [0] + OS.PANGO_PIXELS (pos.x) - getBorderWidth() - thickness.x; int y = offset_y [0] + OS.PANGO_PIXELS (pos.y) - thickness.y; return new Point (x, y); } @@ -1384,12 +1378,6 @@ String getText (int start, int stop) { * */ public int getTextHeight () { - checkWidget(); - return DPIUtil.autoScaleDown(getTextHeightInPixels()); -} - - -int getTextHeightInPixels () { checkWidget(); GtkRequisition requisition = new GtkRequisition (); gtk_widget_get_preferred_size (handle, requisition); @@ -2270,7 +2258,7 @@ void setBackgroundGdkRGBA (long context, long handle, GdkRGBA rgba) { @Override int setBounds (int x, int y, int width, int height, boolean move, boolean resize) { int newHeight = height; - if (resize) newHeight = Math.max (getTextHeightInPixels (), height); + if (resize) newHeight = Math.max (getTextHeight(), height); return super.setBounds (x, y, width, newHeight, move, resize); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java index adae7906a9f..b7adfe13d18 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java @@ -257,7 +257,7 @@ protected void checkSubclass () { } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { +public Point computeSize(int wHint, int hHint, boolean changed) { checkWidget (); display.runSkin(); if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0; @@ -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); @@ -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); } @@ -550,14 +550,6 @@ 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); - drawBackgroundInPixels(gc, rect.x, rect.y, rect.width, rect.height, offsetX, offsetY); -} - -void drawBackgroundInPixels (GC gc, int x, int y, int width, int height, int offsetX, int offsetY) { - checkWidget (); if (gc == null) error (SWT.ERROR_NULL_ARGUMENT); if (gc.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); Control control = findBackgroundControl (); @@ -566,7 +558,7 @@ void drawBackgroundInPixels (GC gc, int x, int y, int width, int height, int off long cairo = data.cairo; Cairo.cairo_save (cairo); if (control.backgroundImage != null) { - Point pt = display.mapInPixels (this, control, 0, 0); + Point pt = display.map(this, control, 0, 0); Cairo.cairo_translate (cairo, -pt.x - offsetX, -pt.y - offsetY); x += pt.x + offsetX; y += pt.y + offsetY; @@ -591,7 +583,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(x, y, width, height); } } @@ -797,7 +789,7 @@ int getChildrenCount () { } @Override -Rectangle getClientAreaInPixels () { +public Rectangle getClientArea() { checkWidget(); if ((state & CANVAS) != 0) { if ((state & ZERO_WIDTH) != 0 && (state & ZERO_HEIGHT) != 0) { @@ -813,7 +805,7 @@ Rectangle getClientAreaInPixels () { int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height; return new Rectangle (0, 0, width, height); } - return super.getClientAreaInPixels(); + return super.getClientArea(); } /** @@ -1411,10 +1403,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=0; --i) { Control child = children [i]; if (child.getVisible ()) { - Point location = child.getLocationInPixels (); + Point location = child.getLocation(); child.printWidget (gc, drawable, depth, x + location.x, y + location.y); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java index cd035eeef94..a80e3be8d5a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java @@ -221,7 +221,7 @@ void drawBackground (Control control, long gdkResource, long cr, int x, int y, i Cairo.cairo_clip(cairo); } if (control.backgroundImage != null) { - Point pt = display.mapInPixels (this, control, 0, 0); + Point pt = display.map(this, control, 0, 0); Cairo.cairo_translate (cairo, -pt.x, -pt.y); x += pt.x; y += pt.y; @@ -693,10 +693,6 @@ public Point computeSize (int wHint, int hHint) { return computeSize (wHint, hHint, true); } -Point computeSizeInPixels (int wHint, int hHint) { - return computeSizeInPixels (wHint, hHint, true); -} - Widget computeTabGroup () { if (isTabGroup()) return this; return parent.computeTabGroup (); @@ -756,7 +752,7 @@ void checkBackground () { } void checkBorder () { - if (getBorderWidthInPixels () == 0) style &= ~SWT.BORDER; + if (getBorderWidth() == 0) style &= ~SWT.BORDER; } void checkMirrored () { @@ -829,15 +825,6 @@ void createWidget(int index) { * @see "computeTrim, getClientArea for controls that implement them" */ 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)); -} - -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { checkWidget(); if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0; if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0; @@ -932,11 +919,6 @@ Accessible _getAccessible () { * */ public Rectangle getBounds () { - checkWidget(); - return DPIUtil.autoScaleDown(getBoundsInPixels()); -} - -Rectangle getBoundsInPixels () { checkWidget(); long topHandle = topHandle (); GtkAllocation allocation = new GtkAllocation (); @@ -973,13 +955,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); -} - -void setBoundsInPixels (Rectangle rect) { checkWidget (); if (rect == null) error (SWT.ERROR_NULL_ARGUMENT); setBounds (rect.x, rect.y, Math.max (0, rect.width), Math.max (0, rect.height), true, true); @@ -1014,12 +989,6 @@ 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)); - setBounds (rect.x, rect.y, Math.max (0, rect.width), Math.max (0, rect.height), true, true); -} - -void setBoundsInPixels (int x, int y, int width, int height) { checkWidget(); setBounds (x, y, Math.max (0, width), Math.max (0, height), true, true); } @@ -1228,11 +1197,6 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize * */ public Point getLocation () { - checkWidget(); - return DPIUtil.autoScaleDown(getLocationInPixels()); -} - -Point getLocationInPixels () { checkWidget(); long topHandle = topHandle (); GtkAllocation allocation = new GtkAllocation (); @@ -1261,13 +1225,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); -} - -void setLocationInPixels (Point location) { checkWidget (); if (location == null) error (SWT.ERROR_NULL_ARGUMENT); setBounds (location.x, location.y, 0, 0, true, false); @@ -1289,12 +1246,6 @@ void setLocationInPixels (Point location) { * */ public void setLocation(int x, int y) { - checkWidget(); - Point loc = DPIUtil.autoScaleUp(new Point (x, y)); - setBounds (loc.x, loc.y, 0, 0, true, false); -} - -void setLocationInPixels(int x, int y) { checkWidget(); setBounds (x, y, 0, 0, true, false); } @@ -1313,11 +1264,6 @@ void setLocationInPixels(int x, int y) { * */ public Point getSize () { - checkWidget(); - return DPIUtil.autoScaleDown(getSizeInPixels()); -} - -Point getSizeInPixels () { checkWidget(); long topHandle = topHandle (); GtkAllocation allocation = new GtkAllocation (); @@ -1351,13 +1297,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); -} - -void setSizeInPixels (Point size) { checkWidget (); if (size == null) error (SWT.ERROR_NULL_ARGUMENT); setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true); @@ -1471,12 +1410,6 @@ void setRelations () { * */ public void setSize (int width, int height) { - checkWidget(); - Point size = DPIUtil.autoScaleUp(new Point (width, height)); - setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true); -} - -void setSizeInPixels (int width, int height) { checkWidget(); setBounds (0, 0, Math.max (0, width), Math.max (0, height), false, true); } @@ -1656,9 +1589,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); } @@ -1720,27 +1653,6 @@ public Point toDisplay(int x, int y) { long window = eventWindow(); 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]); - - return new Point(x, y); -} - -Point toDisplayInPixels(int x, int y) { - checkWidget(); - - int[] origin_x = new int[1], origin_y = new int[1]; - if (GTK.GTK4) { - Point origin = getControlOrigin(); - origin_x[0] = origin.x; - origin_y[0] = origin.y; - } else { - long window = eventWindow(); - GDK.gdk_window_get_origin(window, origin_x, origin_y); - } - if ((style & SWT.MIRRORED) != 0) x = getClientWidth() - x; x += origin_x[0]; y += origin_y[0]; @@ -1774,12 +1686,6 @@ public Point toDisplay (Point point) { return toDisplay (point.x, point.y); } -Point toDisplayInPixels (Point point) { - checkWidget(); - if (point == null) error (SWT.ERROR_NULL_ARGUMENT); - return toDisplayInPixels (point.x, point.y); -} - /** * GTK4 only function to replace gdk_surface_get_origin * @return the origin of the Control's SWTFixed container relative to the Shell @@ -2687,7 +2593,7 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean //Note, input params x/y are relative, the two points below are absolute coords. Point startPos = null; Point currPos = null; - startPos = display.getCursorLocationInPixels(); + startPos = display.getCursorLocation(); while (!quit) { long eventPtr = 0; @@ -2703,7 +2609,7 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean if (eventPtr != 0) { break; } else { - currPos = display.getCursorLocationInPixels(); + currPos = display.getCursorLocation(); dragging = GTK3.gtk_drag_check_threshold (handle, startPos.x, startPos.y, currPos.x, currPos.y); if (dragging) break; @@ -3007,10 +2913,6 @@ GdkRGBA getBaseGdkRGBA () { * */ public int getBorderWidth () { - return DPIUtil.autoScaleDown(getBorderWidthInPixels()); -} - -int getBorderWidthInPixels () { checkWidget(); return 0; } @@ -3531,8 +3433,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; } } @@ -3859,8 +3760,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 (); /* @@ -4147,9 +4048,6 @@ long gtk_motion_notify_event (long widget, long event) { GTK3.gtk_event_controller_handle_event(dragGesture,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])); - int [] eventButton = new int [1]; int [] eventState = new int [1]; if (GTK.GTK4) { @@ -4160,7 +4058,7 @@ long gtk_motion_notify_event (long widget, long event) { GDK.gdk_event_get_state(event, eventState); } - if (sendDragEvent (eventButton[0], eventState[0], scaledEvent.x, scaledEvent.y, false)){ + if (sendDragEvent (eventButton[0], eventState[0], (int)eventX[0], (int)eventY[0], false)){ return 1; } } @@ -4204,7 +4102,7 @@ long gtk_motion_notify_event (long widget, long event) { if (this != display.currentControl) { if (display.currentControl != null && !display.currentControl.isDisposed ()) { display.removeMouseHoverTimeout(display.currentControl.handle); - Point pt = display.mapInPixels(this, display.currentControl, (int)x, (int)y); + Point pt = display.map(this, display.currentControl, (int)x, (int)y); display.currentControl.sendMouseEvent(SWT.MouseExit, 0, time, pt.x, pt.y, isHint, state[0]); } if (!isDisposed ()) { @@ -4469,7 +4367,7 @@ boolean isShowing () { if (!isVisible ()) return false; Control control = this; while (control != null) { - Point size = control.getSizeInPixels (); + Point size = control.getSize(); if (size.x == 0 || size.y == 0) { return false; } @@ -4680,12 +4578,6 @@ void redraw (boolean all) { * @see SWT#DOUBLE_BUFFERED */ 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); -} - -void redrawInPixels (int x, int y, int width, int height, boolean all) { checkWidget(); if (!GTK.gtk_widget_get_visible (topHandle ())) return; if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - width - x; @@ -4867,7 +4759,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 { @@ -5035,7 +4927,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; @@ -5044,15 +4936,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); /** @@ -5935,7 +5827,7 @@ public void setRedraw (boolean redraw) { } else { if (drawCount++ == 0) { if (GTK.gtk_widget_get_realized (handle)) { - Rectangle bounds = getBoundsInPixels (); + Rectangle bounds = getBounds(); if (!GTK.GTK4) { long window = paintWindow (); GdkWindowAttr attributes = new GdkWindowAttr (); @@ -6267,7 +6159,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 @@ -6285,14 +6177,14 @@ boolean showMenu (int x, int y, int detail) { if (temp != 0) OS.g_object_unref(temp); - menu.setLocationInPixels(x, y); + menu.setLocation(x, y); menu.setVisible(true); 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); + menu.setLocation(rect.x, rect.y); } menu.setVisible (true); return true; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java index d1f268b87f8..4abfd8d5db4 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java @@ -175,8 +175,8 @@ public DateTime (Composite parent, int style) { if (isDateWithDropDownButton ()) { //Date w/ drop down button is in containers. //first time round we set the bounds manually for correct Right_to_left behaviour - Point size = computeSizeInPixels (SWT.DEFAULT, SWT.DEFAULT); - setBoundsInPixels (0, 0, size.x, size.y); + Point size = computeSize(SWT.DEFAULT, SWT.DEFAULT); + setBounds(0, 0, size.x, size.y); } } @@ -303,7 +303,7 @@ Point computeMaxTextSize (int wHint, int hHint, boolean changed) { } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { +public Point computeSize(int wHint, int hHint, boolean changed) { checkWidget (); int width = 0, height = 0; @@ -327,9 +327,9 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) { * formatted text. */ Point textSize = computeMaxTextSize (wHint, hHint, changed); - Rectangle trim = computeTrimInPixels (0,0, textSize.x,textSize.y); + Rectangle trim = computeTrim(0,0, textSize.x,textSize.y); if (isDateWithDropDownButton ()){ - Point buttonSize = down.computeSizeInPixels (SWT.DEFAULT, SWT.DEFAULT, changed); + Point buttonSize = down.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed); width = trim.width + buttonSize.x; height = Math.max (trim.height, buttonSize.y); } else if (isDate () || isTime ()) { @@ -342,7 +342,7 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) { if (height == 0) height = DEFAULT_HEIGHT; if (wHint != SWT.DEFAULT) width = wHint; if (hHint != SWT.DEFAULT) height = hHint; - int borderWidth = getBorderWidthInPixels (); + int borderWidth = getBorderWidth(); if (prefferedSize == null && isDateWithDropDownButton ()) { prefferedSize = new Point (width + 2*borderWidth, height+ 2*borderWidth); @@ -353,13 +353,13 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) { } @Override -Rectangle computeTrimInPixels (int x, int y, int width, int height) { +public Rectangle computeTrim(int x, int y, int width, int height) { if (isCalendar ()) { - return super.computeTrimInPixels (x, y, width, height); + return super.computeTrim(x, y, width, height); } checkWidget (); - Rectangle trim = super.computeTrimInPixels (x, y, width, height); + Rectangle trim = super.computeTrim(x, y, width, height); int xborder = 0, yborder = 0; GtkBorder tmp = new GtkBorder (); long context = GTK.gtk_widget_get_style_context (GTK.GTK4 ? editableHandle : textEntryHandle); @@ -613,11 +613,11 @@ void dropDownCalendar (boolean drop) { } //This is the x/y/width/height of the container of DateTime - Point containerBounds = getSizeInPixels (); - Point calendarSize = popupCalendar.computeSizeInPixels (SWT.DEFAULT, SWT.DEFAULT, false); + Point containerBounds = getSize(); + Point calendarSize = popupCalendar.computeSize(SWT.DEFAULT, SWT.DEFAULT, false); //Set the inner calendar pos/size. (not the popup shell pos/size) - popupCalendar.setBoundsInPixels (1, 1, Math.max (containerBounds.x - 2, calendarSize.x), calendarSize.y); + popupCalendar.setBounds(1, 1, Math.max (containerBounds.x - 2, calendarSize.x), calendarSize.y); //Set Date & focus current day popupCalendar.setDate (savedYear, savedMonth, savedDay); @@ -626,8 +626,8 @@ void dropDownCalendar (boolean drop) { Display display = getDisplay (); //To display popup calendar, we need to know where the parent is relative to the whole screen. - Rectangle coordsRelativeToScreen = display.mapInPixels (getParent (), null, getBoundsInPixels ()); - Rectangle displayRect = DPIUtil.autoScaleUp(getMonitor ().getClientArea ()); + Rectangle coordsRelativeToScreen = display.map(getParent (), null, getBounds()); + Rectangle displayRect = getMonitor().getClientArea(); showPopupShell (containerBounds, calendarSize, coordsRelativeToScreen, displayRect); @@ -641,7 +641,7 @@ private void showPopupShell (Point containerBounds, Point calendarSize, Rectangl int y = calculateCalendarYpos (containerBounds, coordsRelativeToScreen, height, displayRect); int x = calculateCalendarXpos (calendarSize, coordsRelativeToScreen, displayRect, width); - popupShell.setBoundsInPixels (x, y, width, height); + popupShell.setBounds(x, y, width, height); popupShell.setVisible (true); if (isFocusControl ()) { popupCalendar.setFocus (); @@ -1725,7 +1725,7 @@ public void setYear (int year) { } @Override -void setBoundsInPixels (int x, int y, int width, int height) { +public void setBounds(int x, int y, int width, int height) { //Date with Drop down is in container. Needs extra handling. if (isDateWithDropDownButton ()) { @@ -1734,21 +1734,21 @@ void setBoundsInPixels (int x, int y, int width, int height) { GTK.gtk_widget_get_preferred_size (sizingHandle, null, requisition); int oldHeight = requisition.height; //Entry should not expand vertically. It is single liner. - int newWidth = width - (down.getSizeInPixels ().x + getGtkBorderPadding ().right); + int newWidth = width - (down.getSize().x + getGtkBorderPadding ().right); GTK.gtk_widget_set_size_request (sizingHandle, (newWidth >= 0) ? newWidth : 0, oldHeight); } - super.setBoundsInPixels (x, y, width, height); + super.setBounds(x, y, width, height); } /** * Usually called when control is resized or first initialized. */ private void setDropDownButtonSize() { - Rectangle rect = getClientAreaInPixels(); + Rectangle rect = getClientArea(); int parentWidth = rect.width; int parentHeight = rect.height; - Point buttonSize = down.computeSizeInPixels(SWT.DEFAULT, parentHeight); + Point buttonSize = down.computeSize(SWT.DEFAULT, parentHeight); int dateEntryHeight = computeNativeSize(GTK.GTK4 ? editableHandle : textEntryHandle, SWT.DEFAULT, SWT.DEFAULT, false).y; @@ -1756,7 +1756,7 @@ private void setDropDownButtonSize() { int newXpos = parentWidth - buttonSize.x - getGtkBorderPadding().left - getGtkBorderPadding().right; int newYPos = parentHeight/2 - dateEntryHeight/2; - down.setBoundsInPixels (newXpos, newYPos, buttonSize.x, dateEntryHeight); + down.setBounds(newXpos, newYPos, buttonSize.x, dateEntryHeight); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java index 0d5e14e746c..0ca05451bdc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java @@ -1753,23 +1753,6 @@ public Shell getActiveShell () { return activeShell; } -/** - * Returns a rectangle describing the receiver's size and location. Note that - * on multi-monitor systems the origin can be negative. - * - * @return the bounding rectangle - * - * @exception SWTException
    - *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • - *
  • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
  • - *
- */ -@Override -public Rectangle getBounds () { - checkDevice (); - return DPIUtil.autoScaleDown (getBoundsInPixels ()); -} - /** * Returns a rectangle which describes the area of the * receiver which is capable of displaying data. @@ -1797,7 +1780,19 @@ public Rectangle getClientArea () { return super.getClientArea(); } -Rectangle getBoundsInPixels () { +/** + * Returns a rectangle describing the receiver's size and location. Note that + * on multi-monitor systems the origin can be negative. + * + * @return the bounding rectangle + * + * @exception SWTException
    + *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • + *
  • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
  • + *
+ */ +@Override +public Rectangle getBounds() { checkDevice (); Rectangle bounds = new Rectangle(0, 0, 0, 0); int maxWidth = 0, maxHeight = 0; @@ -1976,10 +1971,6 @@ boolean filters (int eventType) { * */ public Point getCursorLocation() { - return DPIUtil.autoScaleDown(getCursorLocationInPixels()); -} - -Point getCursorLocationInPixels() { checkDevice(); int[] x = new int[1], y = new int[1]; @@ -2640,7 +2631,7 @@ Rectangle getWorkArea() { public Monitor[] getMonitors() { checkDevice(); Monitor[] monitors = null; - Rectangle workArea = DPIUtil.autoScaleDown(getWorkArea ()); + Rectangle workArea = getWorkArea(); long display = GDK.gdk_display_get_default(); if (display != 0) { int monitorCount; @@ -2661,10 +2652,10 @@ public Monitor[] getMonitors() { Monitor monitor = new Monitor(); monitor.handle = gdkMonitor; - monitor.x = DPIUtil.autoScaleDown(geometry.x); - monitor.y = DPIUtil.autoScaleDown(geometry.y); - monitor.width = DPIUtil.autoScaleDown(geometry.width); - monitor.height = DPIUtil.autoScaleDown(geometry.height); + monitor.x = geometry.x; + monitor.y = geometry.y; + monitor.width = geometry.width; + monitor.height = geometry.height; if (!OS.isX11()) { int scaleFactor = (int) GDK.gdk_monitor_get_scale_factor(gdkMonitor); monitor.zoom = scaleFactor * 100; @@ -2676,10 +2667,10 @@ public Monitor[] getMonitors() { * since it takes into account per-monitor trim. Not available in GTK4. */ if (!GTK.GTK4) GDK.gdk_monitor_get_workarea(gdkMonitor, geometry); - monitor.clientX = DPIUtil.autoScaleDown(geometry.x); - monitor.clientY = DPIUtil.autoScaleDown(geometry.y); - monitor.clientWidth = DPIUtil.autoScaleDown(geometry.width); - monitor.clientHeight = DPIUtil.autoScaleDown(geometry.height); + monitor.clientX = geometry.x; + monitor.clientY = geometry.y; + monitor.clientWidth = geometry.width; + monitor.clientHeight = geometry.height; monitors[i] = monitor; } @@ -4001,27 +3992,6 @@ public Point map (Control from, Control to, Point point) { * @since 2.1.2 */ public Point map (Control from, Control to, int x, int y) { - checkDevice (); - if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); - if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); - Point point = new Point (x, y); - if (from == to) return point; - if (from != null) { - Point origin = DPIUtil.autoScaleDown (GTK.GTK4 ? from.getSurfaceOrigin() : from.getWindowOrigin ()); - if ((from.style & SWT.MIRRORED) != 0) point.x = DPIUtil.autoScaleDown (from.getClientWidth ()) - point.x; - point.x += origin.x; - point.y += origin.y; - } - if (to != null) { - Point origin = DPIUtil.autoScaleDown (GTK.GTK4 ? to.getSurfaceOrigin() : to.getWindowOrigin ()); - point.x -= origin.x; - point.y -= origin.y; - if ((to.style & SWT.MIRRORED) != 0) point.x = DPIUtil.autoScaleDown (to.getClientWidth ()) - point.x; - } - return point; -} - -Point mapInPixels (Control from, Control to, int x, int y) { checkDevice (); if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); @@ -4084,12 +4054,6 @@ public Rectangle map (Control from, Control to, Rectangle rectangle) { return map (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height); } -Rectangle mapInPixels (Control from, Control to, Rectangle rectangle) { - checkDevice(); - if (rectangle == null) error (SWT.ERROR_NULL_ARGUMENT); - return mapInPixels (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height); -} - /** * Maps a point from one coordinate system to another. * When the control is null, coordinates are mapped to @@ -4136,35 +4100,7 @@ public Rectangle map (Control from, Control to, int x, int y, int width, int hei if (from == to) return rect; boolean fromRTL = false, toRTL = false; if (from != null) { - Point origin = DPIUtil.autoScaleDown (GTK.GTK4 ? from.getSurfaceOrigin () : from.getWindowOrigin ()); - if (fromRTL = (from.style & SWT.MIRRORED) != 0) rect.x = DPIUtil.autoScaleDown (from.getClientWidth ()) - rect.x; - rect.x += origin.x; - rect.y += origin.y; - } - if (to != null) { - Point origin = DPIUtil.autoScaleDown (GTK.GTK4 ? to.getSurfaceOrigin() : to.getWindowOrigin ()); - rect.x -= origin.x; - rect.y -= origin.y; - if (toRTL = (to.style & SWT.MIRRORED) != 0) rect.x = DPIUtil.autoScaleDown (to.getClientWidth ()) - rect.x; - } - - if (fromRTL != toRTL) rect.x -= rect.width; - return rect; -} - -Rectangle mapInPixels (Control from, Control to, int x, int y, int width, int height) { - checkDevice(); - if (from != null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); - if (to != null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); - - // TODO: GTK4 no longer able to retrieve surface/window origin - if (GTK.GTK4) return new Rectangle(x, y, 0, 0); - - Rectangle rect = new Rectangle (x, y, width, height); - if (from == to) return rect; - boolean fromRTL = false, toRTL = false; - if (from != null) { - Point origin = from.getWindowOrigin (); + Point origin = GTK.GTK4 ? from.getSurfaceOrigin () : from.getWindowOrigin (); if (fromRTL = (from.style & SWT.MIRRORED) != 0) rect.x = from.getClientWidth () - rect.x; rect.x += origin.x; rect.y += origin.y; @@ -4288,8 +4224,8 @@ public boolean post (Event event) { int type = event.type; if (type == SWT.MouseMove) { - Rectangle loc = DPIUtil.autoScaleUp(event.getBounds()); - setCursorLocationInPixels(new Point(loc.x, loc.y)); + Rectangle loc = event.getBounds(); + setCursorLocation(new Point(loc.x, loc.y)); return true; } @@ -5242,23 +5178,12 @@ public void setCursorLocation (int x, int y) { setCursorLocation(new Point (x, y)); } -void setCursorLocationInPixels (Point location) { - long gdkDisplay = GDK.gdk_display_get_default(); - long gdkPointer = GDK.gdk_get_pointer(gdkDisplay); - if (GTK.GTK4) { - //TODO: GTK4 no gdk_device_warp - } else { - long gdkScreen = GDK.gdk_screen_get_default(); - GDK.gdk_device_warp(gdkPointer, gdkScreen, location.x, location.y); - } -} - /** * Sets the location of the on-screen pointer relative to the top left corner * of the screen. Note: It is typically considered bad practice for a * program to move the on-screen pointer location. * - * @param point new position + * @param location new position * * @exception SWTException
    *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • @@ -5268,11 +5193,17 @@ void setCursorLocationInPixels (Point location) { * * @since 2.0 */ -public void setCursorLocation (Point point) { +public void setCursorLocation (Point location) { checkDevice (); - if (point == null) error (SWT.ERROR_NULL_ARGUMENT); - point = DPIUtil.autoScaleUp(point); - setCursorLocationInPixels(point); + if (location == null) error (SWT.ERROR_NULL_ARGUMENT); + long gdkDisplay = GDK.gdk_display_get_default(); + long gdkPointer = GDK.gdk_get_pointer(gdkDisplay); + if (GTK.GTK4) { + //TODO: GTK4 no gdk_device_warp + } else { + long gdkScreen = GDK.gdk_screen_get_default(); + GDK.gdk_device_warp(gdkPointer, gdkScreen, location.x, location.y); + } } /** @@ -5566,7 +5497,7 @@ void showIMWindow (Control control) { OS.pango_font_description_free (fontDesc); if (pangoAttrs [0] != 0) GTK.gtk_label_set_attributes (preeditLabel, pangoAttrs[0]); GTK.gtk_label_set_text (preeditLabel, preeditString [0]); - Point point = control.toDisplayInPixels (control.getIMCaretPos ()); + Point point = control.toDisplay(control.getIMCaretPos ()); GTK3.gtk_window_move (preeditWindow, point.x, point.y); GtkRequisition requisition = new GtkRequisition (); GTK.gtk_widget_get_preferred_size (preeditLabel, requisition, null); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java index 8fc0e1a92e5..25397f606c1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java @@ -16,7 +16,6 @@ import org.eclipse.swt.*; import org.eclipse.swt.events.*; 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.gtk4.*; @@ -116,7 +115,7 @@ protected void checkSubclass () { } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { +public Point computeSize(int wHint, int hHint, boolean changed) { if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0; if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0; Point size = computeNativeSize (handle, wHint, hHint, changed); @@ -183,7 +182,7 @@ void createItem (ExpandItem item, int style, int index) { System.arraycopy (items, index, items, index + 1, itemCount - index); items [index] = item; itemCount++; - item.width = Math.max (0, getClientAreaInPixels ().width - spacing * 2); + item.width = Math.max (0, getClientArea().width - spacing * 2); layoutItems(); } @@ -309,7 +308,7 @@ public int getItemCount () { */ public int getSpacing () { checkWidget (); - return DPIUtil.autoScaleDown(spacing); + return spacing; } @Override @@ -484,11 +483,6 @@ void setOrientation (boolean create) { *
*/ public void setSpacing (int spacing) { - checkWidget (); - setSpacingInPixels(DPIUtil.autoScaleUp(spacing)); -} - -void setSpacingInPixels (int spacing) { checkWidget (); if (spacing < 0) return; if (spacing == this.spacing) return; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java index 08e611ebee6..00cdf140bbf 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandItem.java @@ -232,15 +232,8 @@ public boolean getExpanded() { */ public int getHeaderHeight () { checkWidget (); - return DPIUtil.autoScaleDown (getHeaderHeightInPixels ()); -} - -int getHeaderHeightInPixels() { - checkWidget(); - GtkAllocation allocation = new GtkAllocation(); GTK.gtk_widget_get_allocation(GTK.gtk_expander_get_label_widget(handle), allocation); - return allocation.height; } @@ -256,7 +249,7 @@ int getHeaderHeightInPixels() { */ public int getHeight() { checkWidget(); - return DPIUtil.autoScaleDown(height); + return height; } /** @@ -506,11 +499,6 @@ void setForegroundRGBA (GdkRGBA rgba) { * */ public void setHeight (int height) { - checkWidget (); - setHeightInPixels(DPIUtil.autoScaleUp(height)); -} - -void setHeightInPixels (int height) { checkWidget (); if (height < 0) return; this.height = height; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java index 7e20a4986a0..9d8ac5f8f59 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java @@ -110,14 +110,14 @@ long clientHandle () { } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { - Point size = super.computeSizeInPixels(wHint, hHint, changed); +public Point computeSize(int wHint, int hHint, boolean changed) { + Point size = super.computeSize(wHint, hHint, changed); int width = computeNativeSize (handle, SWT.DEFAULT, SWT.DEFAULT, false).x; size.x = Math.max (size.x, width); return size; } @Override -Rectangle computeTrimInPixels (int x, int y, int width, int height) { +public Rectangle computeTrim(int x, int y, int width, int height) { checkWidget(); forceResize (); GtkAllocation allocation = new GtkAllocation(); @@ -132,8 +132,8 @@ Rectangle computeTrimInPixels (int x, int y, int width, int height) { } @Override -Rectangle getClientAreaInPixels () { - Rectangle clientRectangle = super.getClientAreaInPixels (); +public Rectangle getClientArea() { + Rectangle clientRectangle = super.getClientArea(); /* * Bug 453827 Child position fix. * SWT's calls to gtk_widget_size_allocate and gtk_widget_set_allocation diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java index ed2eb59080f..7588d96f0e0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java @@ -139,7 +139,7 @@ Point computeNativeSize (long h, int wHint, int hHint, boolean changed) { } } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { +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; @@ -369,7 +369,7 @@ public int getAlignment () { } @Override -int getBorderWidthInPixels () { +public int getBorderWidth() { checkWidget(); if (frameHandle != 0) { return getThickness (frameHandle).x; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java index 099764719a6..700cd57692b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java @@ -18,7 +18,6 @@ import org.eclipse.swt.accessibility.*; import org.eclipse.swt.events.*; 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.gtk4.*; @@ -121,7 +120,7 @@ public void addSelectionListener (SelectionListener listener) { } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { +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; @@ -130,19 +129,19 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) { //TEMPORARY CODE if (wHint == 0) { layout.setWidth (1); - Rectangle rect = DPIUtil.autoScaleUp(layout.getBounds ()); + Rectangle rect = layout.getBounds (); width = 0; height = rect.height; } else { - layout.setWidth (DPIUtil.autoScaleDown(wHint)); - Rectangle rect = DPIUtil.autoScaleUp(layout.getBounds ()); + layout.setWidth(wHint); + Rectangle rect = layout.getBounds (); width = rect.width; height = rect.height; } layout.setWidth (layoutWidth); if (wHint != SWT.DEFAULT) width = wHint; if (hHint != SWT.DEFAULT) height = hHint; - int border = getBorderWidthInPixels (); + int border = getBorderWidth(); width += border * 2; height += border * 2; return new Point (width, height); @@ -191,9 +190,9 @@ void drawWidget(GC gc) { if ((state & DISABLED) != 0) gc.setForeground (disabledColor); layout.draw (gc, 0, 0, selStart, selEnd, null, null); if (hasFocus () && focusIndex != -1) { - Rectangle [] rects = getRectanglesInPixels (focusIndex); + Rectangle [] rects = getRectangles(focusIndex); for (int i = 0; i < rects.length; i++) { - Rectangle rect = DPIUtil.autoScaleDown(rects [i]); + Rectangle rect = rects [i]; gc.drawFocus (rect.x, rect.y, rect.width, rect.height); } } @@ -292,7 +291,7 @@ String getNameText () { return getText (); } -Rectangle [] getRectanglesInPixels (int linkIndex) { +Rectangle [] getRectangles(int linkIndex) { int lineCount = layout.getLineCount (); Rectangle [] rects = new Rectangle [lineCount]; int [] lineOffsets = layout.getLineOffsets (); @@ -303,13 +302,13 @@ String getNameText () { while (point.y > lineOffsets [lineEnd]) lineEnd++; int index = 0; if (lineStart == lineEnd) { - rects [index++] = DPIUtil.autoScaleUp (layout.getBounds (point.x, point.y)); + rects [index++] = layout.getBounds (point.x, point.y); } else { - rects [index++] = DPIUtil.autoScaleUp (layout.getBounds (point.x, lineOffsets [lineStart]-1)); - rects [index++] = DPIUtil.autoScaleUp (layout.getBounds (lineOffsets [lineEnd-1], point.y)); + rects [index++] = layout.getBounds (point.x, lineOffsets [lineStart]-1); + rects [index++] = layout.getBounds (lineOffsets [lineEnd-1], point.y); if (lineEnd - lineStart > 1) { for (int i = lineStart; i < lineEnd - 1; i++) { - rects [index++] = DPIUtil.autoScaleUp (layout.getLineBounds (i)); + rects [index++] = layout.getLineBounds (i); } } } @@ -365,7 +364,7 @@ long gtk_button_press_event (long widget, long event) { int x = (int) eventX[0]; int y = (int) eventY[0]; if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x; - int offset = DPIUtil.autoScaleUp(layout.getOffset (x, y, null)); + int offset = layout.getOffset (x, y, null); int oldSelectionX = selection.x; int oldSelectionY = selection.y; selection.x = offset; @@ -376,11 +375,11 @@ long gtk_button_press_event (long widget, long event) { oldSelectionX = oldSelectionY; oldSelectionY = temp; } - Rectangle rect = DPIUtil.autoScaleUp(layout.getBounds (oldSelectionX, oldSelectionY)); - redrawInPixels (rect.x, rect.y, rect.width, rect.height, false); + Rectangle rect = layout.getBounds (oldSelectionX, oldSelectionY); + redraw(rect.x, rect.y, rect.width, rect.height, false); } for (int j = 0; j < offsets.length; j++) { - Rectangle [] rects = getRectanglesInPixels (j); + Rectangle [] rects = getRectangles(j); for (int i = 0; i < rects.length; i++) { Rectangle rect = rects [i]; if (rect.contains (x, y)) { @@ -419,7 +418,7 @@ long gtk_button_release_event (long widget, long event) { int x = (int) eventX[0]; int y = (int) eventY[0]; if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x; - Rectangle [] rects = getRectanglesInPixels (focusIndex); + Rectangle [] rects = getRectangles(focusIndex); for (int i = 0; i < rects.length; i++) { Rectangle rect = rects [i]; if (rect.contains (x, y)) { @@ -544,7 +543,7 @@ long gtk_motion_notify_event (long widget, long event) { if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x; if ((state[0] & GDK.GDK_BUTTON1_MASK) != 0) { int oldSelection = selection.y; - selection.y = DPIUtil.autoScaleUp(layout.getOffset (x, y, null)); + selection.y = layout.getOffset (x, y, null); if (selection.y != oldSelection) { int newSelection = selection.y; if (oldSelection > newSelection) { @@ -553,11 +552,11 @@ long gtk_motion_notify_event (long widget, long event) { newSelection = temp; } Rectangle rect = layout.getBounds (oldSelection, newSelection); - redrawInPixels (rect.x, rect.y, rect.width, rect.height, false); + redraw(rect.x, rect.y, rect.width, rect.height, false); } } else { for (int j = 0; j < offsets.length; j++) { - Rectangle [] rects = getRectanglesInPixels (j); + Rectangle [] rects = getRectangles(j); for (int i = 0; i < rects.length; i++) { Rectangle rect = rects [i]; if (rect.contains (x, y)) { @@ -810,7 +809,7 @@ int parseMnemonics (char[] buffer, int start, int end, StringBuilder result) { int setBounds(int x, int y, int width, int height, boolean move, boolean resize) { int result = super.setBounds (x, y, width,height, move, resize); if ((result & RESIZED) != 0) { - layout.setWidth (DPIUtil.autoScaleDown((width > 0 ? width : -1))); + layout.setWidth(width > 0 ? width : -1); redraw (); } return result; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java index bb1bcf8cb1f..3dea647947a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java @@ -269,7 +269,7 @@ int applyThemeBackground () { } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { +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; @@ -282,7 +282,7 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) { * based on the number of items in the table */ if (size.y == 0 && hHint == SWT.DEFAULT) { - size.y = getItemCount() * getItemHeightInPixels(); + size.y = getItemCount() * getItemHeight(); } /* @@ -291,7 +291,7 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) { * so need to assign default height */ if (size.y == 0 && hHint == SWT.DEFAULT) size.y = DEFAULT_HEIGHT; - Rectangle trim = computeTrimInPixels (0, 0, size.x, size.y); + Rectangle trim = computeTrim(0, 0, size.x, size.y); size.x = trim.width; size.y = trim.height; return size; @@ -543,12 +543,6 @@ public int getItemCount () { */ public int getItemHeight () { checkWidget(); - return DPIUtil.autoScaleDown(getItemHeightInPixels()); -} - -int getItemHeightInPixels() { - checkWidget(); - final int BASE_ITEM_PADDING = 1; int[] h = new int [1]; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java index 22bb51cdb4c..ccc4737a67d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Menu.java @@ -1198,11 +1198,6 @@ public void setEnabled(boolean enabled) { */ public void setLocation (int x, int y) { checkWidget (); - setLocation (new Point (x, y)); -} - -void setLocationInPixels (int x, int y) { - checkWidget(); if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return; this.x = x; this.y = y; @@ -1235,13 +1230,8 @@ void setLocationInPixels (int x, int y) { */ public void setLocation (Point location) { checkWidget (); - setLocationInPixels (DPIUtil.autoScaleUp (location)); -} - -void setLocationInPixels (Point location) { - checkWidget(); if (location == null) error (SWT.ERROR_NULL_ARGUMENT); - setLocationInPixels (location.x, location.y); + setLocation(location.x, location.y); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java index 0b131624385..ce057341e56 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java @@ -17,7 +17,6 @@ import org.eclipse.swt.*; import org.eclipse.swt.events.*; 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.gtk4.*; @@ -122,13 +121,13 @@ static int checkStyle(int style) { } @Override -Point computeSizeInPixels(int wHint, int hHint, boolean changed) { +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; - int border = getBorderWidthInPixels(); + int border = getBorderWidth(); int width = border * 2, height = border * 2; if ((style & SWT.HORIZONTAL) != 0) { width += DEFAULT_WIDTH; @@ -191,11 +190,11 @@ void gtk_gesture_press_event(long gesture, int n_press, double x, double y, long Event jEvent = new Event(); jEvent.time = GDK.gdk_event_get_time(event); Rectangle eventRect = new Rectangle(lastX, lastY, width, height); - jEvent.setBounds(DPIUtil.autoScaleDown(eventRect)); + jEvent.setBounds(eventRect); if ((style & SWT.SMOOTH) == 0) { jEvent.detail = SWT.DRAG; } - if ((parent.style & SWT.MIRRORED) != 0) jEvent.x = DPIUtil.autoScaleDown(parent.getClientWidth() - width) - jEvent.x; + if ((parent.style & SWT.MIRRORED) != 0) jEvent.x = parent.getClientWidth() - width - jEvent.x; sendSelectionEvent(SWT.Selection, jEvent, true); if (isDisposed()) return; @@ -241,15 +240,15 @@ void gtk4_motion_event(long controller, double x, double y, long event) { Event jEvent = new Event(); jEvent.time = GDK.gdk_event_get_time(event); Rectangle eventRect = new Rectangle(newX, newY, width, height); - jEvent.setBounds(DPIUtil.autoScaleDown(eventRect)); + jEvent.setBounds(eventRect); if ((style & SWT.SMOOTH) == 0) { jEvent.detail = SWT.DRAG; } - if ((parent.style & SWT.MIRRORED) != 0) jEvent.x = DPIUtil.autoScaleDown(parent.getClientWidth() - width) - jEvent.x; + if ((parent.style & SWT.MIRRORED) != 0) jEvent.x = parent.getClientWidth() - width - jEvent.x; sendSelectionEvent(SWT.Selection, jEvent, true); if (isDisposed()) return; - Rectangle rect = DPIUtil.autoScaleUp(jEvent.getBounds()); + Rectangle rect = jEvent.getBounds(); if (jEvent.doit) { lastX = rect.x; lastY = rect.y; @@ -261,7 +260,7 @@ void gtk4_motion_event(long controller, double x, double y, long event) { * Use lastX instead of rect.x, as lastX takes into account * the event.doit flag. See bug 522140. */ - setBoundsInPixels(lastX, lastY, width, height); + setBounds(lastX, lastY, width, height); } } @@ -307,18 +306,18 @@ boolean gtk4_key_press_event(long controller, int keyval, int keycode, int state Event jEvent = new Event(); jEvent.time = GDK.gdk_event_get_time(event); Rectangle eventRect = new Rectangle(newX, newY, width, height); - jEvent.setBounds(DPIUtil.autoScaleDown(eventRect)); - if ((parent.style & SWT.MIRRORED) != 0) jEvent.x = DPIUtil.autoScaleDown(parent.getClientWidth() - width) - jEvent.x; + jEvent.setBounds(eventRect); + if ((parent.style & SWT.MIRRORED) != 0) jEvent.x = parent.getClientWidth() - width - jEvent.x; sendSelectionEvent(SWT.Selection, jEvent, true); if (isDisposed()) break; if (jEvent.doit) { - Rectangle rect = DPIUtil.autoScaleUp(jEvent.getBounds()); + Rectangle rect = jEvent.getBounds(); lastX = rect.x; lastY = rect.y; if ((parent.style & SWT.MIRRORED) != 0) lastX = parent.getClientWidth() - width - lastX; if ((style & SWT.SMOOTH) != 0) { - setBoundsInPixels(rect.x, rect.y, width, height); + setBounds(rect.x, rect.y, width, height); if (isDisposed()) break; } } @@ -360,22 +359,22 @@ long gtk_button_press_event(long widget, long event) { Event jEvent = new Event(); jEvent.time = GDK.gdk_event_get_time(event); Rectangle eventRect = new Rectangle(lastX, lastY, width, height); - jEvent.setBounds(DPIUtil.autoScaleDown(eventRect)); + jEvent.setBounds(eventRect); if ((style & SWT.SMOOTH) == 0) { jEvent.detail = SWT.DRAG; } - if ((parent.style & SWT.MIRRORED) != 0) jEvent.x = DPIUtil.autoScaleDown(parent.getClientWidth() - width) - jEvent.x; + if ((parent.style & SWT.MIRRORED) != 0) jEvent.x = parent.getClientWidth() - width - jEvent.x; sendSelectionEvent(SWT.Selection, jEvent, true); if (isDisposed()) return 0; if (jEvent.doit) { dragging = true; - Rectangle rect = DPIUtil.autoScaleUp(jEvent.getBounds()); + Rectangle rect = jEvent.getBounds(); lastX = rect.x; lastY = rect.y; if ((parent.style & SWT.MIRRORED) != 0) lastX = parent.getClientWidth() - width - lastX; parent.update(true, (style & SWT.SMOOTH) == 0); if ((style & SWT.SMOOTH) != 0) { - setBoundsInPixels(rect.x, rect.y, width, height); + setBounds(rect.x, rect.y, width, height); // widget could be disposed at this point } } @@ -402,14 +401,14 @@ long gtk_button_release_event(long widget, long event) { Event jEvent = new Event(); jEvent.time = GDK.gdk_event_get_time(event); Rectangle eventRect = new Rectangle(lastX, lastY, width, height); - jEvent.setBounds(DPIUtil.autoScaleDown(eventRect)); - if ((parent.style & SWT.MIRRORED) != 0) jEvent.x = DPIUtil.autoScaleDown(parent.getClientWidth() - width) - jEvent.x; + jEvent.setBounds(eventRect); + if ((parent.style & SWT.MIRRORED) != 0) jEvent.x = parent.getClientWidth() - width - jEvent.x; sendSelectionEvent(SWT.Selection, jEvent, true); if (isDisposed()) return result; if (jEvent.doit) { if ((style & SWT.SMOOTH) != 0) { - Rectangle rect = DPIUtil.autoScaleUp(jEvent.getBounds()); - setBoundsInPixels(rect.x, rect.y, width, height); + Rectangle rect = jEvent.getBounds(); + setBounds(rect.x, rect.y, width, height); // widget could be disposed at this point } } @@ -497,19 +496,19 @@ long gtk_key_press_event(long widget, long eventPtr) { Event event = new Event(); event.time = GDK.gdk_event_get_time(eventPtr); Rectangle eventRect = new Rectangle(newX, newY, width, height); - event.setBounds(DPIUtil.autoScaleDown(eventRect)); - if ((parent.style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown(parent.getClientWidth() - width) - event.x; + event.setBounds(eventRect); + if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth() - width - event.x; sendSelectionEvent(SWT.Selection, event, true); if (ptrGrabResult == GDK.GDK_GRAB_SUCCESS) gdk_pointer_ungrab(gdkResource, GDK.GDK_CURRENT_TIME); if (isDisposed()) break; if (event.doit) { - Rectangle rect = DPIUtil.autoScaleUp(event.getBounds()); + Rectangle rect = event.getBounds(); lastX = rect.x; lastY = rect.y; if ((parent.style & SWT.MIRRORED) != 0) lastX = parent.getClientWidth() - width - lastX; if ((style & SWT.SMOOTH) != 0) { - setBoundsInPixels(rect.x, rect.y, width, height); + setBounds(rect.x, rect.y, width, height); if (isDisposed()) break; } @@ -519,7 +518,7 @@ long gtk_key_press_event(long widget, long eventPtr) { } else { cursorX += width / 2; } - display.setCursorLocation(parent.toDisplayInPixels(cursorX, cursorY)); + display.setCursorLocation(parent.toDisplay(cursorX, cursorY)); } break; } @@ -586,15 +585,15 @@ long gtk_motion_notify_event(long widget, long eventPtr) { Event event = new Event(); event.time = GDK.gdk_event_get_time(eventPtr); Rectangle eventRect = new Rectangle(newX, newY, width, height); - event.setBounds(DPIUtil.autoScaleDown(eventRect)); + event.setBounds(eventRect); if ((style & SWT.SMOOTH) == 0) { event.detail = SWT.DRAG; } - if ((parent.style & SWT.MIRRORED) != 0) event.x = DPIUtil.autoScaleDown(parent.getClientWidth() - width) - event.x; + if ((parent.style & SWT.MIRRORED) != 0) event.x = parent.getClientWidth() - width - event.x; sendSelectionEvent(SWT.Selection, event, true); if (isDisposed()) return 0; - Rectangle rect = DPIUtil.autoScaleUp(event.getBounds()); + Rectangle rect = event.getBounds(); if (event.doit) { lastX = rect.x; lastY = rect.y; @@ -606,7 +605,7 @@ long gtk_motion_notify_event(long widget, long eventPtr) { * Use lastX instead of rect.x, as lastX takes into account * the event.doit flag. See bug 522140. */ - setBoundsInPixels(lastX, lastY, width, height); + setBounds(lastX, lastY, width, height); } return result; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java index c65bfd7367e..83df2687181 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scale.java @@ -109,7 +109,7 @@ static int checkStyle (int style) { } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { +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; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java index 1b6747bf801..4a94d9f610c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ScrollBar.java @@ -17,7 +17,6 @@ import org.eclipse.swt.*; import org.eclipse.swt.events.*; 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.gtk4.*; @@ -289,11 +288,6 @@ public int getSelection () { * */ public Point getSize () { - checkWidget (); - return DPIUtil.autoScaleDown (getSizeInPixels ()); -} - -Point getSizeInPixels () { checkWidget (); if (handle == 0) return new Point (0,0); GtkRequisition requisition = new GtkRequisition (); @@ -333,12 +327,6 @@ public int getThumb () { */ public Rectangle getThumbBounds() { checkWidget(); - return DPIUtil.autoScaleDown(getThumbBoundsInPixels()); -} - -Rectangle getThumbBoundsInPixels() { - checkWidget(); - int[] slider_start = new int[1], slider_end = new int[1]; long rangeHandle = GTK.GTK4 ? GTK4.gtk_widget_get_first_child(handle) : handle; GTK.gtk_range_get_slider_range(rangeHandle, slider_start, slider_end); @@ -402,11 +390,6 @@ Rectangle getThumbBoundsInPixels() { */ public Rectangle getThumbTrackBounds () { checkWidget (); - return DPIUtil.autoScaleDown(getThumbTrackBoundsInPixels()); -} - -Rectangle getThumbTrackBoundsInPixels () { - checkWidget(); int x = 0, y = 0, width, height; /* diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java index 71bc811137c..177359dfc30 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Scrollable.java @@ -16,7 +16,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.gtk4.*; @@ -115,12 +114,6 @@ long clientHandle () { * @see #getClientArea */ public Rectangle computeTrim (int x, int y, int width, int height) { - checkWidget(); - Rectangle rect = DPIUtil.autoScaleUp(new Rectangle (x, y, width, height)); - return DPIUtil.autoScaleDown(computeTrimInPixels(rect.x, rect.y, rect.width, rect.height)); -} - -Rectangle computeTrimInPixels (int x, int y, int width, int height) { checkWidget(); int border = 0; if (fixedHandle != 0) border += gtk_container_get_border_width_or_margin (fixedHandle); @@ -211,7 +204,7 @@ void destroyScrollBar (ScrollBar bar) { } @Override -int getBorderWidthInPixels () { +public int getBorderWidth() { checkWidget(); int border = 0; if (fixedHandle != 0) border += gtk_container_get_border_width_or_margin (fixedHandle); @@ -245,11 +238,6 @@ int getBorderWidthInPixels () { * @see #computeTrim */ public Rectangle getClientArea () { - checkWidget (); - return DPIUtil.autoScaleDown(getClientAreaInPixels()); -} - -Rectangle getClientAreaInPixels () { checkWidget (); if(RESIZE_ON_GETCLIENTAREA) { forceResize (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java index b561a37c853..aa7f6635e43 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java @@ -552,7 +552,7 @@ void adjustTrim (int widthHint, int heightHint) { } else { trimStyle = Display.TRIM_NONE; } - Rectangle bounds = getBoundsInPixels(); + Rectangle bounds = getBounds(); int widthAdjustment = display.trimWidths[trimStyle] - trimWidth; int heightAdjustment = display.trimHeights[trimStyle] - trimHeight; if (widthAdjustment == 0 && heightAdjustment == 0) return; @@ -659,11 +659,11 @@ void bringToTop (boolean force) { void center () { if (parent == null) return; - Rectangle rect = getBoundsInPixels (); - Rectangle parentRect = display.mapInPixels (parent, null, parent.getClientAreaInPixels()); + Rectangle rect = getBounds(); + Rectangle parentRect = display.map(parent, null, parent.getClientArea()); int x = Math.max (parentRect.x, parentRect.x + (parentRect.width - rect.width) / 2); int y = Math.max (parentRect.y, parentRect.y + (parentRect.height - rect.height) / 2); - Rectangle monitorRect = DPIUtil.autoScaleUp(parent.getMonitor ().getClientArea()); + Rectangle monitorRect = parent.getMonitor ().getClientArea(); if (x + rect.width > monitorRect.x + monitorRect.width) { x = Math.max (monitorRect.x, monitorRect.x + monitorRect.width - rect.width); } else { @@ -674,7 +674,7 @@ void center () { } else { y = Math.max (y, monitorRect.y); } - setLocationInPixels (x, y); + setLocation(x, y); } @Override @@ -713,9 +713,9 @@ void closeWidget () { } @Override -Rectangle computeTrimInPixels (int x, int y, int width, int height) { +public Rectangle computeTrim(int x, int y, int width, int height) { checkWidget(); - Rectangle trim = super.computeTrimInPixels (x, y, width, height); + Rectangle trim = super.computeTrim(x, y, width, height); int border = 0; if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0 || isCustomResize()) { border = gtk_container_get_border_width_or_margin (shellHandle); @@ -1257,12 +1257,12 @@ public boolean getFullScreen () { } @Override -Point getLocationInPixels () { +public Point getLocation() { checkWidget (); // Bug in GTK: when shell is moved and then hidden, its location does not get updated. // Move it before getting its location. if (!getVisible() && moved) { - setLocationInPixels(oldX, oldY); + setLocation(oldX, oldY); } int [] x = new int [1], y = new int [1]; if (GTK.GTK4) { @@ -1295,11 +1295,6 @@ public boolean getMaximized () { * @since 3.1 */ public Point getMinimumSize () { - checkWidget (); - return DPIUtil.autoScaleDown (getMinimumSizeInPixels ()); -} - -Point getMinimumSizeInPixels () { checkWidget (); int width = Math.max (1, geometry.getMinWidth() + trimWidth ()); int height = Math.max (1, geometry.getMinHeight() + trimHeight ()); @@ -1323,12 +1318,6 @@ Point getMinimumSizeInPixels () { */ public Point getMaximumSize () { checkWidget (); - return DPIUtil.autoScaleDown (getMaximumSizeInPixels ()); -} - -Point getMaximumSizeInPixels () { - checkWidget (); - int width = Math.min (Integer.MAX_VALUE, geometry.getMaxWidth() + trimWidth ()); int height = Math.min (Integer.MAX_VALUE, geometry.getMaxHeight() + trimHeight ()); return new Point (width, height); @@ -1380,7 +1369,7 @@ public boolean getModified () { } @Override -Point getSizeInPixels () { +public Point getSize() { checkWidget (); GtkAllocation allocation = new GtkAllocation (); GTK.gtk_widget_get_allocation (vboxHandle, allocation); @@ -2319,7 +2308,7 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize * anything different from the current bounds. */ if (getMaximized ()) { - Rectangle rect = getBoundsInPixels (); + Rectangle rect = getBounds(); boolean sameOrigin = !move || (rect.x == x && rect.y == y); boolean sameExtent = !resize || (rect.width == width && rect.height == height); if (sameOrigin && sameExtent) return 0; @@ -2434,7 +2423,7 @@ public void setEnabled (boolean enabled) { long parentHandle = shellHandle; GTK.gtk_widget_realize (parentHandle); long window = gtk_widget_get_window (parentHandle); - Rectangle rect = getBoundsInPixels (); + Rectangle rect = getBounds(); GdkWindowAttr attributes = new GdkWindowAttr (); attributes.width = rect.width; attributes.height = rect.height; @@ -2659,11 +2648,6 @@ public void setMinimized (boolean minimized) { * @since 3.1 */ public void setMinimumSize (int width, int height) { - checkWidget (); - setMinimumSize (new Point (width, height)); -} - -void setMinimumSizeInPixels (int width, int height) { checkWidget (); geometry.setMinWidth(Math.max (width, trimWidth ()) - trimWidth ()); geometry.setMinHeight(Math.max (height, trimHeight ()) - trimHeight ()); @@ -2698,14 +2682,9 @@ void setMinimumSizeInPixels (int width, int height) { * @since 3.1 */ public void setMinimumSize (Point size) { - checkWidget (); - setMinimumSizeInPixels (DPIUtil.autoScaleUp (size)); -} - -void setMinimumSizeInPixels (Point size) { checkWidget (); if (size == null) error (SWT.ERROR_NULL_ARGUMENT); - setMinimumSizeInPixels (size.x, size.y); + setMinimumSize(size.x, size.y); } /** @@ -2728,9 +2707,15 @@ void setMinimumSizeInPixels (Point size) { * * @since 3.116 */ -public void setMaximumSize (int width, int height) { +public void setMaximumSize(int width, int height) { checkWidget (); - setMaximumSize (new Point (width, height)); + geometry.setMaxWidth(Math.max (width, trimWidth ()) - trimWidth ()); + geometry.setMaxHeight(Math.max (height, trimHeight ()) - trimHeight ()); + int hint = GDK.GDK_HINT_MAX_SIZE; + if (geometry.getMinWidth() > 0 || geometry.getMinHeight() > 0) { + hint = hint | GDK.GDK_HINT_MIN_SIZE; + } + GTK3.gtk_window_set_geometry_hints (shellHandle, 0, (GdkGeometry) geometry, hint); } /** @@ -2756,25 +2741,9 @@ public void setMaximumSize (int width, int height) { * @since 3.116 */ public void setMaximumSize (Point size) { - checkWidget (); - setMaximumSizeInPixels (DPIUtil.autoScaleUp (size)); -} - -void setMaximumSizeInPixels (Point size) { checkWidget (); if (size == null) error (SWT.ERROR_NULL_ARGUMENT); - setMaximumSizeInPixels (size.x, size.y); -} - -void setMaximumSizeInPixels (int width, int height) { - checkWidget (); - geometry.setMaxWidth(Math.max (width, trimWidth ()) - trimWidth ()); - geometry.setMaxHeight(Math.max (height, trimHeight ()) - trimHeight ()); - int hint = GDK.GDK_HINT_MAX_SIZE; - if (geometry.getMinWidth() > 0 || geometry.getMinHeight() > 0) { - hint = hint | GDK.GDK_HINT_MIN_SIZE; - } - GTK3.gtk_window_set_geometry_hints (shellHandle, 0, (GdkGeometry) geometry, hint); + setMaximumSize(size.x, size.y); } /** @@ -2858,7 +2827,7 @@ static Region mirrorRegion (Region region) { int [] nRects = new int [1]; long [] rects = new long [1]; gdk_region_get_rectangles (rgn, rects, nRects); - Rectangle bounds = DPIUtil.autoScaleUp(region.getBounds ()); + Rectangle bounds = region.getBounds (); cairo_rectangle_int_t rect = new cairo_rectangle_int_t(); for (int i = 0; i < nRects [0]; i++) { Cairo.memmove (rect, rects[0] + (i * GdkRectangle.sizeof), GdkRectangle.sizeof); @@ -2900,7 +2869,7 @@ public void setVisible (boolean visible) { checkWidget(); if (moved) { //fix shell location if it was moved. - setLocationInPixels(oldX, oldY); + setLocation(oldX, oldY); } int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL; if ((style & mask) != 0) { @@ -3013,7 +2982,7 @@ public void setVisible (boolean visible) { opened = true; if (!moved) { moved = true; - Point location = getLocationInPixels(); + Point location = getLocation(); oldX = location.x; oldY = location.y; sendEvent (SWT.Move); @@ -3021,7 +2990,7 @@ public void setVisible (boolean visible) { } if (!resized) { resized = true; - Point size = getSizeInPixels (); + Point size = getSize(); oldWidth = size.x - trimWidth (); oldHeight = size.y - trimHeight (); sendEvent (SWT.Resize); @@ -3379,7 +3348,7 @@ public void forceActive () { } @Override -Rectangle getBoundsInPixels () { +public Rectangle getBounds() { checkWidget (); int [] x = new int [1], y = new int [1]; if ((state & Widget.DISPOSE_SENT) == 0) { @@ -3464,7 +3433,7 @@ Point getWindowOrigin () { * window trims etc. from the window manager. That's why getLocation () * is not safe to use for coordinate mappings after the shell has been made visible. */ - return getLocationInPixels (); + return getLocation(); } return super.getWindowOrigin( ); } @@ -3472,7 +3441,7 @@ Point getWindowOrigin () { @Override Point getSurfaceOrigin () { if (!mapped) { - return getLocationInPixels (); + return getLocation(); } return super.getSurfaceOrigin( ); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java index 869f1656c76..b09d20cde0a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Slider.java @@ -291,7 +291,7 @@ void deregister() { } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { +public Point computeSize(int wHint, int hHint, boolean changed) { checkWidget(); GTK.gtk_widget_realize(handle); if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java index 0bea1a4c29f..f1a10283fdb 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java @@ -200,7 +200,7 @@ protected void checkSubclass () { } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { +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; @@ -211,7 +211,7 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) { GTK.gtk_widget_get_preferred_size(handle, requisition, null); int width = wHint == SWT.DEFAULT ? requisition.width : Math.max(wHint, requisition.width); int height = hHint == SWT.DEFAULT ? requisition.height : hHint; - Rectangle trim = computeTrimInPixels(0, 0, width, height); + Rectangle trim = computeTrim(0, 0, width, height); return new Point(trim.width, trim.height); } else { GTK.gtk_widget_realize (handle); @@ -247,16 +247,16 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) { width = wHint == SWT.DEFAULT ? requisition.width : Math.max(wHint, requisition.width); height = hHint == SWT.DEFAULT ? requisition.height : hHint; OS.pango_layout_set_text (layout, buffer2, buffer2.length); - Rectangle trim = computeTrimInPixels (0, 0, width, height); + Rectangle trim = computeTrim(0, 0, width, height); return new Point (trim.width, trim.height); } } @Override -Rectangle computeTrimInPixels (int x, int y, int width, int height) { +public Rectangle computeTrim(int x, int y, int width, int height) { checkWidget (); int xborder = 0, yborder = 0; - Rectangle trim = super.computeTrimInPixels (x, y, width, height); + Rectangle trim = super.computeTrim(x, y, width, height); GtkBorder tmp = new GtkBorder(); long context = GTK.gtk_widget_get_style_context (handle); int state_flag = GTK.gtk_widget_get_state_flags(handle); @@ -429,7 +429,7 @@ void fixIM () { } @Override -int getBorderWidthInPixels () { +public int getBorderWidth() { checkWidget(); if ((this.style & SWT.BORDER) != 0) { return getThickness (handle).x; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java index e3f7631a40c..24775f6749f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java @@ -171,9 +171,9 @@ long clientHandle () { } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { +public Point computeSize(int wHint, int hHint, boolean changed) { checkWidget (); - Point size = super.computeSizeInPixels (wHint, hHint, changed); + Point size = super.computeSize(wHint, hHint, changed); if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0; if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0; boolean scrollable = GTK.gtk_notebook_get_scrollable (handle); @@ -188,7 +188,7 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) { } @Override -Rectangle computeTrimInPixels (int x, int y, int width, int height) { +public Rectangle computeTrim(int x, int y, int width, int height) { checkWidget(); forceResize (); long clientHandle = clientHandle (); @@ -211,8 +211,8 @@ Rectangle computeTrimInPixels (int x, int y, int width, int height) { } @Override -Rectangle getClientAreaInPixels () { - Rectangle clientRectangle = super.getClientAreaInPixels (); +public Rectangle getClientArea() { + Rectangle clientRectangle = super.getClientArea(); /* * Bug 454936 (see also other 454936 references) @@ -356,7 +356,7 @@ void destroyItem (TabItem item) { if (newIndex != -1) { Control control = items [newIndex].getControl (); if (control != null && !control.isDisposed ()) { - control.setBoundsInPixels (getClientAreaInPixels()); + control.setBounds(getClientArea()); control.setVisible (true); } Event event = new Event (); @@ -589,7 +589,7 @@ long gtk_switch_page(long notebook, long page, int page_num) { if (GTK.GTK4) { Control control = item.getControl(); - control.setBoundsInPixels(getClientAreaInPixels()); + control.setBounds(getClientArea()); } else { int index = GTK.gtk_notebook_get_current_page(handle); if (index != -1) { @@ -603,7 +603,7 @@ long gtk_switch_page(long notebook, long page, int page_num) { Control control = item.getControl(); if (control != null && !control.isDisposed()) { - control.setBoundsInPixels(getClientAreaInPixels()); + control.setBounds(getClientArea()); control.setVisible(true); } } @@ -666,7 +666,7 @@ Point minimumSize (int wHint, int hHint, boolean flushCache) { index++; } if (index == count) { - Rectangle rect = DPIUtil.autoScaleUp(child.getBounds ()); + Rectangle rect = child.getBounds (); width = Math.max (width, rect.x + rect.width); height = Math.max (height, rect.y + rect.height); } else { @@ -674,7 +674,7 @@ Point minimumSize (int wHint, int hHint, boolean flushCache) { * Since computeSize can be overridden by subclasses, we cannot * call computeSizeInPixels directly. */ - Point size = DPIUtil.autoScaleUp(child.computeSize (DPIUtil.autoScaleDown(wHint), DPIUtil.autoScaleDown(hHint), flushCache)); + Point size = child.computeSize(wHint, hHint, flushCache); width = Math.max (width, size.x); height = Math.max (height, size.y); } @@ -793,7 +793,7 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize TabItem item = items [index]; Control control = item.control; if (control != null && !control.isDisposed ()) { - control.setBoundsInPixels (getClientAreaInPixels ()); + control.setBounds(getClientArea()); } } } @@ -870,7 +870,7 @@ void setSelection (int index, boolean notify) { TabItem item = items [newIndex]; Control control = item.control; if (control != null && !control.isDisposed ()) { - control.setBoundsInPixels (getClientAreaInPixels ()); + control.setBounds(getClientArea()); control.setVisible (true); } if (notify) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java index 64479c09e02..dc0be9a15b1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java @@ -160,11 +160,6 @@ void destroyWidget () { */ public Rectangle getBounds () { checkWidget (); - return DPIUtil.autoScaleDown (getBoundsInPixels ()); -} - -Rectangle getBoundsInPixels () { - checkWidget(); GtkAllocation allocation = new GtkAllocation (); GTK.gtk_widget_get_allocation (handle, allocation); int x = allocation.x; @@ -339,7 +334,7 @@ public void setControl(Control control) { } } if (newControl != null) { - newControl.setBoundsInPixels (parent.getClientAreaInPixels ()); + newControl.setBounds(parent.getClientArea()); newControl.setVisible (true); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java index d2d99021f65..2cac637c079 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java @@ -488,7 +488,7 @@ public void clearAll () { } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { +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; @@ -521,7 +521,7 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) { if (wHint == SWT.DEFAULT && size.x == 0 && columnCount == 0) { size.x = maxWidth; } - Rectangle trim = computeTrimInPixels (0, 0, size.x, size.y); + Rectangle trim = computeTrim(0, 0, size.x, size.y); size.x = trim.width; /* * Feature in GTK: sometimes GtkScrolledWindow's with no scrollbars @@ -1157,7 +1157,7 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean long [] path = new long [1]; if (GTK.gtk_gesture_drag_get_start_point(dragGesture, startX, startY)) { if (getHeaderVisible()) { - startY[0]-= getHeaderHeightInPixels(); + startY[0]-= getHeaderHeight(); } if (GTK.gtk_tree_view_get_path_at_pos (handle, (int) startX[0], (int) startY[0], path, null, null, null)) { if (path [0] != 0) { @@ -1185,7 +1185,7 @@ long eventSurface () { } @Override -Rectangle getClientAreaInPixels() { +public Rectangle getClientArea() { checkWidget(); if(RESIZE_ON_GETCLIENTAREA) { forceResize(); @@ -1434,11 +1434,6 @@ TableItem getFocusItem () { */ public int getGridLineWidth () { checkWidget (); - return DPIUtil.autoScaleDown (getGridLineWidthInPixels ()); -} - -int getGridLineWidthInPixels () { - checkWidget(); return 0; } @@ -1488,11 +1483,6 @@ public Color getHeaderForeground () { */ public int getHeaderHeight () { checkWidget (); - return DPIUtil.autoScaleDown (getHeaderHeightInPixels ()); -} - -int getHeaderHeightInPixels () { - checkWidget(); if (!GTK.gtk_tree_view_get_headers_visible(handle)) return 0; int height = 0; @@ -1598,11 +1588,6 @@ public TableItem getItem (int index) { * */ public TableItem getItem (Point point) { - checkWidget(); - return getItemInPixels(DPIUtil.autoScaleUp(point)); -} - -TableItem getItemInPixels (Point point) { checkWidget(); if (point == null) error (SWT.ERROR_NULL_ARGUMENT); long [] path = new long [1]; @@ -1657,11 +1642,6 @@ public int getItemCount () { */ public int getItemHeight () { checkWidget (); - return DPIUtil.autoScaleDown (getItemHeightInPixels ()); -} - -int getItemHeightInPixels () { - checkWidget(); int height = 0; if (itemCount == 0) { @@ -2879,11 +2859,7 @@ void sendMeasureEvent (long cell, long width, long height) { int imageWidth = 0; if (image != null) { Rectangle bounds; - if (DPIUtil.useCairoAutoScale()) { - bounds = image.getBounds (); - } else { - bounds = image.getBoundsInPixels(); - } + bounds = image.getBounds(); imageWidth = bounds.width; } contentWidth [0] += imageWidth; @@ -2894,11 +2870,11 @@ void sendMeasureEvent (long cell, long width, long height) { event.index = columnIndex; event.gc = gc; Rectangle eventRect = new Rectangle (0, 0, contentWidth [0], contentHeight [0]); - event.setBounds (DPIUtil.autoScaleDown (eventRect)); + event.setBounds(eventRect); if (isSelected) event.detail = SWT.SELECTED; sendEvent (SWT.MeasureItem, event); gc.dispose (); - Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ()); + Rectangle rect = event.getBounds(); contentWidth [0] = rect.width - imageWidth; if (contentHeight [0] < rect.height) contentHeight [0] = rect.height; if (width != 0) C.memmove (width, contentWidth, 4); @@ -3048,13 +3024,11 @@ void rendererRender (long cell, long cr, long snapshot, long widget, long backgr if (cr != 0) { GdkRectangle r = new GdkRectangle(); GDK.gdk_cairo_get_clip_rectangle(cr, r); - Rectangle rect2 = DPIUtil.autoScaleDown(rect); // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075 - gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height); + gc.setClipping(rect.x, r.y, r.width, r.height); } else { - Rectangle rect2 = DPIUtil.autoScaleDown(rect); // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075 - gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height); + gc.setClipping(rect.x, rect.y, rect.width, rect.height); } @@ -3072,7 +3046,7 @@ void rendererRender (long cell, long cr, long snapshot, long widget, long backgr event.index = columnIndex; event.gc = gc; event.detail = drawState; - event.setBounds (DPIUtil.autoScaleDown (eventRect)); + event.setBounds(eventRect); sendEvent (SWT.EraseItem, event); } finally { Cairo.cairo_translate (cr, 0, y_offset); @@ -3106,7 +3080,7 @@ void rendererRender (long cell, long cr, long snapshot, long widget, long backgr if ((drawState & SWT.BACKGROUND) != 0 && (drawState & SWT.SELECTED) == 0) { GC gc = getGC(cr); gc.setBackground (item.getBackground (columnIndex)); - gc.fillRectangle (DPIUtil.autoScaleDown (rendererRect.toRectangle ())); + gc.fillRectangle(rendererRect.toRectangle()); gc.dispose (); } if ((drawState & SWT.FOREGROUND) != 0 || GTK.GTK_IS_CELL_RENDERER_TOGGLE (cell)) { @@ -3142,11 +3116,7 @@ void rendererRender (long cell, long cr, long snapshot, long widget, long backgr int imageWidth = 0; if (image != null) { Rectangle bounds; - if (DPIUtil.useCairoAutoScale()) { - bounds = image.getBounds (); - } else { - bounds = image.getBoundsInPixels (); - } + bounds = image.getBounds(); imageWidth = bounds.width; } contentX [0] -= imageWidth; @@ -3176,9 +3146,8 @@ void rendererRender (long cell, long cr, long snapshot, long widget, long backgr gc.setFont (item.getFont (columnIndex)); if ((style & SWT.MIRRORED) != 0) rect.x = getClientWidth () - rect.width - rect.x; - Rectangle rect2 = DPIUtil.autoScaleDown(rect); // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075 - gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height); + gc.setClipping(rect.x, rect.y, rect.width, rect.height); // SWT.PaintItem/SWT.EraseItem often expect that event.y matches // what 'event.item.getBounds()' returns. The workaround is to @@ -3194,7 +3163,7 @@ void rendererRender (long cell, long cr, long snapshot, long widget, long backgr event.index = columnIndex; event.gc = gc; event.detail = drawState; - event.setBounds (DPIUtil.autoScaleDown (eventRect)); + event.setBounds(eventRect); sendEvent (SWT.PaintItem, event); } finally { Cairo.cairo_translate (cr, 0, y_offset); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java index d44c0037a3b..5a73a58fddc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableColumn.java @@ -319,11 +319,6 @@ public String getToolTipText () { */ public int getWidth () { checkWidget (); - return DPIUtil.autoScaleDown(getWidthInPixels()); -} - -int getWidthInPixels () { - checkWidget(); if (!GTK.gtk_tree_view_column_get_visible (handle)) { return 0; } @@ -507,7 +502,7 @@ public void pack () { } OS.g_free (iter); } - setWidthInPixels(width); + setWidth(width); } @Override @@ -760,11 +755,6 @@ public void setToolTipText(String string) { */ public void setWidth (int width) { checkWidget (); - setWidthInPixels (DPIUtil.autoScaleUp (width)); -} - -void setWidthInPixels (int width) { - checkWidget(); if (width < 0) return; if (width == lastWidth) return; if (width > 0) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java index 92af154acff..be72fb30440 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java @@ -288,26 +288,6 @@ public Color getBackground () { * @since 3.2 */ public Rectangle getBounds () { - return DPIUtil.autoScaleDown (getBoundsinPixels ()); -} - -/** - * Returns a rectangle describing the size and location of the receiver's - * text relative to its parent. - * - * @return the bounding rectangle of the receiver's text - * - * @exception SWTException
    - *
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • - *
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • - *
- * - * @since 3.105 - */ -Rectangle getBoundsinPixels () { - // TODO fully test on early and later versions of GTK - // shifted a bit too far right on later versions of GTK - however, old Tree also had this problem - checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); long parentHandle = parent.handle; long column = GTK.gtk_tree_view_get_column (parentHandle, 0); @@ -394,11 +374,6 @@ public Color getBackground (int index) { */ public Rectangle getBounds (int index) { checkWidget (); - return DPIUtil.autoScaleDown (getBoundsInPixels (index)); -} - -Rectangle getBoundsInPixels (int index) { - checkWidget(); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); long parentHandle = parent.handle; long column = 0; @@ -601,11 +576,6 @@ public Image getImage (int index) { * */ public Rectangle getImageBounds (int index) { - checkWidget (); - return DPIUtil.autoScaleDown (getImageBoundsInPixels (index)); -} - -Rectangle getImageBoundsInPixels (int index) { checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); long parentHandle = parent.handle; @@ -742,11 +712,6 @@ public String getText (int index) { * @since 3.3 */ public Rectangle getTextBounds (int index) { - checkWidget (); - return DPIUtil.autoScaleDown (getTextBoundsInPixels (index)); -} - -Rectangle getTextBoundsInPixels (int index) { checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); int count = Math.max (1, parent.getColumnCount ()); @@ -807,12 +772,7 @@ Rectangle getTextBoundsInPixels (int index) { Image image = _getImage(index); int imageWidth = 0; if (image != null) { - if (DPIUtil.useCairoAutoScale()) { - imageWidth = image.getBounds ().width; - } else { - imageWidth = image.getBoundsInPixels ().width; - } - + imageWidth = image.getBounds().width; } if (x [0] < imageWidth) { rect.x += imageWidth; @@ -1212,13 +1172,8 @@ public void setImage(int index, Image image) { if (!parent.pixbufSizeSet) { if (image != null) { int iWidth, iHeight; - if (DPIUtil.useCairoAutoScale()) { - iWidth = image.getBounds ().width; - iHeight = image.getBounds ().height; - } else { - iWidth = image.getBoundsInPixels ().width; - iHeight = image.getBoundsInPixels ().height; - } + iWidth = image.getBounds().width; + iHeight = image.getBounds().height; if (iWidth > currentWidth [0] || iHeight > currentHeight [0]) { GTK.gtk_cell_renderer_set_fixed_size (pixbufRenderer, iWidth, iHeight); parent.pixbufHeight = iHeight; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java index a5470f9e08d..a9674a487c2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java @@ -622,7 +622,7 @@ public void clearSelection () { } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { +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; @@ -669,14 +669,14 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) { if (height == 0) height = DEFAULT_HEIGHT; width = wHint == SWT.DEFAULT ? width : wHint; height = hHint == SWT.DEFAULT ? height : hHint; - Rectangle trim = computeTrimInPixels (0, 0, width, height); + Rectangle trim = computeTrim(0, 0, width, height); return new Point (trim.width, trim.height); } @Override -Rectangle computeTrimInPixels (int x, int y, int width, int height) { +public Rectangle computeTrim(int x, int y, int width, int height) { checkWidget (); - Rectangle trim = super.computeTrimInPixels (x, y, width, height); + Rectangle trim = super.computeTrim(x, y, width, height); int xborder = 0, yborder = 0; if ((style & SWT.SINGLE) != 0) { GtkBorder tmp = new GtkBorder(); @@ -905,9 +905,9 @@ void fixIM () { } @Override -int getBorderWidthInPixels () { +public int getBorderWidth() { checkWidget(); - if ((style & SWT.MULTI) != 0) return super.getBorderWidthInPixels (); + if ((style & SWT.MULTI) != 0) return super.getBorderWidth(); if ((this.style & SWT.BORDER) != 0) { return getThickness (handle).x; } @@ -948,11 +948,6 @@ public int getCaretLineNumber () { * */ public Point getCaretLocation () { - checkWidget (); - return DPIUtil.autoScaleDown(getCaretLocationInPixels()); -} - -Point getCaretLocationInPixels () { checkWidget (); if ((style & SWT.SINGLE) != 0) { int index = GTK.gtk_editable_get_position (handle); @@ -962,7 +957,7 @@ Point getCaretLocationInPixels () { long layout = GTK3.gtk_entry_get_layout (handle); PangoRectangle pos = new PangoRectangle (); OS.pango_layout_index_to_pos (layout, index, pos); - int x = offset_x [0] + OS.PANGO_PIXELS (pos.x) - getBorderWidthInPixels (); + int x = offset_x [0] + OS.PANGO_PIXELS (pos.x) - getBorderWidth(); int y = offset_y [0] + OS.PANGO_PIXELS (pos.y); return new Point (x, y); } else { @@ -1532,11 +1527,6 @@ public int getTopIndex () { * */ public int getTopPixel () { - checkWidget (); - return DPIUtil.autoScaleDown(getTopPixelInPixels()); -} - -int getTopPixelInPixels () { checkWidget (); if ((style & SWT.SINGLE) != 0) return 0; byte [] position = new byte [ITER_SIZEOF]; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java index be019ea0d78..2515754e8e7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java @@ -172,7 +172,7 @@ int applyThemeBackground () { } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { +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; @@ -302,15 +302,10 @@ public ToolItem getItem (int index) { */ public ToolItem getItem (Point point) { checkWidget(); - return getItemInPixels(DPIUtil.autoScaleUp(point)); -} - - -ToolItem getItemInPixels (Point point) { if (point == null) error (SWT.ERROR_NULL_ARGUMENT); ToolItem[] items = getItems(); for (int i=0; i */ public void setLocation (int x, int y) { - checkWidget (); - setLocation (new Point (x, y)); -} - -void setLocationInPixels (int x, int y) { checkWidget (); this.x = x; this.y = y; @@ -745,14 +740,9 @@ void setLocationInPixels (int x, int y) { * */ public void setLocation (Point location) { - checkWidget (); - setLocationInPixels(DPIUtil.autoScaleUp(location)); -} - -void setLocationInPixels (Point location) { checkWidget (); if (location == null) error (SWT.ERROR_NULL_ARGUMENT); - setLocationInPixels (location.x, location.y); + setLocation(location.x, location.y); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java index 42723c9f4c7..da673edf244 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java @@ -200,7 +200,7 @@ Point adjustMoveCursor () { int newX = bounds.x + bounds.width / 2; int newY = bounds.y; - Point point = display.mapInPixels(parent, null, newX, newY); + Point point = display.map(parent, null, newX, newY); display.setCursorLocation(point); int[] actualX = new int[1], actualY = new int[1], state = new int[1]; @@ -237,7 +237,7 @@ Point adjustResizeCursor () { newY = bounds.y + bounds.height / 2; } - Point point = display.mapInPixels (parent, null, newX, newY); + Point point = display.map(parent, null, newX, newY); display.setCursorLocation (point); /* @@ -368,7 +368,7 @@ void drawRectangles (Rectangle [] rects) { // Ensure we have absolute screen coordinates. (btw, there are no absolute coordinates on Wayland, so Tracker(Display) is probably broken). if (parent != null) { // if Tracker(Display) has absolute coords. Tracker(Composite) has relative. For relative, we need to find absolute. - cachedUnion = display.mapInPixels(parent, null, cachedUnion) ; + cachedUnion = display.map(parent, null, cachedUnion) ; } if (!cachedCombinedDisplayResolution.intersects(cachedUnion)) { @@ -382,7 +382,7 @@ void drawRectangles (Rectangle [] rects) { // Combine Rects into a region. (region is not necessarily a rectangle, E.g it can be 'L' shaped etc..). for (int i = 0; i < rects.length; i++) { // Turn filled rectangles into just the outer lines by drawing one line at a time. - Rectangle r = parent != null ? display.mapInPixels(parent, null, rects[i]) : rects[i]; + Rectangle r = parent != null ? display.map(parent, null, rects[i]) : rects[i]; rect.x = r.x; rect.y = r.y; rect.width = r.width + 1; @@ -436,16 +436,6 @@ void drawRectangles (Rectangle [] rects) { * */ public Rectangle [] getRectangles () { - checkWidget(); - Rectangle [] result = new Rectangle [rectangles.length]; - for (int i = 0; i < rectangles.length; i++) { - Rectangle current = rectangles [i]; - result [i] = DPIUtil.autoScaleDown (new Rectangle (current.x, current.y, current.width, current.height)); - } - return result; -} - -Rectangle [] getRectanglesInPixels () { checkWidget(); Rectangle [] result = new Rectangle [rectangles.length]; for (int i = 0; i < rectangles.length; i++) { @@ -529,9 +519,9 @@ long gtk_key_press_event (long widget, long eventPtr) { } Event event = new Event (); Rectangle eventRect = new Rectangle (oldX + xChange, oldY + yChange, 0, 0); - event.setBounds (DPIUtil.autoScaleDown (eventRect)); + event.setBounds(eventRect); if (parent != null && (parent.style & SWT.MIRRORED) != 0) { - event.x = DPIUtil.autoScaleDown (parent.getClientWidth ()) - event.width - event.x; + event.x = parent.getClientWidth () - event.width - event.x; } if ((style & SWT.RESIZE) != 0) { resizeRectangles (xChange, yChange); @@ -659,11 +649,11 @@ long gtk_mouse (int eventType, long widget, long eventPtr) { Event event = new Event (); if (parent == null) { Rectangle eventRect = new Rectangle (newX [0], newY [0], 0, 0); - event.setBounds (DPIUtil.autoScaleDown (eventRect)); + event.setBounds(eventRect); } else { - Point screenCoord = display.mapInPixels (parent, null, newX [0], newY [0]); + Point screenCoord = display.map(parent, null, newX [0], newY [0]); Rectangle eventRect = new Rectangle (screenCoord.x, screenCoord.y, 0, 0); - event.setBounds (DPIUtil.autoScaleDown (eventRect)); + event.setBounds(eventRect); } if ((style & SWT.RESIZE) != 0) { resizeRectangles (newX [0] - oldX, newY [0] - oldY); @@ -846,7 +836,7 @@ public boolean open () { GDK.gdk_window_set_override_redirect (overlayWindow, true); } setTrackerBackground(true); - Rectangle bounds = display.getBoundsInPixels(); + Rectangle bounds = display.getBounds(); GTK3.gtk_window_move (overlay, bounds.x, bounds.y); GTK3.gtk_window_resize (overlay, bounds.width, bounds.height); GTK.gtk_widget_show (overlay); @@ -1154,16 +1144,6 @@ public void setCursor (Cursor newCursor) { * */ public void setRectangles (Rectangle [] rectangles) { - checkWidget(); - if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT); - int length = rectangles.length; - for (int i = 0; i < length; i++) { - rectangles [i] = DPIUtil.autoScaleUp (rectangles [i]); - } - setRectanglesInPixels (rectangles); -} - -void setRectanglesInPixels (Rectangle [] rectangles) { checkWidget(); if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT); int length = rectangles.length; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java index 808623da98d..2957265fa80 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java @@ -618,7 +618,7 @@ void clearAll (boolean all, long parentIter) { } @Override -Point computeSizeInPixels (int wHint, int hHint, boolean changed) { +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; @@ -645,7 +645,7 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) { * the number of items at the root of the tree. */ if (hHint == SWT.DEFAULT && size.y == getHeaderHeight()) { - int itemHeight = getItemHeightInPixels(); + int itemHeight = getItemHeight(); // Initialize to height of root items & header size.y = getItemCount() * itemHeight + getHeaderHeight(); @@ -657,7 +657,7 @@ Point computeSizeInPixels (int wHint, int hHint, boolean changed) { } } - Rectangle trim = computeTrimInPixels (0, 0, size.x, size.y); + Rectangle trim = computeTrim(0, 0, size.x, size.y); size.x = trim.width; /* * Feature in GTK: sometimes GtkScrolledWindow's with no scrollbars @@ -1320,7 +1320,7 @@ boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean long [] path = new long [1]; if (GTK.gtk_gesture_drag_get_start_point(dragGesture, startX, startY)) { if (getHeaderVisible()) { - startY[0]-= getHeaderHeightInPixels(); + startY[0]-= getHeaderHeight(); } if (GTK.gtk_tree_view_get_path_at_pos (handle, (int) startX[0], (int) startY[0], path, null, null, null)) { if (path [0] != 0) { @@ -1343,7 +1343,7 @@ long eventWindow () { } @Override -Rectangle getClientAreaInPixels () { +public Rectangle getClientArea() { checkWidget(); if(RESIZE_ON_GETCLIENTAREA) { forceResize(); @@ -1602,11 +1602,6 @@ TreeItem getFocusItem () { */ public int getGridLineWidth () { checkWidget (); - return DPIUtil.autoScaleDown (getGridLineWidthInPixels ()); -} - -int getGridLineWidthInPixels () { - checkWidget(); return 0; } @@ -1656,11 +1651,6 @@ public Color getHeaderForeground () { */ public int getHeaderHeight () { checkWidget (); - return DPIUtil.autoScaleDown (getHeaderHeightInPixels ()); -} - -int getHeaderHeightInPixels () { - checkWidget(); if (!GTK.gtk_tree_view_get_headers_visible(handle)) return 0; int height = 0; @@ -1771,11 +1761,6 @@ public TreeItem getItem (int index) { */ public TreeItem getItem (Point point) { checkWidget(); - return getItemInPixels(DPIUtil.autoScaleUp(point)); -} - -TreeItem getItemInPixels (Point point) { - checkWidget (); if (point == null) error (SWT.ERROR_NULL_ARGUMENT); long [] path = new long [1]; GTK.gtk_widget_realize (handle); @@ -1846,11 +1831,6 @@ public int getItemCount () { */ public int getItemHeight () { checkWidget (); - return DPIUtil.autoScaleDown (getItemHeightInPixels ()); -} - -int getItemHeightInPixels () { - checkWidget(); int height = 0; int itemCount = GTK.gtk_tree_model_iter_n_children(modelHandle, 0); @@ -3078,11 +3058,6 @@ void sendMeasureEvent (long cell, long width, long height) { int imageWidth = 0; if (image != null && !image.isDisposed()) { Rectangle bounds; - if (DPIUtil.useCairoAutoScale()) { - bounds = image.getBounds (); - } else { - bounds = image.getBoundsInPixels (); - } bounds = image.getBounds (); imageWidth = bounds.width; } @@ -3094,7 +3069,7 @@ void sendMeasureEvent (long cell, long width, long height) { event.index = columnIndex; event.gc = gc; Rectangle eventRect = new Rectangle (0, 0, contentWidth [0], contentHeight [0]); - event.setBounds (DPIUtil.autoScaleDown (eventRect)); + event.setBounds(eventRect); long path = GTK.gtk_tree_model_get_path (modelHandle, iter); long selection = GTK.gtk_tree_view_get_selection (handle); if (GTK.gtk_tree_selection_path_is_selected (selection, path)) { @@ -3103,7 +3078,7 @@ void sendMeasureEvent (long cell, long width, long height) { GTK.gtk_tree_path_free (path); sendEvent (SWT.MeasureItem, event); gc.dispose (); - Rectangle rect = DPIUtil.autoScaleUp (event.getBounds ()); + Rectangle rect = event.getBounds(); contentWidth [0] = rect.width - imageWidth; if (contentHeight [0] < rect.height) contentHeight [0] = rect.height; if (width != 0) C.memmove (width, contentWidth, 4); @@ -3253,12 +3228,10 @@ void rendererRender (long cell, long cr, long snapshot, long widget, long backgr if (cr != 0) { // Use the original rectangle, not the Cairo clipping for the y, width, and height values. // See bug 535124. - Rectangle rect2 = DPIUtil.autoScaleDown(rect); - gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height); + gc.setClipping(rect.x, rect.y, rect.width, rect.height); } else { - Rectangle rect2 = DPIUtil.autoScaleDown(rect); // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075 - gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height); + gc.setClipping(rect.x, rect.y, rect.width, rect.height); } // SWT.PaintItem/SWT.EraseItem often expect that event.y matches @@ -3275,7 +3248,7 @@ void rendererRender (long cell, long cr, long snapshot, long widget, long backgr event.index = columnIndex; event.gc = gc; event.detail = drawState; - event.setBounds (DPIUtil.autoScaleDown (eventRect)); + event.setBounds(eventRect); sendEvent (SWT.EraseItem, event); } finally { Cairo.cairo_translate (cr, 0, y_offset); @@ -3300,7 +3273,7 @@ void rendererRender (long cell, long cr, long snapshot, long widget, long backgr if ((drawState & SWT.BACKGROUND) != 0 && (drawState & SWT.SELECTED) == 0) { GC gc = getGC(cr); gc.setBackground (item.getBackground (columnIndex)); - gc.fillRectangle (DPIUtil.autoScaleDown (rendererRect.toRectangle ())); + gc.fillRectangle(rendererRect.toRectangle()); gc.dispose (); } if ((drawState & SWT.FOREGROUND) != 0 || GTK.GTK_IS_CELL_RENDERER_TOGGLE (cell)) { @@ -3336,11 +3309,7 @@ void rendererRender (long cell, long cr, long snapshot, long widget, long backgr int imageWidth = 0; if (image != null) { Rectangle bounds; - if(DPIUtil.useCairoAutoScale()) { - bounds = image.getBounds (); - } else { - bounds = image.getBoundsInPixels (); - } + bounds = image.getBounds(); imageWidth = bounds.width; } // Account for the image width on GTK3, see bug 535124. @@ -3378,10 +3347,8 @@ void rendererRender (long cell, long cr, long snapshot, long widget, long backgr if ((style & SWT.MIRRORED) != 0) { rect.x = getClientWidth () - rect.width - rect.x; } - - Rectangle rect2 = DPIUtil.autoScaleDown(rect); // Caveat: rect2 is necessary because GC#setClipping(Rectangle) got broken by bug 446075 - gc.setClipping(rect2.x, rect2.y, rect2.width, rect2.height); + gc.setClipping(rect.x, rect.y, rect.width, rect.height); // SWT.PaintItem/SWT.EraseItem often expect that event.y matches // what 'event.item.getBounds()' returns. The workaround is to @@ -3397,7 +3364,7 @@ void rendererRender (long cell, long cr, long snapshot, long widget, long backgr event.index = columnIndex; event.gc = gc; event.detail = drawState; - event.setBounds (DPIUtil.autoScaleDown (eventRect)); + event.setBounds(eventRect); sendEvent (SWT.PaintItem, event); } finally { Cairo.cairo_translate (cr, 0, y_offset); @@ -3478,7 +3445,7 @@ public void setInsertMark (TreeItem item, boolean before) { } if (item.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); if (item.parent != this) return; - Rectangle rect = item.getBoundsInPixels(); + Rectangle rect = item.getBounds(); long [] path = new long [1]; GTK.gtk_widget_realize (handle); if (!GTK.gtk_tree_view_get_path_at_pos(handle, rect.x, rect.y, path, null, null, null)) return; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java index 8c9cab8bb73..022b9b2674c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeColumn.java @@ -321,11 +321,6 @@ public String getToolTipText () { */ public int getWidth () { checkWidget (); - return DPIUtil.autoScaleDown (getWidthInPixels ()); -} - -int getWidthInPixels () { - checkWidget(); if (!GTK.gtk_tree_view_column_get_visible (handle)) { return 0; } @@ -485,7 +480,7 @@ public void pack () { } OS.g_free (iter); } - setWidthInPixels(width); + setWidth(width); } @Override @@ -734,11 +729,6 @@ public void setToolTipText(String string) { * */ public void setWidth(int width) { - checkWidget(); - setWidthInPixels(DPIUtil.autoScaleUp(width)); -} - -void setWidthInPixels(int width) { checkWidget(); if (width < 0) return; if (width == lastWidth) return; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java index 15ca6fd4ec3..a323af2601d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java @@ -407,12 +407,6 @@ public Color getBackground (int index) { */ public Rectangle getBounds (int index) { checkWidget (); - return DPIUtil.autoScaleDown (getBoundsInPixels (index)); -} - -Rectangle getBoundsInPixels (int index) { - // TODO fully test on early and later versions of GTK - checkWidget(); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); long parentHandle = parent.handle; long column = 0; @@ -453,11 +447,6 @@ Rectangle getBoundsInPixels (int index) { * */ public Rectangle getBounds () { - checkWidget (); - return DPIUtil.autoScaleDown (getBoundsInPixels ()); -} - -Rectangle getBoundsInPixels () { // TODO fully test on early and later versions of GTK // shifted a bit too far right on later versions of GTK - however, old Tree also had this problem checkWidget (); @@ -693,11 +682,6 @@ public Image getImage (int index) { * @since 3.1 */ public Rectangle getImageBounds (int index) { - checkWidget (); - return DPIUtil.autoScaleDown(getImageBoundsInPixels(index)); -} - -Rectangle getImageBoundsInPixels (int index) { // TODO fully test on early and later versions of GTK checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); @@ -927,11 +911,6 @@ public String getText (int index) { * @since 3.3 */ public Rectangle getTextBounds (int index) { - checkWidget (); - return DPIUtil.autoScaleDown(getTextBoundsInPixels(index)); -} - -Rectangle getTextBoundsInPixels (int index) { checkWidget (); if (!parent.checkData (this)) error (SWT.ERROR_WIDGET_DISPOSED); int count = Math.max (1, parent.getColumnCount ()); @@ -991,11 +970,7 @@ Rectangle getTextBoundsInPixels (int index) { Image image = _getImage(index); int imageWidth = 0; if (image != null) { - if (DPIUtil.useCairoAutoScale()) { - imageWidth = image.getBounds ().width; - } else { - imageWidth = image.getBoundsInPixels ().width; - } + imageWidth = image.getBounds().width; } if (x [0] < imageWidth) { rect.x += imageWidth; @@ -1529,13 +1504,9 @@ public void setImage(int index, Image image) { if (!parent.pixbufSizeSet) { if (image != null) { int iWidth, iHeight; - if (DPIUtil.useCairoAutoScale()) { - iWidth = image.getBounds ().width; - iHeight = image.getBounds ().height; - } else { - iWidth = image.getBoundsInPixels ().width; - iHeight = image.getBoundsInPixels ().height; - } + iWidth = image.getBounds().width; + iHeight = image.getBounds().height; + if (iWidth > currentWidth [0] || iHeight > currentHeight [0]) { GTK.gtk_cell_renderer_set_fixed_size (pixbufRenderer, iWidth, iHeight); parent.pixbufSizeSet = true; diff --git a/bundles/org.eclipse.swt/META-INF/MANIFEST.MF b/bundles/org.eclipse.swt/META-INF/MANIFEST.MF index 0d1e38a2f97..b56e48fbad5 100644 --- a/bundles/org.eclipse.swt/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.swt/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-SymbolicName: org.eclipse.swt; singleton:=true -Bundle-Version: 3.127.0.qualifier +Bundle-Version: 3.128.0.qualifier Bundle-ManifestVersion: 2 Bundle-Localization: plugin DynamicImport-Package: org.eclipse.swt.accessibility2 diff --git a/bundles/org.eclipse.swt/pom.xml b/bundles/org.eclipse.swt/pom.xml index 7575e1f32a3..7ccf4bcc272 100644 --- a/bundles/org.eclipse.swt/pom.xml +++ b/bundles/org.eclipse.swt/pom.xml @@ -21,7 +21,7 @@ org.eclipse.swt org.eclipse.swt - 3.127.0-SNAPSHOT + 3.128.0-SNAPSHOT eclipse-plugin