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>
<project_license>GPL-3.0+</project_license>
<name>discord-screenaudio</name>
<developer_name>Malte Jürgens</developer_name>
<releases>
<release version="${DISCORD_SCEENAUDIO_VERSION_FULL}" timestamp="${TIMESTAMP}" />
</releases>

View File

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

View File

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

View File

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

View File

@@ -24,11 +24,9 @@
MainWindow *MainWindow::m_instance = nullptr;
MainWindow::MainWindow(bool useNotifySend, QWidget *parent)
: QMainWindow(parent) {
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
assert(MainWindow::m_instance == nullptr);
MainWindow::m_instance = this;
m_useNotifySend = useNotifySend;
setupWebView();
resize(1000, 700);
showMaximized();
@@ -42,36 +40,22 @@ void MainWindow::setupWebView() {
m_webView = new QWebEngineView(this);
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
KNotification *notification =
new KNotification("discordNotification");
notification->setTitle(notificationInfo->title());
notification->setText(notificationInfo->message());
notification->setPixmap(
QPixmap::fromImage(notificationInfo->icon()));
notification->setDefaultAction("View");
connect(notification, &KNotification::defaultActivated,
[&, notificationInfo = std::move(notificationInfo)]() {
notificationInfo->click();
activateWindow();
});
notification->sendEvent();
QWebEngineProfile::defaultProfile()->setNotificationPresenter(
[&](std::unique_ptr<QWebEngineNotification> notificationInfo) {
KNotification *notification = new KNotification("discordNotification");
notification->setTitle(notificationInfo->title());
notification->setText(notificationInfo->message());
notification->setPixmap(QPixmap::fromImage(notificationInfo->icon()));
notification->setDefaultAction("View");
connect(notification, &KNotification::defaultActivated,
[&, notificationInfo = std::move(notificationInfo)]() {
notificationInfo->click();
activateWindow();
});
notification->sendEvent();
});
#endif
}
});
setCentralWidget(m_webView);
}

View File

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

1
submodules/Vencord Submodule

Submodule submodules/Vencord added at 0d996633f2