From 0bad9912ce1988c0b6af3f22a9adf3f175fd6879 Mon Sep 17 00:00:00 2001 From: Seth Morabito Date: Wed, 11 Jan 2023 13:31:22 -0800 Subject: [PATCH] Repaint Video window at 30fps A bug caused the video window to repaint only when the cursor was blinking. This meant that if the cursor was disabled, the window would never update! This change removes the repaint logic from the cursor blinking timer, and instead puts it into its own periodic timer callback that runs independently of cursor blink. --- .../java/com/loomcom/symon/ui/VideoWindow.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/com/loomcom/symon/ui/VideoWindow.java b/src/main/java/com/loomcom/symon/ui/VideoWindow.java index 1610539..ac7130e 100644 --- a/src/main/java/com/loomcom/symon/ui/VideoWindow.java +++ b/src/main/java/com/loomcom/symon/ui/VideoWindow.java @@ -61,6 +61,7 @@ public class VideoWindow extends JFrame implements DeviceChangeListener { private static final Logger logger = Logger.getLogger(VideoWindow.class.getName()); + private static final long WINDOW_REPAINT_INTERVAL = 66; // 30fps rate private static final int CHAR_WIDTH = 8; private static final int CHAR_HEIGHT = 8; @@ -127,6 +128,18 @@ public class VideoWindow extends JFrame implements DeviceChangeListener { public void run() { if (cursorBlinkRate > 0) { hideCursor = !hideCursor; + } + } + }); + } + } + + private class WindowPainter implements Runnable { + public void run() { + SwingUtilities.invokeLater(new Runnable () { + @Override + public void run() { + if (VideoWindow.this.isVisible()) { VideoWindow.this.repaint(); } } @@ -152,6 +165,11 @@ public class VideoWindow extends JFrame implements DeviceChangeListener { TimeUnit.MILLISECONDS); } + scheduler.scheduleAtFixedRate(new WindowPainter(), + WINDOW_REPAINT_INTERVAL, + WINDOW_REPAINT_INTERVAL, + TimeUnit.MILLISECONDS); + // Capture some state from the CRTC that will define the // window size. When these values change, the window will // need to re-pack and redraw.