// WComponentPeer overrides
  @SuppressWarnings("unchecked")
  protected void disposeImpl() {
    AppContext appContext = SunToolkit.targetToAppContext(target);
    synchronized (appContext) {
      List<WWindowPeer> l = (List<WWindowPeer>) appContext.get(ACTIVE_WINDOWS_KEY);
      if (l != null) {
        l.remove(this);
      }
    }

    // Remove ourself from the Map of DisplayChangeListeners
    GraphicsConfiguration gc = getGraphicsConfiguration();
    ((Win32GraphicsDevice) gc.getDevice()).removeDisplayChangedListener(this);

    synchronized (getStateLock()) {
      TranslucentWindowPainter currentPainter = painter;
      if (currentPainter != null) {
        currentPainter.flush();
        // don't set the current one to null here; reduces the chances of
        // MT issues (like NPEs)
      }
    }

    super.disposeImpl();
  }
示例#2
0
 private static int getGraphicsConfigScreen(GraphicsConfiguration gc) {
   // TODO: this method can be implemented in a more
   // efficient way by forwarding to the delegate
   GraphicsDevice gd = gc.getDevice();
   GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
   GraphicsDevice[] gds = ge.getScreenDevices();
   for (int i = 0; i < gds.length; i++) {
     if (gds[i] == gd) {
       return i;
     }
   }
   // Should never happen if gc is a screen device config
   return 0;
 }
示例#3
0
  /**
   * The incoming bounds describe the maximized size and position of the window on the monitor that
   * displays the window. But the window manager expects that the bounds are based on the size and
   * position of the primary monitor, even if the window ultimately maximizes onto a secondary
   * monitor. And the window manager adjusts these values to compensate for differences between the
   * primary monitor and the monitor that displays the window. The method translates the incoming
   * bounds to the values acceptable by the window manager. For more details, please refer to
   * 6699851.
   */
  private void adjustMaximizedBounds(Rectangle b) {
    GraphicsConfiguration currentDevGC = getGraphicsConfiguration();

    GraphicsDevice primaryDev =
        GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    GraphicsConfiguration primaryDevGC = primaryDev.getDefaultConfiguration();

    if (currentDevGC != null && currentDevGC != primaryDevGC) {
      Rectangle currentDevBounds = currentDevGC.getBounds();
      Rectangle primaryDevBounds = primaryDevGC.getBounds();

      boolean isCurrentDevLarger =
          ((currentDevBounds.width - primaryDevBounds.width > 0)
              || (currentDevBounds.height - primaryDevBounds.height > 0));

      // the window manager doesn't seem to compensate for differences when
      // the primary monitor is larger than the monitor that display the window
      if (isCurrentDevLarger) {
        b.width -= (currentDevBounds.width - primaryDevBounds.width);
        b.height -= (currentDevBounds.height - primaryDevBounds.height);
      }
    }
  }
  void initialize() {
    super.initialize();

    updateInsets(insets_);

    Font f = ((Window) target).getFont();
    if (f == null) {
      f = defaultFont;
      ((Window) target).setFont(f);
      setFont(f);
    }
    // Express our interest in display changes
    GraphicsConfiguration gc = getGraphicsConfiguration();
    ((Win32GraphicsDevice) gc.getDevice()).addDisplayChangedListener(this);

    initActiveWindowsTracking((Window) target);

    updateIconImages();

    Shape shape = ((Window) target).getShape();
    if (shape != null) {
      applyShape(Region.getInstance(shape, null));
    }

    float opacity = ((Window) target).getOpacity();
    if (opacity < 1.0f) {
      setOpacity(opacity);
    }

    synchronized (getStateLock()) {
      // default value of a boolean field is 'false', so set isOpaque to
      // true here explicitly
      this.isOpaque = true;
      setOpaque(((Window) target).isOpaque());
    }
  }