Add a temporary workaround for the CHIP

Reported this to the CHIP team: Seeing some odd exception from deep within Java's awt classes ("Width (0) and height (0) must be non-zero"). This is triggered because the libX11 function XQueryBestCursor is returning a width and height of zero, which seems to be a bug. I am guessing that this will also pop up with other Java applications.

This makes things work on the CHIP w/ OS image 4.4 and latest packages. I also tested on OS X, but I am not familiar enough with the Tweak Mode to say for sure.
This commit is contained in:
gohai
2016-07-01 14:18:09 +02:00
parent d00bff1307
commit 6ce890bffb
2 changed files with 26 additions and 4 deletions

View File

@@ -25,6 +25,7 @@ import processing.mode.java.tweak.*;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
@@ -401,8 +402,16 @@ public class JavaTextAreaPainter extends TextAreaPainter
int cursorType;
BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
Cursor blankCursor;
// this is a temporary workaround for the CHIP, will be removed
{
Dimension cursorSize = Toolkit.getDefaultToolkit().getBestCursorSize(16, 16);
if (cursorSize.width == 0 || cursorSize.height == 0) {
blankCursor = Cursor.getDefaultCursor();
} else {
blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, new Point(0, 0), "blank cursor");
}
}
@Override
synchronized public void paint(Graphics gfx) {