예제 #1
0
 public void windowLostFocus(WindowEvent e) {
   applicationActive = false;
   if (isXEmbedActive()) {
     xembedLog.fine("Sending WINDOW_DEACTIVATE");
     xembed.sendMessage(xembed.handle, XEMBED_WINDOW_DEACTIVATE);
   }
 }
예제 #2
0
 void notifyChildEmbedded() {
   xembed.sendMessage(
       xembed.handle,
       XEMBED_EMBEDDED_NOTIFY,
       getWindow(),
       Math.min(xembed.version, XEMBED_VERSION),
       0);
   if (isApplicationActive()) {
     xembedLog.fine("Sending WINDOW_ACTIVATE during initialization");
     xembed.sendMessage(xembed.handle, XEMBED_WINDOW_ACTIVATE);
     if (hasFocus()) {
       xembedLog.fine("Sending FOCUS_GAINED during initialization");
       xembed.sendMessage(xembed.handle, XEMBED_FOCUS_IN, XEMBED_FOCUS_CURRENT, 0, 0);
     }
   }
 }
예제 #3
0
  public boolean postProcessKeyEvent(KeyEvent e) {
    // 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.

    XWindowPeer parent = getToplevelXWindow();
    if (parent == null || !((Window) parent.getTarget()).isFocused() || target.isFocusOwner()) {
      return false;
    }

    boolean result = false;

    if (xembedLog.isLoggable(PlatformLogger.FINER)) xembedLog.finer("Post-processing event " + e);

    // Process ACCELERATORS
    AWTKeyStroke stroke = AWTKeyStroke.getAWTKeyStrokeForEvent(e);
    long accel_id = 0;
    boolean exists = false;
    synchronized (ACCEL_LOCK) {
      exists = accel_lookup.containsKey(stroke);
      if (exists) {
        accel_id = accel_lookup.get(stroke).longValue();
      }
    }
    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;
    GrabbedKey key = new GrabbedKey(e);
    synchronized (GRAB_LOCK) {
      exists = grabbed_keys.contains(key);
    }
    if (exists) {
      if (xembedLog.isLoggable(PlatformLogger.FINE)) xembedLog.fine("Forwarding grabbed key " + e);
      forwardKeyEvent(e);
      result = true;
    }

    return result;
  }
예제 #4
0
 void canvasFocusLost(FocusEvent e) {
   if (isXEmbedActive() && !e.isTemporary()) {
     xembedLog.fine("Forwarding FOCUS_LOST");
     int num = 0;
     if (AccessController.doPrivileged(new GetBooleanAction("sun.awt.xembed.testing"))) {
       Component opp = e.getOppositeComponent();
       try {
         num = Integer.parseInt(opp.getName());
       } catch (NumberFormatException nfe) {
       }
     }
     xembed.sendMessage(xembed.handle, XEMBED_FOCUS_OUT, num, 0, 0);
   }
 }
예제 #5
0
 void canvasFocusGained(FocusEvent e) {
   if (isXEmbedActive()) {
     xembedLog.fine("Forwarding FOCUS_GAINED");
     int flavor = XEMBED_FOCUS_CURRENT;
     if (e instanceof CausedFocusEvent) {
       CausedFocusEvent ce = (CausedFocusEvent) e;
       if (ce.getCause() == CausedFocusEvent.Cause.TRAVERSAL_FORWARD) {
         flavor = XEMBED_FOCUS_FIRST;
       } else if (ce.getCause() == CausedFocusEvent.Cause.TRAVERSAL_BACKWARD) {
         flavor = XEMBED_FOCUS_LAST;
       }
     }
     xembed.sendMessage(xembed.handle, XEMBED_FOCUS_IN, flavor, 0, 0);
   }
 }
예제 #6
0
 public void modalityPopped(ModalityEvent ev) {
   xembed.sendMessage(xembed.handle, XEMBED_MODALITY_OFF);
 }