Screen sharing (X11): add hide mouse cursor option

This commit is contained in:
trilene 2021-02-18 16:53:30 -05:00
parent 8df10eeeca
commit 3b26cf4ba3
4 changed files with 35 additions and 3 deletions

View file

@ -14,6 +14,7 @@ Popup {
frameRateCombo.currentIndex = frameRateCombo.find(Settings.screenShareFrameRate); frameRateCombo.currentIndex = frameRateCombo.find(Settings.screenShareFrameRate);
remoteVideoCheckBox.checked = Settings.screenShareRemoteVideo; remoteVideoCheckBox.checked = Settings.screenShareRemoteVideo;
hideCursorCheckBox.checked = Settings.screenShareHideCursor;
} }
palette: colors palette: colors
@ -55,6 +56,15 @@ Popup {
ToolTip.visible: hovered ToolTip.visible: hovered
} }
CheckBox {
id: hideCursorCheckBox
Layout.alignment: Qt.AlignLeft
Layout.leftMargin: 8
Layout.rightMargin: 8
text: qsTr("Hide mouse cursor")
}
RowLayout { RowLayout {
Layout.margins: 8 Layout.margins: 8
@ -70,6 +80,7 @@ Popup {
Settings.microphone = micCombo.currentText; Settings.microphone = micCombo.currentText;
Settings.screenShareFrameRate = frameRateCombo.currentText; Settings.screenShareFrameRate = frameRateCombo.currentText;
Settings.screenShareRemoteVideo = remoteVideoCheckBox.checked; Settings.screenShareRemoteVideo = remoteVideoCheckBox.checked;
Settings.screenShareHideCursor = hideCursorCheckBox.checked;
CallManager.sendInvite(TimelineManager.timeline.roomId(), CallType.SCREEN); CallManager.sendInvite(TimelineManager.timeline.roomId(), CallType.SCREEN);
close(); close();
} }

View file

@ -115,6 +115,7 @@ UserSettings::load(std::optional<QString> profile)
cameraFrameRate_ = settings.value("user/camera_frame_rate", QString()).toString(); cameraFrameRate_ = settings.value("user/camera_frame_rate", QString()).toString();
screenShareFrameRate_ = settings.value("user/screen_share_frame_rate", 5).toInt(); screenShareFrameRate_ = settings.value("user/screen_share_frame_rate", 5).toInt();
screenShareRemoteVideo_ = settings.value("user/screen_share_remote_video", false).toBool(); screenShareRemoteVideo_ = settings.value("user/screen_share_remote_video", false).toBool();
screenShareHideCursor_ = settings.value("user/screen_share_hide_cursor", false).toBool();
useStunServer_ = settings.value("user/use_stun_server", false).toBool(); useStunServer_ = settings.value("user/use_stun_server", false).toBool();
if (profile) // set to "" if it's the default to maintain compatibility if (profile) // set to "" if it's the default to maintain compatibility
@ -466,6 +467,16 @@ UserSettings::setScreenShareRemoteVideo(bool state)
save(); save();
} }
void
UserSettings::setScreenShareHideCursor(bool state)
{
if (state == screenShareHideCursor_)
return;
screenShareHideCursor_ = state;
emit screenShareHideCursorChanged(state);
save();
}
void void
UserSettings::setProfile(QString profile) UserSettings::setProfile(QString profile)
{ {
@ -617,6 +628,7 @@ UserSettings::save()
settings.setValue("camera_frame_rate", cameraFrameRate_); settings.setValue("camera_frame_rate", cameraFrameRate_);
settings.setValue("screen_share_frame_rate", screenShareFrameRate_); settings.setValue("screen_share_frame_rate", screenShareFrameRate_);
settings.setValue("screen_share_remote_video", screenShareRemoteVideo_); settings.setValue("screen_share_remote_video", screenShareRemoteVideo_);
settings.setValue("screen_share_hide_cursor", screenShareHideCursor_);
settings.setValue("use_stun_server", useStunServer_); settings.setValue("use_stun_server", useStunServer_);
settings.setValue("currentProfile", profile_); settings.setValue("currentProfile", profile_);

View file

@ -90,6 +90,8 @@ class UserSettings : public QObject
NOTIFY screenShareFrameRateChanged) NOTIFY screenShareFrameRateChanged)
Q_PROPERTY(bool screenShareRemoteVideo READ screenShareRemoteVideo WRITE Q_PROPERTY(bool screenShareRemoteVideo READ screenShareRemoteVideo WRITE
setScreenShareRemoteVideo NOTIFY screenShareRemoteVideoChanged) setScreenShareRemoteVideo NOTIFY screenShareRemoteVideoChanged)
Q_PROPERTY(bool screenShareHideCursor READ screenShareHideCursor WRITE
setScreenShareHideCursor NOTIFY screenShareHideCursorChanged)
Q_PROPERTY( Q_PROPERTY(
bool useStunServer READ useStunServer WRITE setUseStunServer NOTIFY useStunServerChanged) bool useStunServer READ useStunServer WRITE setUseStunServer NOTIFY useStunServerChanged)
Q_PROPERTY(bool shareKeysWithTrustedUsers READ shareKeysWithTrustedUsers WRITE Q_PROPERTY(bool shareKeysWithTrustedUsers READ shareKeysWithTrustedUsers WRITE
@ -149,6 +151,7 @@ public:
void setCameraFrameRate(QString frameRate); void setCameraFrameRate(QString frameRate);
void setScreenShareFrameRate(int frameRate); void setScreenShareFrameRate(int frameRate);
void setScreenShareRemoteVideo(bool state); void setScreenShareRemoteVideo(bool state);
void setScreenShareHideCursor(bool state);
void setUseStunServer(bool state); void setUseStunServer(bool state);
void setShareKeysWithTrustedUsers(bool state); void setShareKeysWithTrustedUsers(bool state);
void setProfile(QString profile); void setProfile(QString profile);
@ -199,6 +202,7 @@ public:
QString cameraFrameRate() const { return cameraFrameRate_; } QString cameraFrameRate() const { return cameraFrameRate_; }
int screenShareFrameRate() const { return screenShareFrameRate_; } int screenShareFrameRate() const { return screenShareFrameRate_; }
bool screenShareRemoteVideo() const { return screenShareRemoteVideo_; } bool screenShareRemoteVideo() const { return screenShareRemoteVideo_; }
bool screenShareHideCursor() const { return screenShareHideCursor_; }
bool useStunServer() const { return useStunServer_; } bool useStunServer() const { return useStunServer_; }
bool shareKeysWithTrustedUsers() const { return shareKeysWithTrustedUsers_; } bool shareKeysWithTrustedUsers() const { return shareKeysWithTrustedUsers_; }
QString profile() const { return profile_; } QString profile() const { return profile_; }
@ -239,6 +243,7 @@ signals:
void cameraFrameRateChanged(QString frameRate); void cameraFrameRateChanged(QString frameRate);
void screenShareFrameRateChanged(int frameRate); void screenShareFrameRateChanged(int frameRate);
void screenShareRemoteVideoChanged(bool state); void screenShareRemoteVideoChanged(bool state);
void screenShareHideCursorChanged(bool state);
void useStunServerChanged(bool state); void useStunServerChanged(bool state);
void shareKeysWithTrustedUsersChanged(bool state); void shareKeysWithTrustedUsersChanged(bool state);
void profileChanged(QString profile); void profileChanged(QString profile);
@ -284,6 +289,7 @@ private:
QString cameraFrameRate_; QString cameraFrameRate_;
int screenShareFrameRate_; int screenShareFrameRate_;
bool screenShareRemoteVideo_; bool screenShareRemoteVideo_;
bool screenShareHideCursor_;
bool useStunServer_; bool useStunServer_;
QString profile_; QString profile_;
QString userId_; QString userId_;

View file

@ -918,10 +918,13 @@ WebRTCSession::addVideoPipeline(int vp8PayloadType)
nhlog::ui()->error("WebRTC: failed to create ximagesrc"); nhlog::ui()->error("WebRTC: failed to create ximagesrc");
return false; return false;
} }
g_object_set(source, "use-damage", 0, nullptr); g_object_set(source, "use-damage", FALSE, nullptr);
g_object_set(source, "xid", 0, nullptr); g_object_set(source, "xid", 0, nullptr);
auto settings = ChatPage::instance()->userSettings();
int frameRate = ChatPage::instance()->userSettings()->screenShareFrameRate(); g_object_set(source, "show-pointer", !settings->screenShareHideCursor(), nullptr);
nhlog::ui()->debug("WebRTC: screen share hide mouse cursor: {}",
settings->screenShareHideCursor());
int frameRate = settings->screenShareFrameRate();
caps = gst_caps_new_simple( caps = gst_caps_new_simple(
"video/x-raw", "framerate", GST_TYPE_FRACTION, frameRate, 1, nullptr); "video/x-raw", "framerate", GST_TYPE_FRACTION, frameRate, 1, nullptr);
nhlog::ui()->debug("WebRTC: screen share frame rate: {} fps", frameRate); nhlog::ui()->debug("WebRTC: screen share frame rate: {} fps", frameRate);