From proetel at aicas.de Thu Apr 21 00:36:14 2011 From: proetel at aicas.de (Ingo Proetel) Date: Thu, 21 Apr 2011 09:36:14 +0200 Subject: [PATCH 1 of 2] Added flag to mark a peer to clear its background with an new paintevent. This gives target implementations better control when peers need to clear their background In-Reply-To: References: Message-ID: <033a795ade9cd0e36126.1303371374@crowley> # HG changeset patch # User Ingo Proetel # Date 1303371341 -7200 # Node ID 033a795ade9cd0e361267719079384ab0d84fdf6 # Parent 5f7eafa98597dfb14967164eb3fd1a554c5a23ab Added flag to mark a peer to clear its background with an new paintevent. This gives target implementations better control when peers need to clear their background. diff -r 5f7eafa98597 -r 033a795ade9c src/share/classes/sun/awt/peer/cacio/CacioComponentPeer.java --- a/src/share/classes/sun/awt/peer/cacio/CacioComponentPeer.java Wed Apr 20 11:40:07 2011 +0200 +++ b/src/share/classes/sun/awt/peer/cacio/CacioComponentPeer.java Thu Apr 21 09:35:41 2011 +0200 @@ -619,7 +619,6 @@ // laid out correctly. swingComponent.validate(); } - needsClearBackground = true; } public void setEnabled(boolean enable) { @@ -797,4 +796,13 @@ boolean isLayouting() { return false; } + + /** + * Mark this peer so that the next paint event clears the background. + */ + public void clearBackground() + { + needsClearBackground = true; + } + } diff -r 5f7eafa98597 -r 033a795ade9c src/share/classes/sun/awt/peer/cacio/CacioEventPump.java --- a/src/share/classes/sun/awt/peer/cacio/CacioEventPump.java Wed Apr 20 11:40:07 2011 +0200 +++ b/src/share/classes/sun/awt/peer/cacio/CacioEventPump.java Thu Apr 21 09:35:41 2011 +0200 @@ -174,16 +174,25 @@ postEvent(source, ev); } - + protected final void postPaintEvent(CacioComponent source, int x, int y, - int width, int height) { - + int width, int height, boolean paintBackground) { + if (paintBackground) + { + ((CacioComponentPeer) source).clearBackground(); + } + PaintEvent ev = PaintEventDispatcher.getPaintEventDispatcher() .createPaintEvent(source.getAWTComponent(), x, y, width, height); postEvent(source, ev); } - + + protected final void postPaintEvent(CacioComponent source, int x, int y, + int width, int height) { + postPaintEvent(source, x, y, width, height, false); + } + protected final void postFocusEvent(CacioComponent source, int id, boolean temporary, CacioComponent opposite) { From proetel at aicas.de Thu Apr 21 00:36:13 2011 From: proetel at aicas.de (Ingo Proetel) Date: Thu, 21 Apr 2011 09:36:13 +0200 Subject: [PATCH 0 of 2] Paint patches Message-ID: Hello, these two patches improve the painting of CacioPeers. The first patch gives the target implementation better control over clearing the peers background. The second patch disables peerPaint on Windows that have native decoration. This minimizes unnecessary paints. I think that the second patch is a temporary solution. At some point I'd like to split decoration issues from CacioWindowPeer into a CacioDecoratingWindowPeer subclass. This would simplify the handling between decorating and non-decorating CacioPeers. Cheers Ingo From proetel at aicas.de Thu Apr 21 00:36:15 2011 From: proetel at aicas.de (Ingo Proetel) Date: Thu, 21 Apr 2011 09:36:15 +0200 Subject: [PATCH 2 of 2] Do not paint the JRootPane for Windows that get their decoration from the system and do not have a menu bar In-Reply-To: References: Message-ID: <0852643719870188c13f.1303371375@crowley> # HG changeset patch # User Ingo Proetel # Date 1303371344 -7200 # Node ID 0852643719870188c13f141ef395579f08d6f97c # Parent 033a795ade9cd0e361267719079384ab0d84fdf6 Do not paint the JRootPane for Windows that get their decoration from the system and do not have a menu bar. diff -r 033a795ade9c -r 085264371987 src/share/classes/sun/awt/peer/cacio/CacioWindowPeer.java --- a/src/share/classes/sun/awt/peer/cacio/CacioWindowPeer.java Thu Apr 21 09:35:41 2011 +0200 +++ b/src/share/classes/sun/awt/peer/cacio/CacioWindowPeer.java Thu Apr 21 09:35:44 2011 +0200 @@ -148,6 +148,7 @@ // we cannot have menu support... Window window = (Window) getAWTComponent(); JRootPane jrootpane = new JRootPane(); + jrootpane.setDoubleBuffered(false); return jrootpane; } @@ -319,27 +320,28 @@ @Override protected void peerPaint(Graphics g, boolean update) { - /* - * Don't paint the whole area, we only need to paint the frame - * borders - */ - JComponent c = getSwingComponent(); - if (c != null) { - Insets insets = getInsets(); - - Area clip = new Area(c.getBounds()); - Rectangle clip2 = - new Rectangle(insets.left, - insets.top, - c.getWidth() - insets.left - insets.right, - c.getHeight() - insets.bottom - insets.top); - clip.subtract(new Area(clip2)); - - Graphics peerG = new WindowClippedGraphics((Graphics2D) g, clip); - try { - c.paint(peerG); - } finally { - peerG.dispose(); + if (shouldDecorate() || getSwingComponent().getJMenuBar() != null) { + /* + * Don't paint the whole area, we only need to paint the frame + * borders + */ + JComponent c = getSwingComponent(); + if (c != null) { + Insets insets = getInsets(); + Area clip = new Area(c.getBounds()); + Rectangle clip2 = + new Rectangle(insets.left, + insets.top, + c.getWidth() - insets.left - insets.right, + c.getHeight() - insets.bottom - insets.top); + clip.subtract(new Area(clip2)); + + Graphics peerG = new WindowClippedGraphics((Graphics2D) g, clip); + try { + c.paint(peerG); + } finally { + peerG.dispose(); + } } } } From ralf.heini at aicas.de Tue Apr 26 07:34:02 2011 From: ralf.heini at aicas.de (Ralf Heini) Date: Tue, 26 Apr 2011 16:34:02 +0200 Subject: Patch: New interface method PlatformToplevelWindow.setBlocked() Message-ID: <4DB6D7DA.3050200@aicas.de> # HG changeset patch # Parent b80e8e3db13ef54489cc61137b407ba47c187e45 New interface method PlatformToplevelWindow.setBlocked() diff -r b80e8e3db13e src/share/classes/sun/awt/peer/cacio/CacioComponentPeer.java --- a/src/share/classes/sun/awt/peer/cacio/CacioComponentPeer.java Mon Apr 04 14:27:06 2011 +0200 +++ b/src/share/classes/sun/awt/peer/cacio/CacioComponentPeer.java Mon Apr 04 16:01:00 2011 +0200 @@ -44,6 +44,7 @@ import java.awt.Rectangle; import java.awt.Toolkit; import java.awt.Transparency; +import java.awt.Window; import java.awt.event.FocusEvent; import java.awt.event.KeyEvent; @@ -190,12 +191,14 @@ private void initProxy() { if (swingComponent != null) { - - // Setup the proxy window. - proxy = new ProxyWindow(this, swingComponent); - proxy.setBounds(awtComponent.getX(), awtComponent.getY(), - awtComponent.getWidth(), awtComponent.getHeight()); - proxy.setVisible(awtComponent.isVisible()); + // No proxy window is needed for a real window. + if (!(awtComponent instanceof Window)) { + // Setup the proxy window. + proxy = new ProxyWindow(this, swingComponent); + proxy.setBounds(awtComponent.getX(), awtComponent.getY(), + awtComponent.getWidth(), awtComponent.getHeight()); + proxy.setVisible(awtComponent.isVisible()); + } } } diff -r b80e8e3db13e src/share/classes/sun/awt/peer/cacio/CacioDialogPeer.java --- a/src/share/classes/sun/awt/peer/cacio/CacioDialogPeer.java Mon Apr 04 14:27:06 2011 +0200 +++ b/src/share/classes/sun/awt/peer/cacio/CacioDialogPeer.java Mon Apr 04 16:01:00 2011 +0200 @@ -28,10 +28,13 @@ import java.awt.Dialog; import java.awt.Window; import java.awt.peer.DialogPeer; +import java.awt.peer.WindowPeer; import java.util.List; import javax.swing.JRootPane; +import sun.awt.ComponentAccessor; + class CacioDialogPeer extends CacioWindowPeer implements DialogPeer { public CacioDialogPeer(Dialog awtC, PlatformWindowFactory pwf) { @@ -53,9 +56,14 @@ } public void blockWindows(List windows) { + for (Window window : windows) { + WindowPeer peer = (WindowPeer)ComponentAccessor.getPeer(window); + if (peer != null) { + peer.setModalBlocked((Dialog)getAWTComponent(), true); + } + } } - @Override protected int getRootPaneDecorationStyle() { if ((! isDecorateDialogs()) diff -r b80e8e3db13e src/share/classes/sun/awt/peer/cacio/CacioWindowPeer.java --- a/src/share/classes/sun/awt/peer/cacio/CacioWindowPeer.java Mon Apr 04 14:27:06 2011 +0200 +++ b/src/share/classes/sun/awt/peer/cacio/CacioWindowPeer.java Mon Apr 04 16:01:00 2011 +0200 @@ -48,6 +48,8 @@ import javax.swing.UIManager; import javax.swing.border.Border; +import sun.awt.ComponentAccessor; + class CacioWindowPeer extends CacioContainerPeer implements WindowPeer { @@ -57,6 +59,8 @@ private static final Font defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12); + protected boolean blocked; + /** * Ask Cacio to decorate the windows. This method sets the decoration * for both dialogs and windows. @@ -171,7 +175,19 @@ } public void setModalBlocked(Dialog blocker, boolean blocked) { - // TODO Auto-generated method stub + if (this.blocked == blocked) { + return; + } + + if (blocker != null) { + CacioWindowPeer dialogPeer = (CacioDialogPeer)ComponentAccessor.getPeer(blocker); + if (dialogPeer != null) { + dialogPeer.setModalBlocked(null, !blocked); + } + } + + getToplevelWindow().setBlocked(blocked); + this.blocked = blocked; } diff -r b80e8e3db13e src/share/classes/sun/awt/peer/cacio/PlatformToplevelWindow.java --- a/src/share/classes/sun/awt/peer/cacio/PlatformToplevelWindow.java Mon Apr 04 14:27:06 2011 +0200 +++ b/src/share/classes/sun/awt/peer/cacio/PlatformToplevelWindow.java Mon Apr 04 16:01:00 2011 +0200 @@ -89,5 +89,16 @@ * @param title the title to set */ void setTitle(String title); + + /** + * Blocks or unblocks the native window. + * This is only called for toplevel frames and dialogs. + * + * @param blocked true if set to blocked + * + * @see DialogPeer#blockWindows(List) + * @see WindowPeer#setModalBlocked(Dialog, boolean) + */ + void setBlocked(boolean blocked); } diff -r b80e8e3db13e src/share/classes/sun/awt/peer/cacio/ProxyWindowPeer.java --- a/src/share/classes/sun/awt/peer/cacio/ProxyWindowPeer.java Mon Apr 04 14:27:06 2011 +0200 +++ b/src/share/classes/sun/awt/peer/cacio/ProxyWindowPeer.java Mon Apr 04 16:01:00 2011 +0200 @@ -87,9 +87,7 @@ @Override public void setModalBlocked(Dialog blocker, boolean blocked) { - if (target instanceof WindowPeer) { - ((WindowPeer) target).setModalBlocked(blocker, blocked); - } + // Nothing to do here yet. } @Override diff -r b80e8e3db13e src/share/classes/sun/awt/peer/cacio/managed/ManagedWindow.java --- a/src/share/classes/sun/awt/peer/cacio/managed/ManagedWindow.java Mon Apr 04 14:27:06 2011 +0200 +++ b/src/share/classes/sun/awt/peer/cacio/managed/ManagedWindow.java Mon Apr 04 16:01:00 2011 +0200 @@ -409,6 +409,11 @@ } @Override + public void setBlocked(boolean blocked) { + // TODO: Implement this. + } + + @Override public boolean requestFocus(Component lightweightChild, boolean temporary, boolean focusedWindowChangeAllowed, long time, Cause cause) { From ralf.heini at aicas.de Thu Apr 28 01:03:47 2011 From: ralf.heini at aicas.de (Ralf Heini) Date: Thu, 28 Apr 2011 10:03:47 +0200 Subject: Patch: Window also needs a proxy window Message-ID: <4DB91F63.7000907@aicas.de> This was changed in a former patch but a proxy window is required for decorated mangaged windows. -------------- next part -------------- A non-text attachment was scrubbed... Name: always-use-proxy-window.patch Type: text/x-patch Size: 1395 bytes Desc: not available Url : http://mail.openjdk.java.net/pipermail/caciocavallo-dev/attachments/20110428/bfa5556a/always-use-proxy-window.patch