Esempio n. 1
0
  public LWWindowPeer(
      Window target,
      PlatformComponent platformComponent,
      PlatformWindow platformWindow,
      PeerType peerType) {
    super(target, platformComponent);
    this.platformWindow = platformWindow;
    this.peerType = peerType;

    Window owner = target.getOwner();
    LWWindowPeer ownerPeer =
        owner == null ? null : (LWWindowPeer) AWTAccessor.getComponentAccessor().getPeer(owner);
    PlatformWindow ownerDelegate = (ownerPeer != null) ? ownerPeer.getPlatformWindow() : null;

    // The delegate.initialize() needs a non-null GC on X11.
    GraphicsConfiguration gc = getTarget().getGraphicsConfiguration();
    synchronized (getStateLock()) {
      // graphicsConfig should be updated according to the real window
      // bounds when the window is shown, see 4868278
      this.graphicsConfig = gc;
    }

    if (!target.isFontSet()) {
      target.setFont(DEFAULT_FONT);
    }

    if (!target.isBackgroundSet()) {
      target.setBackground(SystemColor.window);
    } else {
      // first we check if user provided alpha for background. This is
      // similar to what Apple's Java do.
      // Since JDK7 we should rely on setOpacity() only.
      // this.opacity = c.getAlpha();
    }

    if (!target.isForegroundSet()) {
      target.setForeground(SystemColor.windowText);
      // we should not call setForeground because it will call a repaint
      // which the peer may not be ready to do yet.
    }

    platformWindow.initialize(target, this, ownerDelegate);

    // Init warning window(for applets)
    SecurityWarningWindow warn = null;
    if (target.getWarningString() != null) {
      // accessSystemTray permission allows to display TrayIcon, TrayIcon tooltip
      // and TrayIcon balloon windows without a warning window.
      if (!AWTAccessor.getWindowAccessor().isTrayIconWindow(target)) {
        LWToolkit toolkit = (LWToolkit) Toolkit.getDefaultToolkit();
        warn = toolkit.createSecurityWarning(target, this);
      }
    }

    warningWindow = warn;
  }
Esempio n. 2
0
 @Override
 public boolean rejectFocusRequest(FocusEvent.Cause cause) {
   // Cross-app activation requests are not allowed.
   if (cause != FocusEvent.Cause.MOUSE_EVENT
       && !((LWCToolkit) Toolkit.getDefaultToolkit()).isApplicationActive()) {
     focusLogger.fine("the app is inactive, so the request is rejected");
     return true;
   }
   return false;
 }
Esempio n. 3
0
  /**
   * *********************************************************** Callbacks from the AWTWindow and
   * AWTView objc classes. ***********************************************************
   */
  private void deliverWindowFocusEvent(boolean gained, CPlatformWindow opposite) {
    // Fix for 7150349: ingore "gained" notifications when the app is inactive.
    if (gained && !((LWCToolkit) Toolkit.getDefaultToolkit()).isApplicationActive()) {
      focusLogger.fine("the app is inactive, so the notification is ignored");
      return;
    }

    LWWindowPeer oppositePeer = (opposite == null) ? null : opposite.getPeer();
    responder.handleWindowFocusEvent(gained, oppositePeer);
  }
Esempio n. 4
0
 @Override // PlatformWindow
 public void toFront() {
   final long nsWindowPtr = getNSWindowPtr();
   LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit();
   Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
   final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
   if (w != null
       && acc.getPeer(w) != null
       && ((LWWindowPeer) acc.getPeer(w)).getPeerType() == LWWindowPeer.PeerType.EMBEDDED_FRAME
       && !lwcToolkit.isApplicationActive()) {
     lwcToolkit.activateApplicationIgnoringOtherApps();
   }
   updateFocusabilityForAutoRequestFocus(false);
   nativePushNSWindowToFront(nsWindowPtr);
   updateFocusabilityForAutoRequestFocus(true);
 }
Esempio n. 5
0
 void deinstallModalityListener() {
   ((SunToolkit) Toolkit.getDefaultToolkit()).removeModalityListener(this);
 }
Esempio n. 6
0
 void installModalityListener() {
   ((SunToolkit) Toolkit.getDefaultToolkit()).addModalityListener(this);
 }