jdk/src/solaris/classes/sun/awt/X11/XWM.java
changeset 2802 d05a9dcc8296
parent 2472 b7aba00cabb6
child 3938 ef327bd847c0
child 4191 ca8d3ef845c8
equal deleted inserted replaced
2760:f038acdbdf9c 2802:d05a9dcc8296
   274             }
   274             }
   275 
   275 
   276             winmgr_running = false;
   276             winmgr_running = false;
   277             substruct.set_event_mask(XConstants.SubstructureRedirectMask);
   277             substruct.set_event_mask(XConstants.SubstructureRedirectMask);
   278 
   278 
   279             XToolkit.WITH_XERROR_HANDLER(DetectWMHandler);
   279             XToolkit.WITH_XERROR_HANDLER(detectWMHandler);
   280             XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(),
   280             XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(),
   281                                                 XToolkit.getDefaultRootWindow(),
   281                                                 XToolkit.getDefaultRootWindow(),
   282                                                 XConstants.CWEventMask,
   282                                                 XConstants.CWEventMask,
   283                                                 substruct.pData);
   283                                                 substruct.pData);
   284             XToolkit.RESTORE_XERROR_HANDLER();
   284             XToolkit.RESTORE_XERROR_HANDLER();
   319 
   319 
   320         WindowPropertyGetter getter =
   320         WindowPropertyGetter getter =
   321             new WindowPropertyGetter(window, XA_ENLIGHTENMENT_COMMS, 0, 14, false,
   321             new WindowPropertyGetter(window, XA_ENLIGHTENMENT_COMMS, 0, 14, false,
   322                                      XAtom.XA_STRING);
   322                                      XAtom.XA_STRING);
   323         try {
   323         try {
   324             int status = getter.execute(XToolkit.IgnoreBadWindowHandler);
   324             int status = getter.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   325             if (status != XConstants.Success || getter.getData() == 0) {
   325             if (status != XConstants.Success || getter.getData() == 0) {
   326                 return 0;
   326                 return 0;
   327             }
   327             }
   328 
   328 
   329             if (getter.getActualType() != XAtom.XA_STRING
   329             if (getter.getActualType() != XAtom.XA_STRING
   437             }
   437             }
   438             WindowPropertyGetter getter2 =
   438             WindowPropertyGetter getter2 =
   439                 new WindowPropertyGetter(wmwin, XA_DT_SM_STATE_INFO, 0, 1,
   439                 new WindowPropertyGetter(wmwin, XA_DT_SM_STATE_INFO, 0, 1,
   440                                          false, XA_DT_SM_STATE_INFO);
   440                                          false, XA_DT_SM_STATE_INFO);
   441             try {
   441             try {
   442                 status = getter2.execute(XToolkit.IgnoreBadWindowHandler);
   442                 status = getter2.execute(XErrorHandler.IgnoreBadWindowHandler.getInstance());
   443 
   443 
   444 
   444 
   445                 if (status != XConstants.Success || getter2.getData() == 0) {
   445                 if (status != XConstants.Success || getter2.getData() == 0) {
   446                     log.finer("Getting of _DT_SM_STATE_INFO is not successfull");
   446                     log.finer("Getting of _DT_SM_STATE_INFO is not successfull");
   447                     return false;
   447                     return false;
   569     static boolean isNonReparentingWM() {
   569     static boolean isNonReparentingWM() {
   570         return (XWM.getWMID() == XWM.COMPIZ_WM || XWM.getWMID() == XWM.LG3D_WM);
   570         return (XWM.getWMID() == XWM.COMPIZ_WM || XWM.getWMID() == XWM.LG3D_WM);
   571     }
   571     }
   572 
   572 
   573     /*
   573     /*
   574      * Temporary error handler that ensures that we know if
       
   575      * XChangeProperty succeeded or not.
       
   576      */
       
   577     static XToolkit.XErrorHandler VerifyChangePropertyHandler = new XToolkit.XErrorHandler() {
       
   578             public int handleError(long display, XErrorEvent err) {
       
   579                 XToolkit.XERROR_SAVE(err);
       
   580                 if (err.get_request_code() == XProtocolConstants.X_ChangeProperty) {
       
   581                     return 0;
       
   582                 } else {
       
   583                     return XToolkit.SAVED_ERROR_HANDLER(display, err);
       
   584                 }
       
   585             }
       
   586         };
       
   587 
       
   588     /*
       
   589      * Prepare IceWM check.
   574      * Prepare IceWM check.
   590      *
   575      *
   591      * The only way to detect IceWM, seems to be by setting
   576      * The only way to detect IceWM, seems to be by setting
   592      * _ICEWM_WINOPTHINT(_ICEWM_WINOPTHINT/8) on root and checking if it
   577      * _ICEWM_WINOPTHINT(_ICEWM_WINOPTHINT/8) on root and checking if it
   593      * was immediately deleted by IceWM.
   578      * was immediately deleted by IceWM.
   615             return false;
   600             return false;
   616         }
   601         }
   617 
   602 
   618         XToolkit.awtLock();
   603         XToolkit.awtLock();
   619         try {
   604         try {
   620             XToolkit.WITH_XERROR_HANDLER(VerifyChangePropertyHandler);
   605             XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
   621             XlibWrapper.XChangePropertyS(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(),
   606             XlibWrapper.XChangePropertyS(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(),
   622                                          XA_ICEWM_WINOPTHINT.getAtom(),
   607                                          XA_ICEWM_WINOPTHINT.getAtom(),
   623                                          XA_ICEWM_WINOPTHINT.getAtom(),
   608                                          XA_ICEWM_WINOPTHINT.getAtom(),
   624                                          8, XConstants.PropModeReplace,
   609                                          8, XConstants.PropModeReplace,
   625                                          new String(opt));
   610                                          new String(opt));
   680 
   665 
   681     /*
   666     /*
   682      * Temporary error handler that checks if selecting for
   667      * Temporary error handler that checks if selecting for
   683      * SubstructureRedirect failed.
   668      * SubstructureRedirect failed.
   684      */
   669      */
   685     static boolean winmgr_running = false;
   670     private static boolean winmgr_running = false;
   686     static XToolkit.XErrorHandler DetectWMHandler = new XToolkit.XErrorHandler() {
   671     private static XErrorHandler detectWMHandler = new XErrorHandler.XBaseErrorHandler() {
   687             public int handleError(long display, XErrorEvent err) {
   672         @Override
   688                 XToolkit.XERROR_SAVE(err);
   673         public int handleError(long display, XErrorEvent err) {
   689                 if (err.get_request_code() == XProtocolConstants.X_ChangeWindowAttributes
   674             if ((err.get_request_code() == XProtocolConstants.X_ChangeWindowAttributes) &&
   690                     && err.get_error_code() == XConstants.BadAccess)
   675                 (err.get_error_code() == XConstants.BadAccess))
   691                 {
   676             {
   692                     winmgr_running = true;
   677                 winmgr_running = true;
   693                     return 0;
   678                 return 0;
   694                 } else {
   679             }
   695                     return XToolkit.SAVED_ERROR_HANDLER(display, err);
   680             return super.handleError(display, err);
   696                 }
   681         }
   697             }
   682     };
   698         };
       
   699 
   683 
   700     /*
   684     /*
   701      * Make an educated guess about running window manager.
   685      * Make an educated guess about running window manager.
   702      * XXX: ideally, we should detect wm restart.
   686      * XXX: ideally, we should detect wm restart.
   703      */
   687      */