From 3b26cf4ba37c0944a6a297968d40da309be82b69 Mon Sep 17 00:00:00 2001 From: trilene Date: Thu, 18 Feb 2021 16:53:30 -0500 Subject: [PATCH] Screen sharing (X11): add hide mouse cursor option --- resources/qml/voip/ScreenShare.qml | 11 +++++++++++ src/UserSettingsPage.cpp | 12 ++++++++++++ src/UserSettingsPage.h | 6 ++++++ src/WebRTCSession.cpp | 9 ++++++--- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/resources/qml/voip/ScreenShare.qml b/resources/qml/voip/ScreenShare.qml index b21a26fd..331e1c11 100644 --- a/resources/qml/voip/ScreenShare.qml +++ b/resources/qml/voip/ScreenShare.qml @@ -14,6 +14,7 @@ Popup { frameRateCombo.currentIndex = frameRateCombo.find(Settings.screenShareFrameRate); remoteVideoCheckBox.checked = Settings.screenShareRemoteVideo; + hideCursorCheckBox.checked = Settings.screenShareHideCursor; } palette: colors @@ -55,6 +56,15 @@ Popup { ToolTip.visible: hovered } + CheckBox { + id: hideCursorCheckBox + + Layout.alignment: Qt.AlignLeft + Layout.leftMargin: 8 + Layout.rightMargin: 8 + text: qsTr("Hide mouse cursor") + } + RowLayout { Layout.margins: 8 @@ -70,6 +80,7 @@ Popup { Settings.microphone = micCombo.currentText; Settings.screenShareFrameRate = frameRateCombo.currentText; Settings.screenShareRemoteVideo = remoteVideoCheckBox.checked; + Settings.screenShareHideCursor = hideCursorCheckBox.checked; CallManager.sendInvite(TimelineManager.timeline.roomId(), CallType.SCREEN); close(); } diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index 186a03bb..765e1e81 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -115,6 +115,7 @@ UserSettings::load(std::optional profile) cameraFrameRate_ = settings.value("user/camera_frame_rate", QString()).toString(); screenShareFrameRate_ = settings.value("user/screen_share_frame_rate", 5).toInt(); 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(); if (profile) // set to "" if it's the default to maintain compatibility @@ -466,6 +467,16 @@ UserSettings::setScreenShareRemoteVideo(bool state) save(); } +void +UserSettings::setScreenShareHideCursor(bool state) +{ + if (state == screenShareHideCursor_) + return; + screenShareHideCursor_ = state; + emit screenShareHideCursorChanged(state); + save(); +} + void UserSettings::setProfile(QString profile) { @@ -617,6 +628,7 @@ UserSettings::save() settings.setValue("camera_frame_rate", cameraFrameRate_); settings.setValue("screen_share_frame_rate", screenShareFrameRate_); settings.setValue("screen_share_remote_video", screenShareRemoteVideo_); + settings.setValue("screen_share_hide_cursor", screenShareHideCursor_); settings.setValue("use_stun_server", useStunServer_); settings.setValue("currentProfile", profile_); diff --git a/src/UserSettingsPage.h b/src/UserSettingsPage.h index 4de9913a..6e00572a 100644 --- a/src/UserSettingsPage.h +++ b/src/UserSettingsPage.h @@ -90,6 +90,8 @@ class UserSettings : public QObject NOTIFY screenShareFrameRateChanged) Q_PROPERTY(bool screenShareRemoteVideo READ screenShareRemoteVideo WRITE setScreenShareRemoteVideo NOTIFY screenShareRemoteVideoChanged) + Q_PROPERTY(bool screenShareHideCursor READ screenShareHideCursor WRITE + setScreenShareHideCursor NOTIFY screenShareHideCursorChanged) Q_PROPERTY( bool useStunServer READ useStunServer WRITE setUseStunServer NOTIFY useStunServerChanged) Q_PROPERTY(bool shareKeysWithTrustedUsers READ shareKeysWithTrustedUsers WRITE @@ -149,6 +151,7 @@ public: void setCameraFrameRate(QString frameRate); void setScreenShareFrameRate(int frameRate); void setScreenShareRemoteVideo(bool state); + void setScreenShareHideCursor(bool state); void setUseStunServer(bool state); void setShareKeysWithTrustedUsers(bool state); void setProfile(QString profile); @@ -199,6 +202,7 @@ public: QString cameraFrameRate() const { return cameraFrameRate_; } int screenShareFrameRate() const { return screenShareFrameRate_; } bool screenShareRemoteVideo() const { return screenShareRemoteVideo_; } + bool screenShareHideCursor() const { return screenShareHideCursor_; } bool useStunServer() const { return useStunServer_; } bool shareKeysWithTrustedUsers() const { return shareKeysWithTrustedUsers_; } QString profile() const { return profile_; } @@ -239,6 +243,7 @@ signals: void cameraFrameRateChanged(QString frameRate); void screenShareFrameRateChanged(int frameRate); void screenShareRemoteVideoChanged(bool state); + void screenShareHideCursorChanged(bool state); void useStunServerChanged(bool state); void shareKeysWithTrustedUsersChanged(bool state); void profileChanged(QString profile); @@ -284,6 +289,7 @@ private: QString cameraFrameRate_; int screenShareFrameRate_; bool screenShareRemoteVideo_; + bool screenShareHideCursor_; bool useStunServer_; QString profile_; QString userId_; diff --git a/src/WebRTCSession.cpp b/src/WebRTCSession.cpp index 9c01ddc4..acd54b77 100644 --- a/src/WebRTCSession.cpp +++ b/src/WebRTCSession.cpp @@ -918,10 +918,13 @@ WebRTCSession::addVideoPipeline(int vp8PayloadType) nhlog::ui()->error("WebRTC: failed to create ximagesrc"); 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); - - int frameRate = ChatPage::instance()->userSettings()->screenShareFrameRate(); + auto settings = ChatPage::instance()->userSettings(); + 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( "video/x-raw", "framerate", GST_TYPE_FRACTION, frameRate, 1, nullptr); nhlog::ui()->debug("WebRTC: screen share frame rate: {} fps", frameRate);