aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt/classes/com/sun
diff options
context:
space:
mode:
Diffstat (limited to 'src/newt/classes/com/sun')
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/Window.java15
-rw-r--r--src/newt/classes/com/sun/javafx/newt/WindowEvent.java6
-rw-r--r--src/newt/classes/com/sun/javafx/newt/WindowListener.java2
-rw-r--r--src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java6
-rwxr-xr-xsrc/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java23
5 files changed, 48 insertions, 4 deletions
diff --git a/src/newt/classes/com/sun/javafx/newt/Window.java b/src/newt/classes/com/sun/javafx/newt/Window.java
index 29d4b6195..d649b53a4 100755
--- a/src/newt/classes/com/sun/javafx/newt/Window.java
+++ b/src/newt/classes/com/sun/javafx/newt/Window.java
@@ -221,7 +221,8 @@ public abstract class Window implements NativeWindow
return undecorated;
}
-
+ public void requestFocus() {
+ }
//
// NativeWindow impl
@@ -551,7 +552,7 @@ public abstract class Window implements NativeWindow
private ArrayList keyListeners = new ArrayList();
protected void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) {
- KeyEvent e = new KeyEvent(true, eventType, this, System.currentTimeMillis(),
+ KeyEvent e = new KeyEvent(true, eventType, this, System.currentTimeMillis(),
modifiers, keyCode, keyChar);
if(DEBUG_KEY_EVENT) {
System.out.println("sendKeyEvent: "+e);
@@ -627,8 +628,16 @@ public abstract class Window implements NativeWindow
case WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY:
l.windowDestroyNotify(e);
break;
+ case WindowEvent.EVENT_WINDOW_GAINED_FOCUS:
+ l.windowGainedFocus(e);
+ break;
+ case WindowEvent.EVENT_WINDOW_LOST_FOCUS:
+ l.windowLostFocus(e);
+ break;
default:
- throw new NativeWindowException("Unexpected window event type " + e.getEventType());
+ throw
+ new NativeWindowException("Unexpected window event type "
+ + e.getEventType());
}
}
}
diff --git a/src/newt/classes/com/sun/javafx/newt/WindowEvent.java b/src/newt/classes/com/sun/javafx/newt/WindowEvent.java
index a502e912c..634672f32 100644
--- a/src/newt/classes/com/sun/javafx/newt/WindowEvent.java
+++ b/src/newt/classes/com/sun/javafx/newt/WindowEvent.java
@@ -36,7 +36,9 @@ package com.sun.javafx.newt;
public class WindowEvent extends Event {
public static final int EVENT_WINDOW_RESIZED = 100;
public static final int EVENT_WINDOW_MOVED = 101;
- public static final int EVENT_WINDOW_DESTROY_NOTIFY = 102;
+ public static final int EVENT_WINDOW_DESTROY_NOTIFY = 102;
+ public static final int EVENT_WINDOW_GAINED_FOCUS = 103;
+ public static final int EVENT_WINDOW_LOST_FOCUS = 104;
public WindowEvent(int eventType, Window source, long when) {
this(false, eventType, source, when);
@@ -51,6 +53,8 @@ public class WindowEvent extends Event {
case EVENT_WINDOW_RESIZED: return "WINDOW_RESIZED";
case EVENT_WINDOW_MOVED: return "WINDOW_MOVED";
case EVENT_WINDOW_DESTROY_NOTIFY: return "EVENT_WINDOW_DESTROY_NOTIFY";
+ case EVENT_WINDOW_GAINED_FOCUS: return "EVENT_WINDOW_GAINED_FOCUS";
+ case EVENT_WINDOW_LOST_FOCUS: return "EVENT_WINDOW_LOST_FOCUS";
default: return "unknown (" + type + ")";
}
}
diff --git a/src/newt/classes/com/sun/javafx/newt/WindowListener.java b/src/newt/classes/com/sun/javafx/newt/WindowListener.java
index e8423cbcc..81624fa75 100644
--- a/src/newt/classes/com/sun/javafx/newt/WindowListener.java
+++ b/src/newt/classes/com/sun/javafx/newt/WindowListener.java
@@ -37,4 +37,6 @@ public interface WindowListener extends EventListener {
public void windowResized(WindowEvent e);
public void windowMoved(WindowEvent e);
public void windowDestroyNotify(WindowEvent e);
+ public void windowGainedFocus(WindowEvent e);
+ public void windowLostFocus(WindowEvent e);
}
diff --git a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
index 196396857..8f7c309f8 100644
--- a/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/opengl/GLWindow.java
@@ -83,6 +83,12 @@ public class GLWindow extends Window implements GLAutoDrawable {
public void windowMoved(WindowEvent e) {
}
+ public void windowGainedFocus(WindowEvent e) {
+ }
+
+ public void windowLostFocus(WindowEvent e) {
+ }
+
public void windowDestroyNotify(WindowEvent e) {
sendDispose = true;
}
diff --git a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
index 2073c5d1b..6c7d8ab56 100755
--- a/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
+++ b/src/newt/classes/com/sun/javafx/newt/windows/WindowsWindow.java
@@ -134,6 +134,14 @@ public class WindowsWindow extends Window {
}
// @Override
+ public void requestFocus() {
+ super.requestFocus();
+ if (windowHandle != 0L) {
+ requestFocus(windowHandle);
+ }
+ }
+
+ // @Override
public void setTitle(String title) {
if (title == null) {
title = "";
@@ -188,6 +196,7 @@ public class WindowsWindow extends Window {
private native boolean setFullScreen0(long windowHandle, boolean fullscreen);
private static native void setPosition(long windowHandle, int x, int y);
private static native void setTitle(long windowHandle, String title);
+ private static native void requestFocus(long windowHandle);
private void sizeChanged(int newWidth, int newHeight) {
width = newWidth;
@@ -200,4 +209,18 @@ public class WindowsWindow extends Window {
y = newY;
sendWindowEvent(WindowEvent.EVENT_WINDOW_MOVED);
}
+
+ /**
+ *
+ * @param focusOwner if focusGained is true, focusOwner is the previous
+ * focus owner, if focusGained is false, focusOwner is the new focus owner
+ * @param focusGained
+ */
+ private void focusChanged(long focusOwner, boolean focusGained) {
+ if (focusGained) {
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_GAINED_FOCUS);
+ } else {
+ sendWindowEvent(WindowEvent.EVENT_WINDOW_LOST_FOCUS);
+ }
+ }
}