Skip to content

Commit

Permalink
JBR-6032 WLToolkit: Uninitialized WLComponentPeer sends paint requests
Browse files Browse the repository at this point in the history
Skip sending paint events for not configured peers
  • Loading branch information
avu authored and jbrbot committed Nov 8, 2024
1 parent 35bb2d2 commit 145d640
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/java.desktop/unix/classes/sun/awt/wl/WLComponentPeer.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public class WLComponentPeer implements ComponentPeer {
boolean paintPending = false;
boolean isLayouting = false;
boolean visible = false;
boolean surfaceAssigned = false;

int x;
int y;
Expand Down Expand Up @@ -146,6 +147,11 @@ public Color getBackground() {
}

public void postPaintEvent(int x, int y, int w, int h) {
if (!hasSurface()) {
log.warning("WLComponentPeer: No surface. Skipping paint request x=" + x + " y=" + y +
" width=" + w + " height=" + h);
return;
}
PaintEvent event = PaintEventDispatcher.getPaintEventDispatcher().
createPaintEvent(target, x, y, w, h);
if (event != null) {
Expand All @@ -165,6 +171,9 @@ boolean isVisible() {
return visible;
}

boolean hasSurface() {
return surfaceAssigned;
}

@Override
public void reparent(ContainerPeer newContainer) {
Expand Down Expand Up @@ -266,6 +275,7 @@ protected void wlSetVisible(boolean v) {
performLocked(() -> {
WLToolkit.unregisterWLSurface(getWLSurface(nativePtr));
SurfaceData.convertTo(WLSurfaceDataExt.class, surfaceData).assignSurface(0);
surfaceAssigned = false;
nativeHideFrame(nativePtr);
});
}
Expand Down Expand Up @@ -987,6 +997,7 @@ void notifyConfigured(int newWidth, int newHeight, boolean active, boolean maxim
final long wlSurfacePtr = getWLSurface(nativePtr);
// TODO: this needs to be done only once after wlSetVisible(true)
SurfaceData.convertTo(WLSurfaceDataExt.class, surfaceData).assignSurface(wlSurfacePtr);
surfaceAssigned = true;
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine(String.format("%s configured to %dx%d", this, newWidth, newHeight));
}
Expand Down

0 comments on commit 145d640

Please sign in to comment.