src/solaris/classes/sun/awt/X11/XWM.java

Print this page


   1 /*
   2  * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 265              */
 266             final long default_screen_number =
 267                 XlibWrapper.DefaultScreen(XToolkit.getDisplay());
 268             final String selection_name = "WM_S" + default_screen_number;
 269 
 270             long selection_owner =
 271                 XlibWrapper.XGetSelectionOwner(XToolkit.getDisplay(),
 272                                                XAtom.get(selection_name).getAtom());
 273             if (insLog.isLoggable(PlatformLogger.FINE)) {
 274                 insLog.finer("selection owner of " + selection_name
 275                              + " is " + selection_owner);
 276             }
 277 
 278             if (selection_owner != XConstants.None) {
 279                 return false;
 280             }
 281 
 282             winmgr_running = false;
 283             substruct.set_event_mask(XConstants.SubstructureRedirectMask);
 284 
 285             XToolkit.WITH_XERROR_HANDLER(detectWMHandler);
 286             XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(),
 287                                                 XToolkit.getDefaultRootWindow(),
 288                                                 XConstants.CWEventMask,
 289                                                 substruct.pData);
 290             XToolkit.RESTORE_XERROR_HANDLER();
 291 
 292             /*
 293              * If no WM is running then our selection for SubstructureRedirect
 294              * succeeded and needs to be undone (hey we are *not* a WM ;-).
 295              */
 296             if (!winmgr_running) {
 297                 substruct.set_event_mask(0);
 298                 XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(),
 299                                                     XToolkit.getDefaultRootWindow(),
 300                                                     XConstants.CWEventMask,
 301                                                     substruct.pData);
 302                 if (insLog.isLoggable(PlatformLogger.FINE)) {
 303                     insLog.finer("It looks like there is no WM thus NO_WM");
 304                 }
 305             }
 306 
 307             return !winmgr_running;
 308         } finally {
 309             substruct.dispose();
 310         }


 599      */
 600     static final XAtom XA_ICEWM_WINOPTHINT = new XAtom("_ICEWM_WINOPTHINT", false);
 601     static final char opt[] = {
 602         'A','W','T','_','I','C','E','W','M','_','T','E','S','T','\0',
 603         'a','l','l','W','o','r','k','s','p','a','c','e','s','\0',
 604         '0','\0'
 605     };
 606     static boolean prepareIsIceWM() {
 607         /*
 608          * Choose something innocuous: "AWT_ICEWM_TEST allWorkspaces 0".
 609          * IceWM expects "class\0option\0arg\0" with zero bytes as delimiters.
 610          */
 611 
 612         if (!XA_ICEWM_WINOPTHINT.isInterned()) {
 613             log.finer("{0} is not interned", XA_ICEWM_WINOPTHINT);
 614             return false;
 615         }
 616 
 617         XToolkit.awtLock();
 618         try {
 619             XToolkit.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
 620             XlibWrapper.XChangePropertyS(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(),
 621                                          XA_ICEWM_WINOPTHINT.getAtom(),
 622                                          XA_ICEWM_WINOPTHINT.getAtom(),
 623                                          8, XConstants.PropModeReplace,
 624                                          new String(opt));
 625             XToolkit.RESTORE_XERROR_HANDLER();
 626 
 627             if (XToolkit.saved_error != null && XToolkit.saved_error.get_error_code() != XConstants.Success) {

 628                 log.finer("Erorr getting XA_ICEWM_WINOPTHINT property");
 629                 return false;
 630             }
 631             log.finer("Prepared for IceWM detection");
 632             return true;
 633         } finally {
 634             XToolkit.awtUnlock();
 635         }
 636     }
 637 
 638     /*
 639      * Is IceWM running?
 640      *
 641      * Note well: Only call this if awt_wm_prepareIsIceWM succeeded, or a
 642      * false positive will be reported.
 643      */
 644     static boolean isIceWM() {
 645         if (!XA_ICEWM_WINOPTHINT.isInterned()) {
 646             log.finer("{0} is not interned", XA_ICEWM_WINOPTHINT);
 647             return false;


   1 /*
   2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 265              */
 266             final long default_screen_number =
 267                 XlibWrapper.DefaultScreen(XToolkit.getDisplay());
 268             final String selection_name = "WM_S" + default_screen_number;
 269 
 270             long selection_owner =
 271                 XlibWrapper.XGetSelectionOwner(XToolkit.getDisplay(),
 272                                                XAtom.get(selection_name).getAtom());
 273             if (insLog.isLoggable(PlatformLogger.FINE)) {
 274                 insLog.finer("selection owner of " + selection_name
 275                              + " is " + selection_owner);
 276             }
 277 
 278             if (selection_owner != XConstants.None) {
 279                 return false;
 280             }
 281 
 282             winmgr_running = false;
 283             substruct.set_event_mask(XConstants.SubstructureRedirectMask);
 284 
 285             XErrorHandlerUtil.WITH_XERROR_HANDLER(detectWMHandler);
 286             XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(),
 287                                                 XToolkit.getDefaultRootWindow(),
 288                                                 XConstants.CWEventMask,
 289                                                 substruct.pData);
 290             XErrorHandlerUtil.RESTORE_XERROR_HANDLER();
 291 
 292             /*
 293              * If no WM is running then our selection for SubstructureRedirect
 294              * succeeded and needs to be undone (hey we are *not* a WM ;-).
 295              */
 296             if (!winmgr_running) {
 297                 substruct.set_event_mask(0);
 298                 XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(),
 299                                                     XToolkit.getDefaultRootWindow(),
 300                                                     XConstants.CWEventMask,
 301                                                     substruct.pData);
 302                 if (insLog.isLoggable(PlatformLogger.FINE)) {
 303                     insLog.finer("It looks like there is no WM thus NO_WM");
 304                 }
 305             }
 306 
 307             return !winmgr_running;
 308         } finally {
 309             substruct.dispose();
 310         }


 599      */
 600     static final XAtom XA_ICEWM_WINOPTHINT = new XAtom("_ICEWM_WINOPTHINT", false);
 601     static final char opt[] = {
 602         'A','W','T','_','I','C','E','W','M','_','T','E','S','T','\0',
 603         'a','l','l','W','o','r','k','s','p','a','c','e','s','\0',
 604         '0','\0'
 605     };
 606     static boolean prepareIsIceWM() {
 607         /*
 608          * Choose something innocuous: "AWT_ICEWM_TEST allWorkspaces 0".
 609          * IceWM expects "class\0option\0arg\0" with zero bytes as delimiters.
 610          */
 611 
 612         if (!XA_ICEWM_WINOPTHINT.isInterned()) {
 613             log.finer("{0} is not interned", XA_ICEWM_WINOPTHINT);
 614             return false;
 615         }
 616 
 617         XToolkit.awtLock();
 618         try {
 619             XErrorHandlerUtil.WITH_XERROR_HANDLER(XErrorHandler.VerifyChangePropertyHandler.getInstance());
 620             XlibWrapper.XChangePropertyS(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(),
 621                                          XA_ICEWM_WINOPTHINT.getAtom(),
 622                                          XA_ICEWM_WINOPTHINT.getAtom(),
 623                                          8, XConstants.PropModeReplace,
 624                                          new String(opt));
 625             XErrorHandlerUtil.RESTORE_XERROR_HANDLER();
 626 
 627             if ((XErrorHandlerUtil.saved_error != null) &&
 628                 (XErrorHandlerUtil.saved_error.get_error_code() != XConstants.Success)) {
 629                 log.finer("Erorr getting XA_ICEWM_WINOPTHINT property");
 630                 return false;
 631             }
 632             log.finer("Prepared for IceWM detection");
 633             return true;
 634         } finally {
 635             XToolkit.awtUnlock();
 636         }
 637     }
 638 
 639     /*
 640      * Is IceWM running?
 641      *
 642      * Note well: Only call this if awt_wm_prepareIsIceWM succeeded, or a
 643      * false positive will be reported.
 644      */
 645     static boolean isIceWM() {
 646         if (!XA_ICEWM_WINOPTHINT.isInterned()) {
 647             log.finer("{0} is not interned", XA_ICEWM_WINOPTHINT);
 648             return false;