Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[GTK] GC.copyArea from a display GC returns stale pixels at GDK_SCALE=2

Aperta
#3,685 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java
Ambito
desktop

Direzione di ricerca

Start from the GTK port's GC.copyArea(Image, int, int) implementation (the SWT GTK native/OS layer where gdk_cairo_set_source_window paints the root window), and compare it with the working gdk_pixbuf_get_from_window path plus how GDK_SCALE=2 scale factors feed the cairo source. Reproduce with the issue's snippet under Xvfb with GDK_SCALE=2 and 1. Done means the snippet returns current pixels at scale 2 while scale-1 behavior stays unchanged.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

On GTK with GDK_SCALE=2, GC.copyArea(Image, x, y) on a display GC returns the first read of a screen area again for every later read of the same area.
A shell opened after the first read is missing from the copy, and a shell closed later stays in it.
A read of a different area is current, and gdk_pixbuf_get_from_window on the root window returns the current pixels for the same area.
At scale 1 everything is current.

Snippet:

Display display = new Display();
Shell red = new Shell(display);
red.setBackground(display.getSystemColor(SWT.COLOR_RED));
red.setBounds(0, 0, 1000, 700);
red.open();
pump(display, 1500);
copy(display); // red, as expected

Shell blue = new Shell(display);
blue.setBackground(display.getSystemColor(SWT.COLOR_BLUE));
blue.setBounds(100, 100, 400, 300);
blue.open();
pump(display, 1500);
copy(display); // pixel at (200,200) is still red, expected blue

static void pump(Display display, int millis) throws InterruptedException {
	long end = System.currentTimeMillis() + millis;
	while (System.currentTimeMillis() < end) {
		if (!display.readAndDispatch()) {
			Thread.sleep(10);
		}
	}
}

static int copy(Display display) {
	Image image = new Image(display, 1000, 700);
	GC gc = new GC(display);
	gc.copyArea(image, 0, 0);
	gc.dispose();
	ImageData data = image.getImageData(display.getPrimaryMonitor().getZoom());
	image.dispose();
	return data.getPixel(400, 400);
}

Seen on Linux X11 (Xvfb 3200x2000, dpi 192, GDK_SCALE=2) with the SWT of Eclipse 4.41 (2026-09).
Waiting, flushing and marking the GC's cairo target dirty do not help.
copyArea(Image, int, int) paints the root window through gdk_cairo_set_source_window, which looks like the cached path.

Reading through gdk_pixbuf_get_from_window instead works around it.

Lingua principale
Java
Stelle
202
Fork
206
Merge medio
14h 7m
PR unite (30g)
103

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di eclipse-platform/eclipse.platform.swt

Tutte le issue di eclipse-platform/eclipse.platform.swt

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.