summaryrefslogtreecommitdiff
path: root/gnu/java
diff options
context:
space:
mode:
authorMario Torre <neugens@limasoftware.net>2008-05-07 14:21:57 +0000
committerMario Torre <neugens@limasoftware.net>2008-05-07 14:21:57 +0000
commit13809b05ad9c542eae3af83d671996fb0415bfae (patch)
treebac0d94bb7a2d0234774dfb787e26673d630562e /gnu/java
parent485d2c4f9dd73e2193c1c40d6f0972a798521a7a (diff)
downloadclasspath-13809b05ad9c542eae3af83d671996fb0415bfae.tar.gz
2008-05-07 Mario Torre <neugens@aicas.com>
* gnu/java/awt/peer/x/XEventPump.java (handleEvent): xEvent.code is now masked to identify and react to syntetic events. Added UnmapNotify, DestroyNotify and ClientMessage to the list of event handled. * gnu/java/awt/peer/x/XFramePeer.java (getState): initial implementation. * gnu/java/awt/peer/x/XGraphics2D.java (setPaint): fix NPE, this is a workaround, the code have to be fixed in a better way. * gnu/java/awt/peer/x/XWindowPeer.java (getXwindow): new method to allow access to the underling xwindow. (standardSelect): add more events for notification. (XWindowPeer): call set_wm_delete_window to ask the WM to notify us when a delete event occur.
Diffstat (limited to 'gnu/java')
-rw-r--r--gnu/java/awt/peer/x/XEventPump.java39
-rw-r--r--gnu/java/awt/peer/x/XFramePeer.java3
-rw-r--r--gnu/java/awt/peer/x/XGraphics2D.java8
-rw-r--r--gnu/java/awt/peer/x/XWindowPeer.java13
4 files changed, 53 insertions, 10 deletions
diff --git a/gnu/java/awt/peer/x/XEventPump.java b/gnu/java/awt/peer/x/XEventPump.java
index 7f9843533..df144c827 100644
--- a/gnu/java/awt/peer/x/XEventPump.java
+++ b/gnu/java/awt/peer/x/XEventPump.java
@@ -47,18 +47,22 @@ import java.awt.event.ComponentEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.PaintEvent;
+import java.awt.event.WindowEvent;
import java.util.HashMap;
import gnu.x11.Display;
import gnu.x11.event.ButtonPress;
import gnu.x11.event.ButtonRelease;
+import gnu.x11.event.ClientMessage;
import gnu.x11.event.ConfigureNotify;
+import gnu.x11.event.DestroyNotify;
import gnu.x11.event.Event;
import gnu.x11.event.Expose;
import gnu.x11.event.Input;
import gnu.x11.event.KeyPress;
import gnu.x11.event.KeyRelease;
import gnu.x11.event.MotionNotify;
+import gnu.x11.event.UnmapNotify;
/**
* Fetches events from X, translates them to AWT events and pumps them up
@@ -150,13 +154,13 @@ public class XEventPump
private void handleEvent(Event xEvent)
{
-
Integer key = null;
Window awtWindow = null;
-
+ WindowEvent event = null;
+
if (XToolkit.DEBUG)
System.err.println("fetched event: " + xEvent);
- switch (xEvent.code())
+ switch (xEvent.code() & 0x7f)
{
case ButtonPress.CODE:
ButtonPress bp = (ButtonPress) xEvent;
@@ -264,6 +268,35 @@ public class XEventPump
awtWindow = (Window) windows.get(key);
handleKeyEvent(xEvent, awtWindow);
break;
+ case UnmapNotify.CODE:
+ if (XToolkit.DEBUG)
+ System.err.println("UnmapNotify event: " + xEvent);
+ key = new Integer(((UnmapNotify) xEvent).event_window_id);
+ awtWindow = (Window) windows.get(key);
+ event = new WindowEvent(awtWindow, WindowEvent.WINDOW_CLOSING);
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(event);
+ break;
+ case DestroyNotify.CODE:
+ if (XToolkit.DEBUG)
+ System.err.println("DestroyNotify event: " + xEvent);
+ key = new Integer(((DestroyNotify) xEvent).event_window_id);
+ awtWindow = (Window) windows.get(key);
+ event = new WindowEvent(awtWindow, WindowEvent.WINDOW_CLOSED);
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(event);
+ break;
+ case ClientMessage.CODE:
+ if (XToolkit.DEBUG)
+ System.err.println("ClientMessage event: " + xEvent);
+ if (((ClientMessage) xEvent).delete_window())
+ {
+ if (XToolkit.DEBUG)
+ System.err.println("ClientMessage is a delete_window event");
+ key = new Integer(((ClientMessage) xEvent).window_id);
+ awtWindow = (Window) windows.get(key);
+ event = new WindowEvent(awtWindow, WindowEvent.WINDOW_CLOSING);
+ Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(event);
+ }
+ break;
default:
if (XToolkit.DEBUG)
System.err.println("Unhandled X event: " + xEvent);
diff --git a/gnu/java/awt/peer/x/XFramePeer.java b/gnu/java/awt/peer/x/XFramePeer.java
index 7424dc671..a355c68b3 100644
--- a/gnu/java/awt/peer/x/XFramePeer.java
+++ b/gnu/java/awt/peer/x/XFramePeer.java
@@ -93,8 +93,7 @@ public class XFramePeer
public int getState()
{
- // TODO: Implement this.
- throw new UnsupportedOperationException("Not yet implemented.");
+ return 0;
}
public void setState(int state)
diff --git a/gnu/java/awt/peer/x/XGraphics2D.java b/gnu/java/awt/peer/x/XGraphics2D.java
index 95129666a..68a176f21 100644
--- a/gnu/java/awt/peer/x/XGraphics2D.java
+++ b/gnu/java/awt/peer/x/XGraphics2D.java
@@ -313,7 +313,7 @@ public class XGraphics2D
{
// TODO: Optimize for different standard bit-depths.
Color c = (Color) p;
- XToolkit tk = (XToolkit) Toolkit.getDefaultToolkit();
+ /* XToolkit tk = (XToolkit) Toolkit.getDefaultToolkit();
HashMap colorMap = tk.colorMap;
gnu.x11.Color col = (gnu.x11.Color) colorMap.get(c);
if (col == null)
@@ -323,8 +323,10 @@ public class XGraphics2D
c.getGreen() * 256,
c.getBlue() * 256);
colorMap.put(c, col);
- }
- xgc.set_foreground(col);
+ }*/
+ //xgc.set_foreground(col);
+
+ xgc.set_foreground(c.getRGB());
foreground = c;
}
}
diff --git a/gnu/java/awt/peer/x/XWindowPeer.java b/gnu/java/awt/peer/x/XWindowPeer.java
index f9184ed1c..985c9af85 100644
--- a/gnu/java/awt/peer/x/XWindowPeer.java
+++ b/gnu/java/awt/peer/x/XWindowPeer.java
@@ -73,10 +73,12 @@ public class XWindowPeer
| Event.POINTER_MOTION_MASK
//| Event.RESIZE_REDIRECT_MASK
| Event.EXPOSURE_MASK
- //| Event.PROPERTY_CHANGE_MASK
+ | Event.PROPERTY_CHANGE_MASK
| Event.STRUCTURE_NOTIFY_MASK
+ | Event.SUBSTRUCTURE_NOTIFY_MASK
| Event.KEY_PRESS_MASK
| Event.KEY_RELEASE_MASK
+ //| Event.VISIBILITY_CHANGE_MASK
;
/**
@@ -110,8 +112,10 @@ public class XWindowPeer
int h = Math.max(window.getHeight(), 1);
xwindow = new Window(dev.getDisplay().default_root, x, y, w, h, 0, atts);
xwindow.select_input(standardSelect);
+
dev.getEventPump().registerWindow(xwindow, window);
-
+ xwindow.set_wm_delete_window();
+
boolean undecorated;
if (awtComponent instanceof Frame)
{
@@ -303,4 +307,9 @@ public class XWindowPeer
XGraphicsDevice dev = XToolkit.getDefaultDevice();
dev.getEventPump().unregisterWindow(xwindow);
}
+
+ public Window getXwindow()
+ {
+ return xwindow;
+ }
}