From fceb320f00cbea3e1611dc5c6efaee09a0728921 Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Tue, 21 Jan 2025 17:44:47 +0100 Subject: [PATCH] [GTK] Temporary workaround for LineNumberRulerColumn regression #2740 This temporarily reverts the image creation for the LineNumberRulerColumn on Linux to the state before initializing the buffer image with an ImageGcDrawer. This does currently not work properly for all use cases on Linux/GTK because of an issue with the initialization of Image based on existing ImageData due to the usage of cairo_image_surface_create. Linux-specific workaround for https://github.com/eclipse-platform/eclipse.platform.ui/issues/2740 --- .../text/source/LineNumberRulerColumn.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java index 5f658f5ce89..7f1ca3d66bf 100644 --- a/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java +++ b/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java @@ -42,6 +42,8 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; +import org.eclipse.core.runtime.Platform.OS; + import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; @@ -687,24 +689,25 @@ private void doubleBufferPaint(GC dest) { } if (fBuffer == null) { - fBuffer= newFullBufferImage(size); + newFullBufferImage(visibleLines, size); } else { doPaint(visibleLines, size); } dest.drawImage(fBuffer, 0, 0); } - private Image newFullBufferImage(Point size) { - ImageGcDrawer imageGcDrawer= (gc, imageWidth, imageHeight) -> { - ILineRange lines= JFaceTextUtil.getVisibleModelLines(fCachedTextViewer); - if (lines == null) { - return; - } - // We redraw everything; paint directly into the buffer - initializeGC(gc, 0, 0, imageWidth, imageHeight); - doPaint(gc, lines); - }; - return new Image(fCanvas.getDisplay(), imageGcDrawer, size.x, size.y); + private void newFullBufferImage(ILineRange visibleLines, Point size) { + if (OS.isLinux()) { + fBuffer= new Image(fCanvas.getDisplay(), size.x, size.y); + doPaint(visibleLines, size); + } else { + ImageGcDrawer imageGcDrawer= (gc, imageWidth, imageHeight) -> { + // We redraw everything; paint directly into the buffer + initializeGC(gc, 0, 0, imageWidth, imageHeight); + doPaint(gc, visibleLines); + }; + fBuffer= new Image(fCanvas.getDisplay(), imageGcDrawer, size.x, size.y); + } } private void doPaint(ILineRange visibleLines, Point size) {