Feature: Remember the fullscreen and remote-cursor view state on Linux clients
The Linux client always reported zero for ScreenSettings.FullScreen and RemoteCursor and dropped CMD_FULL_SCREEN / CMD_REMOTE_CURSOR on the floor, so a controller could never reopen a host in the state it was left in. The Windows client has done both for a while. Store both fields in ~/.config/ghost/config.conf next to QualityLevel, report them through the TOKEN_BITMAPINFO ScreenSettings, and update them whenever the controller toggles either option. The controller already applies the reported FullScreen in OnInitDialog, so no protocol or master-side change is required. CustomCursor is deliberately not persisted: Linux clients never send cursor images, so the flag would be inert. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
a628c19341
commit
0b22d5e870
1 file changed
+40
-2
+40
-2
@@ -338,7 +338,7 @@ public:
|
||||
m_width(0), m_height(0),
|
||||
m_pixmap(0), m_gc(nullptr), m_xtestWarned(false),
|
||||
m_bAlgorithm(ALGORITHM_DIFF), m_maxFPS(10), m_qualityLevel(QUALITY_ADAPTIVE),
|
||||
m_h264Bitrate(2000)
|
||||
m_bFullScreen(0), m_bRemoteCursor(0), m_h264Bitrate(2000)
|
||||
{
|
||||
if (!client) {
|
||||
throw std::invalid_argument("IOCPClient pointer cannot be null");
|
||||
@@ -346,6 +346,8 @@ public:
|
||||
|
||||
// 加载保存的质量等级配置
|
||||
LoadQualitySettings();
|
||||
// 加载保存的查看偏好(全屏/远程光标)
|
||||
LoadViewPrefs();
|
||||
|
||||
// 动态加载 X11
|
||||
if (!m_x11.Load()) {
|
||||
@@ -485,9 +487,14 @@ public:
|
||||
ScreenSettings settings = {};
|
||||
settings.MaxFPS = m_maxFPS.load();
|
||||
settings.QualityLevel = m_qualityLevel; // 上报保存的质量等级
|
||||
// 上报主控端上次看这台机器时的界面状态(全屏/远程光标),由主控端
|
||||
// 在每次切换时下发并保存在本机,见 OnReceive 的 CMD_FULL_SCREEN。
|
||||
settings.FullScreen = m_bFullScreen.load();
|
||||
settings.RemoteCursor = m_bRemoteCursor.load();
|
||||
memcpy(&buf[1 + sizeof(BITMAPINFOHEADER_LNX) + 2 * sizeof(uint64_t)], &settings, sizeof(ScreenSettings));
|
||||
m_client->Send2Server((char*)buf.data(), ulLength);
|
||||
Mprintf(">>> SendBitmapInfo: clientID=%llu, QualityLevel=%d\n", clientID, m_qualityLevel);
|
||||
Mprintf(">>> SendBitmapInfo: clientID=%llu, QualityLevel=%d, FullScreen=%d, RemoteCursor=%d\n",
|
||||
clientID, m_qualityLevel, settings.FullScreen, settings.RemoteCursor);
|
||||
}
|
||||
|
||||
virtual VOID OnReceive(PBYTE data, ULONG size)
|
||||
@@ -506,6 +513,18 @@ public:
|
||||
}
|
||||
break;
|
||||
|
||||
case CMD_FULL_SCREEN:
|
||||
// 主控端进入/退出全屏: [cmd:1][fullscreen:1]
|
||||
// 这是"主控端看这台机器"的视图偏好,逐客户端保存在本机,下次
|
||||
// 打开远程桌面时随 ScreenSettings.FullScreen 上报,主控端据此直接全屏。
|
||||
if (size >= 2) SetViewPref("FullScreen", m_bFullScreen, data[1] ? 1 : 0);
|
||||
break;
|
||||
|
||||
case CMD_REMOTE_CURSOR:
|
||||
// 主控端远程光标开关: [cmd:1][remoteCursor:1]
|
||||
if (size >= 2) SetViewPref("RemoteCursor", m_bRemoteCursor, data[1] ? 1 : 0);
|
||||
break;
|
||||
|
||||
case CMD_QUALITY_LEVEL:
|
||||
// 质量等级调整: [cmd:1][level:1][persist:1]
|
||||
if (size >= 2) {
|
||||
@@ -645,6 +664,23 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// 加载保存的查看偏好(全屏、远程光标)
|
||||
void LoadViewPrefs()
|
||||
{
|
||||
m_bFullScreen.store(m_config.GetInt("FullScreen", 0));
|
||||
m_bRemoteCursor.store(m_config.GetInt("RemoteCursor", 0));
|
||||
Mprintf(">>> LoadViewPrefs: FullScreen=%d, RemoteCursor=%d\n",
|
||||
m_bFullScreen.load(), m_bRemoteCursor.load());
|
||||
}
|
||||
|
||||
// 保存查看偏好并同步到下次上报的 ScreenSettings
|
||||
void SetViewPref(const char* key, std::atomic<int>& slot, int value)
|
||||
{
|
||||
slot.store(value);
|
||||
m_config.SetInt(key, value);
|
||||
Mprintf(">>> %s saved: %d\n", key, value);
|
||||
}
|
||||
|
||||
// 加载保存的质量设置
|
||||
void LoadQualitySettings()
|
||||
{
|
||||
@@ -882,6 +918,8 @@ private:
|
||||
std::atomic<int> m_maxFPS; // 最大帧率
|
||||
int8_t m_qualityLevel; // 当前质量等级 (-1=自适应, 0-5=具体等级)
|
||||
LinuxConfig m_config; // 配置持久化 (~/.config/ghost/config.conf)
|
||||
std::atomic<int> m_bFullScreen; // 全屏偏好(主控端下发,随 ScreenSettings 上报)
|
||||
std::atomic<int> m_bRemoteCursor; // 远程光标偏好(同上)
|
||||
|
||||
// H264 编码器
|
||||
std::unique_ptr<X264Encoder> m_h264Encoder;
|
||||
|
||||
Reference in new issue
Block a user