Skip to content

Commit

Permalink
renamed monitor data into generic form of Display for compatibility f…
Browse files Browse the repository at this point in the history
…or other devices.
  • Loading branch information
bob0bob committed Sep 22, 2023
1 parent 6a590db commit 8594c1d
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,13 @@ private Rect getSurfaceFrame() {
}

@Override
public Monitors getMonitors() {
public Displays getDisplays() {
// TODO Auto-generated method stub
return null;
}

@Override
public int getPrimaryMonitor() {
public int getPrimaryDisplay() {
// TODO Auto-generated method stub
return 0;
}
Expand Down
8 changes: 4 additions & 4 deletions jme3-core/src/main/java/com/jme3/app/LegacyApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,8 @@ public Object call() {
*
* @return returns a list of monitors and their information.
*/
public Monitors getMonitors() {
return context.getMonitors();
public Displays getDisplays() {
return context.getDisplays();
}

/**
Expand All @@ -835,7 +835,7 @@ public Monitors getMonitors() {
*
* @return the position of the value in the arraylist of the primary monitor.
*/
public int getPrimaryMonitor() {
return context.getPrimaryMonitor();
public int getPrimaryDisplay() {
return context.getPrimaryDisplay();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
*
* @author Kevin Bales
*/
public class MonitorInfo {
public class DisplayInfo {

/**
* monitorID - monitor id that was return from Lwjgl3.
*/
public long monitorID = 0;
public long displayID = 0;

/**
* width - width that was return from Lwjgl3.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@
import java.util.ArrayList;

/**
* This class holds all information about all monitors that where return from the glfwGetMonitors()
* This class holds all information about all displays that where return from the glfwGetMonitors()
* call. It stores them into an <ArrayList>
*
* @author Kevin Bales
*/
public class Monitors {
public class Displays {

private ArrayList<MonitorInfo> monitors = new ArrayList<MonitorInfo>();
private ArrayList<DisplayInfo> monitors = new ArrayList<DisplayInfo>();

public int addNewMonitor(long monitorID) {
MonitorInfo info = new MonitorInfo();
info.monitorID = monitorID;
DisplayInfo info = new DisplayInfo();
info.displayID = monitorID;
monitors.add(info);
return monitors.size() - 1;
}

/**
* This function returns the size of the monitor ArrayList
* This function returns the size of the displays ArrayList
*
* @return the
*/
Expand All @@ -54,12 +54,12 @@ public int size() {
}

/**
* Call to get monitor information on a certain monitor.
* Call to get monitor information on a certain display.
*
* @param pos the position in the arraylist of the monitor information that you want to get.
* @return returns the MonitorInfo data for the monitor called for.
* @param pos the position in the arraylist of the display information that you want to get.
* @return returns the DisplayInfo data for the display called for.
*/
public MonitorInfo get(int pos) {
public DisplayInfo get(int pos) {
if (pos < monitors.size())
return monitors.get(pos);

Expand All @@ -76,7 +76,7 @@ public MonitorInfo get(int pos) {
*/
public void setInfo(int monPos, String name, int width, int height, int rate) {
if (monPos < monitors.size()) {
MonitorInfo info = monitors.get(monPos);
DisplayInfo info = monitors.get(monPos);
if (info != null) {
info.width = width;
info.height = height;
Expand All @@ -91,9 +91,9 @@ public void setInfo(int monPos, String name, int width, int height, int rate) {
*
* @param monPos the position in the arraylist of which monitor is the primary monitor
*/
public void setPrimaryMonitor(int monPos) {
public void setActiveMonitor(int monPos) {
if (monPos < monitors.size()) {
MonitorInfo info = monitors.get(monPos);
DisplayInfo info = monitors.get(monPos);
if (info != null)
info.primary = true;
}
Expand Down
12 changes: 6 additions & 6 deletions jme3-core/src/main/java/com/jme3/system/JmeContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,18 @@ public enum Type {
public int getWindowYPosition();

/**
* This call will return a list of Monitors that glfwGetMonitors() returns and information about
* This call will return a list of Displays that glfwGetMonitors() returns and information about
* the monitor, like width, height, and refresh rate.
*
* @return returns a list of monitors and their information.
* @return returns a list of displays and their information.
*/
public Monitors getMonitors();
public Displays getDisplays();

/**
* Use this to get the positional number of the primary monitor from the glfwGetMonitors()
* Use this to get the positional number of the primary Displays from the glfwGetMonitors()
* function call.
*
* @return the position of the value in the arraylist of the primary monitor.
* @return the position of the value in the arraylist of the primary Displays.
*/
public int getPrimaryMonitor();
public int getPrimaryDisplay();
}
4 changes: 2 additions & 2 deletions jme3-core/src/main/java/com/jme3/system/NullContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,13 @@ public int getWindowYPosition() {
}

@Override
public Monitors getMonitors() {
public Displays getDisplays() {
// TODO Auto-generated method stub
return null;
}

@Override
public int getPrimaryMonitor() {
public int getPrimaryDisplay() {
// TODO Auto-generated method stub
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions jme3-desktop/src/main/java/com/jme3/system/AWTContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ public int getWindowYPosition() {
}

@Override
public Monitors getMonitors() {
public Displays getDisplays() {
// TODO Auto-generated method stub
return null;
}

@Override
public int getPrimaryMonitor() {
public int getPrimaryDisplay() {
// TODO Auto-generated method stub
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,13 @@ public int getWindowYPosition() {
}

@Override
public Monitors getMonitors() {
public Displays getDisplays() {
// TODO Auto-generated method stub
return null;
}

@Override
public int getPrimaryMonitor() {
public int getPrimaryDisplay() {
// TODO Auto-generated method stub
return 0;
}
Expand Down
10 changes: 5 additions & 5 deletions jme3-examples/src/main/java/jme3test/app/TestMonitorApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.system.AppSettings;
import com.jme3.system.MonitorInfo;
import com.jme3.system.Monitors;
import com.jme3.system.DisplayInfo;
import com.jme3.system.Displays;

/**
* Tests the capability to change which monitor the window will be created on.
Expand All @@ -67,7 +67,7 @@ public class TestMonitorApp extends SimpleApplication
private BitmapText selectedMonitorTxt;
private BitmapText fullScreenTxt;
private int monitorSelected = 0;
private Monitors monitors = null;
private Displays monitors = null;

public static void main(String[] args) {
TestMonitorApp app = new TestMonitorApp();
Expand Down Expand Up @@ -116,7 +116,7 @@ public void simpleInitApp() {

// Get the selected monitor
monitorSelected = settings.getMonitor();
monitors = context.getMonitors();
monitors = context.getDisplays();
if (monitors != null)
numMonitors = monitors.size();

Expand Down Expand Up @@ -155,7 +155,7 @@ public void simpleInitApp() {

// Let's loop through all the monitors and display on the screen
for (int i = 0; i < monitors.size(); i++) {
MonitorInfo monitor = monitors.get(i);
DisplayInfo monitor = monitors.get(i);
labelValue = "Mon : " + i + " " + monitor.name + " " + monitor.width
+ "," + monitor.height + " refresh: " + monitor.rate;
txt = new BitmapText(loadGuiFont());
Expand Down
4 changes: 2 additions & 2 deletions jme3-ios/src/main/java/com/jme3/system/ios/IGLESContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,13 @@ public int getWindowYPosition() {
}

@Override
public Monitors getMonitors() {
public Displays getDisplays() {
// TODO Auto-generated method stub
return null;
}

@Override
public int getPrimaryMonitor() {
public int getPrimaryDisplay() {
// TODO Auto-generated method stub
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.jme3.system.JmeCanvasContext;
import com.jme3.system.JmeContext.Type;
import com.jme3.system.JmeSystem;
import com.jme3.system.Monitors;
import com.jme3.system.Displays;
import com.jme3.system.Platform;
import java.awt.Canvas;
import java.util.logging.Level;
Expand Down Expand Up @@ -484,13 +484,13 @@ protected void createContext(AppSettings settings) {
}

@Override
public Monitors getMonitors() {
public Displays getDisplays() {
// TODO Auto-generated method stub
return null;
}

@Override
public int getPrimaryMonitor() {
public int getPrimaryDisplay() {
// TODO Auto-generated method stub
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

import com.jme3.system.AppSettings;
import com.jme3.system.JmeContext.Type;
import com.jme3.system.Monitors;
import com.jme3.system.Displays;

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
Expand Down Expand Up @@ -285,13 +285,13 @@ private ByteBuffer imageToByteBuffer(BufferedImage image) {
}

@Override
public Monitors getMonitors() {
public Displays getDisplays() {
// TODO Auto-generated method stub
return null;
}

@Override
public int getPrimaryMonitor() {
public int getPrimaryDisplay() {
// TODO Auto-generated method stub
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import com.jme3.input.TouchInput;
import com.jme3.input.dummy.DummyKeyInput;
import com.jme3.input.dummy.DummyMouseInput;
import com.jme3.system.Monitors;
import com.jme3.system.Displays;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
Expand Down Expand Up @@ -221,13 +221,13 @@ public void setTitle(String title) {
}

@Override
public Monitors getMonitors() {
public Displays getDisplays() {
// TODO Auto-generated method stub
return null;
}

@Override
public int getPrimaryMonitor() {
public int getPrimaryDisplay() {
// TODO Auto-generated method stub
return 0;
}
Expand Down
18 changes: 9 additions & 9 deletions jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import com.jme3.system.AppSettings;
import com.jme3.system.JmeContext;
import com.jme3.system.JmeSystem;
import com.jme3.system.Monitors;
import com.jme3.system.Displays;
import com.jme3.system.NanoTimer;
import com.jme3.util.BufferUtils;
import com.jme3.util.SafeArrayList;
Expand Down Expand Up @@ -882,12 +882,12 @@ public int getWindowYPosition() {
* @return returns the Primary Monitor Position.
*/
@Override
public int getPrimaryMonitor()
public int getPrimaryDisplay()
{
long prim = glfwGetPrimaryMonitor();
Monitors monitors = getMonitors();
Displays monitors = getDisplays();
for ( int i = 0; i < monitors.size(); i++ ) {
long monitorI = monitors.get(i).monitorID;
long monitorI = monitors.get(i).displayID;
if (monitorI == prim)
return i;
}
Expand All @@ -905,9 +905,9 @@ public int getPrimaryMonitor()
* @return return the monitorID if found otherwise return Primary Monitor
*/
private long getMonitor(int pos) {
Monitors monitors = getMonitors();
Displays monitors = getDisplays();
if (pos < monitors.size())
return monitors.get(pos).monitorID;
return monitors.get(pos).displayID;

LOGGER.log(Level.SEVERE,"Couldn't locate Monitor requested in the list of Monitors. pos:"+pos+" size: "+ monitors.size());
return glfwGetPrimaryMonitor();
Expand All @@ -922,17 +922,17 @@ private long getMonitor(int pos) {
*/

@Override
public Monitors getMonitors() {
public Displays getDisplays() {
PointerBuffer monitors = glfwGetMonitors();
long primary = glfwGetPrimaryMonitor();
Monitors monitorList = new Monitors();
Displays monitorList = new Displays();

for ( int i = 0; i < monitors.limit(); i++ ) {
long monitorI = monitors.get(i);
int monPos = monitorList.addNewMonitor(monitorI);
//lets check if this monitor is the primary monitor. If use mark it as such.
if (primary == monitorI)
monitorList.setPrimaryMonitor(monPos);
monitorList.setActiveMonitor(monPos);

final GLFWVidMode modes = glfwGetVideoMode(monitorI);
String name = glfwGetMonitorName(monitorI);
Expand Down
Loading

0 comments on commit 8594c1d

Please sign in to comment.