Fix handling of InterruptedExceptions

This commit is contained in:
Cameron Gutman
2022-05-22 15:31:06 -05:00
parent 4901b0c78f
commit fb09c9692c
8 changed files with 115 additions and 40 deletions

View File

@@ -116,7 +116,14 @@ public class AbsoluteTouchContext implements TouchContext {
try {
// FIXME: Sleeping on the main thread sucks
Thread.sleep(50);
} catch (InterruptedException ignored) {}
} catch (InterruptedException e) {
e.printStackTrace();
// InterruptedException clears the thread's interrupt status. Since we can't
// handle that here, we will re-interrupt the thread to set the interrupt
// status back to true.
Thread.currentThread().interrupt();
}
conn.sendMouseButtonUp(MouseButtonPacket.BUTTON_LEFT);
}
}

View File

@@ -139,7 +139,14 @@ public class RelativeTouchContext implements TouchContext {
// do input detection by polling
try {
Thread.sleep(100);
} catch (InterruptedException ignored) {}
} catch (InterruptedException e) {
e.printStackTrace();
// InterruptedException clears the thread's interrupt status. Since we can't
// handle that here, we will re-interrupt the thread to set the interrupt
// status back to true.
Thread.currentThread().interrupt();
}
// Raise the mouse button
conn.sendMouseButtonUp(buttonIndex);