2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / gnu / gcj / xlib / Display.java
blob50ff1291b71b2a8282cf3d5cab5cf1434d37df08
1 /* Copyright (C) 1999, 2000 Free Software Foundation
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
7 details. */
9 package gnu.gcj.xlib;
11 import java.util.Dictionary;
12 import java.util.Hashtable;
13 import java.util.Vector;
14 import java.util.Enumeration;
16 import gnu.gcj.RawData;
18 /**
19 * A connection to an X11 display.
21 * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
24 public class Display
26 static
28 staticInit();
31 public Display()
33 init();
36 private static native void staticInit();
37 private native void init();
38 protected native void finalize();
40 RawData display = null;
42 /* TODO?: Rather than storing such data here, we might consider
43 using the context manager facilities provided by Xlib... */
44 private Dictionary xids = new Hashtable();
46 protected final void addXID(int xid, XID window)
48 xids.put(new Integer(xid), window);
51 protected final void removeXID(int xid)
53 xids.remove(new Integer(xid));
56 public final Window getDefaultRootWindow()
58 int rootXID = getDefaultRootWindowXID();
59 return getWindow(rootXID);
62 public final XID getXID(int xid)
64 return (XID) xids.get(new Integer(xid));
67 public final Window getWindow(int xid)
69 Window window = (Window) getXID(xid);
70 if (window == null)
72 window = new Window(this, xid);
73 addXID(xid, window);
75 return window;
78 public final Screen getDefaultScreen()
80 /* Screens objects are not cached since they are lightweight.
81 We just create a new object when requested. */
82 return new Screen(this, getDefaultScreenNumber());
85 public final native int getDefaultScreenNumber();
87 private final native int getDefaultRootWindowXID();
89 private Dictionary atoms = new Hashtable();
91 public final int getAtom(String name)
93 Integer atomInt = (Integer) atoms.get(name);
94 if (atomInt == null)
95 return internAtom(name);
96 return atomInt.intValue();
99 // TODO?: cache reverse lookup too?
100 public final native String getAtomName(int atom);
102 private final native int internAtom(String name);
104 public native void flush();