mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-20 07:10:32 +00:00
attempted to fix fullscreen issues on other OS’s
This commit is contained in:
@@ -5,7 +5,6 @@ import java.awt.Color;
|
|||||||
import java.awt.Container;
|
import java.awt.Container;
|
||||||
import java.awt.Cursor;
|
import java.awt.Cursor;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Frame;
|
|
||||||
import java.awt.GraphicsDevice;
|
import java.awt.GraphicsDevice;
|
||||||
import java.awt.GraphicsEnvironment;
|
import java.awt.GraphicsEnvironment;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
@@ -16,6 +15,7 @@ import javax.swing.Box;
|
|||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JProgressBar;
|
import javax.swing.JProgressBar;
|
||||||
|
|
||||||
@@ -27,6 +27,8 @@ import com.limelight.nvstream.NvConnectionListener.Stage;
|
|||||||
public class StreamFrame extends JFrame {
|
public class StreamFrame extends JFrame {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private int centerX;
|
||||||
|
private int centerY;
|
||||||
private KeyboardHandler keyboard;
|
private KeyboardHandler keyboard;
|
||||||
private MouseHandler mouse;
|
private MouseHandler mouse;
|
||||||
private JProgressBar spinner;
|
private JProgressBar spinner;
|
||||||
@@ -34,6 +36,13 @@ public class StreamFrame extends JFrame {
|
|||||||
|
|
||||||
private NvConnection conn;
|
private NvConnection conn;
|
||||||
|
|
||||||
|
public StreamFrame() {
|
||||||
|
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
this.setSize(1280,720);
|
||||||
|
centerX = dim.width/2-this.getSize().width/2;
|
||||||
|
centerY = dim.height/2-this.getSize().height/2;
|
||||||
|
}
|
||||||
|
|
||||||
public void build(NvConnection conn, boolean fullscreen) {
|
public void build(NvConnection conn, boolean fullscreen) {
|
||||||
this.conn = conn;
|
this.conn = conn;
|
||||||
|
|
||||||
@@ -46,30 +55,31 @@ public class StreamFrame extends JFrame {
|
|||||||
|
|
||||||
this.setFocusTraversalKeysEnabled(false);
|
this.setFocusTraversalKeysEnabled(false);
|
||||||
|
|
||||||
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
|
|
||||||
this.setSize(1280,720);
|
|
||||||
|
|
||||||
//This might break if the screen res is too small...not sure though
|
//This might break if the screen res is too small...not sure though
|
||||||
this.setLocation(dim.width/2-this.getSize().width/2, 0);
|
this.setLocation(centerX, 0);
|
||||||
|
|
||||||
this.setUndecorated(true);
|
|
||||||
this.setBackground(Color.BLACK);
|
this.setBackground(Color.BLACK);
|
||||||
|
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
makeFullScreen();
|
makeFullScreen();
|
||||||
this.setLocation(getLocation().x, dim.height/2-this.getSize().height/2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hideCursor();
|
hideCursor();
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeFullScreen() {
|
private void makeFullScreen() {
|
||||||
|
|
||||||
this.setExtendedState(Frame.MAXIMIZED_BOTH);
|
|
||||||
|
|
||||||
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
|
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
|
||||||
if (gd.isFullScreenSupported()) {
|
if (gd.isFullScreenSupported()) {
|
||||||
|
this.setUndecorated(true);
|
||||||
gd.setFullScreenWindow(this);
|
gd.setFullScreenWindow(this);
|
||||||
|
this.setLocation(centerX, centerY);
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(
|
||||||
|
this,
|
||||||
|
"Your operating system does not support fullscreen.",
|
||||||
|
"Fullscreen Unsupported",
|
||||||
|
JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user