Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20201127044806
20201202180738
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.7/SwingJS-site.zip
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.8/SwingJS-site.zip
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9-j11/SwingJS-site.zip
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20201127044806
20201202180738
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
24 changes: 2 additions & 22 deletions sources/net.sf.j2s.java.core/src/java/awt/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -3797,7 +3797,7 @@ protected void dispatchEventImplComp(AWTEvent e) {
return;
}

if (!e.focusManagerIsDispatching) {
if (!e.focusManagerIsDispatching) {
// Invoke the private focus retargeting method which provides
// lightweight Component support
if (e.isPosted) {
Expand Down Expand Up @@ -5921,27 +5921,7 @@ public void addNotify() {
// able to get window-related events by itself. If any
// have been enabled, then the nearest native container must
// be enabled.
if (parent != null) {
long mask = 0;
if ((mouseListener != null) || ((eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0)) {
mask |= AWTEvent.MOUSE_EVENT_MASK;
}
if ((mouseMotionListener != null) || ((eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0)) {
mask |= AWTEvent.MOUSE_MOTION_EVENT_MASK;
}
if ((mouseWheelListener != null) || ((eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0)) {
mask |= AWTEvent.MOUSE_WHEEL_EVENT_MASK;
}
if (focusListener != null || (eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0) {
mask |= AWTEvent.FOCUS_EVENT_MASK;
}
if (keyListener != null || (eventMask & AWTEvent.KEY_EVENT_MASK) != 0) {
mask |= AWTEvent.KEY_EVENT_MASK;
}
if (mask != 0) {
parent.proxyEnableEvents(mask);
}
}
((JSComponent) this).秘setProxy(parent);
// } else {
// // It's native. If the parent is lightweight it
// // will need some help.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void pumpEventsForFilter(int id, Conditional cond, EventFilter filter) {
this.filter = filter;
this.cond = cond;
this.id = id;
run1(INIT);
super.run1(INIT);
}

// @Override
Expand Down Expand Up @@ -272,8 +272,11 @@ void pumpEventsForFilter(int id, Conditional cond, EventFilter filter) {
@SuppressWarnings("unused")
protected void dispatchAndReturn(Runnable r, int mode) {
JSThread me = this;
JSFunction f = /** @j2sNative function() {r.run$();me.run1$I(mode)}|| */ null;
JSToolkit.dispatch(f, 0, 0);
JSFunction f = /** @j2sNative function() {
r.run$();
me.run1$I(mode);
}|| */ null;
JSToolkit.dispatch(f, 1, 0);
}

private void finish() {
Expand Down
4 changes: 2 additions & 2 deletions sources/net.sf.j2s.java.core/src/java/awt/EventQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public void postEvent(AWTEvent event) {
final void postEventPrivate(AWTEvent theEvent) {
theEvent.isPosted = true;
synchronized (this) {
if (dispatchThread == null && nextQueue == null) {
if ((dispatchThread == null || !dispatchThread.isAlive()) && nextQueue == null) {
if (theEvent.getSource() == AWTAutoShutdown.getInstance()) {
return;
} else {
Expand Down Expand Up @@ -910,7 +910,7 @@ public static boolean isDispatchThread() {

final void initDispatchThread() {
synchronized (this) {
if (dispatchThread == null
if (dispatchThread == null || !dispatchThread.isAlive()
//&& !threadGroup.isDestroyed()
) {
// (EventDispatchThread) AccessController
Expand Down
71 changes: 70 additions & 1 deletion sources/net.sf.j2s.java.core/src/java/awt/JSComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
package java.awt;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import java.awt.peer.ComponentPeer;
Expand All @@ -35,7 +36,6 @@
import java.util.Arrays;

import javax.swing.Action;
import javax.swing.JApplet;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
Expand All @@ -53,6 +53,9 @@
import swingjs.JSAppletViewer;
import swingjs.JSFrameViewer;
import swingjs.JSGraphics2D;
import swingjs.JSKeyEvent;
import swingjs.JSMouse;
import swingjs.JSToolkit;
import swingjs.JSUtil;
import swingjs.api.js.DOMNode;
import swingjs.api.js.HTML5Canvas;
Expand Down Expand Up @@ -861,4 +864,70 @@ public Insets getInsets() {
}
}

public Object 秘getLastKeyListener() {
AWTEventMulticaster k = (AWTEventMulticaster) keyListener;
return (k == null ? null : /** @j2sNative k.b || k.a || */k);
}

public void 秘setProxy(Container parent) {
if (parent != null) {
long mask = 0;
if ((mouseListener != null) || ((eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0)) {
mask |= AWTEvent.MOUSE_EVENT_MASK;
}
if ((mouseMotionListener != null) || ((eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0)) {
mask |= AWTEvent.MOUSE_MOTION_EVENT_MASK;
}
if ((mouseWheelListener != null) || ((eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0)) {
mask |= AWTEvent.MOUSE_WHEEL_EVENT_MASK;
}
if (focusListener != null || (eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0) {
mask |= AWTEvent.FOCUS_EVENT_MASK;
}
if (keyListener != null || (eventMask & AWTEvent.KEY_EVENT_MASK) != 0) {
mask |= AWTEvent.KEY_EVENT_MASK;
}
if (mask != 0) {
parent.proxyEnableEvents(mask);
}
}
}

/**
* From j2sApplet vis JSMouse
* @param c
*
* @param id
* @param modifiers
* @param jqevent
* @param time
* @return
*/
public static boolean 秘dispatchKeyEvent(JComponent c, int id, Object jqevent, long time) {
if (id == 0)
id = JSMouse.fixEventType(jqevent, 0);
if (id == KeyEvent.KEY_TYPED) {
// HTML5 keypress is no longer reliable
JSToolkit.consumeEvent(jqevent);
return false;
}
if (c != null) {
JSComponentUI ui = c.秘getUI();
KeyEvent e = JSKeyEvent.newJSKeyEvent(c, jqevent, id, false);
// create our own KEY_PRESSED event
c.dispatchEvent(e);
if (!ui.j2sDoPropagate)
JSToolkit.consumeEvent(e);
if (!e.isConsumed() && id == KeyEvent.KEY_PRESSED && e.getKeyChar() != KeyEvent.CHAR_UNDEFINED) {
e = JSKeyEvent.newJSKeyEvent(c, jqevent, KeyEvent.KEY_TYPED, false);
// yield to keyboard focus manager
c.dispatchEvent(e);

if (!ui.j2sDoPropagate)
JSToolkit.consumeEvent(e);
}
}
return true;
}

}
8 changes: 4 additions & 4 deletions sources/net.sf.j2s.java.core/src/java/awt/JSPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ public void addNotify() {
// }
}

@Override
public ComponentPeer getOrCreatePeer() {
return (ui == null ? null : peer == null ? (peer = getToolkit().createPanel((Panel) (Object) this)) : peer);
}
// @Override
// public ComponentPeer getOrCreatePeer() {
// return (ui == null ? null : peer == null ? (peer = getToolkit().createPanel((Panel) (Object) this)) : peer);
// }

/**
* SwingJS added for focus management
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ public String getRequestMethod() {
*/
public int getResponseCode() throws IOException {
/*
* We're got the response code already
* We've got the response code already
*/
if (responseCode != -1) {
return responseCode;
Expand Down
Loading