From 9449b554ba84aacb5895eb8e88f6c50e3bf8f8d4 Mon Sep 17 00:00:00 2001 From: yzct12345 Date: Tue, 13 Dec 2022 19:34:36 -0500 Subject: [PATCH] Disable compositor on Qt Linux --- CMakeLists.txt | 8 ++++++-- src/yuzu/CMakeLists.txt | 3 +++ src/yuzu/main.cpp | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 47eddf99e9..43e69bc415 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -260,11 +260,15 @@ if(ENABLE_QT6 AND Qt6_LOCATION) list(APPEND CMAKE_PREFIX_PATH "${Qt6_LOCATION}") endif() +if (UNIX AND NOT APPLE) + find_package(X11 REQUIRED) +endif() + function(set_yuzu_qt_components) # Best practice is to ask for all components at once, so they are from the same version set(YUZU_QT_COMPONENTS2 Core Widgets Concurrent) - if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - list(APPEND YUZU_QT_COMPONENTS2 DBus) + if (UNIX AND NOT APPLE) + list(APPEND YUZU_QT_COMPONENTS2 DBus X11Extras) endif() if (YUZU_USE_QT_MULTIMEDIA) list(APPEND YUZU_QT_COMPONENTS2 Multimedia) diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 4a7d35617c..47980a832f 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -319,11 +319,14 @@ target_link_libraries(yuzu PRIVATE Boost::boost glad Qt${QT_MAJOR_VERSION}::Widg target_link_libraries(yuzu PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) target_link_libraries(yuzu PRIVATE Vulkan::Headers) + if (NOT WIN32) target_include_directories(yuzu PRIVATE ${Qt${QT_MAJOR_VERSION}Gui_PRIVATE_INCLUDE_DIRS}) endif() if (UNIX AND NOT APPLE) target_link_libraries(yuzu PRIVATE Qt${QT_MAJOR_VERSION}::DBus) + target_link_libraries(yuzu PRIVATE Qt${QT_MAJOR_VERSION}X11Extras) + target_link_libraries(yuzu PRIVATE ${X11_LIBRARIES}) endif() target_compile_definitions(yuzu PRIVATE diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 6c204416fa..6452bed506 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -164,6 +164,12 @@ extern "C" { __declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001; __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; } +#elif defined(__linux__) +#include +#include +#undef KeyPress +#undef None +#undef Success #endif constexpr int default_mouse_hide_timeout = 2500; @@ -4269,6 +4275,15 @@ int main(int argc, char* argv[]) { setlocale(LC_ALL, "C"); GMainWindow main_window{std::move(config), has_broken_vulkan}; +#if defined(__linux__) + if (QX11Info::isPlatformX11()) { + long disable_compositor = 1; + XChangeProperty(QX11Info::display(), static_cast(main_window.winId()), + XInternAtom(QX11Info::display(), "_NET_WM_BYPASS_COMPOSITOR", false), + XCB_ATOM_CARDINAL, 32, PropModeReplace, (unsigned char*)&disable_compositor, + 1); + } +#endif // After settings have been loaded by GMainWindow, apply the filter main_window.show();