예제 #1
0
  /*
   * 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
  private void handleKeyButton(long wParam, long lParam, long millis) {
    if (keyboard == null) return;

    byte previous_state = (byte) ((lParam >>> 30) & 0x1);
    byte state = (byte) (1 - ((lParam >>> 31) & 0x1));
    boolean repeat = state == previous_state; // Repeat message
    byte extended = (byte) ((lParam >>> 24) & 0x1);
    int scan_code = (int) ((lParam >>> 16) & 0xFF);

    keyboard.handleKey((int) wParam, scan_code, extended != 0, state, millis, repeat);
  }
예제 #3
0
 private void handleChar(long wParam, long lParam, long millis) {
   byte previous_state = (byte) ((lParam >>> 30) & 0x1);
   byte state = (byte) (1 - ((lParam >>> 31) & 0x1));
   boolean repeat = state == previous_state;
   if (keyboard != null) keyboard.handleChar((int) (wParam & 0xFFFF), millis, repeat);
 }
예제 #4
0
 public void readKeyboard(ByteBuffer buffer) {
   keyboard.read(buffer);
 }
예제 #5
0
 public void pollKeyboard(ByteBuffer keyDownBuffer) {
   keyboard.poll(keyDownBuffer);
 }
예제 #6
0
  private long doHandleMessage(long hwnd, int msg, long wParam, long lParam, long millis) {
    /*switch ( msg ) {
    	case 0x0:
    	case 0x0020:
    	case 0x0084:
    	case WM_MOUSEMOVE:
    		break;
    	default:
    		WindowsEventDebug.printMessage(msg, wParam, lParam);
    }*/

    if (parent != null && !isFocused) {
      switch (msg) {
        case WM_LBUTTONDOWN:
        case WM_RBUTTONDOWN:
        case WM_MBUTTONDOWN:
        case WM_XBUTTONDOWN:
          sendMessage(parent_hwnd, msg, wParam, lParam);
      }
    }

    switch (msg) {
        // disable screen saver and monitor power down messages which wreak havoc
      case WM_ACTIVATE:
        /*switch ((int)wParam) {
        	case WA_ACTIVE:
        	case WA_CLICKACTIVE:
        		appActivate(true);
        		break;
        	case WA_INACTIVE:
        		appActivate(false);
        		break;
        }*/
        return 0L;
      case WM_SIZE:
        switch ((int) wParam) {
          case SIZE_RESTORED:
          case SIZE_MAXIMIZED:
            maximized = ((int) wParam) == SIZE_MAXIMIZED;
            resized = true;
            updateWidthAndHeight();
            setMinimized(false);
            break;
          case SIZE_MINIMIZED:
            setMinimized(true);
            break;
        }
        break;
      case WM_SIZING:
        resized = true;
        updateWidthAndHeight();
        break;
      case WM_SETCURSOR:
        if ((lParam & 0xFFFF) == HTCLIENT) {
          // if the cursor is inside the client area, reset it
          // to the current LWJGL-cursor
          updateCursor();
          return -1; // TRUE
        } else {
          // let Windows handle cursors outside the client area for resizing, etc.
          return defWindowProc(hwnd, msg, wParam, lParam);
        }
      case WM_KILLFOCUS:
        appActivate(false);
        return 0L;
      case WM_SETFOCUS:
        appActivate(true);
        return 0L;
      case WM_MOUSEACTIVATE:
        if (parent != null) {
          if (!isFocused) grabFocus();
          return 3L; // MA_NOACTIVATE
        }
        break;
      case WM_MOUSEMOVE:
        int xPos = (int) (short) (lParam & 0xFFFF);
        int yPos = transformY(getHwnd(), (int) (short) ((lParam >> 16) & 0xFFFF));
        handleMouseMoved(xPos, yPos, millis);
        checkCursorState();
        mouseInside = true;
        if (!trackingMouse) {
          trackingMouse = nTrackMouseEvent(hwnd);
        }
        return 0L;
      case WM_MOUSEWHEEL:
        int dwheel = (int) (short) ((wParam >> 16) & 0xFFFF);
        handleMouseScrolled(dwheel, millis);
        return 0L;
      case WM_LBUTTONDOWN:
        handleMouseButton(0, 1, millis);
        return 0L;
      case WM_LBUTTONUP:
        handleMouseButton(0, 0, millis);
        return 0L;
      case WM_RBUTTONDOWN:
        handleMouseButton(1, 1, millis);
        return 0L;
      case WM_RBUTTONUP:
        handleMouseButton(1, 0, millis);
        return 0L;
      case WM_MBUTTONDOWN:
        handleMouseButton(2, 1, millis);
        return 0L;
      case WM_MBUTTONUP:
        handleMouseButton(2, 0, millis);
        return 0L;
      case WM_XBUTTONUP:
        if ((wParam >> 16) == XBUTTON1) {
          handleMouseButton(3, 0, millis);
        } else {
          handleMouseButton(4, 0, millis);
        }
        return 1;
      case WM_XBUTTONDOWN:
        if ((wParam & 0xFF) == MK_XBUTTON1) {
          handleMouseButton(3, 1, millis);
        } else {
          handleMouseButton(4, 1, millis);
        }
        return 1;
      case WM_SYSCHAR:
      case WM_CHAR:
        handleChar(wParam, lParam, millis);
        return 0L;
      case WM_SYSKEYUP:
        /* Fall through */
      case WM_KEYUP:
        // SysRq apparently only generates WM_KEYUP, so we'll fake a WM_KEYDOWN
        if (wParam == WindowsKeycodes.VK_SNAPSHOT
            && keyboard != null
            && !keyboard.isKeyDown(org.lwjgl.input.Keyboard.KEY_SYSRQ)) {
          // Set key state to pressed
          long fake_lparam = lParam & ~(1 << 31);
          // Set key previous state to released
          fake_lparam &= ~(1 << 30);
          handleKeyButton(wParam, fake_lparam, millis);
        }
        /* Fall through */
      case WM_SYSKEYDOWN:
        /* Fall through */
      case WM_KEYDOWN:
        handleKeyButton(wParam, lParam, millis);
        break;
      case WM_QUIT:
        close_requested = true;
        return 0L;
      case WM_SYSCOMMAND:
        switch ((int) (wParam & 0xfff0)) {
          case SC_KEYMENU:
          case SC_MOUSEMENU:
          case SC_SCREENSAVE:
          case SC_MONITORPOWER:
            return 0L;
          case SC_CLOSE:
            close_requested = true;
            return 0L;
          default:
            break;
        }
        break;
      case WM_PAINT:
        is_dirty = true;
        break;
      case WM_MOUSELEAVE:
        mouseInside = false;
        trackingMouse = false;
        break;
      case WM_CANCELMODE:
        nReleaseCapture();
        /* fall through */
      case WM_CAPTURECHANGED:
        if (captureMouse != -1) {
          handleMouseButton(captureMouse, 0, millis);
          captureMouse = -1;
        }
        return 0L;
      case WM_WINDOWPOSCHANGED:
        if (getWindowRect(hwnd, rect_buffer)) {
          rect.copyFromBuffer(rect_buffer);
          x = rect.top;
          y = rect.bottom;
        } else {
          LWJGLUtil.log("WM_WINDOWPOSCHANGED: Unable to get window rect");
        }
        break;
      case WM_GETICON:
        iconsLoaded = true;
        break;
    }

    return defWindowProc(hwnd, msg, wParam, lParam);
  }