Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion cq_editor/__main__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import os
import sys
import argparse

from PyQt5.QtWidgets import QApplication

NAME = "CQ-editor"

# need to initialize QApp here, otherewise svg icons do not work on windows
# Reorder QT_QPA_PLATFORM so Qt reaches a Wayland plugin only after everything
# else has failed to load, defaulting to xcb. OCCT does not yet support Wayland.
if sys.platform == "linux":
# Desktops such as COSMIC export QT_QPA_PLATFORM="wayland;xcb" session-wide,
# we want to respect this config as far as possible, without using wayland.
plugins = (os.environ.get("QT_QPA_PLATFORM") or "xcb").split(";")
os.environ["QT_QPA_PLATFORM"] = ";".join(
sorted(plugins, key=lambda plugin: plugin.startswith("wayland"))
)

# need to initialize QApp here, otherwise svg icons do not work on windows
app = QApplication(sys.argv, applicationName=NAME)

from .main_window import MainWindow
Expand Down
1 change: 1 addition & 0 deletions cq_editor/widgets/occt_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def _get_window_win(self, wid):

def _get_window_linux(self, wid):

# X11 only as OCCT currently doesn't have wayland support
from OCP.Xw import Xw_Window

return Xw_Window(self.display_connection, int(wid))
Expand Down
5 changes: 0 additions & 5 deletions run.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import sys
import os
import faulthandler

# OCP's Xw_Window requires an X11 window ID, so we force XCB so winId() is valid under Wayland/XWayland.
if sys.platform == "linux" and "QT_QPA_PLATFORM" not in os.environ:
os.environ["QT_QPA_PLATFORM"] = "xcb"

# PyInstaller with console=False sets sys.stdout/stderr to None on Windows
if sys.stdout is None:
sys.stdout = open("nul", "w")
Expand Down
Loading