summaryrefslogtreecommitdiff
path: root/libjava/gnu/gcj/xlib/WindowAttributes.java
blob: 23be37d6363ae47f48a2f42edf980b87603f13ce (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
106
107
108
109
110
111
112
113
114
/* Copyright (C) 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 gnu.gcj.RawData;

/**
 * 
 * Collection of attributes that can be applied to or read from an
 * X11 window.
 *
 * <p>TODO: Split this class into two classes. One for the structure
 * XSetWindowAttributes and one for the XWindowAttributes.  However
 * they should still share this common base class.
 *
 * @author Rolf W. Rasmussen <rolfwr@ii.uib.no> */
public class WindowAttributes
{
  // Must match definitions in X.h:
  public final static long MASK_BUTTON_PRESS     = 1L<< 2,
                           MASK_BUTTON_RELEASE   = 1L<< 3,
                           MASK_EXPOSURE         = 1L<<15,
                           MASK_STRUCTURE_NOTIFY = 1L<<17;

  public WindowAttributes()
  {
    init(null);
  }
  
  public WindowAttributes(Window from)
  {
    initFromWindow(from);
  }

  private native void initFromWindow(Window from);
  private native void init(WindowAttributes copyFrom);
  protected native void finalize();
    
  public Object clone()
  {
    try
      {
	WindowAttributes attributes = (WindowAttributes) super.clone();
	// In case of an exception before the stucture is copied.
	attributes.in  = null;
	attributes.out = null;
	
	// FIXME: do anything else?
	
	attributes.init(this);
	return attributes;
      }
    catch (CloneNotSupportedException ex)
      {
	// This should never happen.
	throw new InternalError ();
      }
  }

  public native void setBackground(long pixel);
  public native void setBackground(Pixmap pixmap);
  public native void setEventMask(long eventMask);

  public void setVisual(Visual visual)
  {
    this.visual = visual;
  }

  /**
   * Retrieve the visual. 
   *
   * @return the visual that is or should be used by a window.  null
   * means CopyFormParent. 
   */
  public native Visual getVisual();

  Display display;

  /**
   * Reference to XWindowAttribute structure containing attributes
   * read from a window.
   */
  RawData in = null;

  /**
   * Reference to XSetWindowAttribute structure containing attributes
   * to be applied to a window.
   */
  RawData out = null;

  long mask;

  /** null means CopyFromParent during window creation. */
  Visual visual = null;

  public native void apply(Window window);

  final RawData getXSetWindowAttributesStructure()
  {
    if (out == null)
      initOut();
    return out;
  }
  
  void initOut()
  {
    throw new UnsupportedOperationException("not implemented yet");
  }
}