581 : WindowEvent.WINDOW_DEICONIFIED); 582 postEvent(iconifyEvent); 583 584 int newWindowState = iconify ? Frame.ICONIFIED : Frame.NORMAL; 585 postWindowStateChangedEvent(newWindowState); 586 587 // REMIND: RepaintManager doesn't repaint iconified windows and 588 // hence ignores any repaint request during deiconification. 589 // So, we need to repaint window explicitly when it becomes normal. 590 if (!iconify) { 591 repaintPeer(); 592 } 593 } 594 595 public void notifyZoom(boolean isZoomed) { 596 int newWindowState = isZoomed ? Frame.MAXIMIZED_BOTH : Frame.NORMAL; 597 postWindowStateChangedEvent(newWindowState); 598 } 599 600 /** 601 * Called by the delegate when any part of the window should be repainted. 602 */ 603 public void notifyExpose(final int x, final int y, final int w, final int h) { 604 // TODO: there's a serious problem with Swing here: it handles 605 // the exposition internally, so SwingPaintEventDispatcher always 606 // return null from createPaintEvent(). However, we flush the 607 // back buffer here unconditionally, so some flickering may appear. 608 // A possible solution is to split postPaintEvent() into two parts, 609 // and override that part which is only called after if 610 // createPaintEvent() returned non-null value and flush the buffer 611 // from the overridden method 612 flushOnscreenGraphics(); 613 repaintPeer(new Rectangle(x, y, w, h)); 614 } 615 616 /** 617 * Called by the delegate when this window is moved/resized by user. 618 * There's no notifyReshape() in LWComponentPeer as the only 619 * components which could be resized by user are top-level windows. 620 */ 621 public final void notifyReshape(int x, int y, int w, int h) { 622 boolean moved = false; 623 boolean resized = false; 624 synchronized (getStateLock()) { 625 moved = (x != sysX) || (y != sysY); 626 resized = (w != sysW) || (h != sysH); 627 sysX = x; 628 sysY = y; 629 sysW = w; 630 sysH = h; 631 } 632 633 // Check if anything changed 634 if (!moved && !resized) { 635 return; 636 } 637 // First, update peer's bounds 638 setBounds(x, y, w, h, SET_BOUNDS, false, false); 639 640 // Second, update the graphics config and surface data 641 checkIfOnNewScreen(); 642 if (resized) { 643 replaceSurfaceData(); 644 flushOnscreenGraphics(); 645 } 646 647 // Third, COMPONENT_MOVED/COMPONENT_RESIZED events 648 if (moved) { 649 handleMove(x, y, true); 650 } 651 if (resized) { 652 handleResize(w, h,true); 653 } 654 } 655 656 private void clearBackground(final int w, final int h) { 657 final Graphics g = getOnscreenGraphics(getForeground(), getBackground(), 658 getFont()); 659 if (g != null) { 660 try { 661 if (g instanceof Graphics2D) { 662 ((Graphics2D) g).setComposite(AlphaComposite.Src); 663 } 664 if (isTranslucent()) { 665 g.setColor(nonOpaqueBackground); 666 g.fillRect(0, 0, w, h); 667 } 668 if (!isTextured()) { 669 if (g instanceof SunGraphics2D) { 670 SG2DConstraint((SunGraphics2D) g, getRegion()); 671 } 672 g.setColor(getBackground()); | 581 : WindowEvent.WINDOW_DEICONIFIED); 582 postEvent(iconifyEvent); 583 584 int newWindowState = iconify ? Frame.ICONIFIED : Frame.NORMAL; 585 postWindowStateChangedEvent(newWindowState); 586 587 // REMIND: RepaintManager doesn't repaint iconified windows and 588 // hence ignores any repaint request during deiconification. 589 // So, we need to repaint window explicitly when it becomes normal. 590 if (!iconify) { 591 repaintPeer(); 592 } 593 } 594 595 public void notifyZoom(boolean isZoomed) { 596 int newWindowState = isZoomed ? Frame.MAXIMIZED_BOTH : Frame.NORMAL; 597 postWindowStateChangedEvent(newWindowState); 598 } 599 600 /** 601 * Called by the {@code PlatformWindow} when any part of the window should 602 * be repainted. 603 */ 604 public final void notifyExpose(final Rectangle r) { 605 repaintPeer(r); 606 } 607 608 /** 609 * Called by the {@code PlatformWindow} when this window is moved/resized by 610 * user. There's no notifyReshape() in LWComponentPeer as the only 611 * components which could be resized by user are top-level windows. 612 */ 613 public final void notifyReshape(int x, int y, int w, int h) { 614 final boolean moved; 615 final boolean resized; 616 synchronized (getStateLock()) { 617 moved = (x != sysX) || (y != sysY); 618 resized = (w != sysW) || (h != sysH); 619 sysX = x; 620 sysY = y; 621 sysW = w; 622 sysH = h; 623 } 624 625 // Check if anything changed 626 if (!moved && !resized) { 627 return; 628 } 629 // First, update peer's bounds 630 setBounds(x, y, w, h, SET_BOUNDS, false, false); 631 632 // Second, update the graphics config and surface data 633 checkIfOnNewScreen(); 634 if (resized) { 635 replaceSurfaceData(); 636 flushOnscreenGraphics(); 637 } 638 639 // Third, COMPONENT_MOVED/COMPONENT_RESIZED/PAINT events 640 if (moved) { 641 handleMove(x, y, true); 642 } 643 if (resized) { 644 handleResize(w, h, true); 645 repaintPeer(); 646 } 647 } 648 649 private void clearBackground(final int w, final int h) { 650 final Graphics g = getOnscreenGraphics(getForeground(), getBackground(), 651 getFont()); 652 if (g != null) { 653 try { 654 if (g instanceof Graphics2D) { 655 ((Graphics2D) g).setComposite(AlphaComposite.Src); 656 } 657 if (isTranslucent()) { 658 g.setColor(nonOpaqueBackground); 659 g.fillRect(0, 0, w, h); 660 } 661 if (!isTextured()) { 662 if (g instanceof SunGraphics2D) { 663 SG2DConstraint((SunGraphics2D) g, getRegion()); 664 } 665 g.setColor(getBackground()); |