From 1080e1344bbc12aa5ed87c1d6975fc7fa9f7469d Mon Sep 17 00:00:00 2001 From: Brian Matzon Date: Wed, 16 Jul 2003 21:02:48 +0000 Subject: [PATCH] fix: isClosedRequested now sets flag to false after call added support for isFocused --- src/java/org/lwjgl/Window.java | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/java/org/lwjgl/Window.java b/src/java/org/lwjgl/Window.java index ef570ccc..762d9d06 100644 --- a/src/java/org/lwjgl/Window.java +++ b/src/java/org/lwjgl/Window.java @@ -37,6 +37,9 @@ public abstract class Window { /** Whether the window is currently minimized */ private boolean minimized; + + /** Whether the window has focus */ + private boolean focused = true; /** Whether the window has been asked to close by the user or underlying OS */ private boolean closeRequested; @@ -131,13 +134,16 @@ public abstract class Window { */ private native void nSetTitle(String title); - /** - * @return true if the user or operating system has asked the window to close - */ - public final boolean isCloseRequested() { - assert isCreated(); - return closeRequested; - } + /** + * @return true if the user or operating system has asked the window to close + */ + public final boolean isCloseRequested() { + assert isCreated(); + + boolean currentValue = closeRequested; + closeRequested = false; + return currentValue; + } /** * @return true if the window is minimized or otherwise not visible @@ -146,6 +152,14 @@ public abstract class Window { assert isCreated(); return minimized; } + + /** + * @return true if window is focused + */ + public final boolean isFocused() { + assert isCreated(); + return focused; + } /** * Minimize the game and allow the operating system's default display to become