Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempting to fix Wayland #697

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ option(GPU_DEBUG_INFO "Enable additional GPU debugging info" OFF)
option(ENABLE_OPENGL "Enable OpenGL rendering backend" ON)
option(ENABLE_VULKAN "Enable Vulkan rendering backend" ON)
option(ENABLE_METAL "Enable Metal rendering backend (if available)" ON)
option(ENABLE_WAYLAND "Enable Wayland support on Linux platforms" ON)
option(ENABLE_LTO "Enable link-time optimization" OFF)
option(ENABLE_TESTS "Compile unit-tests" OFF)
option(ENABLE_USER_BUILD "Make a user-facing build. These builds have various assertions disabled, LTO, and more" OFF)
Expand Down Expand Up @@ -140,6 +141,10 @@ add_compile_definitions(NOMINMAX) # Make windows.h not define min/ma
add_compile_definitions(WIN32_LEAN_AND_MEAN) # Make windows.h not include literally everything
add_compile_definitions(SDL_MAIN_HANDLED)

if(ENABLE_WAYLAND)
add_compile_definitions(WAYLAND_ENABLED)
endif()

if(ENABLE_DISCORD_RPC AND NOT ANDROID)
add_subdirectory(third_party/discord-rpc)
include_directories(third_party/discord-rpc/include)
Expand Down
6 changes: 3 additions & 3 deletions src/panda_qt/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent)
resize(800, 240 * 4);

// We pass a callback to the screen widget that will be triggered every time we resize the screen
screen = new ScreenWidget([this](u32 width, u32 height) { handleScreenResize(width, height); }, this);
setCentralWidget(screen);
screen = new ScreenWidget([this](u32 width, u32 height) { handleScreenResize(width, height); }, nullptr);
// setCentralWidget(screen);

screen->show();
appRunning = true;
Expand Down Expand Up @@ -695,4 +695,4 @@ void MainWindow::setupControllerSensors(SDL_GameController* controller) {
if (haveAccelerometer) {
SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_ACCEL, SDL_TRUE);
}
}
}
7 changes: 6 additions & 1 deletion src/panda_qt/screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ScreenWidget::ScreenWidget(ResizeCallback resizeCallback, QWidget* parent) : QWi
setAttribute(Qt::WA_KeyCompression, false);
setFocusPolicy(Qt::StrongFocus);
setMouseTracking(true);
show();

if (!createGLContext()) {
Helpers::panic("Failed to create GL context for display");
Expand Down Expand Up @@ -72,14 +73,18 @@ bool ScreenWidget::createGLContext() {
this->windowInfo = *windowInfo;

glContext = GL::Context::Create(*getWindowInfo(), versionsToTry);
if (!glContext) {
return false;
}

glContext->DoneCurrent();
}

return glContext != nullptr;
}

qreal ScreenWidget::devicePixelRatioFromScreen() const {
const QScreen* screenForRatio = window()->windowHandle()->screen();
const QScreen* screenForRatio = windowHandle()->screen();
if (!screenForRatio) {
screenForRatio = QGuiApplication::primaryScreen();
}
Expand Down
Loading