Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2310,7 +2310,12 @@ long gtk_draw (long widget, long cairo) {
return 0;
}
drawInheritedBackground (cairo);
return super.gtk_draw (widget, cairo);
if (GTK.GTK4) {
return super.gtk_draw (widget, cairo);
} else {
// On GTK3 super.gtk_draw will be lost by items drawing thus handle explicitly in windowProc.
Comment thread
akurtakov marked this conversation as resolved.
return 0;
}
}

@Override
Expand Down Expand Up @@ -4116,6 +4121,13 @@ long windowProc (long handle, long arg0, long user_data) {
}
propagateDraw(handle, arg0);
}
/*
* Ensure the paint listener's drawing appears on top of items rather than being
* overwritten by them.
*/
if (!GTK.GTK4) {
gtk3_paintEvent(arg0);
}
break;
}
case EXPOSE_EVENT_INVERSE: {
Expand Down Expand Up @@ -4194,6 +4206,33 @@ void checkSetDataInProcessBeforeRemoval(int start, int end) {
}
}

/**
* Fire the paint event explicitly, so the paint listener's drawing is not lost.
*/
private void gtk3_paintEvent(long cairo) {
if ((state & OBSCURED) != 0) return;
if (drawRegion) {
cairoClipRegion(cairo);
}
if (!hooksPaint()) return;
GdkRectangle rect = new GdkRectangle();
GDK.gdk_cairo_get_clip_rectangle(cairo, rect);
Event event = new Event();
event.count = 1;
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();
if (drawRegion) data.regionSet = eventRegion;
data.cairo = cairo;
GC gc = event.gc = GC.gtk_new(this, data);
gc.setClipping(eventBounds.x, eventBounds.y, eventBounds.width, eventBounds.height);
drawWidget(gc);
sendEvent(SWT.Paint, event);
gc.dispose();
event.gc = null;
}

@Override
public void dispose() {
super.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2480,7 +2480,12 @@ long gtk_draw (long widget, long cairo) {
return 0;
}
drawInheritedBackground (cairo);
return super.gtk_draw (widget, cairo);
if (GTK.GTK4) {
return super.gtk_draw (widget, cairo);
} else {
// On GTK3 super.gtk_draw will be lost by items drawing thus handle explicitly in windowProc.
Comment thread
akurtakov marked this conversation as resolved.
return 0;
}
}

@Override
Expand Down Expand Up @@ -4192,6 +4197,13 @@ long windowProc (long handle, long arg0, long user_data) {
}
propagateDraw(handle, arg0);
}
/*
* Ensure the paint listener's drawing appears on top of items rather than being
* overwritten by them.
*/
if (!GTK.GTK4) {
gtk3_paintEvent(arg0);
}
break;
}
case EXPOSE_EVENT_INVERSE: {
Expand Down Expand Up @@ -4267,6 +4279,33 @@ void checkSetDataInProcessBeforeRemoval() {
}
}

/**
* Fire the paint event explicitly, so the paint listener's drawing is not lost.
*/
private void gtk3_paintEvent(long cairo) {
if ((state & OBSCURED) != 0) return;
if (drawRegion) {
cairoClipRegion(cairo);
}
if (!hooksPaint()) return;
GdkRectangle rect = new GdkRectangle();
GDK.gdk_cairo_get_clip_rectangle(cairo, rect);
Event event = new Event();
event.count = 1;
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();
if (drawRegion) data.regionSet = eventRegion;
data.cairo = cairo;
GC gc = event.gc = GC.gtk_new(this, data);
gc.setClipping(eventBounds.x, eventBounds.y, eventBounds.width, eventBounds.height);
drawWidget(gc);
sendEvent(SWT.Paint, event);
gc.dispose();
event.gc = null;
}

private void throwCannotRemoveItem(int i) {
String message = "Cannot remove item with index " + i + ".";
throw new SWTException(message);
Expand Down
Loading