blob: 50ff1291b71b2a8282cf3d5cab5cf1434d37df08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/* Copyright (C) 1999, 2000 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package gnu.gcj.xlib;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Vector;
import java.util.Enumeration;
import gnu.gcj.RawData;
/**
* A connection to an X11 display.
*
* @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
*/
public class Display
{
static
{
staticInit();
}
public Display()
{
init();
}
private static native void staticInit();
private native void init();
protected native void finalize();
RawData display = null;
/* TODO?: Rather than storing such data here, we might consider
using the context manager facilities provided by Xlib... */
private Dictionary xids = new Hashtable();
protected final void addXID(int xid, XID window)
{
xids.put(new Integer(xid), window);
}
protected final void removeXID(int xid)
{
xids.remove(new Integer(xid));
}
public final Window getDefaultRootWindow()
{
int rootXID = getDefaultRootWindowXID();
return getWindow(rootXID);
}
public final XID getXID(int xid)
{
return (XID) xids.get(new Integer(xid));
}
public final Window getWindow(int xid)
{
Window window = (Window) getXID(xid);
if (window == null)
{
window = new Window(this, xid);
addXID(xid, window);
}
return window;
}
public final Screen getDefaultScreen()
{
/* Screens objects are not cached since they are lightweight.
We just create a new object when requested. */
return new Screen(this, getDefaultScreenNumber());
}
public final native int getDefaultScreenNumber();
private final native int getDefaultRootWindowXID();
private Dictionary atoms = new Hashtable();
public final int getAtom(String name)
{
Integer atomInt = (Integer) atoms.get(name);
if (atomInt == null)
return internAtom(name);
return atomInt.intValue();
}
// TODO?: cache reverse lookup too?
public final native String getAtomName(int atom);
private final native int internAtom(String name);
public native void flush();
}
|