Skip to content

Commit fc91502

Browse files
authored
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
1 parent 3a99bdc commit fc91502

File tree

8 files changed

+36
-48
lines changed

8 files changed

+36
-48
lines changed

.github/workflows/linux-builds.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
run: |
1717
sudo apt-get update --fix-missing
1818
sudo apt-get install qt5-default
19-
sudo apt-get install libqt5x11extras5-dev
2019
- name: qmake
2120
run: qmake
2221
- name: make

.travis.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ matrix:
99
os: linux
1010
dist: trusty
1111
group: stable
12-
before_install:
13-
- sudo apt-get -y install libqt5x11extras5-dev
1412
addons:
1513
apt:
1614
sources:
@@ -20,8 +18,6 @@ matrix:
2018
packages:
2119
- qt55base
2220
- qt55tools
23-
- qt55x11extras
24-
- libqt5x11extras5-dev
2521
- gcc-9
2622
- g++-9
2723
script:
@@ -39,8 +35,6 @@ matrix:
3935
services:
4036
- xvfb
4137
compiler: gcc
42-
before_install:
43-
- sudo apt-get -y install libqt5x11extras5-dev
4438
addons:
4539
apt:
4640
sources:
@@ -50,8 +44,6 @@ matrix:
5044
packages:
5145
- qt514base
5246
- qt514tools
53-
- qt514x11extras
54-
- libqt5x11extras5-dev
5547
- gcc-9
5648
- g++-9
5749
- libc6-i386
@@ -73,8 +65,6 @@ matrix:
7365
services:
7466
- xvfb
7567
compiler: gcc
76-
before_install:
77-
- sudo apt-get -y install libqt5x11extras5-dev
7868
addons:
7969
apt:
8070
sources:
@@ -84,8 +74,6 @@ matrix:
8474
packages:
8575
- qt514base
8676
- qt514tools
87-
- qt514x11extras
88-
- libqt5x11extras5-dev
8977
- gcc-9
9078
- g++-9
9179
- libc6-i386
@@ -107,8 +95,6 @@ matrix:
10795
services:
10896
- xvfb
10997
compiler: gcc
110-
before_install:
111-
- sudo apt-get -y install libqt5x11extras5-dev
11298
addons:
11399
apt:
114100
sources:
@@ -118,8 +104,6 @@ matrix:
118104
packages:
119105
- qt514base
120106
- qt514tools
121-
- qt514x11extras
122-
- libqt5x11extras5-dev
123107
- gcc-9
124108
- g++-9
125109
- libc6-i386
@@ -147,8 +131,6 @@ matrix:
147131
services:
148132
- xvfb
149133
compiler: gcc
150-
before_install:
151-
- sudo apt-get -y install libqt5x11extras5-dev
152134
addons:
153135
apt:
154136
sources:
@@ -158,8 +140,6 @@ matrix:
158140
packages:
159141
- qt514base
160142
- qt514tools
161-
- qt514x11extras
162-
- libqt5x11extras5-dev
163143
- gcc-9
164144
- g++-9
165145
- libc6-i386

ads.pri

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ else{
1717

1818
unix:!macx {
1919
LIBS += -lxcb
20-
QT += x11extras
2120
}

adsConfig.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@ include(CMakeFindDependencyMacro)
22
find_dependency(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED)
33
find_dependency(Qt5Gui ${REQUIRED_QT_VERSION} REQUIRED)
44
find_dependency(Qt5Widgets ${REQUIRED_QT_VERSION} REQUIRED)
5-
if(UNIX AND NOT APPLE)
6-
find_dependency(Qt5X11Extras ${REQUIRED_QT_VERSION} REQUIRED)
7-
endif()
85
include("${CMAKE_CURRENT_LIST_DIR}/adsTargets.cmake")

setup.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,7 @@ def swig_sources (self, sources, extension=None):
227227
extension.extra_link_args += ['-F' + self.qtconfig.QT_INSTALL_LIBS,
228228
'-mmacosx-version-min=10.9']
229229
elif sys.platform == 'linux':
230-
extension.extra_compile_args += ['-D', 'QT_X11EXTRAS_LIB', '-std=c++11']
231-
extension.include_dirs += [os.path.join(self.qt_include_dir, 'QtX11Extras')]
232-
extension.libraries += ['Qt5X11Extras' + self.qt_libinfix]
230+
extension.extra_compile_args += ['-std=c++11']
233231

234232
return super().swig_sources(sources, extension)
235233

src/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ project(QtAdvancedDockingSystem LANGUAGES CXX VERSION ${VERSION_SHORT})
33
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
44
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED)
55
if (UNIX AND NOT APPLE)
6-
find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS X11Extras REQUIRED)
6+
include_directories(${Qt${QT_VERSION_MAJOR}Gui_PRIVATE_INCLUDE_DIRS})
77
endif()
88
set(CMAKE_INCLUDE_CURRENT_DIR ON)
99
if(BUILD_STATIC)
@@ -64,10 +64,6 @@ endif()
6464
target_link_libraries(qtadvanceddocking PUBLIC Qt${QT_VERSION_MAJOR}::Core
6565
Qt${QT_VERSION_MAJOR}::Gui
6666
Qt${QT_VERSION_MAJOR}::Widgets)
67-
if(UNIX AND NOT APPLE)
68-
target_link_libraries(qtadvanceddocking PUBLIC Qt${QT_VERSION_MAJOR}::X11Extras)
69-
target_link_libraries(qtadvanceddocking PRIVATE xcb)
70-
endif()
7167
set_target_properties(qtadvanceddocking PROPERTIES
7268
AUTOMOC ON
7369
AUTORCC ON

src/ads_globals.cpp

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@
3939
#include "ads_globals.h"
4040

4141
#ifdef Q_OS_LINUX
42-
#include <QX11Info>
4342
#include <QSettings>
4443
#include <QFile>
45-
#endif
46-
47-
4844
#include <QApplication>
45+
#include <qpa/qplatformnativeinterface.h>
46+
#endif
4947

5048
namespace ads
5149
{
@@ -57,10 +55,31 @@ static QString _window_manager;
5755
static QHash<QString, xcb_atom_t> _xcb_atom_cache;
5856

5957

58+
//============================================================================
59+
bool is_platform_x11()
60+
{
61+
return QGuiApplication::platformName() == QLatin1String("xcb");
62+
}
63+
64+
65+
//============================================================================
66+
xcb_connection_t* x11_connection()
67+
{
68+
if (!qApp)
69+
return nullptr;
70+
QPlatformNativeInterface *native = qApp->platformNativeInterface();
71+
if (!native)
72+
return nullptr;
73+
74+
void *connection = native->nativeResourceForIntegration(QByteArray("connection"));
75+
return reinterpret_cast<xcb_connection_t *>(connection);
76+
}
77+
78+
6079
//============================================================================
6180
xcb_atom_t xcb_get_atom(const char *name)
6281
{
63-
if (!QX11Info::isPlatformX11())
82+
if (!is_platform_x11())
6483
{
6584
return XCB_ATOM_NONE;
6685
}
@@ -69,7 +88,7 @@ xcb_atom_t xcb_get_atom(const char *name)
6988
{
7089
return _xcb_atom_cache[key];
7190
}
72-
xcb_connection_t *connection = QX11Info::connection();
91+
xcb_connection_t *connection = x11_connection();
7392
xcb_intern_atom_cookie_t request = xcb_intern_atom(connection, 1, strlen(name), name);
7493
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(connection, request, NULL);
7594
if (!reply)
@@ -93,7 +112,7 @@ xcb_atom_t xcb_get_atom(const char *name)
93112
//============================================================================
94113
void xcb_update_prop(bool set, WId window, const char *type, const char *prop, const char *prop2)
95114
{
96-
auto connection = QX11Info::connection();
115+
auto connection = x11_connection();
97116
xcb_atom_t type_atom = xcb_get_atom(type);
98117
xcb_atom_t prop_atom = xcb_get_atom(prop);
99118
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
118137
//============================================================================
119138
xcb_get_property_reply_t* _xcb_get_props(WId window, const char *type, unsigned int atom_type)
120139
{
121-
if (!QX11Info::isPlatformX11())
140+
if (!is_platform_x11())
122141
{
123142
return nullptr;
124143
}
125-
xcb_connection_t *connection = QX11Info::connection();
144+
xcb_connection_t *connection = x11_connection();
126145
xcb_atom_t type_atom = xcb_get_atom(type);
127146
if (type_atom == XCB_ATOM_NONE)
128147
{
@@ -191,7 +210,7 @@ bool xcb_dump_props(WId window, const char *type)
191210
QVector<xcb_atom_t> atoms;
192211
xcb_get_prop_list(window, type, atoms, XCB_ATOM_ATOM);
193212
qDebug() << "\n\n!!!" << type << " - " << atoms.length();
194-
xcb_connection_t *connection = QX11Info::connection();
213+
xcb_connection_t *connection = x11_connection();
195214
for (auto atom : atoms)
196215
{
197216
auto foo = xcb_get_atom_name(connection, atom);
@@ -206,7 +225,7 @@ bool xcb_dump_props(WId window, const char *type)
206225
//============================================================================
207226
void xcb_add_prop(bool state, WId window, const char *type, const char *prop)
208227
{
209-
if (!QX11Info::isPlatformX11())
228+
if (!is_platform_x11())
210229
{
211230
return;
212231
}
@@ -227,7 +246,7 @@ void xcb_add_prop(bool state, WId window, const char *type, const char *prop)
227246
{
228247
atoms.remove(index);
229248
}
230-
xcb_connection_t *connection = QX11Info::connection();
249+
xcb_connection_t *connection = x11_connection();
231250
xcb_change_property(connection, XCB_PROP_MODE_REPLACE, window, type_atom, XCB_ATOM_ATOM, 32, atoms.count(), atoms.constData());
232251
xcb_flush(connection);
233252
}
@@ -238,11 +257,11 @@ QString detectWindowManagerX11()
238257
{
239258
// Tries to detect the windowmanager via X11.
240259
// See: https://specifications.freedesktop.org/wm-spec/1.3/ar01s03.html#idm46018259946000
241-
if (!QX11Info::isPlatformX11())
260+
if (!is_platform_x11())
242261
{
243262
return "UNKNOWN";
244263
}
245-
xcb_connection_t *connection = QX11Info::connection();
264+
xcb_connection_t *connection = x11_connection();
246265
xcb_screen_t *first_screen = xcb_setup_roots_iterator (xcb_get_setup (connection)).data;
247266
if(!first_screen)
248267
{

src/src.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ SOURCES += \
7373
unix:!macx {
7474
HEADERS += linux/FloatingWidgetTitleBar.h
7575
SOURCES += linux/FloatingWidgetTitleBar.cpp
76-
QT += x11extras
7776
LIBS += -lxcb
77+
QT += gui-private
7878
}
7979

8080
isEmpty(PREFIX){

0 commit comments

Comments
 (0)