source: trunk/src/gcc/libjava/gnu/gcj/xlib/Display.java@ 1519

Last change on this file since 1519 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.2 KB
Line 
1/* Copyright (C) 1999, 2000 Free Software Foundation
2
3 This file is part of libgcj.
4
5This software is copyrighted work licensed under the terms of the
6Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
7details. */
8
9package gnu.gcj.xlib;
10
11import java.util.Dictionary;
12import java.util.Hashtable;
13import java.util.Vector;
14import java.util.Enumeration;
15
16import gnu.gcj.RawData;
17
18/**
19 * A connection to an X11 display.
20 *
21 * @author Rolf W. Rasmussen <[email protected]>
22 */
23
24public class Display
25{
26 static
27 {
28 staticInit();
29 }
30
31 public Display()
32 {
33 init();
34 }
35
36 private static native void staticInit();
37 private native void init();
38 protected native void finalize();
39
40 RawData display = null;
41
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();
45
46 protected final void addXID(int xid, XID window)
47 {
48 xids.put(new Integer(xid), window);
49 }
50
51 protected final void removeXID(int xid)
52 {
53 xids.remove(new Integer(xid));
54 }
55
56 public final Window getDefaultRootWindow()
57 {
58 int rootXID = getDefaultRootWindowXID();
59 return getWindow(rootXID);
60 }
61
62 public final XID getXID(int xid)
63 {
64 return (XID) xids.get(new Integer(xid));
65 }
66
67 public final Window getWindow(int xid)
68 {
69 Window window = (Window) getXID(xid);
70 if (window == null)
71 {
72 window = new Window(this, xid);
73 addXID(xid, window);
74 }
75 return window;
76 }
77
78 public final Screen getDefaultScreen()
79 {
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());
83 }
84
85 public final native int getDefaultScreenNumber();
86
87 private final native int getDefaultRootWindowXID();
88
89 private Dictionary atoms = new Hashtable();
90
91 public final int getAtom(String name)
92 {
93 Integer atomInt = (Integer) atoms.get(name);
94 if (atomInt == null)
95 return internAtom(name);
96 return atomInt.intValue();
97 }
98
99 // TODO?: cache reverse lookup too?
100 public final native String getAtomName(int atom);
101
102 private final native int internAtom(String name);
103
104 public native void flush();
105}
Note: See TracBrowser for help on using the repository browser.