source: trunk/gcc/libjava/gnu/gcj/xlib/Screen.java

Last change on this file was 2, checked in by bird, 22 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: 1.9 KB
Line 
1/* Copyright (C) 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 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 */
21public 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}
Note: See TracBrowser for help on using the repository browser.