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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
/* Copyright (C) 2000, 2002, 2003 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.awt.xlib;
import java.awt.*;
import java.awt.peer.*;
import java.awt.image.*;
import gnu.gcj.xlib.WMSizeHints;
import gnu.gcj.xlib.WindowAttributes;
import gnu.gcj.xlib.Display;
import gnu.gcj.xlib.Visual;
import gnu.gcj.xlib.Screen;
import gnu.gcj.xlib.XConfigureEvent;
/** FIXME: a lot of the code here should be moved down to XWindowPeer. */
public class XFramePeer extends XCanvasPeer implements FramePeer
{
private boolean processingConfigureNotify = false;
public XFramePeer(Frame frame)
{
super(frame);
// Set some defaults for a toplevel component:
if (frame.getFont() == null)
frame.setFont(new Font("helvetica", Font.PLAIN, 12));
if (frame.getBackground() == null)
frame.setBackground(Color.lightGray);
if (frame.getForeground() == null)
frame.setForeground(Color.black);
}
/** Find parent window for toplevel window, ie. root window of
selected screen. Bounds are not changed. */
gnu.gcj.xlib.Window locateParentWindow(Rectangle bounds)
{
Screen screen = config.getVisual().getScreen();
return screen.getRootWindow();
}
void initWindowProperties()
{
Frame frame = (Frame) component;
setResizable(frame.isResizable());
String title = frame.getTitle();
if (!title.equals("")) setTitle(title);
}
long getBasicEventMask()
{
return super.getBasicEventMask() |
WindowAttributes.MASK_STRUCTURE_NOTIFY;
}
void configureNotify(XConfigureEvent configEvent)
{
processingConfigureNotify = true; // to avoid setBounds flood
component.setBounds(configEvent.getBounds());
processingConfigureNotify = false;
}
/* Overridden to ignore request to set bounds if the request occurs
while processing an XConfigureNotify event, in which case the X
window already has the desired bounds.
That's what java.awt.Window.setBoundsCallback is for, but it's
package-private, and using our own flag eliminates the need to
circumvent java security.
*/
public void setBounds(int x, int y, int width, int height)
{
if (!processingConfigureNotify)
super.setBounds(x, y, width, height);
}
// Implementing ContainerPeer:
static final Insets INSETS_0_PROTOTYPE = new Insets(0, 0, 0, 0);
public Insets getInsets()
{
return (Insets) INSETS_0_PROTOTYPE.clone();
}
public Insets insets ()
{
return getInsets ();
}
public void beginValidate()
{
}
public void endValidate()
{
// reassert sizing hints
Frame frame = (Frame) component;
setResizable(frame.isResizable());
}
// Implementing WindowPeer:
public void toBack()
{
window.toBack ();
}
public void toFront()
{
window.toFront ();
}
// Implementing FramePeer:
public void setIconImage(Image image)
{
throw new UnsupportedOperationException("not implemented yet");
}
public void setMenuBar(MenuBar mb)
{
throw new UnsupportedOperationException("not implemented yet");
}
public void setTitle(String title)
{
synchronized (window.getDisplay())
{
// Oh, what a nice implementation :-)
window.setProperty("WM_NAME", "STRING", title);
ensureFlush();
}
}
public void setResizable(boolean resizable)
{
Frame frame = (Frame) component;
WMSizeHints sizeHints = new WMSizeHints();
if (resizable)
{
Dimension minSize = frame.getMinimumSize();
sizeHints.setMinSize(minSize.width, minSize.height);
Dimension maxSize = frame.getMaximumSize();
if ((maxSize.width < Short.MAX_VALUE) ||
(maxSize.height < Short.MAX_VALUE))
{
maxSize.width = Math.min(maxSize.width, Short.MAX_VALUE);
maxSize.height = Math.min(maxSize.height, Short.MAX_VALUE);
sizeHints.setMaxSize(maxSize.width, maxSize.height);
}
}
else
{
// lock resizing to current bounds
Dimension size = frame.getSize();
sizeHints.setMinSize(size.width, size.height);
sizeHints.setMaxSize(size.width, size.height);
}
sizeHints.applyNormalHints(window);
}
public int getState ()
{
return 0;
}
public void setState (int state)
{
}
public void setMaximizedBounds (Rectangle r)
{
}
public void beginLayout () { }
public void endLayout () { }
public boolean isPaintPending () { return false; }
/**
* @since 1.5
*/
public void setBoundsPrivate (int x, int y, int width, int height)
{
// TODO: Implement this.
throw new UnsupportedOperationException("Not yet implemented.");
}
public Rectangle getBoundsPrivate()
{
// TODO: Implement this.
throw new UnsupportedOperationException("Not yet implemented.");
}
/**
* @since 1.5
*/
public void updateAlwaysOnTop()
{
}
/**
* @since 1.5
*/
public boolean requestWindowFocus ()
{
return false;
}
public void setAlwaysOnTop(boolean alwaysOnTop)
{
throw new UnsupportedOperationException("not implemented yet");
}
public void updateFocusableWindowState()
{
throw new UnsupportedOperationException("not implemented yet");
}
public void setModalBlocked(Dialog blocker, boolean blocked)
{
throw new UnsupportedOperationException("not implemented yet");
}
public void updateMinimumSize()
{
throw new UnsupportedOperationException("not implemented yet");
}
public void updateIconImages()
{
throw new UnsupportedOperationException("not implemented yet");
}
}
|