x & C -> x if we know that x & ~C == 0
[official-gcc.git] / libjava / gnu / gcj / xlib / Screen.java
blob675ed1b9bd0650f4301b799a39133490947d9113
1 /* Copyright (C) 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 gnu.gcj.RawData;
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.
19 * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
21 public final class Screen
23 static final int UNKNOWN = -1;
25 Display display;
26 int screenNumber = UNKNOWN;
27 RawData structure;
29 Screen(Display display, RawData screenStructure)
31 structure = screenStructure;
32 this.display = display;
35 public Screen(Display display)
37 this(display, display.getDefaultScreenNumber());
40 public Screen(Display display, int screenNumber)
42 this.display = display;
43 this.screenNumber = screenNumber;
44 initStructure();
47 public final Display getDisplay()
49 return display;
52 public Window getRootWindow()
54 int rootXID = getRootWindowXID();
55 return display.getWindow(rootXID);
58 public Visual getRootVisual()
60 RawData visualStructure = getRootVisualStructure();
61 int depth = getRootDepth();
62 return new Visual(visualStructure, this, depth);
65 private native RawData getRootVisualStructure();
67 public native int getRootDepth();
68 public native int getRootWindowXID();
69 public native int getDefaultColormapXID();
71 native void initStructure();
73 public Colormap getDefaultColormap()
75 return new Colormap(this, getDefaultColormapXID());
78 public final int getScreenNumber()
80 if (screenNumber == UNKNOWN)
81 screenNumber = findScreenNumber();
82 return screenNumber;
85 public native int findScreenNumber();