178 |
178 |
179 alwaysOnTop = ((Window)target).isAlwaysOnTop() && ((Window)target).isAlwaysOnTopSupported(); |
179 alwaysOnTop = ((Window)target).isAlwaysOnTop() && ((Window)target).isAlwaysOnTopSupported(); |
180 |
180 |
181 GraphicsConfiguration gc = getGraphicsConfiguration(); |
181 GraphicsConfiguration gc = getGraphicsConfiguration(); |
182 ((X11GraphicsDevice)gc.getDevice()).addDisplayChangedListener(this); |
182 ((X11GraphicsDevice)gc.getDevice()).addDisplayChangedListener(this); |
183 |
|
184 Rectangle bounds = (Rectangle)(params.get(BOUNDS)); |
|
185 params.put(BOUNDS, constrainBounds(bounds.x, bounds.y, bounds.width, bounds.height)); |
|
186 } |
183 } |
187 |
184 |
188 protected String getWMName() { |
185 protected String getWMName() { |
189 String name = target.getName(); |
186 String name = target.getName(); |
190 if (name == null || name.trim().equals("")) { |
187 if (name == null || name.trim().equals("")) { |
435 |
432 |
436 public XWindowPeer getOwnerPeer() { |
433 public XWindowPeer getOwnerPeer() { |
437 return ownerPeer; |
434 return ownerPeer; |
438 } |
435 } |
439 |
436 |
440 // This method is overriden at the XDecoratedPeer to handle |
|
441 // decorated windows a bit differently. |
|
442 Rectangle constrainBounds(int x, int y, int width, int height) { |
|
443 // We don't restrict the setBounds() operation if the code is trusted. |
|
444 if (!hasWarningWindow()) { |
|
445 return new Rectangle(x, y, width, height); |
|
446 } |
|
447 |
|
448 // The window bounds should be within the visible part of the screen |
|
449 int newX = x; |
|
450 int newY = y; |
|
451 int newW = width; |
|
452 int newH = height; |
|
453 |
|
454 // Now check each point is within the visible part of the screen |
|
455 GraphicsConfiguration gc = ((Window)target).getGraphicsConfiguration(); |
|
456 Rectangle sB = gc.getBounds(); |
|
457 Insets sIn = ((Window)target).getToolkit().getScreenInsets(gc); |
|
458 |
|
459 int screenX = sB.x + sIn.left; |
|
460 int screenY = sB.y + sIn.top; |
|
461 int screenW = sB.width - sIn.left - sIn.right; |
|
462 int screenH = sB.height - sIn.top - sIn.bottom; |
|
463 |
|
464 |
|
465 // First make sure the size is withing the visible part of the screen |
|
466 if (newW > screenW) { |
|
467 newW = screenW; |
|
468 } |
|
469 |
|
470 if (newH > screenH) { |
|
471 newH = screenH; |
|
472 } |
|
473 |
|
474 // Tweak the location if needed |
|
475 if (newX < screenX) { |
|
476 newX = screenX; |
|
477 } else if (newX + newW > screenX + screenW) { |
|
478 newX = screenX + screenW - newW; |
|
479 } |
|
480 |
|
481 if (newY < screenY) { |
|
482 newY = screenY; |
|
483 } else if (newY + newH > screenY + screenH) { |
|
484 newY = screenY + screenH - newH; |
|
485 } |
|
486 |
|
487 return new Rectangle(newX, newY, newW, newH); |
|
488 } |
|
489 |
|
490 //Fix for 6318144: PIT:Setting Min Size bigger than current size enlarges |
437 //Fix for 6318144: PIT:Setting Min Size bigger than current size enlarges |
491 //the window but fails to revalidate, Sol-CDE |
438 //the window but fails to revalidate, Sol-CDE |
492 //This bug is regression for |
439 //This bug is regression for |
493 //5025858: Resizing a decorated frame triggers componentResized event twice. |
440 //5025858: Resizing a decorated frame triggers componentResized event twice. |
494 //Since events are not posted from Component.setBounds we need to send them here. |
441 //Since events are not posted from Component.setBounds we need to send them here. |
495 //Note that this function is overriden in XDecoratedPeer so event |
442 //Note that this function is overriden in XDecoratedPeer so event |
496 //posting is not changing for decorated peers |
443 //posting is not changing for decorated peers |
497 public void setBounds(int x, int y, int width, int height, int op) { |
444 public void setBounds(int x, int y, int width, int height, int op) { |
498 Rectangle newBounds = constrainBounds(x, y, width, height); |
|
499 |
|
500 XToolkit.awtLock(); |
445 XToolkit.awtLock(); |
501 try { |
446 try { |
502 Rectangle oldBounds = getBounds(); |
447 Rectangle oldBounds = getBounds(); |
503 |
448 |
504 super.setBounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height, op); |
449 super.setBounds(x, y, width, height, op); |
505 |
450 |
506 Rectangle bounds = getBounds(); |
451 Rectangle bounds = getBounds(); |
507 |
452 |
508 XSizeHints hints = getHints(); |
453 XSizeHints hints = getHints(); |
509 setSizeHints(hints.get_flags() | XUtilConstants.PPosition | XUtilConstants.PSize, |
454 setSizeHints(hints.get_flags() | XUtilConstants.PPosition | XUtilConstants.PSize, |