use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class Dialog method modalityPopped.
final void modalityPopped() {
Toolkit tk = Toolkit.getDefaultToolkit();
if (tk instanceof SunToolkit) {
SunToolkit stk = (SunToolkit) tk;
stk.notifyModalityPopped(this);
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class DefaultDesktopManager method dragFrameFaster.
// =========== stuff for faster frame dragging ===================
private void dragFrameFaster(JComponent f, int newX, int newY) {
Rectangle previousBounds = new Rectangle(currentBounds.x, currentBounds.y, currentBounds.width, currentBounds.height);
// move the frame
currentBounds.x = newX;
currentBounds.y = newY;
if (didDrag) {
// Only initiate cleanup if we have actually done a drag.
emergencyCleanup(f);
} else {
didDrag = true;
// We reset the danger field as until now we haven't actually
// moved the internal frame so we don't need to initiate repaint.
((JInternalFrame) f).danger = false;
}
boolean floaterCollision = isFloaterCollision(previousBounds, currentBounds);
JComponent parent = (JComponent) f.getParent();
Rectangle visBounds = previousBounds.intersection(desktopBounds);
RepaintManager currentManager = RepaintManager.currentManager(f);
currentManager.beginPaint();
try {
if (!floaterCollision) {
currentManager.copyArea(parent, desktopGraphics, visBounds.x, visBounds.y, visBounds.width, visBounds.height, newX - previousBounds.x, newY - previousBounds.y, true);
}
f.setBounds(currentBounds);
if (!floaterCollision) {
Rectangle r = currentBounds;
currentManager.notifyRepaintPerformed(parent, r.x, r.y, r.width, r.height);
}
if (floaterCollision) {
// since we couldn't blit we just redraw as fast as possible
// the isDragging mucking is to avoid activating emergency
// cleanup
((JInternalFrame) f).isDragging = false;
parent.paintImmediately(currentBounds);
((JInternalFrame) f).isDragging = true;
}
// fake out the repaint manager. We'll take care of everything
currentManager.markCompletelyClean(parent);
currentManager.markCompletelyClean(f);
// compute the minimal newly exposed area
// if the rects intersect then we use computeDifference. Otherwise
// we'll repaint the entire previous bounds
Rectangle[] dirtyRects = null;
if (previousBounds.intersects(currentBounds)) {
dirtyRects = SwingUtilities.computeDifference(previousBounds, currentBounds);
} else {
dirtyRects = new Rectangle[1];
dirtyRects[0] = previousBounds;
}
;
// Fix the damage
for (int i = 0; i < dirtyRects.length; i++) {
parent.paintImmediately(dirtyRects[i]);
Rectangle r = dirtyRects[i];
currentManager.notifyRepaintPerformed(parent, r.x, r.y, r.width, r.height);
}
// new areas of blit were exposed
if (!(visBounds.equals(previousBounds))) {
dirtyRects = SwingUtilities.computeDifference(previousBounds, desktopBounds);
for (int i = 0; i < dirtyRects.length; i++) {
dirtyRects[i].x += newX - previousBounds.x;
dirtyRects[i].y += newY - previousBounds.y;
((JInternalFrame) f).isDragging = false;
parent.paintImmediately(dirtyRects[i]);
((JInternalFrame) f).isDragging = true;
Rectangle r = dirtyRects[i];
currentManager.notifyRepaintPerformed(parent, r.x, r.y, r.width, r.height);
}
}
} finally {
currentManager.endPaint();
}
// update window if it's non-opaque
Window topLevel = SwingUtilities.getWindowAncestor(f);
Toolkit tk = Toolkit.getDefaultToolkit();
if (!topLevel.isOpaque() && (tk instanceof SunToolkit) && ((SunToolkit) tk).needUpdateWindow()) {
AWTAccessor.getWindowAccessor().updateWindow(topLevel);
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class RepaintManager method _getOffscreenBuffer.
private Image _getOffscreenBuffer(Component c, int proposedWidth, int proposedHeight) {
Dimension maxSize = getDoubleBufferMaximumSize();
DoubleBufferInfo doubleBuffer;
int width, height;
// If the window is non-opaque, it's double-buffered at peer's level
Window w = (c instanceof Window) ? (Window) c : SwingUtilities.getWindowAncestor(c);
if (!w.isOpaque()) {
Toolkit tk = Toolkit.getDefaultToolkit();
if ((tk instanceof SunToolkit) && (((SunToolkit) tk).needUpdateWindow())) {
return null;
}
}
if (standardDoubleBuffer == null) {
standardDoubleBuffer = new DoubleBufferInfo();
}
doubleBuffer = standardDoubleBuffer;
width = proposedWidth < 1 ? 1 : (proposedWidth > maxSize.width ? maxSize.width : proposedWidth);
height = proposedHeight < 1 ? 1 : (proposedHeight > maxSize.height ? maxSize.height : proposedHeight);
if (doubleBuffer.needsReset || (doubleBuffer.image != null && (doubleBuffer.size.width < width || doubleBuffer.size.height < height))) {
doubleBuffer.needsReset = false;
if (doubleBuffer.image != null) {
doubleBuffer.image.flush();
doubleBuffer.image = null;
}
width = Math.max(doubleBuffer.size.width, width);
height = Math.max(doubleBuffer.size.height, height);
}
Image result = doubleBuffer.image;
if (doubleBuffer.image == null) {
result = c.createImage(width, height);
doubleBuffer.size = new Dimension(width, height);
if (c instanceof JComponent) {
((JComponent) c).setCreatedDoubleBuffer(true);
doubleBuffer.image = result;
}
// JComponent will inform us when it is no longer valid
// (via removeNotify) we have no such hook to other components,
// therefore we don't keep a ref to the Component
// (indirectly through the Image) by stashing the image.
}
return result;
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class RepaintManager method updateWindows.
private void updateWindows(Map<Component, Rectangle> dirtyComponents) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
if (!(toolkit instanceof SunToolkit && ((SunToolkit) toolkit).needUpdateWindow())) {
return;
}
Set<Window> windows = new HashSet<Window>();
Set<Component> dirtyComps = dirtyComponents.keySet();
for (Iterator<Component> it = dirtyComps.iterator(); it.hasNext(); ) {
Component dirty = it.next();
Window window = dirty instanceof Window ? (Window) dirty : SwingUtilities.getWindowAncestor(dirty);
if (window != null && !window.isOpaque()) {
windows.add(window);
}
}
for (Window window : windows) {
AWTAccessor.getWindowAccessor().updateWindow(window);
}
}
use of sun.awt.SunToolkit in project jdk8u_jdk by JetBrains.
the class RepaintManager method getPaintManager.
private synchronized PaintManager getPaintManager() {
if (paintManager == null) {
PaintManager paintManager = null;
if (doubleBufferingEnabled && !nativeDoubleBuffering) {
switch(bufferStrategyType) {
case BUFFER_STRATEGY_NOT_SPECIFIED:
Toolkit tk = Toolkit.getDefaultToolkit();
if (tk instanceof SunToolkit) {
SunToolkit stk = (SunToolkit) tk;
if (stk.useBufferPerWindow()) {
paintManager = new BufferStrategyPaintManager();
}
}
break;
case BUFFER_STRATEGY_SPECIFIED_ON:
paintManager = new BufferStrategyPaintManager();
break;
default:
break;
}
}
// null case handled in setPaintManager
setPaintManager(paintManager);
}
return paintManager;
}
Aggregations