Skip to content

Commit d342126

Browse files
author
Thomas Singer
committed
[GTK] Can draw outside window on Wayland #3145
`GC.clipping` seems to define the maximum possible clipping rect. However, it did not take into account that controls can be located (partly) outside a client area (e.g. of the shell). Now we reduce the maximum possible clipping rect by the parent client areas so they can't draw over them.
1 parent 65f43d4 commit d342126

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

  • bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.eclipse.swt.internal.*;
2020
import org.eclipse.swt.internal.cairo.*;
2121
import org.eclipse.swt.internal.gtk.*;
22+
import org.eclipse.swt.widgets.*;
2223

2324
/**
2425
* Class <code>GC</code> is where all of the drawing capabilities that are
@@ -2622,6 +2623,16 @@ void init(Drawable drawable, GCData data, long gdkGC) {
26222623
if (cairoTransformationMatrix == null) cairoTransformationMatrix = new double[6];
26232624
Cairo.cairo_get_matrix(data.cairo, cairoTransformationMatrix);
26242625
clipping = getClipping();
2626+
if (drawable instanceof Control control) {
2627+
final Display display = control.getDisplay();
2628+
for (Composite parent = control.getParent(); parent != null; parent = parent.getParent()) {
2629+
Rectangle ancestorClientArea = display.map(parent, control, parent.getClientArea());
2630+
clipping.intersect(ancestorClientArea);
2631+
if (parent instanceof Shell) {
2632+
break;
2633+
}
2634+
}
2635+
}
26252636
}
26262637

26272638
void initCairo() {

0 commit comments

Comments
 (0)