src/java.desktop/unix/classes/sun/awt/X11/XEmbeddedFrame.java

Print this page




   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
  23  * questions.
  24  */
  25 
  26 package sun.awt.X11;
  27 
  28 import java.awt.AWTKeyStroke;

  29 import java.awt.Toolkit;

  30 

  31 import sun.awt.EmbeddedFrame;
  32 import sun.util.logging.PlatformLogger;
  33 
  34 @SuppressWarnings("serial") // JDK-implementation class
  35 public class XEmbeddedFrame extends EmbeddedFrame {
  36 
  37     private static final PlatformLogger log =
  38             PlatformLogger.getLogger(XEmbeddedFrame.class.getName());
  39 
  40     long handle;
  41     public XEmbeddedFrame() {
  42     }
  43 
  44     // handle should be a valid X Window.
  45     public XEmbeddedFrame(long handle) {
  46         this(handle, false);
  47     }
  48 
  49     // Handle is the valid X window
  50     public XEmbeddedFrame(long handle, boolean supportsXEmbed, boolean isTrayIconWindow) {
  51         super(handle, supportsXEmbed);
  52 
  53         if (isTrayIconWindow) {
  54             XTrayIconPeer.suppressWarningString(this);
  55         }
  56 
  57         this.handle = handle;
  58         if (handle != 0) { // Has actual parent
  59             addNotify();
  60             if (!isTrayIconWindow) {
  61                 show();
  62             }
  63         }
  64     }
  65 
  66     @SuppressWarnings("deprecation")
  67     public void addNotify()
  68     {
  69         if (getPeer() == null) {
  70             XToolkit toolkit = (XToolkit)Toolkit.getDefaultToolkit();
  71             setPeer(toolkit.createEmbeddedFrame(this));
  72         }
  73         super.addNotify();
  74     }
  75 
  76     public XEmbeddedFrame(long handle, boolean supportsXEmbed) {
  77         this(handle, supportsXEmbed, false);
  78     }
  79 
  80     /*
  81      * The method shouldn't be called in case of active XEmbed.
  82      */
  83     @SuppressWarnings("deprecation")
  84     public boolean traverseIn(boolean direction) {
  85         XEmbeddedFramePeer peer = (XEmbeddedFramePeer)getPeer();

  86         if (peer != null) {
  87             if (peer.supportsXEmbed() && peer.isXEmbedActive()) {
  88                 log.fine("The method shouldn't be called when XEmbed is active!");
  89             } else {
  90                 return super.traverseIn(direction);
  91             }
  92         }
  93         return false;
  94     }
  95 
  96     @SuppressWarnings("deprecation")
  97     protected boolean traverseOut(boolean direction) {
  98         XEmbeddedFramePeer xefp = (XEmbeddedFramePeer) getPeer();

  99         if (direction == FORWARD) {
 100             xefp.traverseOutForward();
 101         }
 102         else {
 103             xefp.traverseOutBackward();
 104         }
 105         return true;
 106     }
 107 
 108     /*
 109      * The method shouldn't be called in case of active XEmbed.
 110      */
 111     @SuppressWarnings("deprecation")
 112     public void synthesizeWindowActivation(boolean doActivate) {
 113         XEmbeddedFramePeer peer = (XEmbeddedFramePeer)getPeer();

 114         if (peer != null) {
 115             if (peer.supportsXEmbed() && peer.isXEmbedActive()) {
 116                 log.fine("The method shouldn't be called when XEmbed is active!");
 117             } else {
 118                 peer.synthesizeFocusInOut(doActivate);
 119             }
 120         }
 121     }
 122 
 123     @SuppressWarnings("deprecation")
 124     public void registerAccelerator(AWTKeyStroke stroke) {
 125         XEmbeddedFramePeer xefp = (XEmbeddedFramePeer) getPeer();

 126         if (xefp != null) {
 127             xefp.registerAccelerator(stroke);
 128         }
 129     }
 130     @SuppressWarnings("deprecation")
 131     public void unregisterAccelerator(AWTKeyStroke stroke) {
 132         XEmbeddedFramePeer xefp = (XEmbeddedFramePeer) getPeer();

 133         if (xefp != null) {
 134             xefp.unregisterAccelerator(stroke);
 135         }
 136     }
 137 }


   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
  23  * questions.
  24  */
  25 
  26 package sun.awt.X11;
  27 
  28 import java.awt.AWTKeyStroke;
  29 import java.awt.Component;
  30 import java.awt.Toolkit;
  31 import java.awt.peer.ComponentPeer;
  32 
  33 import sun.awt.AWTAccessor;
  34 import sun.awt.EmbeddedFrame;
  35 import sun.util.logging.PlatformLogger;
  36 
  37 @SuppressWarnings("serial") // JDK-implementation class
  38 public class XEmbeddedFrame extends EmbeddedFrame {
  39 
  40     private static final PlatformLogger log =
  41             PlatformLogger.getLogger(XEmbeddedFrame.class.getName());
  42 
  43     long handle;
  44     public XEmbeddedFrame() {
  45     }
  46 
  47     // handle should be a valid X Window.
  48     public XEmbeddedFrame(long handle) {
  49         this(handle, false);
  50     }
  51 
  52     // Handle is the valid X window
  53     public XEmbeddedFrame(long handle, boolean supportsXEmbed, boolean isTrayIconWindow) {
  54         super(handle, supportsXEmbed);
  55 
  56         if (isTrayIconWindow) {
  57             XTrayIconPeer.suppressWarningString(this);
  58         }
  59 
  60         this.handle = handle;
  61         if (handle != 0) { // Has actual parent
  62             addNotify();
  63             if (!isTrayIconWindow) {
  64                 show();
  65             }
  66         }
  67     }
  68 

  69     public void addNotify()
  70     {
  71         if (!isDisplayable()) {
  72             XToolkit toolkit = (XToolkit)Toolkit.getDefaultToolkit();
  73             setPeer(toolkit.createEmbeddedFrame(this));
  74         }
  75         super.addNotify();
  76     }
  77 
  78     public XEmbeddedFrame(long handle, boolean supportsXEmbed) {
  79         this(handle, supportsXEmbed, false);
  80     }
  81 
  82     /*
  83      * The method shouldn't be called in case of active XEmbed.
  84      */

  85     public boolean traverseIn(boolean direction) {
  86         XEmbeddedFramePeer peer = AWTAccessor.getComponentAccessor()
  87                                              .getPeer(this);
  88         if (peer != null) {
  89             if (peer.supportsXEmbed() && peer.isXEmbedActive()) {
  90                 log.fine("The method shouldn't be called when XEmbed is active!");
  91             } else {
  92                 return super.traverseIn(direction);
  93             }
  94         }
  95         return false;
  96     }
  97 

  98     protected boolean traverseOut(boolean direction) {
  99         XEmbeddedFramePeer xefp = AWTAccessor.getComponentAccessor()
 100                                              .getPeer(this);
 101         if (direction == FORWARD) {
 102             xefp.traverseOutForward();
 103         }
 104         else {
 105             xefp.traverseOutBackward();
 106         }
 107         return true;
 108     }
 109 
 110     /*
 111      * The method shouldn't be called in case of active XEmbed.
 112      */

 113     public void synthesizeWindowActivation(boolean doActivate) {
 114         XEmbeddedFramePeer peer = AWTAccessor.getComponentAccessor()
 115                                              .getPeer(this);
 116         if (peer != null) {
 117             if (peer.supportsXEmbed() && peer.isXEmbedActive()) {
 118                 log.fine("The method shouldn't be called when XEmbed is active!");
 119             } else {
 120                 peer.synthesizeFocusInOut(doActivate);
 121             }
 122         }
 123     }
 124 

 125     public void registerAccelerator(AWTKeyStroke stroke) {
 126         XEmbeddedFramePeer xefp = AWTAccessor.getComponentAccessor()
 127                                              .getPeer(this);
 128         if (xefp != null) {
 129             xefp.registerAccelerator(stroke);
 130         }
 131     }
 132 
 133     public void unregisterAccelerator(AWTKeyStroke stroke) {
 134         XEmbeddedFramePeer xefp = AWTAccessor.getComponentAccessor()
 135                                              .getPeer(this);
 136         if (xefp != null) {
 137             xefp.unregisterAccelerator(stroke);
 138         }
 139     }
 140 }