コード例 #1
0
ファイル: GLWindow.java プロジェクト: swkzr/jogl
    @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");
      }
    }
コード例 #2
0
ファイル: WindowDriver.java プロジェクト: metsci/jogl
  private Point getLocationOnScreenImpl(
      final int x, final int y, final NativeWindow parent, final boolean useParent) {
    if (!useParent && !isOffscreenInstance && 0 != surfaceHandle) {
      return OSXUtil.GetLocationOnScreen(surfaceHandle, true, x, y);
    }

    final Point p = new Point(x, y);
    if (useParent) {
      p.translate(parent.getLocationOnScreen(null));
    }
    return p;
  }
コード例 #3
0
ファイル: WindowDriver.java プロジェクト: metsci/jogl
 @Override
 public void updatePosition(int x, int y) {
   final long handle = getWindowHandle();
   if (0 != handle && !isOffscreenInstance) {
     final NativeWindow parent = getParent();
     final boolean useParent = useParent(parent);
     final int pX = parent.getX(), pY = parent.getY();
     final Point p0S = getLocationOnScreenImpl(x, y, parent, useParent);
     if (DEBUG_IMPLEMENTATION) {
       System.err.println(
           "MacWindow: updatePosition() parent["
               + useParent
               + " "
               + pX
               + "/"
               + pY
               + "] "
               + x
               + "/"
               + y
               + " ->  "
               + x
               + "/"
               + y
               + " rel-client-pos, "
               + p0S
               + " screen-client-pos");
     }
     OSXUtil.RunOnMainThread(
         false,
         new Runnable() {
           @Override
           public void run() {
             setWindowClientTopLeftPoint0(handle, p0S.getX(), p0S.getY(), isVisible());
           }
         });
     // no native event (fullscreen, some reparenting)
     positionChanged(true, x, y);
   }
 }
コード例 #4
0
ファイル: WindowDriver.java プロジェクト: metsci/jogl
 /** Callback for native screen position change event of the client area. */
 protected void screenPositionChanged(boolean defer, int newX, int newY) {
   // passed coordinates are in screen position of the client area
   if (getWindowHandle() != 0) {
     final NativeWindow parent = getParent();
     if (null == parent || isOffscreenInstance) {
       if (DEBUG_IMPLEMENTATION) {
         System.err.println(
             "MacWindow.positionChanged.0 (Screen Pos - TOP): ("
                 + getThreadName()
                 + "): (defer: "
                 + defer
                 + ") "
                 + getX()
                 + "/"
                 + getY()
                 + " -> "
                 + newX
                 + "/"
                 + newY);
       }
       positionChanged(defer, newX, newY);
     } else {
       // screen position -> rel child window position
       Point absPos = new Point(newX, newY);
       Point parentOnScreen = parent.getLocationOnScreen(null);
       absPos.translate(parentOnScreen.scale(-1, -1));
       if (DEBUG_IMPLEMENTATION) {
         System.err.println(
             "MacWindow.positionChanged.1 (Screen Pos - CHILD): ("
                 + getThreadName()
                 + "): (defer: "
                 + defer
                 + ") "
                 + getX()
                 + "/"
                 + getY()
                 + " -> absPos "
                 + newX
                 + "/"
                 + newY
                 + ", parentOnScreen "
                 + parentOnScreen
                 + " -> "
                 + absPos);
       }
       positionChanged(defer, absPos.getX(), absPos.getY());
     }
   } else if (DEBUG_IMPLEMENTATION) {
     System.err.println(
         "MacWindow.positionChanged.2 (Screen Pos - IGN): ("
             + getThreadName()
             + "): (defer: "
             + defer
             + ") "
             + getX()
             + "/"
             + getY()
             + " -> "
             + newX
             + "/"
             + newY);
   }
 }
コード例 #5
0
ファイル: WindowDriver.java プロジェクト: metsci/jogl
  @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;
  }
コード例 #6
0
ファイル: WindowDriver.java プロジェクト: metsci/jogl
 private boolean useParent(NativeWindow parent) {
   return null != parent && 0 != parent.getWindowHandle();
 }