Пример #1
0
  public void handleWindowFocusOut(Window oppositeWindow, long serial) {
    Window actualFocusedWindow = XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow();

    // If the actual focused window is not this decorated window then retain it.
    if (actualFocusedWindow != null && actualFocusedWindow != target) {
      Window owner = XWindowPeer.getDecoratedOwner(actualFocusedWindow);

      if (owner != null && owner == target) {
        setActualFocusedWindow((XWindowPeer) ComponentAccessor.getPeer(actualFocusedWindow));
      }
    }
    super.handleWindowFocusOut(oppositeWindow, serial);
  }
Пример #2
0
  public boolean requestWindowFocus(long time, boolean timeProvided) {
    focusLog.fine("Request for decorated window focus");
    // If this is Frame or Dialog we can't assure focus request success - but we still can try
    // If this is Window and its owner Frame is active we can be sure request succedded.
    Window win = (Window) target;
    Window focusedWindow = XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow();
    Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow);

    focusLog.log(
        Level.FINER,
        "Current window is: active={0}, focused={1}",
        new Object[] {Boolean.valueOf(win == activeWindow), Boolean.valueOf(win == focusedWindow)});

    XWindowPeer toFocus = this;
    while (toFocus.nextTransientFor != null) {
      toFocus = toFocus.nextTransientFor;
    }

    if (this == toFocus) {
      if (focusAllowedFor()) {
        if (win == activeWindow && win != focusedWindow) {
          // Happens when focus is on window child
          focusLog.fine("Focus is on child window - transfering it back");
          handleWindowFocusInSync(-1);
        } else {
          focusLog.fine("Requesting focus to this window");
          if (timeProvided) {
            requestXFocus(time);
          } else {
            requestXFocus();
          }
        }
        return true;
      } else {
        return false;
      }
    } else if (toFocus.focusAllowedFor()) {
      focusLog.fine("Requesting focus to " + toFocus);
      if (timeProvided) {
        toFocus.requestXFocus(time);
      } else {
        toFocus.requestXFocus();
      }
      return false;
    } else {
      // This might change when WM will have property to determine focus policy.
      // Right now, because policy is unknown we can't be sure we succedded
      return false;
    }
  }