1 | /* Copyright (C) 2000 Free Software Foundation
|
---|
2 |
|
---|
3 | This file is part of libgcj.
|
---|
4 |
|
---|
5 | This software is copyrighted work licensed under the terms of the
|
---|
6 | Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
---|
7 | details. */
|
---|
8 |
|
---|
9 | package gnu.gcj.xlib;
|
---|
10 |
|
---|
11 | import gnu.gcj.RawData;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * A flyweight class that denotes an X11 screen. Display and screen
|
---|
15 | * number is the only data kept by this class. The real screen
|
---|
16 | * structure is stored in the display. There may exist several
|
---|
17 | * objects denoting the same screen.
|
---|
18 | *
|
---|
19 | * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
|
---|
20 | */
|
---|
21 | public final class Screen
|
---|
22 | {
|
---|
23 | static final int UNKNOWN = -1;
|
---|
24 |
|
---|
25 | Display display;
|
---|
26 | int screenNumber = UNKNOWN;
|
---|
27 | RawData structure;
|
---|
28 |
|
---|
29 | Screen(Display display, RawData screenStructure)
|
---|
30 | {
|
---|
31 | structure = screenStructure;
|
---|
32 | this.display = display;
|
---|
33 | }
|
---|
34 |
|
---|
35 | public Screen(Display display)
|
---|
36 | {
|
---|
37 | this(display, display.getDefaultScreenNumber());
|
---|
38 | }
|
---|
39 |
|
---|
40 | public Screen(Display display, int screenNumber)
|
---|
41 | {
|
---|
42 | this.display = display;
|
---|
43 | this.screenNumber = screenNumber;
|
---|
44 | initStructure();
|
---|
45 | }
|
---|
46 |
|
---|
47 | public final Display getDisplay()
|
---|
48 | {
|
---|
49 | return display;
|
---|
50 | }
|
---|
51 |
|
---|
52 | public Window getRootWindow()
|
---|
53 | {
|
---|
54 | int rootXID = getRootWindowXID();
|
---|
55 | return display.getWindow(rootXID);
|
---|
56 | }
|
---|
57 |
|
---|
58 | public Visual getRootVisual()
|
---|
59 | {
|
---|
60 | RawData visualStructure = getRootVisualStructure();
|
---|
61 | int depth = getRootDepth();
|
---|
62 | return new Visual(visualStructure, this, depth);
|
---|
63 | }
|
---|
64 |
|
---|
65 | private native RawData getRootVisualStructure();
|
---|
66 |
|
---|
67 | public native int getRootDepth();
|
---|
68 | public native int getRootWindowXID();
|
---|
69 | public native int getDefaultColormapXID();
|
---|
70 |
|
---|
71 | native void initStructure();
|
---|
72 |
|
---|
73 | public Colormap getDefaultColormap()
|
---|
74 | {
|
---|
75 | return new Colormap(this, getDefaultColormapXID());
|
---|
76 | }
|
---|
77 |
|
---|
78 | public final int getScreenNumber()
|
---|
79 | {
|
---|
80 | if (screenNumber == UNKNOWN)
|
---|
81 | screenNumber = findScreenNumber();
|
---|
82 | return screenNumber;
|
---|
83 | }
|
---|
84 |
|
---|
85 | public native int findScreenNumber();
|
---|
86 | }
|
---|