Ejemplo n.º 1
0
    @Override
    public synchronized void setVisibleActionPost(boolean visible, boolean nativeWindowCreated) {
      long t0;
      if (Window.DEBUG_IMPLEMENTATION) {
        t0 = System.nanoTime();
        System.err.println(
            "GLWindow.setVisibleActionPost("
                + visible
                + ", "
                + nativeWindowCreated
                + ") "
                + WindowImpl.getThreadName()
                + ", start");
      } else {
        t0 = 0;
      }

      /* if (nativeWindowCreated && null != context) {
          throw new GLException("InternalError: Native Windows has been just created, but context wasn't destroyed (is not null)");
      } */
      if (null == context
          && visible
          && 0 != window.getWindowHandle()
          && 0 < getWidth() * getHeight()) {
        NativeWindow nw;
        if (window.getWrappedWindow() != null) {
          nw =
              NativeWindowFactory.getNativeWindow(
                  window.getWrappedWindow(), window.getPrivateGraphicsConfiguration());
        } else {
          nw = window;
        }
        GLCapabilitiesImmutable glCaps =
            (GLCapabilitiesImmutable) nw.getGraphicsConfiguration().getChosenCapabilities();
        if (null == factory) {
          factory = GLDrawableFactory.getFactory(glCaps.getGLProfile());
        }
        if (null == drawable) {
          drawable = (GLDrawableImpl) factory.createGLDrawable(nw);
        }
        drawable.setRealized(true);
        context = (GLContextImpl) drawable.createContext(sharedContext);
        context.setContextCreationFlags(additionalCtxCreationFlags);
      }
      if (Window.DEBUG_IMPLEMENTATION) {
        System.err.println(
            "GLWindow.setVisibleActionPost("
                + visible
                + ", "
                + nativeWindowCreated
                + ") "
                + WindowImpl.getThreadName()
                + ", fin: dt "
                + (System.nanoTime() - t0) / 1e6
                + "ms");
      }
    }
Ejemplo n.º 2
0
  @Override
  protected boolean reconfigureWindowImpl(
      final int x, final int y, final int width, final int height, int flags) {
    final boolean _isOffscreenInstance = isOffscreenInstance(this, this.getParent());
    isOffscreenInstance = 0 != sscSurfaceHandle || _isOffscreenInstance;
    final PointImmutable pClientLevelOnSreen;
    if (isOffscreenInstance) {
      pClientLevelOnSreen = new Point(0, 0);
    } else {
      final NativeWindow parent = getParent();
      final boolean useParent = useParent(parent);
      if (useParent) {
        pClientLevelOnSreen = getLocationOnScreenImpl(x, y, parent, useParent);
      } else {
        pClientLevelOnSreen = new Point(x, y);
      }
    }

    if (DEBUG_IMPLEMENTATION) {
      final AbstractGraphicsConfiguration cWinCfg = this.getGraphicsConfiguration();
      final NativeWindow pWin = getParent();
      final AbstractGraphicsConfiguration pWinCfg =
          null != pWin ? pWin.getGraphicsConfiguration() : null;
      System.err.println(
          "MacWindow reconfig.0: "
              + x
              + "/"
              + y
              + " -> clientPos "
              + pClientLevelOnSreen
              + " - "
              + width
              + "x"
              + height
              + ",\n\t parent type "
              + (null != pWin ? pWin.getClass().getName() : null)
              + ",\n\t   this-chosenCaps "
              + (null != cWinCfg ? cWinCfg.getChosenCapabilities() : null)
              + ",\n\t parent-chosenCaps "
              + (null != pWinCfg ? pWinCfg.getChosenCapabilities() : null)
              + ", isOffscreenInstance(sscSurfaceHandle "
              + toHexString(sscSurfaceHandle)
              + ", ioi: "
              + _isOffscreenInstance
              + ") -> "
              + isOffscreenInstance
              + "\n\t, "
              + getReconfigureFlagsAsString(null, flags));
      // Thread.dumpStack();
    }

    final boolean setVisible = 0 != (FLAG_IS_VISIBLE & flags);

    if (0 != (FLAG_CHANGE_VISIBILITY & flags) && !setVisible) {
      if (!isOffscreenInstance) {
        OSXUtil.RunOnMainThread(
            false,
            new Runnable() {
              @Override
              public void run() {
                orderOut0(getWindowHandle());
                visibleChanged(true, false);
              }
            });
      } else {
        visibleChanged(true, false);
      }
    }
    if (0 == getWindowHandle() && setVisible
        || 0 != (FLAG_CHANGE_DECORATION & flags)
        || 0 != (FLAG_CHANGE_PARENTING & flags)
        || 0 != (FLAG_CHANGE_FULLSCREEN & flags)) {
      if (isOffscreenInstance) {
        createWindow(
            true, 0 != getWindowHandle(), pClientLevelOnSreen, 64, 64, false, setVisible, false);
      } else {
        createWindow(
            false,
            0 != getWindowHandle(),
            pClientLevelOnSreen,
            width,
            height,
            0 != (FLAG_IS_FULLSCREEN & flags),
            setVisible,
            0 != (FLAG_IS_ALWAYSONTOP & flags));
      }
    } else {
      if (width > 0 && height > 0) {
        if (!isOffscreenInstance) {
          OSXUtil.RunOnMainThread(
              false,
              new Runnable() {
                @Override
                public void run() {
                  setWindowClientTopLeftPointAndSize0(
                      getWindowHandle(),
                      pClientLevelOnSreen.getX(),
                      pClientLevelOnSreen.getY(),
                      width,
                      height,
                      setVisible);
                }
              });
        } // else offscreen size is realized via recreation
        // no native event (fullscreen, some reparenting)
        positionChanged(true, x, y);
        sizeChanged(true, width, height, false);
      }
      if (0 != (FLAG_CHANGE_VISIBILITY & flags) && setVisible) {
        if (!isOffscreenInstance) {
          OSXUtil.RunOnMainThread(
              false,
              new Runnable() {
                @Override
                public void run() {
                  orderFront0(getWindowHandle());
                  visibleChanged(true, true);
                }
              });
        } else {
          visibleChanged(true, true);
        }
      }
      if (!isOffscreenInstance) {
        setAlwaysOnTop0(getWindowHandle(), 0 != (FLAG_IS_ALWAYSONTOP & flags));
      }
    }
    if (DEBUG_IMPLEMENTATION) {
      System.err.println(
          "MacWindow reconfig.X: clientPos "
              + pClientLevelOnSreen
              + ", "
              + width
              + "x"
              + height
              + " -> clientPos "
              + getLocationOnScreenImpl(0, 0)
              + ", insets: "
              + getInsets());
    }
    return true;
  }