Skip to content

Commit

Permalink
Force Qt to use xcb plugin on Wayland (#2526)
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 authored Aug 16, 2024
1 parent e2be446 commit 9e31084
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/gui/Gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,18 @@ std::unique_ptr<gz::gui::Application> createGui(
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1");
}

// check for wayland and force to use X for rendering
if (QString::fromLocal8Bit(qgetenv("XDG_SESSION_TYPE")) == "wayland")
{
if (QString::fromLocal8Bit(qgetenv("QT_QPA_PLATFORM")).isEmpty())
{
gzmsg << "Detected Wayland. Setting Qt to use the xcb plugin: "
<< "'QT_QPA_PLATFORM=xcb'." << std::endl;
qputenv("QT_QPA_PLATFORM", "xcb");
}
}


bool isPlayback = (nullptr != _guiConfig &&
std::string(_guiConfig) == "_playback_");
auto defaultConfig = defaultGuiConfigFile(isPlayback, _defaultGuiConfig);
Expand Down

0 comments on commit 9e31084

Please sign in to comment.