Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions jme3-core/src/main/java/com/jme3/system/AppSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ public final class AppSettings extends HashMap<String, Object> {
defaults.put("SwapBuffers", true);
defaults.put("OpenCL", false);
defaults.put("OpenCLPlatformChooser", DefaultPlatformChooser.class.getName());
defaults.put("CenterWindow", true);
// defaults.put("Icons", null);
}

Expand Down Expand Up @@ -1331,4 +1332,63 @@ public boolean isGraphicsTrace() {
public void setGraphicsTrace(boolean trace) {
putBoolean("GraphicsTrace", trace);
}

/**
* Get the Center Window state
*
* @return true for center the window in the middle of the screen
* @see #setCenterWindow(boolean)
*/
public boolean getCenterWindow() {
return getBoolean("CenterWindow");
}

/**
* True to enable center the window.
*
* @param center whether to center the window or not.
*/
public void setCenterWindow(boolean center) {
putBoolean("CenterWindow", center);
}


/**
* Get the position of the window's X Position
*
* @return int screen coordinates of the X Position of the window
* @see #setWindowXPosition(int)
*/
public int getWindowXPosition() {
return getInteger("windowXpos");
}

/**
* The position of the window's X Position.
*
* @param pos screen coordinates for the X position.
*/
public void setWindowXPosition(int pos) {
putInteger("windowXpos", pos);
}


/**
* Get the position of the window's Y Position
*
* @return int screen coordinates of the Y Position of the window
* @see #setWindowXPosition(int)
*/
public int getWindowYPosition() {
return getInteger("windowYpos");
}

/**
* The position of the window's Y Position.
*
* @param pos screen coordinates for the Y position.
*/
public void setWindowYPosition(int pos) {
putInteger("windowYpos", pos);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,16 @@ public void invoke(final long window, final boolean focus) {
}
});

// Center the window
if (!settings.isFullscreen()) {
glfwSetWindowPos(window,
if (settings.getCenterWindow())
{
// Center the window
glfwSetWindowPos(window,
(videoMode.width() - settings.getWidth()) / 2,
(videoMode.height() - settings.getHeight()) / 2);
} else {
glfwSetWindowPos(window,settings.getWindowXPosition(), settings.getWindowYPosition());
}
}

// Make the OpenGL context current
Expand Down