Disable compositor on Qt Linux

This commit is contained in:
yzct12345 2022-12-13 19:34:36 -05:00 committed by Liam
parent a4696285af
commit 9449b554ba
3 changed files with 24 additions and 2 deletions

View file

@ -260,11 +260,15 @@ if(ENABLE_QT6 AND Qt6_LOCATION)
list(APPEND CMAKE_PREFIX_PATH "${Qt6_LOCATION}") list(APPEND CMAKE_PREFIX_PATH "${Qt6_LOCATION}")
endif() endif()
if (UNIX AND NOT APPLE)
find_package(X11 REQUIRED)
endif()
function(set_yuzu_qt_components) function(set_yuzu_qt_components)
# Best practice is to ask for all components at once, so they are from the same version # Best practice is to ask for all components at once, so they are from the same version
set(YUZU_QT_COMPONENTS2 Core Widgets Concurrent) set(YUZU_QT_COMPONENTS2 Core Widgets Concurrent)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") if (UNIX AND NOT APPLE)
list(APPEND YUZU_QT_COMPONENTS2 DBus) list(APPEND YUZU_QT_COMPONENTS2 DBus X11Extras)
endif() endif()
if (YUZU_USE_QT_MULTIMEDIA) if (YUZU_USE_QT_MULTIMEDIA)
list(APPEND YUZU_QT_COMPONENTS2 Multimedia) list(APPEND YUZU_QT_COMPONENTS2 Multimedia)

View file

@ -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 ${PLATFORM_LIBRARIES} Threads::Threads)
target_link_libraries(yuzu PRIVATE Vulkan::Headers) target_link_libraries(yuzu PRIVATE Vulkan::Headers)
if (NOT WIN32) if (NOT WIN32)
target_include_directories(yuzu PRIVATE ${Qt${QT_MAJOR_VERSION}Gui_PRIVATE_INCLUDE_DIRS}) target_include_directories(yuzu PRIVATE ${Qt${QT_MAJOR_VERSION}Gui_PRIVATE_INCLUDE_DIRS})
endif() endif()
if (UNIX AND NOT APPLE) if (UNIX AND NOT APPLE)
target_link_libraries(yuzu PRIVATE Qt${QT_MAJOR_VERSION}::DBus) 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() endif()
target_compile_definitions(yuzu PRIVATE target_compile_definitions(yuzu PRIVATE

View file

@ -164,6 +164,12 @@ extern "C" {
__declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001; __declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
} }
#elif defined(__linux__)
#include <QtX11Extras/QX11Info>
#include <X11/Xlib.h>
#undef KeyPress
#undef None
#undef Success
#endif #endif
constexpr int default_mouse_hide_timeout = 2500; constexpr int default_mouse_hide_timeout = 2500;
@ -4269,6 +4275,15 @@ int main(int argc, char* argv[]) {
setlocale(LC_ALL, "C"); setlocale(LC_ALL, "C");
GMainWindow main_window{std::move(config), has_broken_vulkan}; GMainWindow main_window{std::move(config), has_broken_vulkan};
#if defined(__linux__)
if (QX11Info::isPlatformX11()) {
long disable_compositor = 1;
XChangeProperty(QX11Info::display(), static_cast<Window>(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 // After settings have been loaded by GMainWindow, apply the filter
main_window.show(); main_window.show();