41 |
import java.awt.Component; |
import java.awt.Component; |
42 |
import java.awt.Frame; |
import java.awt.Frame; |
43 |
import java.awt.Window; |
import java.awt.Window; |
44 |
|
import java.awt.event.ComponentEvent; |
45 |
import java.awt.event.WindowEvent; |
import java.awt.event.WindowEvent; |
46 |
import java.awt.peer.WindowPeer; |
import java.awt.peer.WindowPeer; |
47 |
|
|
105 |
{ |
{ |
106 |
} |
} |
107 |
|
|
108 |
|
public native void setVisibleNative (boolean b); |
109 |
|
public native void setVisibleNativeUnlocked (boolean b); |
110 |
|
|
111 |
native void connectSignals (); |
native void connectSignals (); |
112 |
|
|
113 |
public GtkWindowPeer (Window window) |
public GtkWindowPeer (Window window) |
119 |
public native void toFront(); |
public native void toFront(); |
120 |
|
|
121 |
native void nativeSetBounds (int x, int y, int width, int height); |
native void nativeSetBounds (int x, int y, int width, int height); |
122 |
|
native void nativeSetBoundsUnlocked (int x, int y, int width, int height); |
123 |
|
|
124 |
public void setBounds (int x, int y, int width, int height) |
public void setBounds (int x, int y, int width, int height) |
125 |
{ |
{ |
126 |
|
// prevent window_configure_cb -> awtComponent.setSize -> |
127 |
|
// peer.setBounds -> nativeSetBounds self-deadlock on GDK lock. |
128 |
|
if (Thread.currentThread() == GtkToolkit.mainThread) |
129 |
|
return; |
130 |
|
|
131 |
nativeSetBounds (x, y, |
nativeSetBounds (x, y, |
132 |
width - insets.left - insets.right, |
width - insets.left - insets.right, |
133 |
height - insets.top - insets.bottom); |
height - insets.top - insets.bottom); |
134 |
} |
} |
135 |
|
|
136 |
|
public void setBoundsUnlocked (int x, int y, int width, int height) |
137 |
|
{ |
138 |
|
nativeSetBoundsUnlocked (x, y, |
139 |
|
width - insets.left - insets.right, |
140 |
|
height - insets.top - insets.bottom); |
141 |
|
} |
142 |
|
|
143 |
public void setTitle (String title) |
public void setTitle (String title) |
144 |
{ |
{ |
145 |
gtkWindowSetTitle (title); |
gtkWindowSetTitle (title); |
157 |
gtkWindowSetResizable (resizable); |
gtkWindowSetResizable (resizable); |
158 |
} |
} |
159 |
|
|
|
native void setBoundsCallback (Window window, |
|
|
int x, int y, |
|
|
int width, int height); |
|
|
|
|
160 |
protected void postInsetsChangedEvent (int top, int left, |
protected void postInsetsChangedEvent (int top, int left, |
161 |
int bottom, int right) |
int bottom, int right) |
162 |
{ |
{ |
166 |
insets.right = right; |
insets.right = right; |
167 |
} |
} |
168 |
|
|
169 |
|
// called back by native side: window_configure_cb |
170 |
|
// only called from GTK thread |
171 |
protected void postConfigureEvent (int x, int y, int width, int height) |
protected void postConfigureEvent (int x, int y, int width, int height) |
172 |
{ |
{ |
|
int frame_x = x - insets.left; |
|
|
int frame_y = y - insets.top; |
|
173 |
int frame_width = width + insets.left + insets.right; |
int frame_width = width + insets.left + insets.right; |
174 |
int frame_height = height + insets.top + insets.bottom; |
int frame_height = height + insets.top + insets.bottom; |
175 |
|
|
176 |
if (frame_x != awtComponent.getX() |
if (frame_width != awtComponent.getWidth() |
|
|| frame_y != awtComponent.getY() |
|
|
|| frame_width != awtComponent.getWidth() |
|
177 |
|| frame_height != awtComponent.getHeight()) |
|| frame_height != awtComponent.getHeight()) |
178 |
{ |
awtComponent.setSize(frame_width, frame_height); |
|
setBoundsCallback ((Window) awtComponent, |
|
|
frame_x, frame_y, frame_width, frame_height); |
|
179 |
|
|
180 |
awtComponent.validate(); |
int frame_x = x - insets.left; |
181 |
|
int frame_y = y - insets.top; |
182 |
|
|
183 |
|
if (frame_x != awtComponent.getX() |
184 |
|
|| frame_y != awtComponent.getY()) |
185 |
|
{ |
186 |
|
// awtComponent.setLocation(frame_x, frame_y); |
187 |
} |
} |
188 |
} |
} |
189 |
|
|
190 |
native void nativeSetVisible (boolean b); |
public void show () |
|
public void setVisible (boolean b) |
|
191 |
{ |
{ |
192 |
// Prevent the window manager from automatically placing this |
// Prevent the window manager from automatically placing this |
193 |
// window when it is shown. |
// window when it is shown. |
194 |
if (b) |
setBounds (awtComponent.getX(), |
195 |
setBounds (awtComponent.getX(), |
awtComponent.getY(), |
196 |
awtComponent.getY(), |
awtComponent.getWidth(), |
197 |
awtComponent.getWidth(), |
awtComponent.getHeight()); |
198 |
awtComponent.getHeight()); |
setVisible (true); |
|
nativeSetVisible (b); |
|
199 |
} |
} |
200 |
|
|
201 |
void postWindowEvent (int id, Window opposite, int newState) |
void postWindowEvent (int id, Window opposite, int newState) |
222 |
else |
else |
223 |
q().postEvent (new WindowEvent ((Window) awtComponent, id, opposite)); |
q().postEvent (new WindowEvent ((Window) awtComponent, id, opposite)); |
224 |
} |
} |
225 |
|
public void updateAlwaysOnTop() |
226 |
|
{ |
227 |
|
// TODO Auto-generated method stub |
228 |
|
|
229 |
|
} |
230 |
|
public boolean requestWindowFocus() |
231 |
|
{ |
232 |
|
// TODO Auto-generated method stub |
233 |
|
return false; |
234 |
|
} |
235 |
} |
} |