United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6429775 : Xgl/Compiz/Java 1.5/Swing problem

Details
Type:
Bug
Submit Date:
2006-05-24
Status:
Resolved
Updated Date:
2011-01-19
Project Name:
JDK
Resolved Date:
2006-12-14
Component:
client-libs
OS:
linux
Sub-Component:
java.awt
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:
6u1 (b01)

Related Reports
Backport:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

Description
here is a quote from mail from ###@###.###
>We've encountered some difficulties with Xgl/Compiz displaying apps
>using Java 1.5, Swing and the XToolkit running under Xgl/Compiz.
>
>The difficulty seems to be specifically related to the compiz window
>manager rather than Xgl (our testing has shown the window managers
>enlightment and ratpoision also exhibit the behaviour, but not more
>maintstream managers like metacity).  We've created a test case of
>about
>20 lines long to demonstrate the behaviour (attached), which is that
>windows draw with no contents, but the widgets behavior are still
>present (ie click where a top level menu item should be and the menu
>will appear in more complex apps).  MToolkit does not appear to
>have the
>issue, but of course using it for 1.5 apps is not an ideal
>solution.  Do
>you guys have any interest in helping look at this problem or know
>someone who would inside the Java/Swing team?  Even 30 minutes on the
>phone might give us a better understanding why compiz has the issue
>but
>metacity does not so we can correct what we need to.

The test to reproduce the problem:

import javax.swing.*;

public class WmTest extends JFrame {

public WmTest () {
    JLabel l = new JLabel ("WM Test");

    this.getContentPane().add(l);
    this.setSize(256, 256);

    //this.pack();
    this.setVisible (true);
}

public static void
main (String args[]) {
    WmTest r = new WmTest ();
}

}

                                    

Comments
EVALUATION

Well, I have developed the fix for this problem and I'm going to integrate it in 6u1.  It
may not fix all problems we have under Compiz (Looking Glass), but the situation should be
much better than now.  If some particular problems will be found, please file a separate CR.
                                     
2006-11-29
SUGGESTED FIX

The fix for 6u1 is at http://javaweb.sfbay/jcg/6u1/awt/6429775/
                                     
2006-11-29
EVALUATION

well, to detect Compiz correctly we also need to check an owner of WM_S0 selection (Aaccordnig to ICCCM), since our regular check fails some time.  And we should not postpone changing od transient-for (used in modality) until reparenting (since there
is nor reparenting :)
During testing I've found that we return incorrect insets for NO_WM (when parent is
root) and fixed this in XWM.getInsets().
And finally, I've extracted all code which detects if there is a running WM into
separated method, because it is rather big after all changes I've made.

And to fix 6479959, I've done similar changes.
                                     
2006-11-22
EVALUATION

The suggested fix works. I verified it with 
compiz-0.2.0 + Gnome on Gentoo linux.
                                     
2006-11-03
EVALUATION

I wonder if our new modality implementation works with Compiz.
As soon as I will have it installed I will try.
                                     
2006-07-07
SUGGESTED FIX

here is an output of "sccs diffs -b -C".  Real diffs are attached.

------- XWM.java -------
*** /tmp/sccs.4L8jhr	2006-05-24 14:33:57.000000000 +0400
--- XWM.java	2006-05-24 14:29:53.000000000 +0400
***************
*** 63,68 ****
--- 63,71 ----
      static XAtom XA_OL_DECOR_PIN = new XAtom();
      static XAtom XA_OL_DECOR_CLOSE = new XAtom();
  
+ /* EWMH */
+     static XAtom XA_FRAME_EXTENTS = new XAtom();
+ 
      final static int
          UNDETERMINED_WM = 1,
          NO_WM = 2,
***************
*** 74,80 ****
          KDE2_WM = 8,
          SAWFISH_WM = 9,
          ICE_WM = 10,
!         METACITY_WM = 11;
      public String toString() {
          switch  (WMID) {
            case NO_WM:
--- 77,84 ----
          KDE2_WM = 8,
          SAWFISH_WM = 9,
          ICE_WM = 10,
!         METACITY_WM = 11,
!         COMPIZ_WM = 12;
      public String toString() {
          switch  (WMID) {
            case NO_WM:
***************
*** 97,102 ****
--- 101,108 ----
                return "IceWM";
            case METACITY_WM:
                return "Metacity";
+           case COMPIZ_WM:
+               return "Compiz";
            case UNDETERMINED_WM:
            default:
                return "Undetermined WM";
***************
*** 161,167 ****
              { XA_OL_DECOR_RESIZE,            "_OL_DECOR_RESIZE"              },
              { XA_OL_DECOR_PIN,               "_OL_DECOR_PIN"                 },
              { XA_OL_DECOR_CLOSE,             "_OL_DECOR_CLOSE"               },
!             { XA_MWM_HINTS,                  "_MOTIF_WM_HINTS" }            
          };
          
          String[] names = new String[atomInitList.length];
--- 167,174 ----
              { XA_OL_DECOR_RESIZE,            "_OL_DECOR_RESIZE"              },
              { XA_OL_DECOR_PIN,               "_OL_DECOR_PIN"                 },
              { XA_OL_DECOR_CLOSE,             "_OL_DECOR_CLOSE"               },
!             { XA_MWM_HINTS,                  "_MOTIF_WM_HINTS"               },
!             { XA_FRAME_EXTENTS,              "_NET_FRAME_EXTENTS"            }
          };
          
          String[] names = new String[atomInitList.length];
***************
*** 431,436 ****
--- 438,447 ----
          return isNetWMName("KWin");
      }
  
+     static boolean isCompiz() {
+         return isNetWMName("compiz");
+     }
+ 
      /*
       * Is Metacity running?
       */
***************
*** 669,676 ****
                  awt_wmgr = XWM.SAWFISH_WM;
              } else if (isKDE2()) {
                  awt_wmgr =XWM. KDE2_WM;
!             } else 
!                 if (doIsIceWM && isIceWM()) {
                      awt_wmgr = XWM.ICE_WM;
                  }
              /*
--- 680,688 ----
                  awt_wmgr = XWM.SAWFISH_WM;
              } else if (isKDE2()) {
                  awt_wmgr =XWM. KDE2_WM;
!             } else if (isCompiz()) {
!                 awt_wmgr = XWM.COMPIZ_WM;
!             } else if (doIsIceWM && isIceWM()) {
                  awt_wmgr = XWM.ICE_WM;
              } 
              /*
***************
*** 1319,1324 ****
--- 1331,1339 ----
            case XWM.ENLIGHTEN_WM:
                return readInsetsArray(window, XA_E_FRAME_SIZE,
                                       insets);
+           case XWM.COMPIZ_WM:
+               return readInsetsArray(window, XA_FRAME_EXTENTS,
+                                      insets);
            default:
                return false;
          }

------- XDecoratedPeer.java -------
*** /tmp/sccs.OIrgSA	2006-05-24 14:33:58.000000000 +0400
--- XDecoratedPeer.java	2006-05-24 14:32:13.000000000 +0400
***************
*** 627,633 ****
--- 627,637 ----
          XToolkit.awtLock();
          try {
              int runningWM = XWM.getWMID();
+             insLog.log(Level.FINE, "reparented={0}, visible={1}, WM={2}, decorations={3}",
+                        new Object[] {isReparented(), isVisible(), runningWM, getDecorations()});
+ 
              if (!isReparented() && isVisible() && runningWM != XWM.NO_WM
+                 && runningWM != XWM.COMPIZ_WM
                  && getDecorations() != winAttr.AWT_DECOR_NONE)
              {
                  insLog.fine("- visible but not reparented, skipping");
***************
*** 635,640 ****
--- 639,652 ----
              }
              //Last chance to correct insets
              if (!insets_corrected && getDecorations() != winAttr.AWT_DECOR_NONE) {
+                 Insets correctWM;
+ 
+                 if (runningWM == XWM.COMPIZ_WM)
+                 {
+                     correctWM = XWM.getWM().getInsets(this, window, 0);
+                 }
+                 else
+                 {
                      long parent = -1;
                      XQueryTree qt = new XQueryTree(window);
                      try {
***************
*** 643,649 ****
                  } finally {
                      qt.dispose();
                  }
!                 Insets correctWM = (parent != -1) ? XWM.getWM().getInsets(this, window, parent) : null;
                  if (insLog.isLoggable(Level.FINER)) {
                      if (correctWM != null) {
                          insLog.finer("Configure notify - insets : " + correctWM);
--- 655,663 ----
                      } finally {
                          qt.dispose();
                      }
!                     correctWM = (parent != -1) ? XWM.getWM().getInsets(this, window, parent) : null;
!                 }
! 
                  if (insLog.isLoggable(Level.FINER)) {
                      if (correctWM != null) {
                          insLog.finer("Configure notify - insets : " + correctWM);
***************
*** 683,689 ****
                    case XWM.CDE_WM:
                    case XWM.MOTIF_WM:
                    case XWM.METACITY_WM:
!                   case XWM.SAWFISH_WM: {                      
                        Point xlocation = queryXLocation();
                        if (log.isLoggable(Level.FINE)) log.log(Level.FINE, "New X location: {0}", new Object[]{xlocation});
                        if (xlocation != null) {
--- 697,704 ----
                    case XWM.CDE_WM:
                    case XWM.MOTIF_WM:
                    case XWM.METACITY_WM:
!                   case XWM.SAWFISH_WM:
!                   case XWM.COMPIZ_WM: {
                        Point xlocation = queryXLocation();
                        if (log.isLoggable(Level.FINE)) log.log(Level.FINE, "New X location: {0}", new Object[]{xlocation});
                        if (xlocation != null) {
***************
*** 702,709 ****
                                       copy(currentInsets),
                                       true);
              
-             
- 
              insLog.log(Level.FINER, "Insets are {0}, new dimensions {1}", 
                         new Object[] {currentInsets, newDimensions});
  
--- 717,722 ----
                                     
2006-05-24
EVALUATION

the problem is that AWT filters out all ConfigureNotify if the toplevel is not reparented.
But Compiz doesn't reparent windows at all.
Possible solution would be detect if we are under Compiz and do not filter events
                                     
2006-05-24



Hardware and Software, Engineered to Work Together