Compare commits

..

1 Commits

Author SHA1 Message Date
Malte Jürgens
bdabf68c9b add chromium flags for hardware acceleration 2022-10-15 20:28:38 +02:00
7 changed files with 26 additions and 58 deletions

View File

@@ -4,7 +4,6 @@
<metadata_license>CC0-1.0</metadata_license> <metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0+</project_license> <project_license>GPL-3.0+</project_license>
<name>discord-screenaudio</name> <name>discord-screenaudio</name>
<developer_name>Malte Jürgens</developer_name>
<releases> <releases>
<release version="${DISCORD_SCEENAUDIO_VERSION_FULL}" timestamp="${TIMESTAMP}" /> <release version="${DISCORD_SCEENAUDIO_VERSION_FULL}" timestamp="${TIMESTAMP}" />
</releases> </releases>

View File

@@ -183,21 +183,14 @@ setInterval(() => {
el.appendChild(div); el.appendChild(div);
} }
const buttonContainer = document.getElementsByClassName("container-YkUktl")[0]; const muteBtn = document.getElementsByClassName(
if (!buttonContainer) {
console.log('dsa: Cannot locate Mute/Deafen/Settings button container, please report this on GitHub');
}
const muteBtn = buttonContainer ? buttonContainer.getElementsByClassName(
"button-12Fmur enabled-9OeuTA button-f2h6uQ lookBlank-21BCro colorBrand-I6CyqQ grow-2sR_-F" "button-12Fmur enabled-9OeuTA button-f2h6uQ lookBlank-21BCro colorBrand-I6CyqQ grow-2sR_-F"
)[0] : null; )[0];
window.discordScreenaudioToggleMute = () => muteBtn && muteBtn.click(); window.discordScreenaudioToggleMute = () => muteBtn.click();
const deafenBtn = document.getElementsByClassName(
const deafenBtn = buttonContainer ? buttonContainer.getElementsByClassName(
"button-12Fmur enabled-9OeuTA button-f2h6uQ lookBlank-21BCro colorBrand-I6CyqQ grow-2sR_-F" "button-12Fmur enabled-9OeuTA button-f2h6uQ lookBlank-21BCro colorBrand-I6CyqQ grow-2sR_-F"
)[1] : null; )[1];
window.discordScreenaudioToggleDeafen = () => deafenBtn.click();
window.discordScreenaudioToggleDeafen = () => deafenBtn && deafenBtn.click();
if (window.discordScreenaudioResolutionString) { if (window.discordScreenaudioResolutionString) {
for (const el of document.getElementsByClassName( for (const el of document.getElementsByClassName(

View File

@@ -50,8 +50,6 @@ DiscordPage::DiscordPage(QWidget *parent) : QWebEnginePage(parent) {
false); false);
settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, false); settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, false);
settings()->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, true); settings()->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, true);
settings()->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard,
true);
setUrl(QUrl("https://discord.com/app")); setUrl(QUrl("https://discord.com/app"));

View File

@@ -30,9 +30,6 @@ int main(int argc, char *argv[]) {
QCommandLineOption degubOption("remote-debugging", QCommandLineOption degubOption("remote-debugging",
"Open Chromium Remote Debugging on port 9222"); "Open Chromium Remote Debugging on port 9222");
parser.addOption(degubOption); parser.addOption(degubOption);
QCommandLineOption notifySendOption(
"notify-send", "Use notify-send instead of QT/KF5 notifications");
parser.addOption(notifySendOption);
parser.process(app); parser.process(app);
@@ -41,6 +38,8 @@ int main(int argc, char *argv[]) {
} }
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", qputenv("QTWEBENGINE_CHROMIUM_FLAGS",
"--ignore-gpu-blacklist --enable-gpu-rasterization "
"--enable-native-gpu-memory-buffers --num-raster-threads=4 "
"--enable-features=WebRTCPipeWireCapturer " + "--enable-features=WebRTCPipeWireCapturer " +
qgetenv("QTWEBENGINE_CHROMIUM_FLAGS")); qgetenv("QTWEBENGINE_CHROMIUM_FLAGS"));
@@ -49,7 +48,7 @@ int main(int argc, char *argv[]) {
"--remote-debugging-port=9222 " + "--remote-debugging-port=9222 " +
qgetenv("QTWEBENGINE_CHROMIUM_FLAGS")); qgetenv("QTWEBENGINE_CHROMIUM_FLAGS"));
MainWindow w(parser.isSet(notifySendOption)); MainWindow w;
w.show(); w.show();
return app.exec(); return app.exec();

View File

@@ -24,11 +24,9 @@
MainWindow *MainWindow::m_instance = nullptr; MainWindow *MainWindow::m_instance = nullptr;
MainWindow::MainWindow(bool useNotifySend, QWidget *parent) MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
: QMainWindow(parent) {
assert(MainWindow::m_instance == nullptr); assert(MainWindow::m_instance == nullptr);
MainWindow::m_instance = this; MainWindow::m_instance = this;
m_useNotifySend = useNotifySend;
setupWebView(); setupWebView();
resize(1000, 700); resize(1000, 700);
showMaximized(); showMaximized();
@@ -42,36 +40,22 @@ void MainWindow::setupWebView() {
m_webView = new QWebEngineView(this); m_webView = new QWebEngineView(this);
m_webView->setPage(page); m_webView->setPage(page);
if (m_useKF5Notifications || m_useNotifySend)
QWebEngineProfile::defaultProfile()->setNotificationPresenter(
[&](std::unique_ptr<QWebEngineNotification> notificationInfo) {
if (m_useNotifySend) {
auto title = notificationInfo->title();
auto message = notificationInfo->message();
auto image_path =
QString("/tmp/discord-screenaudio-%1.png").arg(title);
notificationInfo->icon().save(image_path);
QProcess::execute("notify-send",
{"--icon", image_path, "--app-name",
"discord-screenaudio", title, message});
} else if (m_useKF5Notifications) {
#ifdef KNOTIFICATIONS #ifdef KNOTIFICATIONS
KNotification *notification = QWebEngineProfile::defaultProfile()->setNotificationPresenter(
new KNotification("discordNotification"); [&](std::unique_ptr<QWebEngineNotification> notificationInfo) {
notification->setTitle(notificationInfo->title()); KNotification *notification = new KNotification("discordNotification");
notification->setText(notificationInfo->message()); notification->setTitle(notificationInfo->title());
notification->setPixmap( notification->setText(notificationInfo->message());
QPixmap::fromImage(notificationInfo->icon())); notification->setPixmap(QPixmap::fromImage(notificationInfo->icon()));
notification->setDefaultAction("View"); notification->setDefaultAction("View");
connect(notification, &KNotification::defaultActivated, connect(notification, &KNotification::defaultActivated,
[&, notificationInfo = std::move(notificationInfo)]() { [&, notificationInfo = std::move(notificationInfo)]() {
notificationInfo->click(); notificationInfo->click();
activateWindow(); activateWindow();
}); });
notification->sendEvent(); notification->sendEvent();
});
#endif #endif
}
});
setCentralWidget(m_webView); setCentralWidget(m_webView);
} }

View File

@@ -14,7 +14,7 @@ class MainWindow : public QMainWindow {
Q_OBJECT Q_OBJECT
public: public:
explicit MainWindow(bool useNotifySend = false, QWidget *parent = nullptr); explicit MainWindow(QWidget *parent = nullptr);
static MainWindow *instance(); static MainWindow *instance();
private: private:
@@ -25,12 +25,6 @@ private:
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
bool m_wasMaximized; bool m_wasMaximized;
static MainWindow *m_instance; static MainWindow *m_instance;
bool m_useNotifySend;
#ifdef KNOTIFICATIONS
bool m_useKF5Notifications = true;
#else
bool m_useKF5Notifications = false;
#endif
private Q_SLOTS: private Q_SLOTS:
void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest); void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest);

1
submodules/Vencord Submodule

Submodule submodules/Vencord added at 0d996633f2