mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 14:11:33 +00:00
Allow selection between full-screen exclusive mode and borderless windowed mode
This commit is contained in:
+49
-16
@@ -230,26 +230,59 @@ ScrollView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Label {
|
||||||
CheckBox {
|
width: parent.width
|
||||||
id: fullScreenCheck
|
id: windowModeTitle
|
||||||
text: "<font color=\"white\">Full-screen</font>"
|
text: qsTr("Display mode")
|
||||||
font.pointSize: 12
|
font.pointSize: 12
|
||||||
checked: prefs.fullScreen
|
wrapMode: Text.Wrap
|
||||||
onCheckedChanged: {
|
color: "white"
|
||||||
prefs.fullScreen = checked
|
}
|
||||||
|
|
||||||
|
ComboBox {
|
||||||
|
// ignore setting the index at first, and actually set it when the component is loaded
|
||||||
|
Component.onCompleted: {
|
||||||
|
var savedWm = prefs.windowMode
|
||||||
|
currentIndex = 0
|
||||||
|
for (var i = 0; i < windowModeListModel.count; i++) {
|
||||||
|
var thisWm = windowModeListModel.get(i).val;
|
||||||
|
if (savedWm === thisWm) {
|
||||||
|
currentIndex = i
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckBox {
|
id: windowModeComboBox
|
||||||
id: vsyncCheck
|
width: Math.min(bitrateDesc.implicitWidth, parent.width)
|
||||||
text: "<font color=\"white\">Enable V-Sync</font>"
|
textRole: "text"
|
||||||
font.pointSize: 12
|
model: ListModel {
|
||||||
visible: fullScreenCheck.checked
|
id: windowModeListModel
|
||||||
checked: prefs.enableVsync
|
ListElement {
|
||||||
onCheckedChanged: {
|
text: "Full-screen"
|
||||||
prefs.enableVsync = checked
|
val: StreamingPreferences.WM_FULLSCREEN
|
||||||
}
|
}
|
||||||
|
ListElement {
|
||||||
|
text: "Borderless windowed"
|
||||||
|
val: StreamingPreferences.WM_FULLSCREEN_DESKTOP
|
||||||
|
}
|
||||||
|
ListElement {
|
||||||
|
text: "Windowed"
|
||||||
|
val: StreamingPreferences.WM_WINDOWED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onActivated: {
|
||||||
|
prefs.windowMode = windowModeListModel.get(currentIndex).val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
id: vsyncCheck
|
||||||
|
text: "<font color=\"white\">Enable V-Sync</font>"
|
||||||
|
font.pointSize: 12
|
||||||
|
visible: prefs.windowMode === StreamingPreferences.WM_FULLSCREEN
|
||||||
|
checked: prefs.enableVsync
|
||||||
|
onCheckedChanged: {
|
||||||
|
prefs.enableVsync = checked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#define SER_AUDIOCFG "audiocfg"
|
#define SER_AUDIOCFG "audiocfg"
|
||||||
#define SER_VIDEOCFG "videocfg"
|
#define SER_VIDEOCFG "videocfg"
|
||||||
#define SER_VIDEODEC "videodec"
|
#define SER_VIDEODEC "videodec"
|
||||||
|
#define SER_WINDOWMODE "windowmode"
|
||||||
|
|
||||||
StreamingPreferences::StreamingPreferences()
|
StreamingPreferences::StreamingPreferences()
|
||||||
{
|
{
|
||||||
@@ -30,7 +31,6 @@ void StreamingPreferences::reload()
|
|||||||
height = settings.value(SER_HEIGHT, 720).toInt();
|
height = settings.value(SER_HEIGHT, 720).toInt();
|
||||||
fps = settings.value(SER_FPS, 60).toInt();
|
fps = settings.value(SER_FPS, 60).toInt();
|
||||||
bitrateKbps = settings.value(SER_BITRATE, getDefaultBitrate(width, height, fps)).toInt();
|
bitrateKbps = settings.value(SER_BITRATE, getDefaultBitrate(width, height, fps)).toInt();
|
||||||
fullScreen = settings.value(SER_FULLSCREEN, true).toBool();
|
|
||||||
enableVsync = settings.value(SER_VSYNC, true).toBool();
|
enableVsync = settings.value(SER_VSYNC, true).toBool();
|
||||||
gameOptimizations = settings.value(SER_GAMEOPTS, true).toBool();
|
gameOptimizations = settings.value(SER_GAMEOPTS, true).toBool();
|
||||||
playAudioOnHost = settings.value(SER_HOSTAUDIO, false).toBool();
|
playAudioOnHost = settings.value(SER_HOSTAUDIO, false).toBool();
|
||||||
@@ -41,6 +41,10 @@ void StreamingPreferences::reload()
|
|||||||
static_cast<int>(VideoCodecConfig::VCC_AUTO)).toInt());
|
static_cast<int>(VideoCodecConfig::VCC_AUTO)).toInt());
|
||||||
videoDecoderSelection = static_cast<VideoDecoderSelection>(settings.value(SER_VIDEODEC,
|
videoDecoderSelection = static_cast<VideoDecoderSelection>(settings.value(SER_VIDEODEC,
|
||||||
static_cast<int>(VideoDecoderSelection::VDS_AUTO)).toInt());
|
static_cast<int>(VideoDecoderSelection::VDS_AUTO)).toInt());
|
||||||
|
windowMode = static_cast<WindowMode>(settings.value(SER_WINDOWMODE,
|
||||||
|
// Try to load from the old preference value too
|
||||||
|
static_cast<int>(settings.value(SER_FULLSCREEN, true).toBool() ?
|
||||||
|
WindowMode::WM_FULLSCREEN : WindowMode::WM_WINDOWED)).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamingPreferences::save()
|
void StreamingPreferences::save()
|
||||||
@@ -51,7 +55,6 @@ void StreamingPreferences::save()
|
|||||||
settings.setValue(SER_HEIGHT, height);
|
settings.setValue(SER_HEIGHT, height);
|
||||||
settings.setValue(SER_FPS, fps);
|
settings.setValue(SER_FPS, fps);
|
||||||
settings.setValue(SER_BITRATE, bitrateKbps);
|
settings.setValue(SER_BITRATE, bitrateKbps);
|
||||||
settings.setValue(SER_FULLSCREEN, fullScreen);
|
|
||||||
settings.setValue(SER_VSYNC, enableVsync);
|
settings.setValue(SER_VSYNC, enableVsync);
|
||||||
settings.setValue(SER_GAMEOPTS, gameOptimizations);
|
settings.setValue(SER_GAMEOPTS, gameOptimizations);
|
||||||
settings.setValue(SER_HOSTAUDIO, playAudioOnHost);
|
settings.setValue(SER_HOSTAUDIO, playAudioOnHost);
|
||||||
@@ -59,6 +62,7 @@ void StreamingPreferences::save()
|
|||||||
settings.setValue(SER_AUDIOCFG, static_cast<int>(audioConfig));
|
settings.setValue(SER_AUDIOCFG, static_cast<int>(audioConfig));
|
||||||
settings.setValue(SER_VIDEOCFG, static_cast<int>(videoCodecConfig));
|
settings.setValue(SER_VIDEOCFG, static_cast<int>(videoCodecConfig));
|
||||||
settings.setValue(SER_VIDEODEC, static_cast<int>(videoDecoderSelection));
|
settings.setValue(SER_VIDEODEC, static_cast<int>(videoDecoderSelection));
|
||||||
|
settings.setValue(SER_WINDOWMODE, static_cast<int>(windowMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StreamingPreferences::hasAnyHardwareAcceleration()
|
bool StreamingPreferences::hasAnyHardwareAcceleration()
|
||||||
|
|||||||
@@ -50,11 +50,18 @@ public:
|
|||||||
};
|
};
|
||||||
Q_ENUM(VideoDecoderSelection)
|
Q_ENUM(VideoDecoderSelection)
|
||||||
|
|
||||||
|
enum WindowMode
|
||||||
|
{
|
||||||
|
WM_FULLSCREEN,
|
||||||
|
WM_FULLSCREEN_DESKTOP,
|
||||||
|
WM_WINDOWED
|
||||||
|
};
|
||||||
|
Q_ENUM(WindowMode);
|
||||||
|
|
||||||
Q_PROPERTY(int width MEMBER width NOTIFY displayModeChanged)
|
Q_PROPERTY(int width MEMBER width NOTIFY displayModeChanged)
|
||||||
Q_PROPERTY(int height MEMBER height NOTIFY displayModeChanged)
|
Q_PROPERTY(int height MEMBER height NOTIFY displayModeChanged)
|
||||||
Q_PROPERTY(int fps MEMBER fps NOTIFY displayModeChanged)
|
Q_PROPERTY(int fps MEMBER fps NOTIFY displayModeChanged)
|
||||||
Q_PROPERTY(int bitrateKbps MEMBER bitrateKbps NOTIFY bitrateChanged)
|
Q_PROPERTY(int bitrateKbps MEMBER bitrateKbps NOTIFY bitrateChanged)
|
||||||
Q_PROPERTY(bool fullScreen MEMBER fullScreen NOTIFY fullScreenChanged)
|
|
||||||
Q_PROPERTY(bool enableVsync MEMBER enableVsync NOTIFY enableVsyncChanged)
|
Q_PROPERTY(bool enableVsync MEMBER enableVsync NOTIFY enableVsyncChanged)
|
||||||
Q_PROPERTY(bool gameOptimizations MEMBER gameOptimizations NOTIFY gameOptimizationsChanged)
|
Q_PROPERTY(bool gameOptimizations MEMBER gameOptimizations NOTIFY gameOptimizationsChanged)
|
||||||
Q_PROPERTY(bool playAudioOnHost MEMBER playAudioOnHost NOTIFY playAudioOnHostChanged)
|
Q_PROPERTY(bool playAudioOnHost MEMBER playAudioOnHost NOTIFY playAudioOnHostChanged)
|
||||||
@@ -62,13 +69,13 @@ public:
|
|||||||
Q_PROPERTY(AudioConfig audioConfig MEMBER audioConfig NOTIFY audioConfigChanged)
|
Q_PROPERTY(AudioConfig audioConfig MEMBER audioConfig NOTIFY audioConfigChanged)
|
||||||
Q_PROPERTY(VideoCodecConfig videoCodecConfig MEMBER videoCodecConfig NOTIFY videoCodecConfigChanged)
|
Q_PROPERTY(VideoCodecConfig videoCodecConfig MEMBER videoCodecConfig NOTIFY videoCodecConfigChanged)
|
||||||
Q_PROPERTY(VideoDecoderSelection videoDecoderSelection MEMBER videoDecoderSelection NOTIFY videoDecoderSelectionChanged)
|
Q_PROPERTY(VideoDecoderSelection videoDecoderSelection MEMBER videoDecoderSelection NOTIFY videoDecoderSelectionChanged)
|
||||||
|
Q_PROPERTY(WindowMode windowMode MEMBER windowMode NOTIFY windowModeChanged)
|
||||||
|
|
||||||
// Directly accessible members for preferences
|
// Directly accessible members for preferences
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
int fps;
|
int fps;
|
||||||
int bitrateKbps;
|
int bitrateKbps;
|
||||||
bool fullScreen;
|
|
||||||
bool enableVsync;
|
bool enableVsync;
|
||||||
bool gameOptimizations;
|
bool gameOptimizations;
|
||||||
bool playAudioOnHost;
|
bool playAudioOnHost;
|
||||||
@@ -76,11 +83,11 @@ public:
|
|||||||
AudioConfig audioConfig;
|
AudioConfig audioConfig;
|
||||||
VideoCodecConfig videoCodecConfig;
|
VideoCodecConfig videoCodecConfig;
|
||||||
VideoDecoderSelection videoDecoderSelection;
|
VideoDecoderSelection videoDecoderSelection;
|
||||||
|
WindowMode windowMode;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void displayModeChanged();
|
void displayModeChanged();
|
||||||
void bitrateChanged();
|
void bitrateChanged();
|
||||||
void fullScreenChanged();
|
|
||||||
void enableVsyncChanged();
|
void enableVsyncChanged();
|
||||||
void gameOptimizationsChanged();
|
void gameOptimizationsChanged();
|
||||||
void playAudioOnHostChanged();
|
void playAudioOnHostChanged();
|
||||||
@@ -88,5 +95,6 @@ signals:
|
|||||||
void audioConfigChanged();
|
void audioConfigChanged();
|
||||||
void videoCodecConfigChanged();
|
void videoCodecConfigChanged();
|
||||||
void videoDecoderSelectionChanged();
|
void videoDecoderSelectionChanged();
|
||||||
|
void windowModeChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+16
-12
@@ -19,13 +19,6 @@
|
|||||||
#include "video/sl.h"
|
#include "video/sl.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_DARWIN)
|
|
||||||
// Using full-screen desktop allows allows Spaces to work on macOS.
|
|
||||||
#define SDL_OS_FULLSCREEN_FLAG SDL_WINDOW_FULLSCREEN_DESKTOP
|
|
||||||
#else
|
|
||||||
#define SDL_OS_FULLSCREEN_FLAG SDL_WINDOW_FULLSCREEN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
// Scaling the icon down on Win32 looks dreadful, so render at lower res
|
// Scaling the icon down on Win32 looks dreadful, so render at lower res
|
||||||
#define ICON_SIZE 32
|
#define ICON_SIZE 32
|
||||||
@@ -372,6 +365,17 @@ Session::Session(NvComputer* computer, NvApp& app)
|
|||||||
else {
|
else {
|
||||||
m_StreamConfig.packetSize = 1024;
|
m_StreamConfig.packetSize = 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (m_Preferences.windowMode)
|
||||||
|
{
|
||||||
|
case StreamingPreferences::WM_FULLSCREEN_DESKTOP:
|
||||||
|
m_FullScreenFlag = SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||||
|
break;
|
||||||
|
case StreamingPreferences::WM_FULLSCREEN:
|
||||||
|
default:
|
||||||
|
m_FullScreenFlag = SDL_WINDOW_FULLSCREEN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::emitLaunchWarning(QString text)
|
void Session::emitLaunchWarning(QString text)
|
||||||
@@ -595,7 +599,7 @@ void Session::getWindowDimensions(bool fullScreen,
|
|||||||
|
|
||||||
void Session::toggleFullscreen()
|
void Session::toggleFullscreen()
|
||||||
{
|
{
|
||||||
bool fullScreen = !(SDL_GetWindowFlags(m_Window) & SDL_OS_FULLSCREEN_FLAG);
|
bool fullScreen = !(SDL_GetWindowFlags(m_Window) & m_FullScreenFlag);
|
||||||
|
|
||||||
int x, y, width, height;
|
int x, y, width, height;
|
||||||
|
|
||||||
@@ -613,7 +617,7 @@ void Session::toggleFullscreen()
|
|||||||
|
|
||||||
if (fullScreen) {
|
if (fullScreen) {
|
||||||
SDL_SetWindowResizable(m_Window, SDL_FALSE);
|
SDL_SetWindowResizable(m_Window, SDL_FALSE);
|
||||||
SDL_SetWindowFullscreen(m_Window, SDL_OS_FULLSCREEN_FLAG);
|
SDL_SetWindowFullscreen(m_Window, m_FullScreenFlag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -715,7 +719,7 @@ void Session::exec()
|
|||||||
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||||
|
|
||||||
int x, y, width, height;
|
int x, y, width, height;
|
||||||
getWindowDimensions(m_Preferences.fullScreen,
|
getWindowDimensions(m_Preferences.windowMode != StreamingPreferences::WM_WINDOWED,
|
||||||
x, y, width, height);
|
x, y, width, height);
|
||||||
|
|
||||||
m_Window = SDL_CreateWindow("Moonlight",
|
m_Window = SDL_CreateWindow("Moonlight",
|
||||||
@@ -736,7 +740,7 @@ void Session::exec()
|
|||||||
// For non-full screen windows, call getWindowDimensions()
|
// For non-full screen windows, call getWindowDimensions()
|
||||||
// again after creating a window to allow it to account
|
// again after creating a window to allow it to account
|
||||||
// for window chrome size.
|
// for window chrome size.
|
||||||
if (!m_Preferences.fullScreen) {
|
if (m_Preferences.windowMode == StreamingPreferences::WM_WINDOWED) {
|
||||||
getWindowDimensions(false, x, y, width, height);
|
getWindowDimensions(false, x, y, width, height);
|
||||||
|
|
||||||
SDL_SetWindowPosition(m_Window, x, y);
|
SDL_SetWindowPosition(m_Window, x, y);
|
||||||
@@ -754,7 +758,7 @@ void Session::exec()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Enter full screen
|
// Enter full screen
|
||||||
SDL_SetWindowFullscreen(m_Window, SDL_OS_FULLSCREEN_FLAG);
|
SDL_SetWindowFullscreen(m_Window, m_FullScreenFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSvgRenderer svgIconRenderer(QString(":/res/moonlight.svg"));
|
QSvgRenderer svgIconRenderer(QString(":/res/moonlight.svg"));
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ private:
|
|||||||
SDL_SpinLock m_DecoderLock;
|
SDL_SpinLock m_DecoderLock;
|
||||||
bool m_NeedsIdr;
|
bool m_NeedsIdr;
|
||||||
bool m_AudioDisabled;
|
bool m_AudioDisabled;
|
||||||
|
Uint32 m_FullScreenFlag;
|
||||||
|
|
||||||
int m_ActiveVideoFormat;
|
int m_ActiveVideoFormat;
|
||||||
int m_ActiveVideoWidth;
|
int m_ActiveVideoWidth;
|
||||||
|
|||||||
Reference in New Issue
Block a user