From f4aa07682595b30fc871732513570078b87b1c82 Mon Sep 17 00:00:00 2001 From: Deepika Udayagiri Date: Wed, 26 Jun 2024 19:28:24 +0530 Subject: [PATCH] [GTK][HiDpi] Code cleanup for removal of non-cairo scale path Fixes #1300 --- .../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 | 16 +- .../org/eclipse/swt/widgets/Composite.java | 37 ++--- .../gtk/org/eclipse/swt/widgets/Control.java | 154 +++--------------- .../gtk/org/eclipse/swt/widgets/DateTime.java | 40 ++--- .../gtk/org/eclipse/swt/widgets/Display.java | 143 +++++----------- .../org/eclipse/swt/widgets/ExpandBar.java | 12 +- 10 files changed, 118 insertions(+), 403 deletions(-) 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..adef5ce49fe 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); @@ -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..2dea4fbc0e3 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,11 +1734,11 @@ 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); } /** @@ -1748,7 +1748,7 @@ private void setDropDownButtonSize() { Rectangle rect = getClientAreaInPixels(); 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;