From 6fdb21b83d8a232376544e1c1015ee2023a94278 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 27 Jul 2022 16:34:27 +0200 Subject: Warn if X11 is not accelerated/running on llvmpipe --- src/mainwindow.cpp | 62 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index a7bdb58..525242b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -302,31 +302,53 @@ QSize MainWindow::createDistro(const QRect &max) bool MainWindow::createLogWindow() { + // HACK HACK: This doesn't really belong here at all :-/ + // But we can only check this when X is running, so.... + QProcess p; + p.start(QLatin1String("/usr/bin/glxinfo"), QStringList() << QLatin1String("-B")); + p.waitForFinished(1500); + QString str = QString::fromLocal8Bit(p.readAllStandardOutput()); + if (str.contains("Device: llvmpipe") || str.contains("Accelerated: no")) { + int i = str.indexOf("Device: "); + int j = str.indexOf("\n", i); + str = QLatin1String("SLOW Graphics! ") + str.mid(i, j - i); + } else { + str = ""; + } QString path = Settings::logMessageFile(); - if (path.isEmpty()) - return false; - QFile f(path); - if (f.size() == 0 || !f.open(QFile::ReadOnly)) + if (path.isEmpty() && str.isEmpty()) return false; - m_messages = new QTextEdit(this); - QTextStream stream(&f); - const QColor black(Qt::black); - while (!stream.atEnd()) { - bool ok = false; - QString line(stream.readLine()); - int i = line.indexOf(' '); - if (i > 0) { - QString scol(line.left(i)); - uint col = scol.toUInt(&ok, 16); - if (ok) { - m_messages->setTextColor(QColor(QRgb(col))); - line = line.mid(i + 1); + if (!path.isEmpty()) { + QFile f(path); + if ((f.size() == 0 || !f.open(QFile::ReadOnly)) && str.isEmpty()) + return false; + m_messages = new QTextEdit(this); + QTextStream stream(&f); + const QColor black(Qt::black); + while (!stream.atEnd()) { + bool ok = false; + QString line(stream.readLine()); + int i = line.indexOf(' '); + if (i > 0) { + QString scol(line.left(i)); + uint col = scol.toUInt(&ok, 16); + if (ok) { + m_messages->setTextColor(QColor(QRgb(col))); + line = line.mid(i + 1); + } } + if (!ok) { + m_messages->setTextColor(black); + } + m_messages->append(line); } - if (!ok) { - m_messages->setTextColor(black); + } + if (!str.isEmpty()) { + if (m_messages == nullptr) { + m_messages = new QTextEdit(this); } - m_messages->append(line); + m_messages->setTextColor(Qt::red); + m_messages->append(str); } m_messages->setReadOnly(true); m_messages->setStyleSheet("border:none; background:rgba(255,255,255,.33); border-radius:5px"); -- cgit v1.2.3-55-g7522