コード例 #1
0
ファイル: WindowsDisplay.java プロジェクト: ravenocean/lwjgl
  /*
   * Called when the application is alt-tabbed to or from
   */
  private void appActivate(boolean active) {
    if (inAppActivate) {
      return;
    }
    inAppActivate = true;
    isFocused = active;
    if (active) {
      if (Display.isFullscreen()) {
        restoreDisplayMode();
      }
      if (parent == null) {
        setForegroundWindow(getHwnd());
      }
      setFocus(getHwnd());
      redoMakeContextCurrent = true;
      if (Display.isFullscreen()) updateClipping();

      if (keyboard != null) keyboard.fireLostKeyEvents();
    } else if (Display.isFullscreen()) {
      showWindow(getHwnd(), SW_SHOWMINNOACTIVE);
      resetDisplayMode();
    } else updateClipping();
    updateCursor();
    inAppActivate = false;
  }
コード例 #2
0
ファイル: WindowsDisplay.java プロジェクト: ravenocean/lwjgl
  public void setResizable(boolean resizable) {
    if (this.resizable != resizable) {
      int style = (int) getWindowLongPtr(hwnd, GWL_STYLE);
      int styleex = (int) getWindowLongPtr(hwnd, GWL_EXSTYLE);

      // update frame style
      if (resizable && !Display.isFullscreen()) {
        setWindowLongPtr(hwnd, GWL_STYLE, style |= (WS_THICKFRAME | WS_MAXIMIZEBOX));
      } else {
        setWindowLongPtr(hwnd, GWL_STYLE, style &= ~(WS_THICKFRAME | WS_MAXIMIZEBOX));
      }

      // from the existing client rect, determine the new window rect
      // based on the style changes - using AdjustWindowRectEx.
      getClientRect(hwnd, rect_buffer);
      rect.copyFromBuffer(rect_buffer);
      adjustWindowRectEx(rect_buffer, style, false, styleex);
      rect.copyFromBuffer(rect_buffer);

      // force a frame update and resize accordingly
      setWindowPos(
          hwnd,
          HWND_TOP,
          0,
          0,
          rect.right - rect.left,
          rect.bottom - rect.top,
          SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);

      updateWidthAndHeight();
      resized = false;
    }
    this.resizable = resizable;
  }
コード例 #3
0
ファイル: WindowsDisplay.java プロジェクト: ravenocean/lwjgl
 private void updateClipping() {
   if ((Display.isFullscreen() || (mouse != null && mouse.isGrabbed()))
       && !isMinimized
       && isFocused
       && (getForegroundWindow() == getHwnd() || hasParent)) {
     try {
       setupCursorClipping(getHwnd());
     } catch (LWJGLException e) {
       LWJGLUtil.log("setupCursorClipping failed: " + e.getMessage());
     }
   } else {
     resetCursorClipping();
   }
 }
コード例 #4
0
ファイル: WindowsDisplay.java プロジェクト: ravenocean/lwjgl
 public void reshape(int x, int y, int width, int height) {
   nReshape(
       getHwnd(), x, y, width, height, Display.isFullscreen() || isUndecorated(), parent != null);
 }
コード例 #5
0
ファイル: WindowsDisplay.java プロジェクト: ravenocean/lwjgl
  public void createWindow(DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y)
      throws LWJGLException {
    close_requested = false;
    is_dirty = false;
    isMinimized = false;
    isFocused = false;
    redoMakeContextCurrent = false;
    maximized = false;
    this.parent = parent;
    hasParent = parent != null;
    parent_hwnd = parent != null ? getHwnd(parent) : 0;
    this.hwnd =
        nCreateWindow(
            x,
            y,
            mode.getWidth(),
            mode.getHeight(),
            Display.isFullscreen() || isUndecorated(),
            parent != null,
            parent_hwnd);
    this.resizable = false;
    if (hwnd == 0) {
      throw new LWJGLException("Failed to create window");
    }
    this.hdc = getDC(hwnd);
    if (hdc == 0) {
      nDestroyWindow(hwnd);
      throw new LWJGLException("Failed to get dc");
    }

    try {
      if (drawable instanceof DrawableGL) {
        int format =
            WindowsPeerInfo.choosePixelFormat(
                getHdc(),
                0,
                0,
                (PixelFormat) drawable.getPixelFormat(),
                null,
                true,
                true,
                false,
                true);
        WindowsPeerInfo.setPixelFormat(getHdc(), format);
      } else {
        peer_info = new WindowsDisplayPeerInfo(true);
        ((DrawableGLES) drawable)
            .initialize(
                hwnd,
                hdc,
                EGL.EGL_WINDOW_BIT,
                (org.lwjgl.opengles.PixelFormat) drawable.getPixelFormat());
      }
      peer_info.initDC(getHwnd(), getHdc());
      showWindow(getHwnd(), SW_SHOWDEFAULT);

      updateWidthAndHeight();

      if (parent == null) {
        if (Display.isResizable()) {
          setResizable(true);
        }
        setForegroundWindow(getHwnd());
      } else {
        parent_focused = new AtomicBoolean(false);
        parent.addFocusListener(
            parent_focus_tracker =
                new FocusAdapter() {
                  public void focusGained(FocusEvent e) {
                    parent_focused.set(true);
                    clearAWTFocus();
                  }
                });
        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                clearAWTFocus();
              }
            });
      }
      grabFocus();
    } catch (LWJGLException e) {
      nReleaseDC(hwnd, hdc);
      nDestroyWindow(hwnd);
      throw e;
    }
  }