mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-23 08:36:42 +00:00
now have a checkbox to enable/disable fullscreen mode
This commit is contained in:
@@ -28,14 +28,14 @@ public class Limelight implements NvConnectionListener {
|
|||||||
this.host = host;
|
this.host = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startUp() {
|
private void startUp(boolean fullscreen) {
|
||||||
streamFrame = new StreamFrame();
|
streamFrame = new StreamFrame();
|
||||||
conn = new NvConnection(host, this);
|
conn = new NvConnection(host, this);
|
||||||
conn.start(PlatformBinding.getDeviceName(), streamFrame,
|
conn.start(PlatformBinding.getDeviceName(), streamFrame,
|
||||||
VideoDecoderRenderer.FLAG_PREFER_QUALITY,
|
VideoDecoderRenderer.FLAG_PREFER_QUALITY,
|
||||||
PlatformBinding.getAudioRenderer(),
|
PlatformBinding.getAudioRenderer(),
|
||||||
PlatformBinding.getVideoDecoderRenderer());
|
PlatformBinding.getVideoDecoderRenderer());
|
||||||
streamFrame.build(conn);
|
streamFrame.build(conn, fullscreen);
|
||||||
|
|
||||||
startControllerListener();
|
startControllerListener();
|
||||||
}
|
}
|
||||||
@@ -62,9 +62,9 @@ public class Limelight implements NvConnectionListener {
|
|||||||
limeFrame = main.getLimeFrame();
|
limeFrame = main.getLimeFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createInstance(String host) {
|
public static void createInstance(String host, boolean fullscreen) {
|
||||||
Limelight limelight = new Limelight(host);
|
Limelight limelight = new Limelight(host);
|
||||||
limelight.startUp();
|
limelight.startUp(fullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.net.UnknownHostException;
|
|||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
@@ -30,6 +31,7 @@ public class MainFrame {
|
|||||||
private JTextField hostField;
|
private JTextField hostField;
|
||||||
private JButton pair;
|
private JButton pair;
|
||||||
private JButton stream;
|
private JButton stream;
|
||||||
|
private JCheckBox fullscreen;
|
||||||
private JFrame limeFrame;
|
private JFrame limeFrame;
|
||||||
|
|
||||||
public JFrame getLimeFrame() {
|
public JFrame getLimeFrame() {
|
||||||
@@ -60,6 +62,7 @@ public class MainFrame {
|
|||||||
pair.addActionListener(createPairButtonListener());
|
pair.addActionListener(createPairButtonListener());
|
||||||
pair.setToolTipText("Send pair request to GeForce PC");
|
pair.setToolTipText("Send pair request to GeForce PC");
|
||||||
|
|
||||||
|
fullscreen = new JCheckBox("Fullscreen");
|
||||||
|
|
||||||
Box streamBox = Box.createHorizontalBox();
|
Box streamBox = Box.createHorizontalBox();
|
||||||
streamBox.add(Box.createHorizontalGlue());
|
streamBox.add(Box.createHorizontalGlue());
|
||||||
@@ -80,7 +83,9 @@ public class MainFrame {
|
|||||||
Box contentBox = Box.createVerticalBox();
|
Box contentBox = Box.createVerticalBox();
|
||||||
contentBox.add(Box.createVerticalStrut(20));
|
contentBox.add(Box.createVerticalStrut(20));
|
||||||
contentBox.add(hostBox);
|
contentBox.add(hostBox);
|
||||||
contentBox.add(Box.createVerticalStrut(10));
|
contentBox.add(Box.createVerticalStrut(5));
|
||||||
|
contentBox.add(fullscreen);
|
||||||
|
contentBox.add(Box.createVerticalStrut(5));
|
||||||
contentBox.add(streamBox);
|
contentBox.add(streamBox);
|
||||||
contentBox.add(Box.createVerticalStrut(10));
|
contentBox.add(Box.createVerticalStrut(10));
|
||||||
contentBox.add(pairBox);
|
contentBox.add(pairBox);
|
||||||
@@ -89,8 +94,9 @@ public class MainFrame {
|
|||||||
|
|
||||||
centerPane.add(contentBox);
|
centerPane.add(contentBox);
|
||||||
mainPane.add(centerPane, "Center");
|
mainPane.add(centerPane, "Center");
|
||||||
|
|
||||||
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
|
||||||
|
limeFrame.getRootPane().setDefaultButton(stream);
|
||||||
limeFrame.setSize(300, 175);
|
limeFrame.setSize(300, 175);
|
||||||
limeFrame.setLocation(dim.width/2-limeFrame.getSize().width/2, dim.height/2-limeFrame.getSize().height/2);
|
limeFrame.setLocation(dim.width/2-limeFrame.getSize().width/2, dim.height/2-limeFrame.getSize().height/2);
|
||||||
limeFrame.setResizable(false);
|
limeFrame.setResizable(false);
|
||||||
@@ -102,7 +108,7 @@ public class MainFrame {
|
|||||||
return new ActionListener() {
|
return new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Limelight.createInstance(hostField.getText());
|
Limelight.createInstance(hostField.getText(), fullscreen.isSelected());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class StreamFrame extends JFrame {
|
|||||||
private JProgressBar spinner;
|
private JProgressBar spinner;
|
||||||
private JLabel spinnerLabel;
|
private JLabel spinnerLabel;
|
||||||
|
|
||||||
public void build(NvConnection conn) {
|
public void build(NvConnection conn, boolean fullscreen) {
|
||||||
keyboard = new KeyboardHandler(conn);
|
keyboard = new KeyboardHandler(conn);
|
||||||
mouse = new MouseHandler(conn, this);
|
mouse = new MouseHandler(conn, this);
|
||||||
|
|
||||||
@@ -46,18 +46,24 @@ public class StreamFrame extends JFrame {
|
|||||||
this.setSize(1280,720);
|
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, dim.height/2-this.getSize().height/2);
|
this.setLocation(dim.width/2-this.getSize().width/2, 0);
|
||||||
|
|
||||||
//makeFullScreen();
|
this.setUndecorated(true);
|
||||||
|
this.setBackground(Color.BLACK);
|
||||||
|
|
||||||
|
if (fullscreen) {
|
||||||
|
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.setUndecorated(true);
|
|
||||||
this.setExtendedState(Frame.MAXIMIZED_BOTH);
|
this.setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||||
this.setBackground(Color.BLACK);
|
|
||||||
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
|
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
|
||||||
if (gd.isFullScreenSupported()) {
|
if (gd.isFullScreenSupported()) {
|
||||||
gd.setFullScreenWindow(this);
|
gd.setFullScreenWindow(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user