159 while (owner != null) {
160 owner = owner.getOwner();
161 if (owner instanceof Frame) {
162 return (Frame) owner;
163 }
164 }
165 // could get here if passed Window is an owner-less Dialog
166 return null;
167 }
168
169 private boolean fsStatus;
170 private Rectangle ownerOrigBounds = null;
171 private boolean ownerWasVisible;
172 private Window realFSWindow;
173 private WindowListener fsWindowListener;
174 private boolean fsWindowWasAlwaysOnTop;
175 private static native boolean enterFullScreenExclusiveNative(int screen,
176 long hwnd);
177
178 @Override
179 protected void enterFullScreenExclusive(final int screen, WindowPeer wp)
180 {
181 final WWindowPeer wpeer = (WWindowPeer)realFSWindow.getPeer();
182
183 D3DRenderQueue rq = D3DRenderQueue.getInstance();
184 rq.lock();
185 try {
186 rq.flushAndInvokeNow(new Runnable() {
187 public void run() {
188 long hwnd = wpeer.getHWnd();
189 if (hwnd == 0l) {
190 // window is disposed
191 fsStatus = false;
192 return;
193 }
194 fsStatus = enterFullScreenExclusiveNative(screen, hwnd);
195 }
196 });
197 } finally {
198 rq.unlock();
229 * This is a problem for windows for which we do not do any d3d-related
230 * operations (like when we disabled on-screen rendering).
231 *
232 * REMIND: we create an instance per each full-screen device while a single
233 * instance would suffice (but requires more management).
234 */
235 private static class D3DFSWindowAdapter extends WindowAdapter {
236 @Override
237 @SuppressWarnings("static")
238 public void windowDeactivated(WindowEvent e) {
239 D3DRenderQueue.getInstance().restoreDevices();
240 }
241 @Override
242 @SuppressWarnings("static")
243 public void windowActivated(WindowEvent e) {
244 D3DRenderQueue.getInstance().restoreDevices();
245 }
246 }
247
248 @Override
249 protected void addFSWindowListener(Window w) {
250 // if the window is not a toplevel (has an owner) we have to use the
251 // real toplevel to enter the full-screen mode with (4933099).
252 if (!(w instanceof Frame) && !(w instanceof Dialog) &&
253 (realFSWindow = getToplevelOwner(w)) != null)
254 {
255 ownerOrigBounds = realFSWindow.getBounds();
256 WWindowPeer fp = (WWindowPeer)realFSWindow.getPeer();
257
258 ownerWasVisible = realFSWindow.isVisible();
259 Rectangle r = w.getBounds();
260 // we use operations on peer instead of component because calling
261 // them on component will take the tree lock
262 fp.reshape(r.x, r.y, r.width, r.height);
263 fp.setVisible(true);
264 } else {
265 realFSWindow = w;
266 }
267
268 fsWindowWasAlwaysOnTop = realFSWindow.isAlwaysOnTop();
269 ((WWindowPeer)realFSWindow.getPeer()).setAlwaysOnTop(true);
270
271 fsWindowListener = new D3DFSWindowAdapter();
272 realFSWindow.addWindowListener(fsWindowListener);
273 }
274
275 @Override
276 protected void removeFSWindowListener(Window w) {
277 realFSWindow.removeWindowListener(fsWindowListener);
278 fsWindowListener = null;
279
280 /**
281 * Bug 4933099: There is some funny-business to deal with when this
282 * method is called with a Window instead of a Frame. See 4836744
283 * for more information on this. One side-effect of our workaround
284 * for the problem is that the owning Frame of a Window may end
285 * up getting resized during the fullscreen process. When we
286 * return from fullscreen mode, we should resize the Frame to
287 * its original size (just like the Window is being resized
288 * to its original size in GraphicsDevice).
289 */
290 WWindowPeer wpeer = (WWindowPeer)realFSWindow.getPeer();
291 if (wpeer != null) {
292 if (ownerOrigBounds != null) {
293 // if the window went into fs mode before it was realized it
294 // could have (0,0) dimensions
295 if (ownerOrigBounds.width == 0) ownerOrigBounds.width = 1;
320 };
321 final Result res = new Result();
322 rq.flushAndInvokeNow(new Runnable() {
323 public void run() {
324 res.dm = getCurrentDisplayModeNative(screen);
325 }
326 });
327 if (res.dm == null) {
328 return super.getCurrentDisplayMode(screen);
329 }
330 return res.dm;
331 } finally {
332 rq.unlock();
333 }
334 }
335 private static native void configDisplayModeNative(int screen, long hwnd,
336 int width, int height,
337 int bitDepth,
338 int refreshRate);
339 @Override
340 protected void configDisplayMode(final int screen, final WindowPeer w,
341 final int width, final int height,
342 final int bitDepth, final int refreshRate)
343 {
344 // we entered fs mode via gdi
345 if (!fsStatus) {
346 super.configDisplayMode(screen, w, width, height, bitDepth,
347 refreshRate);
348 return;
349 }
350
351 final WWindowPeer wpeer = (WWindowPeer)realFSWindow.getPeer();
352
353 // REMIND: we do this before we switch the display mode, so
354 // the dimensions may be exceeding the dimensions of the screen,
355 // is this a problem?
356
357 // update the bounds of the owner frame
358 if (getFullScreenWindow() != realFSWindow) {
359 Rectangle screenBounds = getDefaultConfiguration().getBounds();
|
159 while (owner != null) {
160 owner = owner.getOwner();
161 if (owner instanceof Frame) {
162 return (Frame) owner;
163 }
164 }
165 // could get here if passed Window is an owner-less Dialog
166 return null;
167 }
168
169 private boolean fsStatus;
170 private Rectangle ownerOrigBounds = null;
171 private boolean ownerWasVisible;
172 private Window realFSWindow;
173 private WindowListener fsWindowListener;
174 private boolean fsWindowWasAlwaysOnTop;
175 private static native boolean enterFullScreenExclusiveNative(int screen,
176 long hwnd);
177
178 @Override
179 @SuppressWarnings("deprecation")
180 protected void enterFullScreenExclusive(final int screen, WindowPeer wp)
181 {
182 final WWindowPeer wpeer = (WWindowPeer)realFSWindow.getPeer();
183
184 D3DRenderQueue rq = D3DRenderQueue.getInstance();
185 rq.lock();
186 try {
187 rq.flushAndInvokeNow(new Runnable() {
188 public void run() {
189 long hwnd = wpeer.getHWnd();
190 if (hwnd == 0l) {
191 // window is disposed
192 fsStatus = false;
193 return;
194 }
195 fsStatus = enterFullScreenExclusiveNative(screen, hwnd);
196 }
197 });
198 } finally {
199 rq.unlock();
230 * This is a problem for windows for which we do not do any d3d-related
231 * operations (like when we disabled on-screen rendering).
232 *
233 * REMIND: we create an instance per each full-screen device while a single
234 * instance would suffice (but requires more management).
235 */
236 private static class D3DFSWindowAdapter extends WindowAdapter {
237 @Override
238 @SuppressWarnings("static")
239 public void windowDeactivated(WindowEvent e) {
240 D3DRenderQueue.getInstance().restoreDevices();
241 }
242 @Override
243 @SuppressWarnings("static")
244 public void windowActivated(WindowEvent e) {
245 D3DRenderQueue.getInstance().restoreDevices();
246 }
247 }
248
249 @Override
250 @SuppressWarnings("deprecation")
251 protected void addFSWindowListener(Window w) {
252 // if the window is not a toplevel (has an owner) we have to use the
253 // real toplevel to enter the full-screen mode with (4933099).
254 if (!(w instanceof Frame) && !(w instanceof Dialog) &&
255 (realFSWindow = getToplevelOwner(w)) != null)
256 {
257 ownerOrigBounds = realFSWindow.getBounds();
258 WWindowPeer fp = (WWindowPeer)realFSWindow.getPeer();
259
260 ownerWasVisible = realFSWindow.isVisible();
261 Rectangle r = w.getBounds();
262 // we use operations on peer instead of component because calling
263 // them on component will take the tree lock
264 fp.reshape(r.x, r.y, r.width, r.height);
265 fp.setVisible(true);
266 } else {
267 realFSWindow = w;
268 }
269
270 fsWindowWasAlwaysOnTop = realFSWindow.isAlwaysOnTop();
271 ((WWindowPeer)realFSWindow.getPeer()).setAlwaysOnTop(true);
272
273 fsWindowListener = new D3DFSWindowAdapter();
274 realFSWindow.addWindowListener(fsWindowListener);
275 }
276
277 @Override
278 @SuppressWarnings("deprecation")
279 protected void removeFSWindowListener(Window w) {
280 realFSWindow.removeWindowListener(fsWindowListener);
281 fsWindowListener = null;
282
283 /**
284 * Bug 4933099: There is some funny-business to deal with when this
285 * method is called with a Window instead of a Frame. See 4836744
286 * for more information on this. One side-effect of our workaround
287 * for the problem is that the owning Frame of a Window may end
288 * up getting resized during the fullscreen process. When we
289 * return from fullscreen mode, we should resize the Frame to
290 * its original size (just like the Window is being resized
291 * to its original size in GraphicsDevice).
292 */
293 WWindowPeer wpeer = (WWindowPeer)realFSWindow.getPeer();
294 if (wpeer != null) {
295 if (ownerOrigBounds != null) {
296 // if the window went into fs mode before it was realized it
297 // could have (0,0) dimensions
298 if (ownerOrigBounds.width == 0) ownerOrigBounds.width = 1;
323 };
324 final Result res = new Result();
325 rq.flushAndInvokeNow(new Runnable() {
326 public void run() {
327 res.dm = getCurrentDisplayModeNative(screen);
328 }
329 });
330 if (res.dm == null) {
331 return super.getCurrentDisplayMode(screen);
332 }
333 return res.dm;
334 } finally {
335 rq.unlock();
336 }
337 }
338 private static native void configDisplayModeNative(int screen, long hwnd,
339 int width, int height,
340 int bitDepth,
341 int refreshRate);
342 @Override
343 @SuppressWarnings("deprecation")
344 protected void configDisplayMode(final int screen, final WindowPeer w,
345 final int width, final int height,
346 final int bitDepth, final int refreshRate)
347 {
348 // we entered fs mode via gdi
349 if (!fsStatus) {
350 super.configDisplayMode(screen, w, width, height, bitDepth,
351 refreshRate);
352 return;
353 }
354
355 final WWindowPeer wpeer = (WWindowPeer)realFSWindow.getPeer();
356
357 // REMIND: we do this before we switch the display mode, so
358 // the dimensions may be exceeding the dimensions of the screen,
359 // is this a problem?
360
361 // update the bounds of the owner frame
362 if (getFullScreenWindow() != realFSWindow) {
363 Rectangle screenBounds = getDefaultConfiguration().getBounds();
|