/* * 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; }
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; }
/** * @return this method will return the height of the Display window. * <p>If running in fullscreen mode it will return the height of the current set DisplayMode. * If Display.setParent(Canvas parent) is being used, the height of the parent will be * returned. * <p>This value will be updated after a call to Display.update(). */ public static int getHeight() { if (Display.isFullscreen()) { return Display.getDisplayMode().getHeight(); } if (parent != null) { return parent.getHeight(); } return height; }
/** * @return this method will return the width of the Display window. * <p>If running in fullscreen mode it will return the width of the current set DisplayMode. * If Display.setParent(Canvas parent) is being used, the width of the parent will be * returned. * <p>This value will be updated after a call to Display.update(). */ public static int getWidth() { if (Display.isFullscreen()) { return Display.getDisplayMode().getWidth(); } if (parent != null) { return parent.getWidth(); } return width; }
/** * @return this method will return the y position (top-left) of the Display window. * <p>If running in fullscreen mode it will return 0. If Display.setParent(Canvas parent) is * being used, the y position of the parent will be returned. */ public static int getY() { if (Display.isFullscreen()) { return 0; } if (parent != null) { return parent.getY(); } return display_impl.getY(); }
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(); } }
public void reshape(int x, int y, int width, int height) { nReshape( getHwnd(), x, y, width, height, Display.isFullscreen() || isUndecorated(), parent != null); }
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; } }