Removes dependency on QtX11Extras for Qt6.2-beta (#331)

* Removes dependency on QtX11Extras and implements placeholder solution with QtGUI private API

* Fixes CMakeLists.txt to work with Qt5 and Qt6

* Removes all other uses of X11extras

* Renames and moves x11 methods into ads::internal

* Fixes typo

* Adds gui-private to src.pro
This commit is contained in:
Charles Cross 2021-07-17 05:49:20 -07:00 committed by GitHub
parent 3a99bdcfb4
commit fc91502162
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 36 additions and 48 deletions

View File

@ -16,7 +16,6 @@ jobs:
run: | run: |
sudo apt-get update --fix-missing sudo apt-get update --fix-missing
sudo apt-get install qt5-default sudo apt-get install qt5-default
sudo apt-get install libqt5x11extras5-dev
- name: qmake - name: qmake
run: qmake run: qmake
- name: make - name: make

View File

@ -9,8 +9,6 @@ matrix:
os: linux os: linux
dist: trusty dist: trusty
group: stable group: stable
before_install:
- sudo apt-get -y install libqt5x11extras5-dev
addons: addons:
apt: apt:
sources: sources:
@ -20,8 +18,6 @@ matrix:
packages: packages:
- qt55base - qt55base
- qt55tools - qt55tools
- qt55x11extras
- libqt5x11extras5-dev
- gcc-9 - gcc-9
- g++-9 - g++-9
script: script:
@ -39,8 +35,6 @@ matrix:
services: services:
- xvfb - xvfb
compiler: gcc compiler: gcc
before_install:
- sudo apt-get -y install libqt5x11extras5-dev
addons: addons:
apt: apt:
sources: sources:
@ -50,8 +44,6 @@ matrix:
packages: packages:
- qt514base - qt514base
- qt514tools - qt514tools
- qt514x11extras
- libqt5x11extras5-dev
- gcc-9 - gcc-9
- g++-9 - g++-9
- libc6-i386 - libc6-i386
@ -73,8 +65,6 @@ matrix:
services: services:
- xvfb - xvfb
compiler: gcc compiler: gcc
before_install:
- sudo apt-get -y install libqt5x11extras5-dev
addons: addons:
apt: apt:
sources: sources:
@ -84,8 +74,6 @@ matrix:
packages: packages:
- qt514base - qt514base
- qt514tools - qt514tools
- qt514x11extras
- libqt5x11extras5-dev
- gcc-9 - gcc-9
- g++-9 - g++-9
- libc6-i386 - libc6-i386
@ -107,8 +95,6 @@ matrix:
services: services:
- xvfb - xvfb
compiler: gcc compiler: gcc
before_install:
- sudo apt-get -y install libqt5x11extras5-dev
addons: addons:
apt: apt:
sources: sources:
@ -118,8 +104,6 @@ matrix:
packages: packages:
- qt514base - qt514base
- qt514tools - qt514tools
- qt514x11extras
- libqt5x11extras5-dev
- gcc-9 - gcc-9
- g++-9 - g++-9
- libc6-i386 - libc6-i386
@ -147,8 +131,6 @@ matrix:
services: services:
- xvfb - xvfb
compiler: gcc compiler: gcc
before_install:
- sudo apt-get -y install libqt5x11extras5-dev
addons: addons:
apt: apt:
sources: sources:
@ -158,8 +140,6 @@ matrix:
packages: packages:
- qt514base - qt514base
- qt514tools - qt514tools
- qt514x11extras
- libqt5x11extras5-dev
- gcc-9 - gcc-9
- g++-9 - g++-9
- libc6-i386 - libc6-i386

View File

@ -17,5 +17,4 @@ else{
unix:!macx { unix:!macx {
LIBS += -lxcb LIBS += -lxcb
QT += x11extras
} }

View File

@ -2,7 +2,4 @@ include(CMakeFindDependencyMacro)
find_dependency(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED) find_dependency(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED)
find_dependency(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED) find_dependency(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED)
find_dependency(Qt5Widgets ${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") include("${CMAKE_CURRENT_LIST_DIR}/adsTargets.cmake")

View File

@ -227,9 +227,7 @@ class build_ext(sipdistutils.build_ext):
extension.extra_link_args += ['-F' + self.qtconfig.QT_INSTALL_LIBS, extension.extra_link_args += ['-F' + self.qtconfig.QT_INSTALL_LIBS,
'-mmacosx-version-min=10.9'] '-mmacosx-version-min=10.9']
elif sys.platform == 'linux': elif sys.platform == 'linux':
extension.extra_compile_args += ['-D', 'QT_X11EXTRAS_LIB', '-std=c++11'] extension.extra_compile_args += ['-std=c++11']
extension.include_dirs += [os.path.join(self.qt_include_dir, 'QtX11Extras')]
extension.libraries += ['Qt5X11Extras' + self.qt_libinfix]
return super().swig_sources(sources, extension) return super().swig_sources(sources, extension)

View File

@ -3,7 +3,7 @@ project(QtAdvancedDockingSystem LANGUAGES CXX VERSION ${VERSION_SHORT})
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED) find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED)
if (UNIX AND NOT APPLE) 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() endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
if(BUILD_STATIC) if(BUILD_STATIC)
@ -64,10 +64,6 @@ endif()
target_link_libraries(qtadvanceddocking PUBLIC Qt${QT_VERSION_MAJOR}::Core target_link_libraries(qtadvanceddocking PUBLIC Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets) 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 set_target_properties(qtadvanceddocking PROPERTIES
AUTOMOC ON AUTOMOC ON
AUTORCC ON AUTORCC ON

View File

@ -39,13 +39,11 @@
#include "ads_globals.h" #include "ads_globals.h"
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
#include <QX11Info>
#include <QSettings> #include <QSettings>
#include <QFile> #include <QFile>
#endif
#include <QApplication> #include <QApplication>
#include <qpa/qplatformnativeinterface.h>
#endif
namespace ads namespace ads
{ {
@ -57,10 +55,31 @@ static QString _window_manager;
static QHash<QString, xcb_atom_t> _xcb_atom_cache; static QHash<QString, xcb_atom_t> _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<xcb_connection_t *>(connection);
}
//============================================================================ //============================================================================
xcb_atom_t xcb_get_atom(const char *name) xcb_atom_t xcb_get_atom(const char *name)
{ {
if (!QX11Info::isPlatformX11()) if (!is_platform_x11())
{ {
return XCB_ATOM_NONE; return XCB_ATOM_NONE;
} }
@ -69,7 +88,7 @@ xcb_atom_t xcb_get_atom(const char *name)
{ {
return _xcb_atom_cache[key]; 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_cookie_t request = xcb_intern_atom(connection, 1, strlen(name), name);
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, request, NULL); xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, request, NULL);
if (!reply) 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) 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 type_atom = xcb_get_atom(type);
xcb_atom_t prop_atom = xcb_get_atom(prop); xcb_atom_t prop_atom = xcb_get_atom(prop);
xcb_client_message_event_t event; 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) 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; return nullptr;
} }
xcb_connection_t *connection = QX11Info::connection(); xcb_connection_t *connection = x11_connection();
xcb_atom_t type_atom = xcb_get_atom(type); xcb_atom_t type_atom = xcb_get_atom(type);
if (type_atom == XCB_ATOM_NONE) if (type_atom == XCB_ATOM_NONE)
{ {
@ -191,7 +210,7 @@ bool xcb_dump_props(WId window, const char *type)
QVector<xcb_atom_t> atoms; QVector<xcb_atom_t> atoms;
xcb_get_prop_list(window, type, atoms, XCB_ATOM_ATOM); xcb_get_prop_list(window, type, atoms, XCB_ATOM_ATOM);
qDebug() << "\n\n!!!" << type << " - " << atoms.length(); qDebug() << "\n\n!!!" << type << " - " << atoms.length();
xcb_connection_t *connection = QX11Info::connection(); xcb_connection_t *connection = x11_connection();
for (auto atom : atoms) for (auto atom : atoms)
{ {
auto foo = xcb_get_atom_name(connection, atom); 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) void xcb_add_prop(bool state, WId window, const char *type, const char *prop)
{ {
if (!QX11Info::isPlatformX11()) if (!is_platform_x11())
{ {
return; return;
} }
@ -227,7 +246,7 @@ void xcb_add_prop(bool state, WId window, const char *type, const char *prop)
{ {
atoms.remove(index); 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_change_property(connection, XCB_PROP_MODE_REPLACE, window, type_atom, XCB_ATOM_ATOM, 32, atoms.count(), atoms.constData());
xcb_flush(connection); xcb_flush(connection);
} }
@ -238,11 +257,11 @@ QString detectWindowManagerX11()
{ {
// Tries to detect the windowmanager via X11. // Tries to detect the windowmanager via X11.
// See: https://specifications.freedesktop.org/wm-spec/1.3/ar01s03.html#idm46018259946000 // See: https://specifications.freedesktop.org/wm-spec/1.3/ar01s03.html#idm46018259946000
if (!QX11Info::isPlatformX11()) if (!is_platform_x11())
{ {
return "UNKNOWN"; 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; xcb_screen_t *first_screen = xcb_setup_roots_iterator (xcb_get_setup (connection)).data;
if(!first_screen) if(!first_screen)
{ {

View File

@ -73,8 +73,8 @@ SOURCES += \
unix:!macx { unix:!macx {
HEADERS += linux/FloatingWidgetTitleBar.h HEADERS += linux/FloatingWidgetTitleBar.h
SOURCES += linux/FloatingWidgetTitleBar.cpp SOURCES += linux/FloatingWidgetTitleBar.cpp
QT += x11extras
LIBS += -lxcb LIBS += -lxcb
QT += gui-private
} }
isEmpty(PREFIX){ isEmpty(PREFIX){