/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
public class XEmbedCanvasPeer extends XCanvasPeer implements WindowFocusListener, KeyEventPostProcessor, ModalityListener, WindowIDProvider {
private static final PlatformLogger xembedLog = PlatformLogger.getLogger("sun.awt.X11.xembed.XEmbedCanvasPeer");
Map<Long, AWTKeyStroke> accelerators = new HashMap<Long, AWTKeyStroke>(); // Maps accelerator ID into AWTKeyStroke
Map<AWTKeyStroke, Long> accel_lookup = new HashMap<AWTKeyStroke, Long>(); // Maps AWTKeyStroke into accelerator ID
XEmbedCanvasPeer() {}
super(params);
}
super(target);
}
// XEmbed canvas should be non-traversable.
// FIXME: Probably should be removed and enforced setting of it by the users
target.setFocusTraversalKeysEnabled(false);
}
| XConstants.ButtonMotionMask | XConstants.ExposureMask | XConstants.StructureNotifyMask | XConstants.SubstructureNotifyMask);
}
void installModalityListener() {
}
void deinstallModalityListener() {
}
void installAcceleratorListener() {
}
void deinstallAcceleratorListener() {
}
void installActivateListener() {
// FIXME: should watch for hierarchy changes
toplevel.addWindowFocusListener(this);
}
}
void deinstallActivateListener() {
}
}
boolean isXEmbedActive() {
}
boolean isApplicationActive() {
return applicationActive;
}
void initDispatching() {
if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Init embedding for " + Long.toHexString(xembed.handle));
try {
} finally {
}
}
void endDispatching() {
try {
// We can't deselect input since someone else might be interested in it
} finally {
}
}
detachChild();
}
}
void childDestroyed() {
}
super.handleEvent(e);
if (isXEmbedActive()) {
switch (e.getID()) {
case FocusEvent.FOCUS_GAINED:
break;
case FocusEvent.FOCUS_LOST:
break;
case KeyEvent.KEY_PRESSED:
case KeyEvent.KEY_RELEASED:
if (!((InputEvent)e).isConsumed()) {
forwardKeyEvent((KeyEvent)e);
}
break;
}
}
}
super.dispatchEvent(ev);
case XConstants.CreateNotify:
}
}
break;
case XConstants.DestroyNotify:
}
}
break;
case XConstants.ReparentNotify:
}
}
// Reparented into us - embed it
} else {
// Reparented out of us - detach it
}
break;
}
}
if (isXEmbedActive()) {
try {
return res;
} finally {
}
} else {
return super.getPreferredSize();
}
}
if (isXEmbedActive()) {
try {
return res;
} finally {
}
} else {
return super.getMinimumSize();
}
}
public void dispose() {
if (isXEmbedActive()) {
detachChild();
}
// BUG: Focus traversal doesn't become enabled after the one round of embedding
//target.setFocusTraversalKeysEnabled(true);
super.dispose();
}
// Focusable is true in order to enable focus traversal through this Canvas
public boolean isFocusable() {
return true;
}
}
}
try {
try {
if ((status == 0) ||
return null;
}
} finally {
}
} finally {
}
}
void childResized() {
// It is not required to update embedder's size when client size changes
// However, since there is no any means to get client size it seems to be the
// only way to provide it. However, it contradicts with Java layout concept -
// so it is disabled for now.
// Rectangle my_bounds = getBounds();
// setBounds(my_bounds.x, my_bounds.y, bounds.width, bounds.height, SET_BOUNDS);
}
XToolkit.postEvent(XToolkit.targetToAppContext(target), new ComponentEvent(target, ComponentEvent.COMPONENT_RESIZED));
}
void focusNext() {
if (isXEmbedActive()) {
public void run() {
}
}));
} else {
}
}
void focusPrev() {
if (isXEmbedActive()) {
public void run() {
}
}));
} else {
}
}
void requestXEmbedFocus() {
if (isXEmbedActive()) {
public void run() {
}
}));
} else {
}
}
void notifyChildEmbedded() {
xembed.sendMessage(xembed.handle, XEMBED_EMBEDDED_NOTIFY, getWindow(), Math.min(xembed.version, XEMBED_VERSION), 0);
if (isApplicationActive()) {
if (hasFocus()) {
}
}
}
void detachChild() {
if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Detaching child " + Long.toHexString(xembed.handle));
/**
* XEmbed specification:
* "The embedder can unmap the client and reparent the client window to the root window. If the
* client receives an ReparentNotify event, it should check the parent field of the XReparentEvent
* structure. If this is the root window of the window's screen, then the protocol is finished and
* there is no further interaction. If it is a window other than the root window, then the protocol
* continues with the new parent acting as the embedder window."
*/
try {
XlibWrapper.XReparentWindow(XToolkit.getDisplay(), xembed.handle, XToolkit.getDefaultRootWindow(), 0, 0);
} finally {
}
}
applicationActive = true;
if (isXEmbedActive()) {
}
}
applicationActive = false;
if (isXEmbedActive()) {
}
}
if (isXEmbedActive()) {
int flavor = XEMBED_FOCUS_CURRENT;
if (e instanceof CausedFocusEvent) {
}
}
}
}
if (isXEmbedActive() && !e.isTemporary()) {
int num = 0;
try {
} catch (NumberFormatException nfe) {
}
}
}
}
}
if (data == 0) {
return;
}
try {
if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Forwarding native key event: " + ke);
try {
} finally {
}
} finally {
}
}
/**
* GTK. Unfortunately, it doesn't support accelerator API, so,
* since this is the ONLY shortcut-processing API available, we
* must support it. See XEmbed.NON_STANDARD_XEMBED_GTK_*
* messages. The format of these messages is as follows:
* - request from client:
* data[1] = NON_STANDARD_XEMBED_GTK_GRAB_KEY or NON_STANDARD_XEMBED_GTK_UNGRAB_KEY
* data[3] = X keysym
* data[4] = X modifiers
*
* - response from server (in case the grabbed key has been pressed):
*/
public void run() {
synchronized(GRAB_LOCK) {
}
}
}));
}
public void run() {
synchronized(GRAB_LOCK) {
}
}
}));
}
public void run() {
if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Registering accelerator " + accel_id + " for " + stroke);
synchronized(ACCEL_LOCK) {
}
}
}
}));
}
public void run() {
synchronized(ACCEL_LOCK) {
if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Unregistering accelerator: " + accel_id);
}
}
}
}));
}
// Find the top-level and see if it is XEmbed client. If so, ask him to
// register the accelerator
}
}
// Find the top-level and see if it is XEmbed client. If so, ask him to
// register the accelerator
}
}
// Processing events only if we are in the focused window but
// we are not focus owner since otherwise we will get
// duplicate shortcut events in the client - one is from
// activate_accelerator, another from forwarded event
// FIXME: This is probably an incompatibility, protocol
// doesn't say anything about disable accelerators when client
// is focused.
return false;
}
boolean result = false;
// Process ACCELERATORS
long accel_id = 0;
boolean exists = false;
synchronized(ACCEL_LOCK) {
if (exists) {
}
}
if (exists) {
if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Activating accelerator " + accel_id);
xembed.sendMessage(xembed.handle, XEMBED_ACTIVATE_ACCELERATOR, accel_id, 0, 0); // FIXME: How about overloaded?
result = true;
}
// Process Grabs, unofficial GTK feature
exists = false;
synchronized(GRAB_LOCK) {
}
if (exists) {
forwardKeyEvent(e);
result = true;
}
return result;
}
}
}
super.handleClientMessage(xev);
if (xembedLog.isLoggable(PlatformLogger.FINER)) xembedLog.finer("Client message to embedder: " + msg);
}
if (isXEmbedActive()) {
case XEMBED_REQUEST_FOCUS:
break;
case XEMBED_FOCUS_NEXT:
focusNext();
break;
case XEMBED_FOCUS_PREV:
focusPrev();
break;
break;
break;
break;
break;
}
} else {
}
}
throws TooManyListenersException {
// Drop target listeners registered with this target will never be
// notified, since all drag notifications are routed to the XEmbed
// client. To avoid confusion we prohibit listeners registration
// by throwing TooManyListenersException as if there is a listener
// registered with this target already.
throw new TooManyListenersException();
}
}
public void setXEmbedDropTarget() {
// Register a drop site on the top level.
public void run() {
}
};
}
public void removeXEmbedDropTarget() {
// Unregister a drop site on the top level.
public void run() {
}
}
};
}
}
return true;
} else {
return false;
}
}
long version;
long flags;
boolean processXEmbedInfo() {
try {
// No more XEMBED_INFO? This is not XEmbed client!
// Unfortunately this is the initial state of the most clients
// FIXME: add 5-state processing
//childDestroyed();
return false;
}
if (new_mapped != currently_mapped) {
xembedLog.fine("Mapping state of the client has changed, old state: " + currently_mapped + ", new state: " + new_mapped);
if (new_mapped) {
try {
} finally {
}
} else {
try {
} finally {
}
}
} else {
}
return true;
} finally {
}
}
if (isXEmbedActive()) {
if (xembedLog.isLoggable(PlatformLogger.FINER)) xembedLog.finer("Property change on client: " + ev);
childResized();
}
}
} else {
}
}
if (isXEmbedActive()) {
childResized();
}
}
}
switch (type) {
case XConstants.PropertyNotify:
break;
case XConstants.ConfigureNotify:
break;
case XConstants.ClientMessage:
break;
}
}
}
static class GrabbedKey {
long keysym;
long modifiers;
}
}
if (data == 0) {
return;
}
try {
try {
} finally {
}
// We recognize only these masks
} finally {
}
}
public int hashCode() {
return (int)keysym & 0xFFFFFFFF;
}
if (!(o instanceof GrabbedKey)) {
return false;
}
}
}
}
}