Fix wayland warning
This commit is contained in:
parent
e18ec416fe
commit
8a307bc0cf
3 changed files with 50 additions and 1 deletions
10
gui/main.py
10
gui/main.py
|
|
@ -13,6 +13,12 @@ import zipfile
|
|||
import shutil
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
if sys.platform.startswith("linux"):
|
||||
from util.linux_desktop import configure_qt_platform
|
||||
|
||||
configure_qt_platform()
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QApplication, QMainWindow, QTabWidget, QVBoxLayout, QHBoxLayout,
|
||||
QWidget, QPushButton, QLabel, QFileDialog, QMessageBox, QProgressBar,
|
||||
|
|
@ -1002,7 +1008,9 @@ def main():
|
|||
QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
|
||||
|
||||
if sys.platform.startswith("linux"):
|
||||
from util.linux_desktop import ensure_linux_desktop_entry
|
||||
from util.linux_desktop import ensure_linux_desktop_entry, install_qt_message_filter
|
||||
|
||||
install_qt_message_filter()
|
||||
ensure_linux_desktop_entry()
|
||||
QGuiApplication.setDesktopFileName("DazedMTLTool")
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,11 @@ from pathlib import Path
|
|||
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(PROJECT_ROOT))
|
||||
|
||||
if sys.platform.startswith("linux"):
|
||||
from util.linux_desktop import configure_qt_platform
|
||||
|
||||
configure_qt_platform()
|
||||
|
||||
|
||||
def check_dependencies():
|
||||
"""Check if required dependencies are installed."""
|
||||
|
|
|
|||
|
|
@ -12,6 +12,42 @@ from util.paths import ICON_PATH, PROJECT_ROOT
|
|||
DESKTOP_ID = "DazedMTLTool"
|
||||
LAUNCH_SCRIPT = PROJECT_ROOT / "scripts" / "launch.sh"
|
||||
|
||||
# Qt logs this on Wayland whenever a dialog tries to steal focus (harmless noise).
|
||||
_WAYLAND_ACTIVATE_WARNING = "Wayland does not support QWindow::requestActivate()"
|
||||
|
||||
|
||||
def _append_qt_logging_rule(rule: str) -> None:
|
||||
category = rule.split("=", 1)[0]
|
||||
existing = os.environ.get("QT_LOGGING_RULES", "")
|
||||
if category in existing:
|
||||
return
|
||||
os.environ["QT_LOGGING_RULES"] = f"{existing};{rule}" if existing else rule
|
||||
|
||||
|
||||
def configure_qt_platform() -> None:
|
||||
"""Apply Linux/Qt environment tweaks before constructing QApplication."""
|
||||
if not sys.platform.startswith("linux"):
|
||||
return
|
||||
_append_qt_logging_rule("qt.qpa.wayland=false")
|
||||
|
||||
|
||||
def install_qt_message_filter() -> None:
|
||||
"""Drop the noisy Wayland requestActivate warning (QT rules miss some builds)."""
|
||||
if not sys.platform.startswith("linux"):
|
||||
return
|
||||
try:
|
||||
from PyQt5.QtCore import QtMsgType, qInstallMessageHandler
|
||||
except ImportError:
|
||||
return
|
||||
|
||||
def _handler(mode, _context, message):
|
||||
if _WAYLAND_ACTIVATE_WARNING in message:
|
||||
return
|
||||
if mode in (QtMsgType.QtWarningMsg, QtMsgType.QtCriticalMsg, QtMsgType.QtFatalMsg):
|
||||
print(message, file=sys.stderr)
|
||||
|
||||
qInstallMessageHandler(_handler)
|
||||
|
||||
|
||||
def installed_desktop_path() -> Path:
|
||||
data_home = os.environ.get("XDG_DATA_HOME", "")
|
||||
|
|
|
|||
Loading…
Reference in a new issue