From 8b467ab3d9d04cd5fe035674b5a567dcfe195c33 Mon Sep 17 00:00:00 2001 From: Hammy Date: Thu, 29 Jul 2021 01:16:20 +0100 Subject: [PATCH] Correctly check images against their dimensions for image polling --- src/main/java/me/goudham/ClipboardUtils.java | 5 ++++- .../java/me/goudham/domain/MyClipboardContent.java | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/goudham/ClipboardUtils.java b/src/main/java/me/goudham/ClipboardUtils.java index a8cb206..3da9cc1 100644 --- a/src/main/java/me/goudham/ClipboardUtils.java +++ b/src/main/java/me/goudham/ClipboardUtils.java @@ -27,7 +27,10 @@ class ClipboardUtils { myClipboardContent.setOldContent(contents.getTransferData(TEXT.getDataFlavor())); } else if (IMAGE.isAvailable(clipboard)) { BufferedImage bufferedImage = convertToBufferedImage((Image) contents.getTransferData(IMAGE.getDataFlavor())); - myClipboardContent.setOldContent(new Dimension(bufferedImage.getWidth(), bufferedImage.getHeight())); + myClipboardContent.setOldContent(bufferedImage); + myClipboardContent.setOldDimensionContent(new Dimension(bufferedImage.getWidth(), bufferedImage.getHeight())); + } else if (FILELIST.isAvailable(clipboard)) { + myClipboardContent.setOldContent(contents.getTransferData(FILELIST.getDataFlavor())); } } catch (UnsupportedFlavorException | IOException exp) { exp.printStackTrace(); diff --git a/src/main/java/me/goudham/domain/MyClipboardContent.java b/src/main/java/me/goudham/domain/MyClipboardContent.java index 032a9ad..2922bde 100644 --- a/src/main/java/me/goudham/domain/MyClipboardContent.java +++ b/src/main/java/me/goudham/domain/MyClipboardContent.java @@ -1,7 +1,10 @@ package me.goudham.domain; +import java.awt.Dimension; + public class MyClipboardContent { private T oldContent; + private Dimension oldDimensionContent; public MyClipboardContent() { } @@ -13,4 +16,12 @@ public class MyClipboardContent { public T getOldContent() { return oldContent; } + + public void setOldDimensionContent(Dimension oldDimensionContent) { + this.oldDimensionContent = oldDimensionContent; + } + + public Dimension getOldDimensionContent() { + return oldDimensionContent; + } }