src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.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


 278         super.dispose();
 279     }
 280 
 281     // Focusable is true in order to enable focus traversal through this Canvas
 282     public boolean isFocusable() {
 283         return true;
 284     }
 285 
 286     Window getTopLevel(Component comp) {
 287         while (comp != null && !(comp instanceof Window)) {
 288             comp = comp.getParent();
 289         }
 290         return (Window)comp;
 291     }
 292 
 293     Rectangle getClientBounds() {
 294         XToolkit.awtLock();
 295         try {
 296             XWindowAttributes wattr = new XWindowAttributes();
 297             try {
 298                 XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
 299                 int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
 300                                                               xembed.handle, wattr.pData);
 301 
 302                 XToolkit.RESTORE_XERROR_HANDLER();
 303 
 304                 if (status == 0 ||
 305                     (XToolkit.saved_error != null &&
 306                      XToolkit.saved_error.get_error_code() != XConstants.Success)) {
 307                     return null;
 308                 }
 309 
 310                 return new Rectangle(wattr.get_x(), wattr.get_y(), wattr.get_width(), wattr.get_height());
 311             } finally {
 312                 wattr.dispose();
 313             }
 314         } finally {
 315             XToolkit.awtUnlock();
 316         }
 317     }
 318 
 319     void childResized() {
 320         if (xembedLog.isLoggable(PlatformLogger.FINER)) {
 321             Rectangle bounds = getClientBounds();
 322             xembedLog.finer("Child resized: " + bounds);
 323             // It is not required to update embedder's size when client size changes
 324             // However, since there is no any means to get client size it seems to be the
 325             // only way to provide it. However, it contradicts with Java layout concept -
 326             // so it is disabled for now.


   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


 278         super.dispose();
 279     }
 280 
 281     // Focusable is true in order to enable focus traversal through this Canvas
 282     public boolean isFocusable() {
 283         return true;
 284     }
 285 
 286     Window getTopLevel(Component comp) {
 287         while (comp != null && !(comp instanceof Window)) {
 288             comp = comp.getParent();
 289         }
 290         return (Window)comp;
 291     }
 292 
 293     Rectangle getClientBounds() {
 294         XToolkit.awtLock();
 295         try {
 296             XWindowAttributes wattr = new XWindowAttributes();
 297             try {
 298                 XErrorHandlerUtil.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
 299                 int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
 300                                                               xembed.handle, wattr.pData);
 301 
 302                 XErrorHandlerUtil.RESTORE_XERROR_HANDLER();
 303 
 304                 if ((status == 0) ||
 305                     ((XErrorHandlerUtil.saved_error != null) &&
 306                     (XErrorHandlerUtil.saved_error.get_error_code() != XConstants.Success))) {
 307                     return null;
 308                 }
 309 
 310                 return new Rectangle(wattr.get_x(), wattr.get_y(), wattr.get_width(), wattr.get_height());
 311             } finally {
 312                 wattr.dispose();
 313             }
 314         } finally {
 315             XToolkit.awtUnlock();
 316         }
 317     }
 318 
 319     void childResized() {
 320         if (xembedLog.isLoggable(PlatformLogger.FINER)) {
 321             Rectangle bounds = getClientBounds();
 322             xembedLog.finer("Child resized: " + bounds);
 323             // It is not required to update embedder's size when client size changes
 324             // However, since there is no any means to get client size it seems to be the
 325             // only way to provide it. However, it contradicts with Java layout concept -
 326             // so it is disabled for now.