コード例 #1
0
ファイル: CPlatformWindow.java プロジェクト: netroby/jdk9-dev
 protected void applyWindowLevel(Window target) {
   if (target.isAlwaysOnTop() && target.getType() != Window.Type.POPUP) {
     CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSFloatingWindowLevel);
   } else if (target.getType() == Window.Type.POPUP) {
     CWrapper.NSWindow.setLevel(getNSWindowPtr(), CWrapper.NSWindow.NSPopUpMenuWindowLevel);
   }
 }
コード例 #2
0
ファイル: CPlatformWindow.java プロジェクト: netroby/jdk9-dev
  private void orderAboveSiblings() {
    if (owner == null) {
      return;
    }

    // NOTE: the logic will fail if we have a hierarchy like:
    //       visible root owner
    //          invisible owner
    //              visible dialog
    // However, this is an unlikely scenario for real life apps
    if (owner.isVisible()) {
      // Recursively pop up the windows from the very bottom so that only
      // the very top-most one becomes the main window
      owner.orderAboveSiblings();

      // Order the window to front of the stack of child windows
      final long nsWindowSelfPtr = getNSWindowPtr();
      final long nsWindowOwnerPtr = owner.getNSWindowPtr();
      CWrapper.NSWindow.orderFront(nsWindowOwnerPtr);
      CWrapper.NSWindow.orderWindow(
          nsWindowSelfPtr, CWrapper.NSWindow.NSWindowAbove, nsWindowOwnerPtr);
    }

    applyWindowLevel(target);
  }
コード例 #3
0
ファイル: CPlatformWindow.java プロジェクト: netroby/jdk9-dev
  @Override
  public boolean requestWindowFocus() {

    long ptr = getNSWindowPtr();
    if (CWrapper.NSWindow.canBecomeMainWindow(ptr)) {
      CWrapper.NSWindow.makeMainWindow(ptr);
    }
    CWrapper.NSWindow.makeKeyAndOrderFront(ptr);
    return true;
  }
コード例 #4
0
ファイル: CPlatformWindow.java プロジェクト: netroby/jdk9-dev
  @Override
  public void setWindowState(int windowState) {
    if (peer == null || !peer.isVisible()) {
      // setVisible() applies the state
      return;
    }

    int prevWindowState = peer.getState();
    if (prevWindowState == windowState) return;

    final long nsWindowPtr = getNSWindowPtr();
    if ((windowState & Frame.ICONIFIED) != 0) {
      // Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
      windowState = Frame.ICONIFIED;
    }
    switch (windowState) {
      case Frame.ICONIFIED:
        if (prevWindowState == Frame.MAXIMIZED_BOTH) {
          // let's return into the normal states first
          // the zoom call toggles between the normal and the max states
          unmaximize();
        }
        CWrapper.NSWindow.miniaturize(nsWindowPtr);
        break;
      case Frame.MAXIMIZED_BOTH:
        if (prevWindowState == Frame.ICONIFIED) {
          // let's return into the normal states first
          CWrapper.NSWindow.deminiaturize(nsWindowPtr);
        }
        maximize();
        break;
      case Frame.NORMAL:
        if (prevWindowState == Frame.ICONIFIED) {
          CWrapper.NSWindow.deminiaturize(nsWindowPtr);
        } else if (prevWindowState == Frame.MAXIMIZED_BOTH) {
          // the zoom call toggles between the normal and the max states
          unmaximize();
        }
        break;
      default:
        throw new RuntimeException("Unknown window state: " + windowState);
    }

    // NOTE: the SWP.windowState field gets updated to the newWindowState
    //       value when the native notification comes to us
  }
コード例 #5
0
ファイル: CPlatformWindow.java プロジェクト: netroby/jdk9-dev
  @Override
  public void setOpaque(boolean isOpaque) {
    CWrapper.NSWindow.setOpaque(getNSWindowPtr(), isOpaque);
    boolean isTextured = (peer == null) ? false : peer.isTextured();
    if (!isTextured) {
      if (!isOpaque) {
        CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), 0);
      } else if (peer != null) {
        Color color = peer.getBackground();
        if (color != null) {
          int rgb = color.getRGB();
          CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), rgb);
        }
      }
    }

    // This is a temporary workaround. Looks like after 7124236 will be fixed
    // the correct place for invalidateShadow() is CGLayer.drawInCGLContext.
    SwingUtilities.invokeLater(this::invalidateShadow);
  }
コード例 #6
0
ファイル: CPlatformWindow.java プロジェクト: netroby/jdk9-dev
  private boolean checkBlockingAndOrder() {
    LWWindowPeer blocker = (peer == null) ? null : peer.getBlocker();
    if (blocker == null) {
      return false;
    }

    if (blocker instanceof CPrinterDialogPeer) {
      return true;
    }

    CPlatformWindow pWindow = (CPlatformWindow) blocker.getPlatformWindow();

    pWindow.orderAboveSiblings();

    final long nsWindowPtr = pWindow.getNSWindowPtr();
    CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr);
    CWrapper.NSWindow.makeKeyAndOrderFront(nsWindowPtr);
    CWrapper.NSWindow.makeMainWindow(nsWindowPtr);

    return true;
  }
コード例 #7
0
ファイル: CPlatformWindow.java プロジェクト: netroby/jdk9-dev
  private void unmaximize() {
    if (!isMaximized()) {
      return;
    }
    if (!undecorated) {
      CWrapper.NSWindow.zoom(getNSWindowPtr());
    } else {
      deliverZoom(false);

      Rectangle toBounds = this.normalBounds;
      this.normalBounds = null;
      setBounds(toBounds.x, toBounds.y, toBounds.width, toBounds.height);
    }
  }
コード例 #8
0
ファイル: CPlatformWindow.java プロジェクト: netroby/jdk9-dev
  private void maximize() {
    if (peer == null || isMaximized()) {
      return;
    }
    if (!undecorated) {
      CWrapper.NSWindow.zoom(getNSWindowPtr());
    } else {
      deliverZoom(true);

      // We need an up to date size of the peer, so we flush the native events
      // to be sure that there are no setBounds requests in the queue.
      LWCToolkit.flushNativeSelectors();
      this.normalBounds = peer.getBounds();
      Rectangle maximizedBounds = peer.getMaximizedBounds();
      setBounds(
          maximizedBounds.x, maximizedBounds.y, maximizedBounds.width, maximizedBounds.height);
    }
  }
コード例 #9
0
ファイル: CPlatformWindow.java プロジェクト: netroby/jdk9-dev
 @Override
 public void setOpacity(float opacity) {
   CWrapper.NSWindow.setAlphaValue(getNSWindowPtr(), opacity);
 }
コード例 #10
0
ファイル: CPlatformWindow.java プロジェクト: netroby/jdk9-dev
 @Override
 public boolean isActive() {
   long ptr = getNSWindowPtr();
   return CWrapper.NSWindow.isKeyWindow(ptr);
 }
コード例 #11
0
ファイル: CPlatformWindow.java プロジェクト: netroby/jdk9-dev
  @Override // PlatformWindow
  public void setVisible(boolean visible) {
    final long nsWindowPtr = getNSWindowPtr();

    // Configure stuff
    updateIconImages();
    updateFocusabilityForAutoRequestFocus(false);

    boolean wasMaximized = isMaximized();

    if (visible && target.isLocationByPlatform()) {
      nativeSetNSWindowLocationByPlatform(getNSWindowPtr());
    }

    // Actually show or hide the window
    LWWindowPeer blocker = (peer == null) ? null : peer.getBlocker();
    if (blocker == null || !visible) {
      // If it ain't blocked, or is being hidden, go regular way
      if (visible) {
        CWrapper.NSWindow.makeFirstResponder(nsWindowPtr, contentView.getAWTView());

        boolean isPopup = (target.getType() == Window.Type.POPUP);
        if (isPopup) {
          // Popups in applets don't activate applet's process
          CWrapper.NSWindow.orderFrontRegardless(nsWindowPtr);
        } else {
          CWrapper.NSWindow.orderFront(nsWindowPtr);
        }

        boolean isKeyWindow = CWrapper.NSWindow.isKeyWindow(nsWindowPtr);
        if (!isKeyWindow) {
          CWrapper.NSWindow.makeKeyWindow(nsWindowPtr);
        }
      } else {
        // immediately hide the window
        CWrapper.NSWindow.orderOut(nsWindowPtr);
        // process the close
        CWrapper.NSWindow.close(nsWindowPtr);
      }
    } else {
      // otherwise, put it in a proper z-order
      CWrapper.NSWindow.orderWindow(
          nsWindowPtr,
          CWrapper.NSWindow.NSWindowBelow,
          ((CPlatformWindow) blocker.getPlatformWindow()).getNSWindowPtr());
    }
    this.visible = visible;

    // Manage the extended state when showing
    if (visible) {
      // Apply the extended state as expected in shared code
      if (target instanceof Frame) {
        if (!wasMaximized && isMaximized()) {
          // setVisible could have changed the native maximized state
          deliverZoom(true);
        } else {
          int frameState = ((Frame) target).getExtendedState();
          if ((frameState & Frame.ICONIFIED) != 0) {
            // Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
            frameState = Frame.ICONIFIED;
          }
          switch (frameState) {
            case Frame.ICONIFIED:
              CWrapper.NSWindow.miniaturize(nsWindowPtr);
              break;
            case Frame.MAXIMIZED_BOTH:
              maximize();
              break;
            default: // NORMAL
              unmaximize(); // in case it was maximized, otherwise this is a no-op
              break;
          }
        }
      }
    }

    nativeSynthesizeMouseEnteredExitedEvents();

    // Configure stuff #2
    updateFocusabilityForAutoRequestFocus(true);

    // Manage parent-child relationship when showing
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();

    if (visible) {
      // Order myself above my parent
      if (owner != null && owner.isVisible()) {
        CWrapper.NSWindow.orderWindow(
            nsWindowPtr, CWrapper.NSWindow.NSWindowAbove, owner.getNSWindowPtr());
        applyWindowLevel(target);
      }

      // Order my own children above myself
      for (Window w : target.getOwnedWindows()) {
        final Object p = acc.getPeer(w);
        if (p instanceof LWWindowPeer) {
          CPlatformWindow pw = (CPlatformWindow) ((LWWindowPeer) p).getPlatformWindow();
          if (pw != null && pw.isVisible()) {
            CWrapper.NSWindow.orderWindow(
                pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove, nsWindowPtr);
            pw.applyWindowLevel(w);
          }
        }
      }
    }

    // Deal with the blocker of the window being shown
    if (blocker != null && visible) {
      // Make sure the blocker is above its siblings
      ((CPlatformWindow) blocker.getPlatformWindow()).orderAboveSiblings();
    }
  }
コード例 #12
0
ファイル: CPlatformWindow.java プロジェクト: netroby/jdk9-dev
 private boolean isMaximized() {
   return undecorated ? this.normalBounds != null : CWrapper.NSWindow.isZoomed(getNSWindowPtr());
 }