Skip to content

[GTK4] custom Paint is under instead of over control #2819

@jonahgraham

Description

@jonahgraham

Consider the following snippet:

public class SnippetDrawOverButton {

public static void main(String [] args) {
	var display = new Display();
	var shell = new Shell(display);
	shell.setLayout(new FillLayout());
	Button button = new Button(shell, SWT.CHECK);
	button.setText("SnippetDrawOverButton");
	Font initialFont = button.getFont();
	FontData[] fontData = initialFont.getFontData();
	for (FontData element : fontData) {
		element.setHeight(24);
	}
	Font newFont = new Font(display, fontData);
	button.setFont(newFont);
	button.addPaintListener(event -> {
		Point rect = button.getSize();
		event.gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
		event.gc.setLineWidth(5);
		event.gc.drawOval(1, 1, rect.x - 2, rect.y - 2);
	});
	shell.pack();
	shell.open ();
	while (!shell.isDisposed()) {
		if (!display.readAndDispatch()) display.sleep();
	}
	display.dispose();
}
}

If you run it on GTK3 you get the oval drawn over the control: (win32 looks similar to GTK3)

Image

But on GTK4 it draws under the control:

Image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions