diff --git a/.github/workflows/linux-builds.yml b/.github/workflows/linux-builds.yml index 4be2a29..5f67e7f 100644 --- a/.github/workflows/linux-builds.yml +++ b/.github/workflows/linux-builds.yml @@ -16,7 +16,6 @@ jobs: run: | sudo apt-get update --fix-missing sudo apt-get install qt5-default - sudo apt-get install libqt5x11extras5-dev - name: qmake run: qmake - name: make diff --git a/.travis.yml b/.travis.yml index d1cf9e6..38db61f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,6 @@ matrix: os: linux dist: trusty group: stable - before_install: - - sudo apt-get -y install libqt5x11extras5-dev addons: apt: sources: @@ -20,8 +18,6 @@ matrix: packages: - qt55base - qt55tools - - qt55x11extras - - libqt5x11extras5-dev - gcc-9 - g++-9 script: @@ -39,8 +35,6 @@ matrix: services: - xvfb compiler: gcc - before_install: - - sudo apt-get -y install libqt5x11extras5-dev addons: apt: sources: @@ -50,8 +44,6 @@ matrix: packages: - qt514base - qt514tools - - qt514x11extras - - libqt5x11extras5-dev - gcc-9 - g++-9 - libc6-i386 @@ -73,8 +65,6 @@ matrix: services: - xvfb compiler: gcc - before_install: - - sudo apt-get -y install libqt5x11extras5-dev addons: apt: sources: @@ -84,8 +74,6 @@ matrix: packages: - qt514base - qt514tools - - qt514x11extras - - libqt5x11extras5-dev - gcc-9 - g++-9 - libc6-i386 @@ -107,8 +95,6 @@ matrix: services: - xvfb compiler: gcc - before_install: - - sudo apt-get -y install libqt5x11extras5-dev addons: apt: sources: @@ -118,8 +104,6 @@ matrix: packages: - qt514base - qt514tools - - qt514x11extras - - libqt5x11extras5-dev - gcc-9 - g++-9 - libc6-i386 @@ -147,8 +131,6 @@ matrix: services: - xvfb compiler: gcc - before_install: - - sudo apt-get -y install libqt5x11extras5-dev addons: apt: sources: @@ -158,8 +140,6 @@ matrix: packages: - qt514base - qt514tools - - qt514x11extras - - libqt5x11extras5-dev - gcc-9 - g++-9 - libc6-i386 diff --git a/ads.pri b/ads.pri index b189626..79e1fff 100644 --- a/ads.pri +++ b/ads.pri @@ -17,5 +17,4 @@ else{ unix:!macx { LIBS += -lxcb - QT += x11extras } diff --git a/adsConfig.cmake b/adsConfig.cmake index 9f9b307..542e5c9 100644 --- a/adsConfig.cmake +++ b/adsConfig.cmake @@ -2,7 +2,4 @@ include(CMakeFindDependencyMacro) find_dependency(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED) find_dependency(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED) find_dependency(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED) -if(UNIX AND NOT APPLE) - find_dependency(Qt5X11Extras ${REQUIRED_QT_VERSION} REQUIRED) -endif() include("${CMAKE_CURRENT_LIST_DIR}/adsTargets.cmake") \ No newline at end of file diff --git a/setup.py b/setup.py index 31546a9..1986df7 100644 --- a/setup.py +++ b/setup.py @@ -227,9 +227,7 @@ class build_ext(sipdistutils.build_ext): extension.extra_link_args += ['-F' + self.qtconfig.QT_INSTALL_LIBS, '-mmacosx-version-min=10.9'] elif sys.platform == 'linux': - extension.extra_compile_args += ['-D', 'QT_X11EXTRAS_LIB', '-std=c++11'] - extension.include_dirs += [os.path.join(self.qt_include_dir, 'QtX11Extras')] - extension.libraries += ['Qt5X11Extras' + self.qt_libinfix] + extension.extra_compile_args += ['-std=c++11'] return super().swig_sources(sources, extension) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 74c66c5..49cd799 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,7 +3,7 @@ project(QtAdvancedDockingSystem LANGUAGES CXX VERSION ${VERSION_SHORT}) find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED) if (UNIX AND NOT APPLE) - find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS X11Extras REQUIRED) + include_directories(${Qt${QT_VERSION_MAJOR}Gui_PRIVATE_INCLUDE_DIRS}) endif() set(CMAKE_INCLUDE_CURRENT_DIR ON) if(BUILD_STATIC) @@ -64,10 +64,6 @@ endif() target_link_libraries(qtadvanceddocking PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets) -if(UNIX AND NOT APPLE) - target_link_libraries(qtadvanceddocking PUBLIC Qt${QT_VERSION_MAJOR}::X11Extras) - target_link_libraries(qtadvanceddocking PRIVATE xcb) -endif() set_target_properties(qtadvanceddocking PROPERTIES AUTOMOC ON AUTORCC ON diff --git a/src/ads_globals.cpp b/src/ads_globals.cpp index 322046e..8eca159 100644 --- a/src/ads_globals.cpp +++ b/src/ads_globals.cpp @@ -39,13 +39,11 @@ #include "ads_globals.h" #ifdef Q_OS_LINUX -#include #include #include -#endif - - #include +#include +#endif namespace ads { @@ -57,10 +55,31 @@ static QString _window_manager; static QHash _xcb_atom_cache; +//============================================================================ + bool is_platform_x11() +{ + return QGuiApplication::platformName() == QLatin1String("xcb"); +} + + +//============================================================================ +xcb_connection_t* x11_connection() +{ + if (!qApp) + return nullptr; + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + if (!native) + return nullptr; + + void *connection = native->nativeResourceForIntegration(QByteArray("connection")); + return reinterpret_cast(connection); +} + + //============================================================================ xcb_atom_t xcb_get_atom(const char *name) { - if (!QX11Info::isPlatformX11()) + if (!is_platform_x11()) { return XCB_ATOM_NONE; } @@ -69,7 +88,7 @@ xcb_atom_t xcb_get_atom(const char *name) { return _xcb_atom_cache[key]; } - xcb_connection_t *connection = QX11Info::connection(); + xcb_connection_t *connection = x11_connection(); xcb_intern_atom_cookie_t request = xcb_intern_atom(connection, 1, strlen(name), name); xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, request, NULL); if (!reply) @@ -93,7 +112,7 @@ xcb_atom_t xcb_get_atom(const char *name) //============================================================================ void xcb_update_prop(bool set, WId window, const char *type, const char *prop, const char *prop2) { - auto connection = QX11Info::connection(); + auto connection = x11_connection(); xcb_atom_t type_atom = xcb_get_atom(type); xcb_atom_t prop_atom = xcb_get_atom(prop); xcb_client_message_event_t event; @@ -118,11 +137,11 @@ void xcb_update_prop(bool set, WId window, const char *type, const char *prop, c //============================================================================ xcb_get_property_reply_t* _xcb_get_props(WId window, const char *type, unsigned int atom_type) { - if (!QX11Info::isPlatformX11()) + if (!is_platform_x11()) { return nullptr; } - xcb_connection_t *connection = QX11Info::connection(); + xcb_connection_t *connection = x11_connection(); xcb_atom_t type_atom = xcb_get_atom(type); if (type_atom == XCB_ATOM_NONE) { @@ -191,7 +210,7 @@ bool xcb_dump_props(WId window, const char *type) QVector atoms; xcb_get_prop_list(window, type, atoms, XCB_ATOM_ATOM); qDebug() << "\n\n!!!" << type << " - " << atoms.length(); - xcb_connection_t *connection = QX11Info::connection(); + xcb_connection_t *connection = x11_connection(); for (auto atom : atoms) { auto foo = xcb_get_atom_name(connection, atom); @@ -206,7 +225,7 @@ bool xcb_dump_props(WId window, const char *type) //============================================================================ void xcb_add_prop(bool state, WId window, const char *type, const char *prop) { - if (!QX11Info::isPlatformX11()) + if (!is_platform_x11()) { return; } @@ -227,7 +246,7 @@ void xcb_add_prop(bool state, WId window, const char *type, const char *prop) { atoms.remove(index); } - xcb_connection_t *connection = QX11Info::connection(); + xcb_connection_t *connection = x11_connection(); xcb_change_property(connection, XCB_PROP_MODE_REPLACE, window, type_atom, XCB_ATOM_ATOM, 32, atoms.count(), atoms.constData()); xcb_flush(connection); } @@ -238,11 +257,11 @@ QString detectWindowManagerX11() { // Tries to detect the windowmanager via X11. // See: https://specifications.freedesktop.org/wm-spec/1.3/ar01s03.html#idm46018259946000 - if (!QX11Info::isPlatformX11()) + if (!is_platform_x11()) { return "UNKNOWN"; } - xcb_connection_t *connection = QX11Info::connection(); + xcb_connection_t *connection = x11_connection(); xcb_screen_t *first_screen = xcb_setup_roots_iterator (xcb_get_setup (connection)).data; if(!first_screen) { diff --git a/src/src.pro b/src/src.pro index 7144c6c..9f6d265 100644 --- a/src/src.pro +++ b/src/src.pro @@ -73,8 +73,8 @@ SOURCES += \ unix:!macx { HEADERS += linux/FloatingWidgetTitleBar.h SOURCES += linux/FloatingWidgetTitleBar.cpp -QT += x11extras LIBS += -lxcb +QT += gui-private } isEmpty(PREFIX){